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