custom MessageBox for YesNo/YesNoCancel button modes

This commit is contained in:
n00mkrad
2022-07-24 22:30:30 +02:00
parent 54fb84de23
commit e6034a87b4
15 changed files with 165 additions and 45 deletions

View File

@@ -504,7 +504,7 @@ namespace Flowframes
if (Program.busy) if (Program.busy)
reason = "The program is still busy."; reason = "The program is still busy.";
DialogResult dialog = MessageBox.Show($"Are you sure you want to exit the program?\n\n{reason}", "Are you sure?", MessageBoxButtons.YesNo); DialogResult dialog = UiUtils.ShowMessageBox($"Are you sure you want to exit the program?\n\n{reason}", "Are you sure?", MessageBoxButtons.YesNo);
if (dialog == DialogResult.No) if (dialog == DialogResult.No)
e.Cancel = true; e.Cancel = true;
@@ -554,7 +554,7 @@ namespace Flowframes
private void cancelBtn_Click(object sender, EventArgs e) private void cancelBtn_Click(object sender, EventArgs e)
{ {
DialogResult dialog = MessageBox.Show($"Are you sure you want to cancel the interpolation?", "Are you sure?", MessageBoxButtons.YesNo); DialogResult dialog = UiUtils.ShowMessageBox($"Are you sure you want to cancel the interpolation?", "Are you sure?", MessageBoxButtons.YesNo);
if (dialog == DialogResult.Yes) if (dialog == DialogResult.Yes)
{ {

View File

@@ -39,8 +39,9 @@ namespace Flowframes.Forms
if (!configGridChanged) if (!configGridChanged)
return; return;
DialogResult dialogResult = MessageBox.Show($"Save the modified configuration file?", "Save Configuration?", MessageBoxButtons.YesNo); DialogResult dialogResult = UiUtils.ShowMessageBox($"Save the modified configuration file?", "Save Configuration?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
DebugFormHelper.SaveGrid(configDataGrid); DebugFormHelper.SaveGrid(configDataGrid);
} }

View File

@@ -29,7 +29,9 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.textLabel = new System.Windows.Forms.Label(); this.textLabel = new System.Windows.Forms.Label();
this.okBtn = new HTAlt.WinForms.HTButton(); this.btn1 = new HTAlt.WinForms.HTButton();
this.btn2 = new HTAlt.WinForms.HTButton();
this.btn3 = new HTAlt.WinForms.HTButton();
this.SuspendLayout(); this.SuspendLayout();
// //
// textLabel // textLabel
@@ -42,20 +44,50 @@
this.textLabel.Size = new System.Drawing.Size(0, 13); this.textLabel.Size = new System.Drawing.Size(0, 13);
this.textLabel.TabIndex = 8; this.textLabel.TabIndex = 8;
// //
// okBtn // btn1
// //
this.okBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btn1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okBtn.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); this.btn1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.okBtn.FlatAppearance.BorderSize = 0; this.btn1.FlatAppearance.BorderSize = 0;
this.okBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.btn1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.okBtn.ForeColor = System.Drawing.Color.White; this.btn1.ForeColor = System.Drawing.Color.White;
this.okBtn.Location = new System.Drawing.Point(232, 126); this.btn1.Location = new System.Drawing.Point(232, 126);
this.okBtn.Name = "okBtn"; this.btn1.Name = "btn1";
this.okBtn.Size = new System.Drawing.Size(100, 23); this.btn1.Size = new System.Drawing.Size(100, 23);
this.okBtn.TabIndex = 46; this.btn1.TabIndex = 46;
this.okBtn.Text = "OK"; this.btn1.Text = "OK";
this.okBtn.UseVisualStyleBackColor = false; this.btn1.UseVisualStyleBackColor = false;
this.okBtn.Click += new System.EventHandler(this.okBtn_Click); this.btn1.Click += new System.EventHandler(this.btn1_Click);
//
// btn2
//
this.btn2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btn2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btn2.FlatAppearance.BorderSize = 0;
this.btn2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn2.ForeColor = System.Drawing.Color.White;
this.btn2.Location = new System.Drawing.Point(126, 126);
this.btn2.Name = "btn2";
this.btn2.Size = new System.Drawing.Size(100, 23);
this.btn2.TabIndex = 47;
this.btn2.Text = "OK";
this.btn2.UseVisualStyleBackColor = false;
this.btn2.Click += new System.EventHandler(this.btn2_Click);
//
// btn3
//
this.btn3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btn3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.btn3.FlatAppearance.BorderSize = 0;
this.btn3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn3.ForeColor = System.Drawing.Color.White;
this.btn3.Location = new System.Drawing.Point(20, 126);
this.btn3.Name = "btn3";
this.btn3.Size = new System.Drawing.Size(100, 23);
this.btn3.TabIndex = 48;
this.btn3.Text = "OK";
this.btn3.UseVisualStyleBackColor = false;
this.btn3.Click += new System.EventHandler(this.btn3_Click);
// //
// MessageForm // MessageForm
// //
@@ -63,7 +95,9 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32))))); this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
this.ClientSize = new System.Drawing.Size(344, 161); this.ClientSize = new System.Drawing.Size(344, 161);
this.Controls.Add(this.okBtn); this.Controls.Add(this.btn3);
this.Controls.Add(this.btn2);
this.Controls.Add(this.btn1);
this.Controls.Add(this.textLabel); this.Controls.Add(this.textLabel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false; this.MaximizeBox = false;
@@ -71,6 +105,7 @@
this.Name = "MessageForm"; this.Name = "MessageForm";
this.ShowIcon = false; this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MessageForm_FormClosing);
this.Load += new System.EventHandler(this.MessageForm_Load); this.Load += new System.EventHandler(this.MessageForm_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -80,6 +115,8 @@
#endregion #endregion
private System.Windows.Forms.Label textLabel; private System.Windows.Forms.Label textLabel;
private HTAlt.WinForms.HTButton okBtn; private HTAlt.WinForms.HTButton btn1;
private HTAlt.WinForms.HTButton btn2;
private HTAlt.WinForms.HTButton btn3;
} }
} }

View File

@@ -14,11 +14,16 @@ namespace Flowframes.Forms
{ {
private string _text = ""; private string _text = "";
private string _title = ""; private string _title = "";
private MessageBoxButtons _btns;
public MessageForm(string text, string title) private bool _dialogResultSet = false;
public MessageForm(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.OK)
{ {
_text = text; _text = text;
_title = title; _title = title;
_btns = buttons;
InitializeComponent(); InitializeComponent();
} }
@@ -26,8 +31,34 @@ namespace Flowframes.Forms
{ {
Text = _title; Text = _title;
textLabel.Text = _text; textLabel.Text = _text;
if(_btns == MessageBoxButtons.OK)
{
SetButtons(true, false, false);
btn1.Text = "OK";
AcceptButton = btn1;
}
else if(_btns == MessageBoxButtons.YesNo)
{
SetButtons(true, true, false);
btn1.Text = "No";
btn2.Text = "Yes";
AcceptButton = btn2;
CancelButton = btn1;
}
else if (_btns == MessageBoxButtons.YesNoCancel)
{
SetButtons(true, true, true);
btn1.Text = "Cancel";
btn2.Text = "No";
btn3.Text = "Yes";
AcceptButton = btn3;
CancelButton = btn1;
}
Size labelSize = GetLabelSize(textLabel); Size labelSize = GetLabelSize(textLabel);
Size = new Size((labelSize.Width + 60).Clamp(360, Program.mainForm.Size.Width), (labelSize.Height + 120).Clamp(200, Program.mainForm.Size.Height)); Size = new Size((labelSize.Width + 60).Clamp(360, Program.mainForm.Size.Width), (labelSize.Height + 120).Clamp(200, Program.mainForm.Size.Height));
CenterToScreen(); CenterToScreen();
} }
@@ -36,9 +67,50 @@ namespace Flowframes.Forms
return TextRenderer.MeasureText(label.Text, label.Font, label.ClientSize, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); return TextRenderer.MeasureText(label.Text, label.Font, label.ClientSize, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl);
} }
private void okBtn_Click(object sender, EventArgs e) private void SetButtons(bool b1, bool b2, bool b3)
{ {
btn1.Visible = b1;
btn2.Visible = b2;
btn3.Visible = b3;
}
private void btn1_Click(object sender, EventArgs e)
{
if (_btns == MessageBoxButtons.OK) // OK Button
DialogResult = DialogResult.OK;
else if (_btns == MessageBoxButtons.YesNo) // No Button
DialogResult = DialogResult.No;
else if (_btns == MessageBoxButtons.YesNoCancel) // Cancel Button
DialogResult = DialogResult.Cancel;
_dialogResultSet = true;
Close(); Close();
} }
private void btn2_Click(object sender, EventArgs e)
{
if (_btns == MessageBoxButtons.YesNo) // Yes Button
DialogResult = DialogResult.Yes;
else if (_btns == MessageBoxButtons.YesNoCancel) // No Button
DialogResult = DialogResult.No;
_dialogResultSet = true;
Close();
}
private void btn3_Click(object sender, EventArgs e)
{
if (_btns == MessageBoxButtons.YesNoCancel) // Yes Button
DialogResult = DialogResult.Yes;
_dialogResultSet = true;
Close();
}
private void MessageForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (_btns != MessageBoxButtons.OK && !_dialogResultSet)
e.Cancel = true;
}
} }
} }

View File

@@ -2,6 +2,7 @@
using Flowframes.IO; using Flowframes.IO;
using Flowframes.Media; using Flowframes.Media;
using Flowframes.MiscUtils; using Flowframes.MiscUtils;
using Flowframes.Ui;
using Microsoft.WindowsAPICodePack.Dialogs; using Microsoft.WindowsAPICodePack.Dialogs;
using System; using System;
using System.Drawing; using System.Drawing;
@@ -239,7 +240,7 @@ namespace Flowframes.Forms
private void cmdDebugMode_SelectedIndexChanged(object sender, EventArgs e) private void cmdDebugMode_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (initialized && cmdDebugMode.SelectedIndex == 2) if (initialized && cmdDebugMode.SelectedIndex == 2)
MessageBox.Show("If you enable this, you need to close the CMD window manually after the process has finished, otherwise processing will be paused!", "Notice"); UiUtils.ShowMessageBox("If you enable this, you need to close the CMD window manually after the process has finished, otherwise processing will be paused!", UiUtils.MessageType.Warning);
} }
private void dedupMode_SelectedIndexChanged(object sender, EventArgs e) private void dedupMode_SelectedIndexChanged(object sender, EventArgs e)
@@ -287,7 +288,7 @@ namespace Flowframes.Forms
private async void resetBtn_Click(object sender, EventArgs e) private async void resetBtn_Click(object sender, EventArgs e)
{ {
DialogResult dialog = MessageBox.Show($"Are you sure you want to reset the configuration?", "Are you sure?", MessageBoxButtons.YesNo); DialogResult dialog = UiUtils.ShowMessageBox($"Are you sure you want to reset the configuration?", "Are you sure?", MessageBoxButtons.YesNo);
if (dialog == DialogResult.No) if (dialog == DialogResult.No)
return; return;

View File

@@ -345,7 +345,7 @@ namespace Flowframes.IO
Fraction guiFps = Program.mainForm.GetCurrentSettings().inFps; Fraction guiFps = Program.mainForm.GetCurrentSettings().inFps;
DialogResult dialogResult = MessageBox.Show("A frame rate file has been found in the parent directory.\n\n" + DialogResult dialogResult = UiUtils.ShowMessageBox("A frame rate file has been found in the parent directory.\n\n" +
$"Click \"Yes\" to use frame rate from the file ({fps}) or \"No\" to use current FPS set in GUI ({guiFps})", "Load Frame Rate From fps.ini?", MessageBoxButtons.YesNo); $"Click \"Yes\" to use frame rate from the file ({fps}) or \"No\" to use current FPS set in GUI ({guiFps})", "Load Frame Rate From fps.ini?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
return fps; return fps;
@@ -664,7 +664,7 @@ namespace Flowframes.IO
{ {
Logger.Log($"Can't write to {dir}! {e.Message}", errMode == ErrorMode.HiddenLog); Logger.Log($"Can't write to {dir}! {e.Message}", errMode == ErrorMode.HiddenLog);
if (errMode == ErrorMode.Messagebox && !BatchProcessing.busy) if (errMode == ErrorMode.Messagebox && !BatchProcessing.busy)
MessageBox.Show($"Can't write to {dir}!\n\n{e.Message}", "Error"); UiUtils.ShowMessageBox($"Can't write to {dir}!\n\n{e.Message}", UiUtils.MessageType.Error);
return false; return false;
} }
} }

View File

@@ -14,6 +14,7 @@ using Flowframes.MiscUtils;
using Flowframes.Os; using Flowframes.Os;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using Flowframes.Ui;
namespace Flowframes.Main namespace Flowframes.Main
{ {
@@ -68,7 +69,7 @@ namespace Flowframes.Main
catch (Exception e) catch (Exception e)
{ {
Logger.Log("FramesToVideo Error: " + e.Message, false); Logger.Log("FramesToVideo Error: " + e.Message, false);
MessageBox.Show("An error occured while trying to convert the interpolated frames to a video.\nCheck the log for details."); UiUtils.ShowMessageBox("An error occured while trying to convert the interpolated frames to a video.\nCheck the log for details.", UiUtils.MessageType.Error);
} }
} }
@@ -252,7 +253,7 @@ namespace Flowframes.Main
Logger.Log("ChunksToVideo Error: " + e.Message, isBackup); Logger.Log("ChunksToVideo Error: " + e.Message, isBackup);
if (!isBackup) if (!isBackup)
MessageBox.Show("An error occured while trying to merge the video chunks.\nCheck the log for details."); UiUtils.ShowMessageBox("An error occured while trying to merge the video chunks.\nCheck the log for details.", UiUtils.MessageType.Error);
} }
Logger.Log($"Merged video chunks in {sw}", true); Logger.Log($"Merged video chunks in {sw}", true);

View File

@@ -242,7 +242,7 @@ namespace Flowframes
{ {
if (!BatchProcessing.busy && IoUtils.GetAmountOfFiles(Path.Combine(currentSettings.tempFolder, Paths.resumeDir), true) > 0) if (!BatchProcessing.busy && IoUtils.GetAmountOfFiles(Path.Combine(currentSettings.tempFolder, Paths.resumeDir), true) > 0)
{ {
DialogResult dialogResult = MessageBox.Show($"Delete the temp folder (Yes) or keep it for resuming later (No)?", "Delete temporary files?", MessageBoxButtons.YesNo); DialogResult dialogResult = UiUtils.ShowMessageBox($"Delete the temp folder (Yes) or keep it for resuming later (No)?", "Delete temporary files?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
Task.Run(async () => { await IoUtils.TryDeleteIfExistsAsync(currentSettings.tempFolder); }); Task.Run(async () => { await IoUtils.TryDeleteIfExistsAsync(currentSettings.tempFolder); });

View File

@@ -135,7 +135,7 @@ namespace Flowframes.Main
public static async Task Reset() public static async Task Reset()
{ {
DialogResult dialog = MessageBox.Show($"Are you sure you want to remove all temporary files?", "Are you sure?", MessageBoxButtons.YesNo); DialogResult dialog = UiUtils.ShowMessageBox($"Are you sure you want to remove all temporary files?", "Are you sure?", MessageBoxButtons.YesNo);
if (dialog == DialogResult.Yes) if (dialog == DialogResult.Yes)
await Cleanup(true); await Cleanup(true);

View File

@@ -225,7 +225,7 @@ namespace Flowframes.Main
{ {
string enc = FfmpegUtils.GetEnc(FfmpegUtils.GetCodec(I.currentSettings.outMode)); string enc = FfmpegUtils.GetEnc(FfmpegUtils.GetCodec(I.currentSettings.outMode));
float maxAv1Fps = 480; float maxAv1Fps = 240;
if (enc.ToLower().Contains("av1") && encodeFps > maxAv1Fps) if (enc.ToLower().Contains("av1") && encodeFps > maxAv1Fps)
{ {

View File

@@ -1,5 +1,6 @@
using Flowframes.IO; using Flowframes.IO;
using Flowframes.MiscUtils; using Flowframes.MiscUtils;
using Flowframes.Ui;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -81,7 +82,7 @@ namespace Flowframes.Os
{ {
if (!quiet) if (!quiet)
{ {
MessageBox.Show("Neither the Flowframes Python Runtime nor System Python installation could be found!\nEither redownload Flowframes with the embedded Python runtime enabled or install Python/Pytorch yourself."); UiUtils.ShowMessageBox("Neither the Flowframes Python Runtime nor System Python installation could be found!\nEither redownload Flowframes with the embedded Python runtime enabled or install Python/Pytorch yourself.");
Interpolate.Cancel("Neither the Flowframes Python Runtime nor System Python installation could be found!"); Interpolate.Cancel("Neither the Flowframes Python Runtime nor System Python installation could be found!");
} }
} }

View File

@@ -5,6 +5,7 @@ using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Flowframes.IO; using Flowframes.IO;
using Flowframes.Ui;
namespace Flowframes.Os namespace Flowframes.Os
{ {
@@ -39,7 +40,7 @@ namespace Flowframes.Os
{ {
if (!File.Exists(Paths.GetVerPath()) && Paths.GetExeDir().ToLower().Contains("temp")) if (!File.Exists(Paths.GetVerPath()) && Paths.GetExeDir().ToLower().Contains("temp"))
{ {
MessageBox.Show("You seem to be running Flowframes out of an archive.\nPlease extract the whole archive first!", "Error"); UiUtils.ShowMessageBox("You seem to be running Flowframes out of an archive.\nPlease extract the whole archive first!", UiUtils.MessageType.Error);
IoUtils.TryDeleteIfExists(Paths.GetDataPath()); IoUtils.TryDeleteIfExists(Paths.GetDataPath());
Application.Exit(); Application.Exit();
} }
@@ -49,7 +50,7 @@ namespace Flowframes.Os
if (Is32Bit() && !Config.GetBool("allow32Bit", false)) if (Is32Bit() && !Config.GetBool("allow32Bit", false))
{ {
MessageBox.Show("This application is not compatible with 32 bit operating systems!", "Error"); UiUtils.ShowMessageBox("This application is not compatible with 32 bit operating systems!", UiUtils.MessageType.Error);
Application.Exit(); Application.Exit();
} }
@@ -58,8 +59,8 @@ namespace Flowframes.Os
if (!version.ToLower().Contains("windows 10") && !version.ToLower().Contains("windows 11") && !Config.GetBool("ignoreIncompatibleOs", false)) if (!version.ToLower().Contains("windows 10") && !version.ToLower().Contains("windows 11") && !Config.GetBool("ignoreIncompatibleOs", false))
{ {
MessageBox.Show($"This application was made for Windows 10/11 and is not officially compatible with {version}.\n\n" + UiUtils.ShowMessageBox($"This application was made for Windows 10/11 and is not officially compatible with {version}.\n\n" +
$"Use it at your own risk and do NOT ask for support as long as your are on {version}.", "Warning"); $"Use it at your own risk and do NOT ask for support as long as your are on {version}.", UiUtils.MessageType.Warning);
} }
} }
@@ -77,8 +78,8 @@ namespace Flowframes.Os
{ {
if (!silent) if (!silent)
{ {
MessageBox.Show("Flowframes will now enable Windows' Developer Mode which is required for video encoding improvements.\n\n" + UiUtils.ShowMessageBox("Flowframes will now enable Windows' Developer Mode which is required for video encoding improvements.\n\n" +
"This requires administrator privileges once.", "Message"); "This requires administrator privileges once.", UiUtils.MessageType.Message);
} }
Logger.Log($"Trying to enable dev mode.", true); Logger.Log($"Trying to enable dev mode.", true);
@@ -107,9 +108,9 @@ namespace Flowframes.Os
{ {
if (!silent) if (!silent)
{ {
MessageBox.Show("Failed to enable developer mode - Perhaps you do not have sufficient privileges.\n\n" + UiUtils.ShowMessageBox("Failed to enable developer mode - Perhaps you do not have sufficient privileges.\n\n" +
"Without Developer Mode, video encoding will be noticably slower.\n\nYou can still try enabling " + "Without Developer Mode, video encoding will be noticably slower.\n\nYou can still try enabling " +
"it manually in the Windows 10 Settings:\nSettings -> Update & security -> For developers -> Developer mode.", "Message"); "it manually in the Windows 10 Settings:\nSettings -> Update & security -> For developers -> Developer mode.", UiUtils.MessageType.Message);
} }
Logger.Log("Failed to enable dev mode.", true); Logger.Log("Failed to enable dev mode.", true);

View File

@@ -1,6 +1,7 @@
using Flowframes.Data; using Flowframes.Data;
using Flowframes.Forms; using Flowframes.Forms;
using Flowframes.IO; using Flowframes.IO;
using Flowframes.Ui;
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
@@ -103,7 +104,7 @@ namespace Flowframes.Os
} }
catch (Exception e) catch (Exception e)
{ {
MessageBox.Show("Error: Failed to download update.\n\n" + e.Message, "Error"); UiUtils.ShowMessageBox("Error: Failed to download update.\n\n" + e.Message, UiUtils.MessageType.Error);
Logger.Log("Updater Error during download: " + e.Message, true); Logger.Log("Updater Error during download: " + e.Message, true);
return; return;
} }
@@ -118,13 +119,13 @@ namespace Flowframes.Os
} }
catch (Exception e) catch (Exception e)
{ {
MessageBox.Show("Error: Failed to install update.\n\n" + e.Message, "Error"); UiUtils.ShowMessageBox("Error: Failed to install update.\n\n" + e.Message, UiUtils.MessageType.Error);
Logger.Log("Updater Error during install: " + e.Message, true); Logger.Log("Updater Error during install: " + e.Message, true);
return; return;
} }
form.SetProgLabel(101f, $"Update downloaded."); form.SetProgLabel(101f, $"Update downloaded.");
await Task.Delay(20); await Task.Delay(20);
MessageBox.Show("Update was installed!\nFlowframes will now close. Restart it to use the new version.", "Message"); UiUtils.ShowMessageBox("Update was installed!\nFlowframes will now close. Restart it to use the new version.");
Application.Exit(); Application.Exit();
} }

View File

@@ -107,7 +107,7 @@ namespace Flowframes.Ui
string interpFrames = interpFrmAmount > 2 ? $"{interpFrmAmount} interpolated frames" : "no interpolated frames"; string interpFrames = interpFrmAmount > 2 ? $"{interpFrmAmount} interpolated frames" : "no interpolated frames";
string msg = $"A temporary folder for this video already exists. It contains {scnFrames}, {srcFrames}, {interpFrames}."; string msg = $"A temporary folder for this video already exists. It contains {scnFrames}, {srcFrames}, {interpFrames}.";
DialogResult dialogResult = MessageBox.Show($"{msg}\n\nClick \"Yes\" to use the existing files or \"No\" to delete them.", "Use files from existing temp folder?", MessageBoxButtons.YesNo); DialogResult dialogResult = UiUtils.ShowMessageBox($"{msg}\n\nClick \"Yes\" to use the existing files or \"No\" to delete them.", "Use files from existing temp folder?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.No) if (dialogResult == DialogResult.No)
{ {
IoUtils.TryDeleteIfExists(tmpFolder); IoUtils.TryDeleteIfExists(tmpFolder);

View File

@@ -96,12 +96,17 @@ namespace Flowframes.Ui
if (type == MessageType.Warning) icon = MessageBoxIcon.Warning; if (type == MessageType.Warning) icon = MessageBoxIcon.Warning;
else if (type == MessageType.Error) icon = MessageBoxIcon.Error; else if (type == MessageType.Error) icon = MessageBoxIcon.Error;
//DialogResult res = MessageBox.Show(text, $"Flowframes - {type}", MessageBoxButtons.OK, icon, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
MessageForm form = new MessageForm(text, type.ToString()); MessageForm form = new MessageForm(text, type.ToString());
form.ShowDialog(); form.ShowDialog();
return DialogResult.OK; return DialogResult.OK;
} }
public static DialogResult ShowMessageBox(string text, string title, MessageBoxButtons btns)
{
MessageForm form = new MessageForm(text, title, btns);
return form.ShowDialog();
}
public enum MoveDirection { Up = -1, Down = 1 }; public enum MoveDirection { Up = -1, Down = 1 };
public static void MoveListViewItem(ListView listView, MoveDirection direction) public static void MoveListViewItem(ListView listView, MoveDirection direction)