diff --git a/DarkUI/Config/Enums.cs b/DarkUI/Config/Enums.cs
index 4e1029f..a09c523 100644
--- a/DarkUI/Config/Enums.cs
+++ b/DarkUI/Config/Enums.cs
@@ -25,4 +25,23 @@
Vertical,
Horizontal
}
+
+ public enum DarkDialogButton
+ {
+ Ok,
+ Close,
+ OkCancel,
+ YesNo,
+ YesNoCancel,
+ AbortRetryIgnore,
+ RetryCancel
+ }
+
+ public enum DarkMessageBoxIcon
+ {
+ None,
+ Information,
+ Warning,
+ Error
+ }
}
diff --git a/DarkUI/Controls/DarkLabel.cs b/DarkUI/Controls/DarkLabel.cs
index 64ed4d7..6b88d4d 100644
--- a/DarkUI/Controls/DarkLabel.cs
+++ b/DarkUI/Controls/DarkLabel.cs
@@ -34,9 +34,6 @@ namespace DarkUI
}
}
- [Category("Layout")]
- [Description("Enables automatic resizing based on font size. Note that this is only valid for label controls that do not wrap text.")]
- [DefaultValue(true)]
public new bool AutoSize
{
get { return base.AutoSize; }
diff --git a/DarkUI/DarkUI.csproj b/DarkUI/DarkUI.csproj
index 4ba540f..a2ee4ec 100644
--- a/DarkUI/DarkUI.csproj
+++ b/DarkUI/DarkUI.csproj
@@ -35,6 +35,7 @@
+
@@ -66,14 +67,31 @@
+
+ Form
+
+
+ DarkDialog.cs
+
Form
+
+ Form
+
+
+ DarkMessageBox.cs
+
True
True
MenuIcons.resx
+
+ True
+ True
+ MessageBoxIcons.resx
+
True
True
@@ -84,11 +102,22 @@
+
+ DarkDialog.cs
+
+
+ DarkMessageBox.cs
+
PublicResXFileCodeGenerator
MenuIcons.Designer.cs
DarkUI
+
+ ResXFileCodeGenerator
+ MessageBoxIcons.Designer.cs
+ DarkUI
+
ResXFileCodeGenerator
ScrollIcons.Designer.cs
@@ -113,6 +142,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/DarkUI/Forms/DarkMessageBox.Designer.cs b/DarkUI/Forms/DarkMessageBox.Designer.cs
new file mode 100644
index 0000000..a285fd1
--- /dev/null
+++ b/DarkUI/Forms/DarkMessageBox.Designer.cs
@@ -0,0 +1,81 @@
+namespace DarkUI
+{
+ partial class DarkMessageBox
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.picIcon = new System.Windows.Forms.PictureBox();
+ this.lblText = new DarkUI.DarkLabel();
+ ((System.ComponentModel.ISupportInitialize)(this.picIcon)).BeginInit();
+ this.SuspendLayout();
+ //
+ // picIcon
+ //
+ this.picIcon.Location = new System.Drawing.Point(10, 10);
+ this.picIcon.Name = "picIcon";
+ this.picIcon.Size = new System.Drawing.Size(32, 32);
+ this.picIcon.TabIndex = 3;
+ this.picIcon.TabStop = false;
+ //
+ // lblText
+ //
+ this.lblText.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
+ this.lblText.Location = new System.Drawing.Point(50, 9);
+ this.lblText.Name = "lblText";
+ this.lblText.Size = new System.Drawing.Size(185, 15);
+ this.lblText.TabIndex = 4;
+ this.lblText.Text = "Something something something";
+ //
+ // DarkMessageBox
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(244, 86);
+ this.Controls.Add(this.lblText);
+ this.Controls.Add(this.picIcon);
+ this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "DarkMessageBox";
+ this.ShowIcon = false;
+ this.ShowInTaskbar = false;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Message box";
+ this.Controls.SetChildIndex(this.picIcon, 0);
+ this.Controls.SetChildIndex(this.lblText, 0);
+ ((System.ComponentModel.ISupportInitialize)(this.picIcon)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PictureBox picIcon;
+ private DarkLabel lblText;
+ }
+}
\ No newline at end of file
diff --git a/DarkUI/Forms/DarkMessageBox.cs b/DarkUI/Forms/DarkMessageBox.cs
new file mode 100644
index 0000000..6cf7d57
--- /dev/null
+++ b/DarkUI/Forms/DarkMessageBox.cs
@@ -0,0 +1,149 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace DarkUI
+{
+ public partial class DarkMessageBox : DarkDialog
+ {
+ #region Field Region
+
+ private string _message;
+ private int _maximumWidth = 350;
+
+ #endregion
+
+ #region Property Region
+
+ [Description("Determines the maximum width of the message box when it autosizes around the displayed message.")]
+ [DefaultValue(350)]
+ public int MaximumWidth
+ {
+ get { return _maximumWidth; }
+ set
+ {
+ _maximumWidth = value;
+ CalculateSize();
+ }
+ }
+
+ #endregion
+
+ #region Constructor Region
+
+ public DarkMessageBox()
+ {
+ InitializeComponent();
+ }
+
+ public DarkMessageBox(string message, string title, DarkMessageBoxIcon icon, DarkDialogButton buttons)
+ : this()
+ {
+ var offsetHeight = Height - picIcon.Height;
+
+ Text = title;
+ _message = message;
+
+ DialogButtons = buttons;
+ SetIcon(icon);
+ }
+
+ public DarkMessageBox(string message)
+ : this(message, null, DarkMessageBoxIcon.None, DarkDialogButton.Ok)
+ { }
+
+ public DarkMessageBox(string message, string title)
+ : this(message, title, DarkMessageBoxIcon.None, DarkDialogButton.Ok)
+ { }
+
+ public DarkMessageBox(string message, string title, DarkDialogButton buttons)
+ : this(message, title, DarkMessageBoxIcon.None, buttons)
+ { }
+
+ public DarkMessageBox(string message, string title, DarkMessageBoxIcon icon)
+ : this(message, title, icon, DarkDialogButton.Ok)
+ { }
+
+ #endregion
+
+ #region Method Region
+
+ private void SetIcon(DarkMessageBoxIcon icon)
+ {
+ switch (icon)
+ {
+ case DarkMessageBoxIcon.None:
+ picIcon.Visible = false;
+ lblText.Left = 10;
+ break;
+ case DarkMessageBoxIcon.Information:
+ picIcon.Image = MessageBoxIcons.info;
+ break;
+ case DarkMessageBoxIcon.Warning:
+ picIcon.Image = MessageBoxIcons.warning;
+ break;
+ case DarkMessageBoxIcon.Error:
+ picIcon.Image = MessageBoxIcons.error;
+ break;
+ }
+ }
+
+ private void CalculateSize()
+ {
+ var width = 260; var height = 124;
+
+ // Reset form back to original size
+ Size = new Size(width, height);
+
+ lblText.Text = string.Empty;
+ lblText.AutoSize = true;
+ lblText.Text = _message;
+
+ // Set the minimum dialog size to whichever is bigger - the original size or the buttons.
+ var minWidth = Math.Max(width, TotalButtonSize + 15);
+
+ // Calculate the total size of the message
+ var totalWidth = lblText.Right + 25;
+
+ // Make sure we're not making the dialog bigger than the maximum size
+ if (totalWidth < _maximumWidth)
+ {
+ // Width is smaller than the maximum width.
+ // This means we can have a single-line message box.
+ // Move the label to accomodate this.
+ width = totalWidth;
+ lblText.Top = picIcon.Top + (picIcon.Height / 2) - (lblText.Height / 2);
+ }
+ else
+ {
+ // Width is larger than the maximum width.
+ // Change the label size and wrap it.
+ width = _maximumWidth;
+ var offsetHeight = Height - picIcon.Height;
+ lblText.AutoUpdateHeight = true;
+ lblText.Width = width - lblText.Left - 25;
+ height = offsetHeight + lblText.Height;
+ }
+
+ // Force the width to the minimum width
+ if (width < minWidth)
+ width = minWidth;
+
+ // Set the new size of the dialog
+ Size = new Size(width, height);
+ }
+
+ #endregion
+
+ #region Event Handler Region
+
+ protected override void OnLoad(EventArgs e)
+ {
+ base.OnLoad(e);
+
+ CalculateSize();
+ }
+
+ #endregion
+ }
+}
diff --git a/DarkUI/Forms/DarkMessageBox.resx b/DarkUI/Forms/DarkMessageBox.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/DarkUI/Forms/DarkMessageBox.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/DarkUI/Icons/MessageBoxIcons.Designer.cs b/DarkUI/Icons/MessageBoxIcons.Designer.cs
new file mode 100644
index 0000000..7c94bba
--- /dev/null
+++ b/DarkUI/Icons/MessageBoxIcons.Designer.cs
@@ -0,0 +1,93 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace DarkUI {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class MessageBoxIcons {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal MessageBoxIcons() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DarkUI.Icons.MessageBoxIcons", typeof(MessageBoxIcons).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap error {
+ get {
+ object obj = ResourceManager.GetObject("error", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap info {
+ get {
+ object obj = ResourceManager.GetObject("info", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap warning {
+ get {
+ object obj = ResourceManager.GetObject("warning", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/DarkUI/Icons/MessageBoxIcons.resx b/DarkUI/Icons/MessageBoxIcons.resx
new file mode 100644
index 0000000..3303bd4
--- /dev/null
+++ b/DarkUI/Icons/MessageBoxIcons.resx
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Resources\error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\info.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\warning.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/DarkUI/Resources/error.png b/DarkUI/Resources/error.png
new file mode 100644
index 0000000..7d96891
Binary files /dev/null and b/DarkUI/Resources/error.png differ
diff --git a/DarkUI/Resources/info.png b/DarkUI/Resources/info.png
new file mode 100644
index 0000000..0a22e72
Binary files /dev/null and b/DarkUI/Resources/info.png differ
diff --git a/DarkUI/Resources/warning.png b/DarkUI/Resources/warning.png
new file mode 100644
index 0000000..6fbf0ef
Binary files /dev/null and b/DarkUI/Resources/warning.png differ
diff --git a/Example/Forms/MainForm.Designer.cs b/Example/Forms/MainForm.Designer.cs
index bcdb59a..fcd6887 100644
--- a/Example/Forms/MainForm.Designer.cs
+++ b/Example/Forms/MainForm.Designer.cs
@@ -77,6 +77,8 @@
this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel6 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel5 = new System.Windows.Forms.ToolStripStatusLabel();
+ this.btnDialog = new DarkUI.DarkButton();
+ this.btnMessageBox = new DarkUI.DarkButton();
this.mnuMain.SuspendLayout();
this.toolMain.SuspendLayout();
this.darkStatusStrip1.SuspendLayout();
@@ -538,16 +540,35 @@
this.toolStripStatusLabel5.Text = "120 MB";
this.toolStripStatusLabel5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
+ // btnDialog
+ //
+ this.btnDialog.Location = new System.Drawing.Point(25, 73);
+ this.btnDialog.Name = "btnDialog";
+ this.btnDialog.Padding = new System.Windows.Forms.Padding(5);
+ this.btnDialog.Size = new System.Drawing.Size(97, 30);
+ this.btnDialog.TabIndex = 3;
+ this.btnDialog.Text = "Dialog";
+ //
+ // btnMessageBox
+ //
+ this.btnMessageBox.Location = new System.Drawing.Point(128, 73);
+ this.btnMessageBox.Name = "btnMessageBox";
+ this.btnMessageBox.Padding = new System.Windows.Forms.Padding(5);
+ this.btnMessageBox.Size = new System.Drawing.Size(97, 30);
+ this.btnMessageBox.TabIndex = 4;
+ this.btnMessageBox.Text = "Message Box";
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(784, 562);
+ this.Controls.Add(this.btnMessageBox);
+ this.Controls.Add(this.btnDialog);
this.Controls.Add(this.darkStatusStrip1);
this.Controls.Add(this.toolMain);
this.Controls.Add(this.mnuMain);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MainMenuStrip = this.mnuMain;
this.MinimumSize = new System.Drawing.Size(640, 480);
this.Name = "MainForm";
@@ -614,6 +635,8 @@
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel6;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5;
+ private DarkUI.DarkButton btnDialog;
+ private DarkUI.DarkButton btnMessageBox;
}
}
diff --git a/Example/Forms/MainForm.cs b/Example/Forms/MainForm.cs
index 0ced87d..8f9f014 100644
--- a/Example/Forms/MainForm.cs
+++ b/Example/Forms/MainForm.cs
@@ -1,5 +1,4 @@
using DarkUI;
-using System.Windows.Forms;
namespace Example
{
@@ -8,6 +7,19 @@ namespace Example
public MainForm()
{
InitializeComponent();
+
+ btnDialog.Click += delegate {
+ var msgBox = new DarkMessageBox("This is small",
+ "Dark UI Example", DarkMessageBoxIcon.Information, DarkDialogButton.AbortRetryIgnore);
+ msgBox.ShowDialog();
+ };
+
+ btnMessageBox.Click += delegate {
+ var msgBox = new DarkMessageBox("This is a test of the dark message box. It's cool, isn't it? You can have really quite a lot of text in here and the message box will size itself appropriately. I dislike how the default .NET message box handled this, so hopefully this will be a better option for you. :)",
+ "Dark UI Example", DarkMessageBoxIcon.Information, DarkDialogButton.AbortRetryIgnore);
+ msgBox.MaximumWidth = 350;
+ msgBox.ShowDialog();
+ };
}
}
}