Skip to content

Commit

Permalink
fix invalid dialog type ...
Browse files Browse the repository at this point in the history
  • Loading branch information
t0815 committed Oct 29, 2023
1 parent c5d0bfd commit f2a310d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
24 changes: 14 additions & 10 deletions MyCBZ/ApplicationMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ namespace Win_CBZ
{
public class ApplicationMessage
{
public const short MT_INFORMATION = 1;
public const short MT_WARNING = 2;
public const short MT_ERROR = 3;
public const short MT_CONFIRMATION = 4;

public enum DialogType : ushort
{
MT_INFORMATION = 1,
MT_WARNING = 2,
MT_ERROR = 3,
MT_CONFIRMATION = 4,
};

[Flags]
public enum DialogButtons : ushort
Expand All @@ -29,7 +33,7 @@ public enum DialogButtons : ushort
MB_QUIT = 128
};

public static DialogResult Show(String message, String title, short type = MT_INFORMATION, DialogButtons buttons = DialogButtons.MB_OK, ScrollBars ShowScrollBars = ScrollBars.None)
public static DialogResult Show(String message, String title, DialogType type = DialogType.MT_INFORMATION, DialogButtons buttons = DialogButtons.MB_OK, ScrollBars ShowScrollBars = ScrollBars.None)
{
ApplicationDialog errorDialog = new ApplicationDialog();
errorDialog.Buttons = buttons;
Expand All @@ -42,7 +46,7 @@ public static DialogResult Show(String message, String title, short type = MT_IN
return errorDialog.ShowDialog();
}

public static DialogResult ShowCustom(String message, String title, short type = MT_INFORMATION, DialogButtons buttons = DialogButtons.MB_OK, ScrollBars ShowScrollBars = ScrollBars.None, int width = 441, int height = 350)
public static DialogResult ShowCustom(String message, String title, DialogType type = DialogType.MT_INFORMATION, DialogButtons buttons = DialogButtons.MB_OK, ScrollBars ShowScrollBars = ScrollBars.None, int width = 441, int height = 350)
{
ApplicationDialog errorDialog = new ApplicationDialog();
errorDialog.Buttons = buttons;
Expand All @@ -55,7 +59,7 @@ public static DialogResult ShowCustom(String message, String title, short type =
return errorDialog.ShowDialog();
}

public static DialogResult ShowWarning(String message, String title, short type = MT_WARNING, DialogButtons buttons = DialogButtons.MB_YES | DialogButtons.MB_CANCEL, ScrollBars ShowScrollBars = ScrollBars.None)
public static DialogResult ShowWarning(String message, String title, DialogType type = DialogType.MT_WARNING, DialogButtons buttons = DialogButtons.MB_YES | DialogButtons.MB_CANCEL, ScrollBars ShowScrollBars = ScrollBars.None)
{
ApplicationDialog errorDialog = new ApplicationDialog();
errorDialog.Buttons = buttons;
Expand All @@ -68,7 +72,7 @@ public static DialogResult ShowWarning(String message, String title, short type
return errorDialog.ShowDialog();
}

public static DialogResult ShowConfirmation(String message, String title, short type = MT_CONFIRMATION, DialogButtons buttons = DialogButtons.MB_YES | DialogButtons.MB_CANCEL, ScrollBars ShowScrollBars = ScrollBars.None)
public static DialogResult ShowConfirmation(String message, String title, DialogType type = DialogType.MT_CONFIRMATION, DialogButtons buttons = DialogButtons.MB_YES | DialogButtons.MB_CANCEL, ScrollBars ShowScrollBars = ScrollBars.None)
{
ApplicationDialog errorDialog = new ApplicationDialog();
errorDialog.Buttons = buttons;
Expand All @@ -80,7 +84,7 @@ public static DialogResult ShowConfirmation(String message, String title, short
return errorDialog.ShowDialog();
}

public static DialogResult ShowError(String message, String title, short type = MT_ERROR, DialogButtons buttons = DialogButtons.MB_OK)
public static DialogResult ShowError(String message, String title, DialogType type = DialogType.MT_ERROR, DialogButtons buttons = DialogButtons.MB_OK)
{
ApplicationDialog errorDialog = new ApplicationDialog();
errorDialog.Buttons = buttons;
Expand All @@ -91,7 +95,7 @@ public static DialogResult ShowError(String message, String title, short type =
return errorDialog.ShowDialog();
}

public static DialogResult ShowException(Exception exception, short type = MT_ERROR, DialogButtons buttons = DialogButtons.MB_OK)
public static DialogResult ShowException(Exception exception, DialogType type = DialogType.MT_ERROR, DialogButtons buttons = DialogButtons.MB_OK)
{
ApplicationDialog errorDialog = new ApplicationDialog();
errorDialog.Buttons = buttons;
Expand Down
10 changes: 5 additions & 5 deletions MyCBZ/Forms/ApplicationDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@ namespace Win_CBZ.Forms
{
public partial class ApplicationDialog : Form
{
private short _type;
private DialogType _type;
private String _message;
private DialogButtons _buttons;
private String _title;

private DialogButtons _existingButtons;

public short DialogType
public DialogType DialogType
{
set
{
switch (value)
{
case MT_INFORMATION:
case DialogType.MT_INFORMATION:
Text = "Information";
DialogIconPictureBox.Image = global::Win_CBZ.Properties.Resources.info_dialog;
break;

case MT_WARNING:
case DialogType.MT_WARNING:
Text = "WARNING!";
DialogIconPictureBox.Image = global::Win_CBZ.Properties.Resources.warning_dialog;
break;

case MT_CONFIRMATION:
case DialogType.MT_CONFIRMATION:
Text = "Please confirm";
DialogIconPictureBox.Image = global::Win_CBZ.Properties.Resources.question_dialog;
break;
Expand Down
10 changes: 5 additions & 5 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ private void NewToolStripMenuItem_Click(object sender, EventArgs e)

if (ArchiveProcessing())
{
ApplicationMessage.ShowWarning("Please wait until current operation has finished.", "Still operations in progress", 2, ApplicationMessage.DialogButtons.MB_OK);
ApplicationMessage.ShowWarning("Please wait until current operation has finished.", "Still operations in progress", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_OK);

}
}
Expand Down Expand Up @@ -1646,7 +1646,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (ArchiveProcessing())
{
DialogResult res = ApplicationMessage.ShowWarning("Warning, there are currently still Tasks running in the Background.\nIt is advised to wait until current operation has finished.", "Still operations in progress", 2, ApplicationMessage.DialogButtons.MB_QUIT | ApplicationMessage.DialogButtons.MB_CANCEL);
DialogResult res = ApplicationMessage.ShowWarning("Warning, there are currently still Tasks running in the Background.\nIt is advised to wait until current operation has finished.", "Still operations in progress", ApplicationMessage.DialogType.MT_WARNING, ApplicationMessage.DialogButtons.MB_QUIT | ApplicationMessage.DialogButtons.MB_CANCEL);
if (res == DialogResult.Yes)
{
if (Program.ProjectModel.IsChanged && !Program.ProjectModel.IsSaved)
Expand Down Expand Up @@ -1804,7 +1804,7 @@ private void PagesList_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
MessageLogger.Instance.Log(LogMessageEvent.LOGMESSAGE_TYPE_ERROR, eduplicate.Message);
e.CancelEdit = true;
ApplicationMessage.ShowException(eduplicate, ApplicationMessage.MT_ERROR);
ApplicationMessage.ShowException(eduplicate, ApplicationMessage.DialogType.MT_ERROR);
}
catch (PageException)
{
Expand Down Expand Up @@ -2461,7 +2461,7 @@ private void CheckBoxDoRenamePages_CheckedChanged(object sender, EventArgs e)
{
if (CheckBoxDoRenamePages.CheckState == CheckState.Checked)
{
DialogResult res = ApplicationMessage.Show("Remaming is not supported in compatibility mode!\r\nPages are renamed automatically according to their respective indices.", "Not supported", 1, ApplicationMessage.DialogButtons.MB_OK);
DialogResult res = ApplicationMessage.Show("Remaming is not supported in compatibility mode!\r\nPages are renamed automatically according to their respective indices.", "Not supported", ApplicationMessage.DialogType.MT_INFORMATION, ApplicationMessage.DialogButtons.MB_OK);
Program.ProjectModel.ApplyRenaming = false;
CheckBoxDoRenamePages.CheckState = CheckState.Unchecked;
}
Expand Down Expand Up @@ -2546,7 +2546,7 @@ private void ToolButtonSetPageType_ButtonClick(object sender, EventArgs e)
{
if (!Program.ProjectModel.MetaData.Exists())
{
DialogResult res = ApplicationMessage.ShowConfirmation("Currently no metadata available!\r\nCBZ needs to contain XML metadata (comicinfo.xml) in order to define individual pagetypes. Add a new set of Metadata now?", "Metadata required", 4, ApplicationMessage.DialogButtons.MB_YES | ApplicationMessage.DialogButtons.MB_NO);
DialogResult res = ApplicationMessage.ShowConfirmation("Currently no metadata available!\r\nCBZ needs to contain XML metadata (comicinfo.xml) in order to define individual pagetypes. Add a new set of Metadata now?", "Metadata required", ApplicationMessage.DialogType.MT_CONFIRMATION, ApplicationMessage.DialogButtons.MB_YES | ApplicationMessage.DialogButtons.MB_NO);
if (res == DialogResult.Yes)
{
BtnAddMetaData_Click(sender, null);
Expand Down

0 comments on commit f2a310d

Please sign in to comment.