diff --git a/Common/Common.csproj b/Common/Common.csproj
index eb24bc269..7c68303b2 100644
--- a/Common/Common.csproj
+++ b/Common/Common.csproj
@@ -74,6 +74,7 @@
Component
+
diff --git a/Common/Forms/ModelessForm.Designer.cs b/Common/Forms/ModelessForm.Designer.cs
index 53ad9c5ee..028eb8821 100644
--- a/Common/Forms/ModelessForm.Designer.cs
+++ b/Common/Forms/ModelessForm.Designer.cs
@@ -51,7 +51,6 @@
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ModelessForm";
- this.Load += new System.EventHandler(this.ModelessForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
diff --git a/Common/Forms/ModelessForm.cs b/Common/Forms/ModelessForm.cs
index a816fb4aa..6af087f10 100644
--- a/Common/Forms/ModelessForm.cs
+++ b/Common/Forms/ModelessForm.cs
@@ -6,62 +6,27 @@ namespace Common.Forms
{
public partial class ModelessForm : Form
{
- ///
- /// Called from the state machine when an operation forces a modeless dialog close.
- ///
- public static void UpdateMessage(MessageEventArgs args)
- {
- if (UpdateMessageHandler == null) return;
- try { UpdateMessageHandler(null, args); }
- catch (Exception) { }
- }
- public static event EventHandler UpdateMessageHandler;
-
- void OnUpdateMessage(object sender, MessageEventArgs args)
- {
- Message = args.Message;
- if (Message != null) label1.Text = Message;
- }
-
-
- ///
- /// Called from the state machine when an operation forces a modeless dialog close.
- ///
- public static void CloseForm()
- {
- if (CloseFormHandler == null) return;
- try { CloseFormHandler(null, null); }
- catch (Exception) { }
- }
- public static event EventHandler CloseFormHandler;
-
- void OnCloseForm(object sender, EventArgs args)
- {
- DialogResult = DialogResult.Cancel;
- Close();
- }
-
-
- public string Title;
- public string Message;
- public Color BackgroundColor;
- public Color TextColor;
- public Font TextFont;
- public string FontFamily;
- public int FontSize;
- public FontStyle FontStyle;
-
-
///
/// Constructor to be used by the application
///
/// Window title
/// Displayed message
- public ModelessForm()
+ public ModelessForm(string message, int backArgb = 0, int textArgb = 0, Font textFont = null, string title = null)
{
InitializeComponent();
ControlBox = false;
+ label1.Text = (message != null) ? message : "Please wait";
+ BackColor = (backArgb != 0) ? Color.FromArgb(backArgb) : Color.LightGreen;
+ ForeColor = (textArgb != 0) ? Color.FromArgb(textArgb) : Color.Black;
+ label1.Font = (textFont != null) ? textFont : new Font("Arial", 14, FontStyle.Regular);
+ Text = (title != null) ? title : string.Empty;
+
+ float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
+ float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height;
+ Width = (int)textWidth + 120; /// Form width calculated from the text width
+ Height += (int)textHeight; /// Form height calculated from the text height
+
UpdateMessageHandler += delegate(object sender, MessageEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler(OnUpdateMessage), sender, args); }
@@ -75,18 +40,37 @@ namespace Common.Forms
};
}
- private void ModelessForm_Load(object sender, EventArgs e)
- {
- if (Title != null) Text = Title;
- if (Message != null) label1.Text = Message;
- if (BackgroundColor != null) BackColor = BackgroundColor;
- if (TextColor != null) ForeColor = TextColor;
- if (FontFamily != null) label1.Font = new Font(FontFamily, FontSize, FontStyle);
- float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
- float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height;
- Width = (int)textWidth + 120; /// Form width calculated from the text width
- Height += (int)textHeight; /// Form height calculated from the text height
+ ///
+ /// Called from the state machine when an operation forces a modeless dialog close.
+ ///
+ public void UpdateMessage(MessageEventArgs args)
+ {
+ if (UpdateMessageHandler == null) return;
+ try { UpdateMessageHandler(null, args); }
+ catch (Exception) { }
+ }
+ public event EventHandler UpdateMessageHandler;
+ void OnUpdateMessage(object sender, MessageEventArgs args)
+ {
+ if (args.Message != null) label1.Text = args.Message;
+ }
+
+
+ ///
+ /// Called from the state machine when an operation forces a modeless dialog close.
+ ///
+ public static void CloseForm()
+ {
+ if (CloseFormHandler == null) return;
+ try { CloseFormHandler(null, null); }
+ catch (Exception) { }
+ }
+ static public event EventHandler CloseFormHandler;
+ void OnCloseForm(object sender, EventArgs args)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
}
}
}
diff --git a/Common/QuitAppException.cs b/Common/QuitAppException.cs
new file mode 100644
index 000000000..ae06a4cb8
--- /dev/null
+++ b/Common/QuitAppException.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace Common
+{
+ public class QuitAppException : Exception
+ {
+ public QuitAppException(string message)
+ : base(message)
+ {
+ }
+ }
+}