mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-12 15:15:45 +02:00
Refactor FormMessage uses with the new DialogResult parameter
This commit is contained in:
parent
c1420bac88
commit
f1db1ba708
@ -13,26 +13,19 @@ bool IJsDialogHandler.OnJSDialog(IWebBrowser browserControl, IBrowser browser, s
|
||||
|
||||
((ChromiumWebBrowser)browserControl).InvokeSafe(() => {
|
||||
FormMessage form = new FormMessage(Program.BrandName, messageText, MessageBoxIcon.None);
|
||||
Button btnConfirm;
|
||||
|
||||
if (dialogType == CefJsDialogType.Alert){
|
||||
btnConfirm = form.AddButton("OK");
|
||||
form.AddButton("OK");
|
||||
}
|
||||
else if (dialogType == CefJsDialogType.Confirm){
|
||||
form.AddButton("No");
|
||||
btnConfirm = form.AddButton("Yes");
|
||||
form.AddButton("No", DialogResult.No);
|
||||
form.AddButton("Yes");
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnConfirm){
|
||||
callback.Continue(true);
|
||||
}
|
||||
else{
|
||||
callback.Continue(false);
|
||||
}
|
||||
|
||||
callback.Continue(form.ShowDialog() == DialogResult.OK);
|
||||
form.Dispose();
|
||||
});
|
||||
|
||||
|
10
Program.cs
10
Program.cs
@ -76,13 +76,11 @@ private static void Main(){
|
||||
else if (attempt == 20){
|
||||
using(FormMessage form = new FormMessage(BrandName+" Cannot Restart", BrandName+" is taking too long to close.", MessageBoxIcon.Warning)){
|
||||
form.AddButton("Exit");
|
||||
Button btnRetry = form.AddButton("Retry");
|
||||
form.AddButton("Retry", DialogResult.Retry);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK){
|
||||
if (form.ClickedButton == btnRetry){
|
||||
attempt /= 2;
|
||||
continue;
|
||||
}
|
||||
if (form.ShowDialog() == DialogResult.Retry){
|
||||
attempt /= 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
|
13
Reporter.cs
13
Reporter.cs
@ -47,9 +47,8 @@ public void HandleException(string caption, string message, bool canIgnore, Exce
|
||||
bool loggedSuccessfully = Log(e.ToString());
|
||||
|
||||
FormMessage form = new FormMessage(caption, message+"\r\nError: "+e.Message, canIgnore ? MessageBoxIcon.Warning : MessageBoxIcon.Error);
|
||||
|
||||
form.AddButton("Exit");
|
||||
Button btnIgnore = form.AddButton("Ignore");
|
||||
form.AddButton("Ignore", DialogResult.Ignore).Enabled = canIgnore;
|
||||
|
||||
Button btnOpenLog = new Button{
|
||||
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
|
||||
@ -68,14 +67,8 @@ public void HandleException(string caption, string message, bool canIgnore, Exce
|
||||
|
||||
form.AddActionControl(btnOpenLog);
|
||||
|
||||
if (!canIgnore){
|
||||
btnIgnore.Enabled = false;
|
||||
}
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK){
|
||||
if (form.ClickedButton == btnIgnore){
|
||||
return;
|
||||
}
|
||||
if (form.ShowDialog() == DialogResult.Ignore){
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
|
Loading…
Reference in New Issue
Block a user