commit 553279b2e936df19b910fe3d175f4cff62f7d50f Author: Eugen Höglinger Date: Thu Feb 27 15:11:17 2020 +0100 Projekt neu angelegt. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a5f80a --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ + +#Ignore thumbnails created by Windows +Thumbs.db +#Ignore files built by Visual Studio +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +.vs/ +#Nuget packages folder +packages/ diff --git a/Daten/Construction.png b/Daten/Construction.png new file mode 100644 index 0000000..0914ebc Binary files /dev/null and b/Daten/Construction.png differ diff --git a/Daten/Email.png b/Daten/Email.png new file mode 100644 index 0000000..6224ae0 Binary files /dev/null and b/Daten/Email.png differ diff --git a/Daten/Error.png b/Daten/Error.png new file mode 100644 index 0000000..500eb96 Binary files /dev/null and b/Daten/Error.png differ diff --git a/Daten/FatalError.png b/Daten/FatalError.png new file mode 100644 index 0000000..17de198 Binary files /dev/null and b/Daten/FatalError.png differ diff --git a/Daten/Information.png b/Daten/Information.png new file mode 100644 index 0000000..6c532b2 Binary files /dev/null and b/Daten/Information.png differ diff --git a/Daten/Instruction.png b/Daten/Instruction.png new file mode 100644 index 0000000..844188f Binary files /dev/null and b/Daten/Instruction.png differ diff --git a/Daten/Question.png b/Daten/Question.png new file mode 100644 index 0000000..edfb8bd Binary files /dev/null and b/Daten/Question.png differ diff --git a/Daten/Telephone.png b/Daten/Telephone.png new file mode 100644 index 0000000..31327bb Binary files /dev/null and b/Daten/Telephone.png differ diff --git a/Daten/Tips.png b/Daten/Tips.png new file mode 100644 index 0000000..a42695d Binary files /dev/null and b/Daten/Tips.png differ diff --git a/Daten/Warning.png b/Daten/Warning.png new file mode 100644 index 0000000..dd4990d Binary files /dev/null and b/Daten/Warning.png differ diff --git a/OwnMessageBox.sln b/OwnMessageBox.sln new file mode 100644 index 0000000..99bc55d --- /dev/null +++ b/OwnMessageBox.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OwnMessageBox", "OwnMessageBox\OwnMessageBox.csproj", "{F421906F-D2C3-4AD2-9C1F-17150AC80E17}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test_OwnMessageBox", "Test_OwnMessageBox\Test_OwnMessageBox\Test_OwnMessageBox.csproj", "{283AB9AE-B155-4143-8661-8F53021AF906}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F421906F-D2C3-4AD2-9C1F-17150AC80E17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F421906F-D2C3-4AD2-9C1F-17150AC80E17}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F421906F-D2C3-4AD2-9C1F-17150AC80E17}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F421906F-D2C3-4AD2-9C1F-17150AC80E17}.Release|Any CPU.Build.0 = Release|Any CPU + {283AB9AE-B155-4143-8661-8F53021AF906}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {283AB9AE-B155-4143-8661-8F53021AF906}.Debug|Any CPU.Build.0 = Debug|Any CPU + {283AB9AE-B155-4143-8661-8F53021AF906}.Release|Any CPU.ActiveCfg = Release|Any CPU + {283AB9AE-B155-4143-8661-8F53021AF906}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4914E6F3-31D2-44BC-99DA-6B95E968B932} + EndGlobalSection +EndGlobal diff --git a/OwnMessageBox/App.config b/OwnMessageBox/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/OwnMessageBox/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OwnMessageBox/Icons.cs b/OwnMessageBox/Icons.cs new file mode 100644 index 0000000..1bf02ab --- /dev/null +++ b/OwnMessageBox/Icons.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace EOwnMessageBox +{ + public class Icons + { + /// + /// Control the possible icons. + /// + public Icons() + { + SetIcon(Icon.Information); //Initialisiere ein Icon + } + + //Die vorhandenen Icons + public enum Icon + { + Construction, + Email, + Error, + FatalError, + Information, + Instruction, + NoIcon, + Question, + Telephon, + Tips, + Warning + } + + /// + /// Stores the current icon. + /// + public Icon CurrentIcon { private set; get; } + + /// + /// Stores the current icon image. + /// + public Bitmap CurrentIconImage { private set; get; } + + /// + /// Sets the used icon. + /// + /// A valid icon. Possible options are: 'Construction', 'Email', 'Error', 'FatalError', 'Information', 'Instruction', 'Question', 'Telephone', 'Tips', 'Warning'. + /// Returns the image name. + public Bitmap SetIcon(Icon icon) + { + switch (icon) + { + case Icon.Construction: + CurrentIconImage = GetIconImage("Test_Form.Resources.Construction.png"); + break; + case Icon.Email: + CurrentIconImage = GetIconImage("Test_Form.Resources.Email.png"); + break; + case Icon.Error: + CurrentIconImage = GetIconImage("Test_Form.Resources.Error.png"); + break; + case Icon.FatalError: + CurrentIconImage = GetIconImage("Test_Form.Resources.FatalError.png"); + break; + case Icon.Instruction: + CurrentIconImage = GetIconImage("Test_Form.Resources.Instruction.png"); + break; + case Icon.Question: + CurrentIconImage = GetIconImage("Test_Form.Resources.Question.png"); + break; + case Icon.Telephon: + CurrentIconImage = GetIconImage("Test_Form.Resources.Telephon.png"); + break; + case Icon.Tips: + CurrentIconImage = GetIconImage("Test_Form.Resources.Tips.png"); + break; + case Icon.Warning: + CurrentIconImage = GetIconImage("Test_Form.Resources.Warning.png"); + break; + default: + CurrentIconImage = GetIconImage("Test_Form.Resources.Information.png"); + break; + } + CurrentIcon = icon; + return CurrentIconImage; + } + + private Bitmap GetIconImage(string icon) + { + Assembly myAssembly = Assembly.GetExecutingAssembly(); + Stream myStream = myAssembly.GetManifestResourceStream(icon); + Bitmap bmp = new Bitmap(myStream); + return bmp; + } + } +} diff --git a/OwnMessageBox/OwnMessageBox.Designer.cs b/OwnMessageBox/OwnMessageBox.Designer.cs new file mode 100644 index 0000000..368d9ed --- /dev/null +++ b/OwnMessageBox/OwnMessageBox.Designer.cs @@ -0,0 +1,120 @@ +namespace EOwnMessageBox +{ + partial class OwnMessageBox + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonCenter = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + this.labelText = new System.Windows.Forms.Label(); + this.pictureBoxIcon = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIcon)).BeginInit(); + this.SuspendLayout(); + // + // buttonLeft + // + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonLeft.Location = new System.Drawing.Point(13, 415); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(75, 23); + this.buttonLeft.TabIndex = 0; + this.buttonLeft.Text = "Left"; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.buttonLeft_Click); + // + // buttonCenter + // + this.buttonCenter.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.buttonCenter.Location = new System.Drawing.Point(363, 415); + this.buttonCenter.Name = "buttonCenter"; + this.buttonCenter.Size = new System.Drawing.Size(75, 23); + this.buttonCenter.TabIndex = 1; + this.buttonCenter.Text = "Center"; + this.buttonCenter.UseVisualStyleBackColor = true; + this.buttonCenter.Click += new System.EventHandler(this.buttonCenter_Click); + // + // buttonRight + // + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.Location = new System.Drawing.Point(713, 415); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(75, 23); + this.buttonRight.TabIndex = 2; + this.buttonRight.Text = "Right"; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.buttonRight_Click); + // + // labelText + // + this.labelText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.labelText.Location = new System.Drawing.Point(13, 13); + this.labelText.Name = "labelText"; + this.labelText.Size = new System.Drawing.Size(775, 399); + this.labelText.TabIndex = 3; + this.labelText.Text = "..."; + // + // pictureBoxIcon + // + this.pictureBoxIcon.BackgroundImage = global::OwnMessageBox.Properties.Resources.Information; + this.pictureBoxIcon.Enabled = false; + this.pictureBoxIcon.Location = new System.Drawing.Point(12, 12); + this.pictureBoxIcon.Name = "pictureBoxIcon"; + this.pictureBoxIcon.Size = new System.Drawing.Size(32, 32); + this.pictureBoxIcon.TabIndex = 4; + this.pictureBoxIcon.TabStop = false; + this.pictureBoxIcon.Visible = false; + // + // OwnMessageBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.pictureBoxIcon); + this.Controls.Add(this.labelText); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonCenter); + this.Controls.Add(this.buttonLeft); + this.Name = "OwnMessageBox"; + this.Text = "OwnMessageBox"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxIcon)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonLeft; + private System.Windows.Forms.Button buttonCenter; + private System.Windows.Forms.Button buttonRight; + private System.Windows.Forms.Label labelText; + private System.Windows.Forms.PictureBox pictureBoxIcon; + } +} + diff --git a/OwnMessageBox/OwnMessageBox.cs b/OwnMessageBox/OwnMessageBox.cs new file mode 100644 index 0000000..e41a678 --- /dev/null +++ b/OwnMessageBox/OwnMessageBox.cs @@ -0,0 +1,437 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace EOwnMessageBox +{ + public partial class OwnMessageBox : Form + { + #region Version und Copyright + // Version und Copyright + string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + string icon = Application.StartupPath + "\\Info.bmp"; + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + string date = value.ToShortDateString(); + string time = value.ToLongTimeString(); + private static DateTime AssemblyDateTime() + { + var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision)); + //Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original) + return buildDateTime; + } + #endregion + + #region Programm-Info + /// + /// Contains the name of the program file + /// + public static string ProgramName { set; get; } + + /// + /// Contains the version of the program file + /// + public static string ProgramVersion { set; get; } + + /// + /// Contains the copyright notice + /// + public static string Copyright { set; get; } + + private void SetProgramInfo() + { + //Name, Version und Copyright setzen + ProgramName = programName; + ProgramVersion = programVersion; + Copyright = copyright; + } + #endregion + + /// + /// Set or Get the pressed button text + /// + public string Result { set; get; } + + public OwnMessageBox() + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + } + + public OwnMessageBox(Window.Size size) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = ""; + HideButton("Left"); + HideButton("Center"); + HideButton("Right"); + } + + public OwnMessageBox(Window.Size size, string name, string lblText) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + this.labelText.Text = lblText; + HideButton("Left"); + HideButton("Center"); + HideButton("Right"); + } + + public OwnMessageBox(Window.Size size, string name, string lblText, string btnCenter) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + this.labelText.Text = lblText; + HideButton("Left"); + this.buttonCenter.Text = btnCenter; + HideButton("Right"); + } + + public OwnMessageBox(Window.Size size, string name, string lblText, string btnLeft, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + HideButton("Center"); + this.buttonRight.Text = btnRight; + } + + public OwnMessageBox(Window.Size size, string name, string lblText, string btnLeft, string btnCenter, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + this.buttonCenter.Text = btnCenter; + this.buttonRight.Text = btnRight; + } + + public OwnMessageBox(Window.Size size, string name, Window.ControlBox ctrlBox, string lblText, string btnCenter) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (ctrlBox == Window.ControlBox.Off) + { + this.ControlBox = false; + } + HideButton("Left"); + this.buttonCenter.Text = btnCenter; + HideButton("Right"); + } + + public OwnMessageBox(Window.Size size, string name, Window.ControlBox ctrlBox, string lblText, string btnLeft, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (ctrlBox == Window.ControlBox.Off) + { + this.ControlBox = false; + } + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + HideButton("Center"); + this.buttonRight.Text = btnRight; + } + + public OwnMessageBox(Window.Size size, string name, Window.ControlBox ctrlBox, string lblText, string btnLeft, string btnCenter, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (ctrlBox == Window.ControlBox.Off) + { + this.ControlBox = false; + } + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + this.buttonCenter.Text = btnCenter; + this.buttonRight.Text = btnRight; + } + + public OwnMessageBox(Window.Size size, string name, Icons.Icon icon, string lblText) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (icon != Icons.Icon.NoIcon) + { + DrawIcon(icon); + ResizeLabel(); + } + this.labelText.Text = lblText; + HideButton("Left"); + HideButton("Center"); + HideButton("Right"); + } + + public OwnMessageBox(Window.Size size, string name, Icons.Icon icon, string lblText, string btnCenter) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (icon != Icons.Icon.NoIcon) + { + DrawIcon(icon); + ResizeLabel(); + } + this.labelText.Text = lblText; + HideButton("Left"); + this.buttonCenter.Text = btnCenter; + HideButton("Right"); + } + + public OwnMessageBox(Window.Size size, string name, Icons.Icon icon, string lblText, string btnLeft, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (icon != Icons.Icon.NoIcon) + { + DrawIcon(icon); + ResizeLabel(); + } + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + HideButton("Center"); + this.buttonRight.Text = btnRight; + } + + public OwnMessageBox(Window.Size size, string name, Icons.Icon icon, string lblText, string btnLeft, string btnCenter, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (icon != Icons.Icon.NoIcon) + { + DrawIcon(icon); + ResizeLabel(); + } + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + this.buttonCenter.Text = btnCenter; + this.buttonRight.Text = btnRight; + } + + public OwnMessageBox(Window.Size size, string name, Window.ControlBox ctrlBox, Icons.Icon icon, string lblText, string btnCenter) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (ctrlBox == Window.ControlBox.Off) + { + this.ControlBox = false; + } + if (icon != Icons.Icon.NoIcon) + { + DrawIcon(icon); + ResizeLabel(); + } + HideButton("Left"); + this.buttonCenter.Text = btnCenter; + HideButton("Right"); + } + + public OwnMessageBox(Window.Size size, string name, Window.ControlBox ctrlBox, Icons.Icon icon, string lblText, string btnLeft, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (ctrlBox == Window.ControlBox.Off) + { + this.ControlBox = false; + } + if (icon != Icons.Icon.NoIcon) + { + DrawIcon(icon); + ResizeLabel(); + } + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + HideButton("Center"); + this.buttonRight.Text = btnRight; + } + + public OwnMessageBox(Window.Size size, string name, Window.ControlBox ctrlBox, Icons.Icon icon, string lblText, string btnLeft, string btnCenter, string btnRight) + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + + this.MinimumSize = new System.Drawing.Size(Window.XSize(Window.Size.Nano), Window.YSize(Window.Size.Nano)); + this.ClientSize = new System.Drawing.Size(Window.XSize(size), Window.YSize(size)); + this.Text = name; + if (ctrlBox == Window.ControlBox.Off) + { + this.ControlBox = false; + } + if (icon != Icons.Icon.NoIcon) + { + DrawIcon(icon); + ResizeLabel(); + } + this.labelText.Text = lblText; + this.buttonLeft.Text = btnLeft; + this.buttonCenter.Text = btnCenter; + this.buttonRight.Text = btnRight; + } + + private System.Drawing.Image SetIcon(Icons.Icon icon) + { + this.pictureBoxIcon.BackgroundImage = global::OwnMessageBox.Properties.Resources.Information; + System.Drawing.Image image = null; + + switch (icon) + { + case Icons.Icon.Construction: + image = global::OwnMessageBox.Properties.Resources.Construction; + break; + case Icons.Icon.Email: + image = global::OwnMessageBox.Properties.Resources.Email; + break; + case Icons.Icon.Error: + image = global::OwnMessageBox.Properties.Resources.Error; + break; + case Icons.Icon.FatalError: + image = global::OwnMessageBox.Properties.Resources.FatalError; + break; + case Icons.Icon.Instruction: + image = global::OwnMessageBox.Properties.Resources.Instruction; + break; + case Icons.Icon.Question: + image = global::OwnMessageBox.Properties.Resources.Question; + break; + case Icons.Icon.Telephon: + image = global::OwnMessageBox.Properties.Resources.Telephone; + break; + case Icons.Icon.Tips: + image = global::OwnMessageBox.Properties.Resources.Tips; + break; + case Icons.Icon.Warning: + image = global::OwnMessageBox.Properties.Resources.Warning; + break; + default: + image = global::OwnMessageBox.Properties.Resources.Information; + break; + } + return image; + } + + private void DrawIcon(Icons.Icon icon) + { + this.pictureBoxIcon.BackgroundImage = SetIcon(icon); + this.pictureBoxIcon.Enabled = true; + this.pictureBoxIcon.Visible = true; + } + + private void ResizeLabel() + { + this.labelText.Size = new System.Drawing.Size(this.labelText.Size.Width - 50, 399); + this.labelText.Location = new System.Drawing.Point(63, 13); + } + + private void HideButton(string pos) + { + switch (pos.ToLower()) + { + case "left": + this.buttonLeft.Enabled = false; + this.buttonLeft.Visible = false; + break; + case "center": + this.buttonCenter.Enabled = false; + this.buttonCenter.Visible = false; + break; + case "right": + this.buttonRight.Enabled = false; + this.buttonRight.Visible = false; + break; + } + } + + #region Button + private void buttonLeft_Click(object sender, EventArgs e) + { + //Den Text des Button zurückgeben + Result = sender.ToString().Remove(0, sender.ToString().LastIndexOf(":") + 2); + Close(); + } + + private void buttonCenter_Click(object sender, EventArgs e) + { + //Den Text des Button zurückgeben + Result = sender.ToString().Remove(0, sender.ToString().LastIndexOf(":") + 2); + Close(); + } + + private void buttonRight_Click(object sender, EventArgs e) + { + //Den Text des Button zurückgeben + Result = sender.ToString().Remove(0, sender.ToString().LastIndexOf(":") + 2); + Close(); + } + #endregion + } +} diff --git a/OwnMessageBox/OwnMessageBox.csproj b/OwnMessageBox/OwnMessageBox.csproj new file mode 100644 index 0000000..5c755ad --- /dev/null +++ b/OwnMessageBox/OwnMessageBox.csproj @@ -0,0 +1,116 @@ + + + + + Debug + AnyCPU + {F421906F-D2C3-4AD2-9C1F-17150AC80E17} + WinExe + OwnMessageBox + OwnMessageBox + v4.6.1 + 512 + true + false + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + Form + + + OwnMessageBox.cs + + + + + + OwnMessageBox.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OwnMessageBox/OwnMessageBox.resx b/OwnMessageBox/OwnMessageBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/OwnMessageBox/OwnMessageBox.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/OwnMessageBox/Program.cs b/OwnMessageBox/Program.cs new file mode 100644 index 0000000..3ac841a --- /dev/null +++ b/OwnMessageBox/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace EOwnMessageBox +{ + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new OwnMessageBox()); + } + } +} diff --git a/OwnMessageBox/Properties/AssemblyInfo.cs b/OwnMessageBox/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8e6a712 --- /dev/null +++ b/OwnMessageBox/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("OwnMessageBox")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OwnMessageBox")] +[assembly: AssemblyCopyright("Copyright © 2018 ")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("f421906f-d2c3-4ad2-9c1f-17150ac80e17")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OwnMessageBox/Properties/Resources.Designer.cs b/OwnMessageBox/Properties/Resources.Designer.cs new file mode 100644 index 0000000..5e13213 --- /dev/null +++ b/OwnMessageBox/Properties/Resources.Designer.cs @@ -0,0 +1,163 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.42000 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace OwnMessageBox.Properties { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [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("OwnMessageBox.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Construction { + get { + object obj = ResourceManager.GetObject("Construction", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Email { + get { + object obj = ResourceManager.GetObject("Email", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Error { + get { + object obj = ResourceManager.GetObject("Error", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap FatalError { + get { + object obj = ResourceManager.GetObject("FatalError", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Information { + get { + object obj = ResourceManager.GetObject("Information", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Instruction { + get { + object obj = ResourceManager.GetObject("Instruction", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Question { + get { + object obj = ResourceManager.GetObject("Question", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Telephone { + get { + object obj = ResourceManager.GetObject("Telephone", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Tips { + get { + object obj = ResourceManager.GetObject("Tips", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Warning { + get { + object obj = ResourceManager.GetObject("Warning", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/OwnMessageBox/Properties/Resources.resx b/OwnMessageBox/Properties/Resources.resx new file mode 100644 index 0000000..dd6c49c --- /dev/null +++ b/OwnMessageBox/Properties/Resources.resx @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\Construction.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Email.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Error.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\FatalError.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Information.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Instruction.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Question.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Telephone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\Tips.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/OwnMessageBox/Properties/Settings.Designer.cs b/OwnMessageBox/Properties/Settings.Designer.cs new file mode 100644 index 0000000..7ed57af --- /dev/null +++ b/OwnMessageBox/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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 OwnMessageBox.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/OwnMessageBox/Properties/Settings.settings b/OwnMessageBox/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/OwnMessageBox/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/OwnMessageBox/Resources/Construction.png b/OwnMessageBox/Resources/Construction.png new file mode 100644 index 0000000..0914ebc Binary files /dev/null and b/OwnMessageBox/Resources/Construction.png differ diff --git a/OwnMessageBox/Resources/Email.png b/OwnMessageBox/Resources/Email.png new file mode 100644 index 0000000..6224ae0 Binary files /dev/null and b/OwnMessageBox/Resources/Email.png differ diff --git a/OwnMessageBox/Resources/Error.png b/OwnMessageBox/Resources/Error.png new file mode 100644 index 0000000..500eb96 Binary files /dev/null and b/OwnMessageBox/Resources/Error.png differ diff --git a/OwnMessageBox/Resources/FatalError.png b/OwnMessageBox/Resources/FatalError.png new file mode 100644 index 0000000..17de198 Binary files /dev/null and b/OwnMessageBox/Resources/FatalError.png differ diff --git a/OwnMessageBox/Resources/Information.png b/OwnMessageBox/Resources/Information.png new file mode 100644 index 0000000..6c532b2 Binary files /dev/null and b/OwnMessageBox/Resources/Information.png differ diff --git a/OwnMessageBox/Resources/Instruction.png b/OwnMessageBox/Resources/Instruction.png new file mode 100644 index 0000000..844188f Binary files /dev/null and b/OwnMessageBox/Resources/Instruction.png differ diff --git a/OwnMessageBox/Resources/Question.png b/OwnMessageBox/Resources/Question.png new file mode 100644 index 0000000..edfb8bd Binary files /dev/null and b/OwnMessageBox/Resources/Question.png differ diff --git a/OwnMessageBox/Resources/Telephone.png b/OwnMessageBox/Resources/Telephone.png new file mode 100644 index 0000000..31327bb Binary files /dev/null and b/OwnMessageBox/Resources/Telephone.png differ diff --git a/OwnMessageBox/Resources/Tips.png b/OwnMessageBox/Resources/Tips.png new file mode 100644 index 0000000..a42695d Binary files /dev/null and b/OwnMessageBox/Resources/Tips.png differ diff --git a/OwnMessageBox/Resources/Warning.png b/OwnMessageBox/Resources/Warning.png new file mode 100644 index 0000000..dd4990d Binary files /dev/null and b/OwnMessageBox/Resources/Warning.png differ diff --git a/OwnMessageBox/Window.cs b/OwnMessageBox/Window.cs new file mode 100644 index 0000000..63cc493 --- /dev/null +++ b/OwnMessageBox/Window.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EOwnMessageBox +{ + public class Window + { + /// + /// Controls the appearance of a window. + /// + public Window() + { + SetWindowSize(Size.Micro); //Initialisiere ein Fenster + } + + public enum Size + { + Nano, + Micro, + Mini, + Midi, + Maxi, + Magnum + } + + public enum ControlBox + { + Off, + On + } + + public enum BorderStyle + { + Fix, + Sizeable + } + + public enum TopMost + { + Off, + On + } + + /// + /// Stores the current window size. + /// + public Size CurrentWindowSize { private set; get; } + + /// + /// Stores the size values of the current window. + /// + public int[] CurrentWindowSizeValue { private set; get; } + + /// + /// Stores the current control box setting. + /// + public ControlBox CurrentControlBox { private set; get; } + + /// + /// Stores the border sizeable setting. + /// + public BorderStyle CurrentBorderStyle { private set; get; } + + /// + /// Stores the window most on top setting. + /// + public TopMost CurrentTopMostStatus { private set; get; } + + /// + /// Sets the widht and height size of a window. + /// + /// A valid window size. Possible options are: 'Nano' (360x270), 'Micro' (480x360), 'Mini' (640x480), 'Midi' (850x640), 'Maxi' (1020x770) und 'Magnum' (1360x1020). + /// Returns the widht and height value of the window. + public int[] SetWindowSize(Size size) + { + int[] windowsSize = new int[2]; + switch (size) + { + case Size.Nano: + windowsSize[0] = 360; + windowsSize[1] = 270; + break; + case Size.Mini: + windowsSize[0] = 640; + windowsSize[1] = 480; + break; + case Size.Midi: + windowsSize[0] = 850; + windowsSize[1] = 640; + break; + case Size.Maxi: + windowsSize[0] = 1020; + windowsSize[1] = 770; + break; + case Size.Magnum: + windowsSize[0] = 1360; + windowsSize[1] = 1020; + break; + default: + windowsSize[0] = 480; + windowsSize[1] = 360; + break; //Size.Micro + } + CurrentWindowSize = size; + CurrentWindowSizeValue = windowsSize; + + return CurrentWindowSizeValue; + } + + /// + /// Sets the controlbox of a window. + /// + /// A valid option. Possible options are 'Off' and 'On'. + /// Returns the control box status. + public Window.ControlBox SetControlBox(ControlBox controlBox) + { + CurrentControlBox = controlBox; + + return controlBox; + } + + /// + /// Sets the border style of a window. + /// + /// A valid option. Possible options are 'Fix' and 'Sizeable'. + /// Returns the control box status. + public Window.BorderStyle SetBorderStyle(BorderStyle borderStyle) + { + CurrentBorderStyle = borderStyle; + + return borderStyle; + } + + /// + /// Sets whether the window is most on top. + /// + /// A valid option. Possible options are 'Off' and 'On'. + /// Returns the most on top status. + public Window.TopMost SetTopMost(TopMost topMost) + { + CurrentTopMostStatus = topMost; + + return topMost; + } + + /// + /// Returns the Window X-Size + /// + /// A valid window size. E.g.: 'Window.Size.Mini' + /// + public static int XSize(Window.Size winSize) + { + var win = new Window(); + return win.SetWindowSize(winSize)[0]; + } + + /// + /// Returns the Window Y-Size + /// + /// A valid window size. E.g.: 'Window.Size.Mini' + /// + public static int YSize(Window.Size winSize) + { + var win = new Window(); + return win.SetWindowSize(winSize)[1]; ; + } + } +} diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/App.config b/Test_OwnMessageBox/Test_OwnMessageBox/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Form1.Designer.cs b/Test_OwnMessageBox/Test_OwnMessageBox/Form1.Designer.cs new file mode 100644 index 0000000..1830571 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Form1.Designer.cs @@ -0,0 +1,61 @@ +namespace Test_OwnMessageBox +{ + partial class Form1 + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.buttonStart = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // buttonStart + // + this.buttonStart.Location = new System.Drawing.Point(13, 156); + this.buttonStart.Name = "buttonStart"; + this.buttonStart.Size = new System.Drawing.Size(75, 23); + this.buttonStart.TabIndex = 0; + this.buttonStart.Text = "Start"; + this.buttonStart.UseVisualStyleBackColor = true; + this.buttonStart.Click += new System.EventHandler(this.buttonStart_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(329, 191); + this.Controls.Add(this.buttonStart); + this.Name = "Form1"; + this.Text = "MyForm"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonStart; + } +} + diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Form1.cs b/Test_OwnMessageBox/Test_OwnMessageBox/Form1.cs new file mode 100644 index 0000000..778d8c9 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Form1.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using EOwnMessageBox; + +namespace Test_OwnMessageBox +{ + public partial class Form1 : Form + { + #region Version und Copyright + // Version und Copyright + string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + string copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + string icon = Application.StartupPath + "\\Info.bmp"; + //Assembly Datum und Zeit + static DateTime value = AssemblyDateTime(); + string date = value.ToShortDateString(); + string time = value.ToLongTimeString(); + private static DateTime AssemblyDateTime() + { + var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; + var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision)); + //Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original) + return buildDateTime; + } + #endregion + + #region Programm-Info + /// + /// Contains the name of the program file + /// + public static string ProgramName { set; get; } + + /// + /// Contains the version of the program file + /// + public static string ProgramVersion { set; get; } + + /// + /// Contains the copyright notice + /// + public static string Copyright { set; get; } + + private void SetProgramInfo() + { + //Name, Version und Copyright setzen + ProgramName = programName; + ProgramVersion = programVersion; + Copyright = copyright; + } + #endregion + + public Form1() + { + SetProgramInfo(); //Name, Version und Copyright setzen + InitializeComponent(); + } + + private void buttonStart_Click(object sender, EventArgs e) + { + var omb = new EOwnMessageBox.OwnMessageBox(Window.Size.Mini); + omb.ShowDialog(); + + var omb1 = new EOwnMessageBox.OwnMessageBox(Window.Size.Nano, "MyMessageBox", "MyMessageBox\nWithout Buttons"); + omb1.ShowDialog(); + + var omb2 = new EOwnMessageBox.OwnMessageBox(Window.Size.Mini, "MyMessageBox", "MyMessageBox\nWith one Buttons", "Center"); + omb2.ShowDialog(); + string buttonPressed = omb2.Result; //Dieser Wert liefert den Beschriftungstext der gedrückten Taste zurück + MessageBox.Show(buttonPressed); //Zeigt welche Taste gedrückt wurde + + var omb3 = new EOwnMessageBox.OwnMessageBox(Window.Size.Midi, "MyMessageBox", "MyMessageBox\nWith two Buttons", "Left", "Right"); + omb3.ShowDialog(); + + var omb4 = new EOwnMessageBox.OwnMessageBox(Window.Size.Micro, "MyMessageBox", "MyMessageBox\nWith three Buttons", "Left", "Center", "Right"); + omb4.ShowDialog(); + + var omb5 = new EOwnMessageBox.OwnMessageBox(Window.Size.Maxi, "MyMessageBox", Window.ControlBox.Off, "MyMessageBox\nWithoutControlBox\nWith one Buttons", "Center"); + omb5.ShowDialog(); + + var omb6 = new EOwnMessageBox.OwnMessageBox(Window.Size.Magnum, "MyMessageBox", Window.ControlBox.Off, "MyMessageBox\nWithoutControlBox\nWith two Buttons", "OK", "Cancel"); + omb6.ShowDialog(); + + var omb7 = new EOwnMessageBox.OwnMessageBox(Window.Size.Mini, "MyMessageBox", Window.ControlBox.Off, "MyMessageBox\nWithoutControlBox\nWith three Buttons", "OK", "Reply", "Cancel"); + omb7.ShowDialog(); + + var omb8 = new EOwnMessageBox.OwnMessageBox(Window.Size.Nano, "MyMessageBox", Icons.Icon.Construction, "MyMessageBox\nWith Icon\nWithout Buttons"); + omb8.ShowDialog(); + + var omb9 = new EOwnMessageBox.OwnMessageBox(Window.Size.Mini, "MyMessageBox", Icons.Icon.Email, "MyMessageBox\nWith Icon\nWith one Buttons", "Center"); + omb9.ShowDialog(); + + var omb10 = new EOwnMessageBox.OwnMessageBox(Window.Size.Midi, "MyMessageBox", Icons.Icon.Error, "MyMessageBox\nWith Icon\nWith two Buttons", "Left", "Right"); + omb10.ShowDialog(); + + var omb11 = new EOwnMessageBox.OwnMessageBox(Window.Size.Micro, "MyMessageBox", Icons.Icon.FatalError, "MyMessageBox\nWith Icon\nWith three Buttons", "Left", "Center", "Right"); + omb11.ShowDialog(); + + var omb12 = new EOwnMessageBox.OwnMessageBox(Window.Size.Maxi, "MyMessageBox", Window.ControlBox.Off, Icons.Icon.Information, "MyMessageBox\nWithoutControlBox\nWith Icon\nWith one Buttons", "Center"); + omb12.ShowDialog(); + + var omb13 = new EOwnMessageBox.OwnMessageBox(Window.Size.Magnum, "MyMessageBox", Window.ControlBox.Off, Icons.Icon.Instruction, "MyMessageBox\nWithoutControlBox\nWith Icon\nWith two Buttons", "OK", "Cancel"); + omb13.ShowDialog(); + + var omb14 = new EOwnMessageBox.OwnMessageBox(Window.Size.Mini, "MyMessageBox", Window.ControlBox.Off, Icons.Icon.Question, "MyMessageBox\nWithoutControlBox\nWith Icon\nWith three Buttons", "OK", "Reply", "Cancel"); + omb14.ShowDialog(); + } + } +} diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Form1.resx b/Test_OwnMessageBox/Test_OwnMessageBox/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Form1.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/Test_OwnMessageBox/Test_OwnMessageBox/Program.cs b/Test_OwnMessageBox/Test_OwnMessageBox/Program.cs new file mode 100644 index 0000000..2f455a3 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Test_OwnMessageBox +{ + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Properties/AssemblyInfo.cs b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e8d263d --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("Test_OwnMessageBox")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Test_OwnMessageBox")] +[assembly: AssemblyCopyright("Copyright © 2018 ")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("283ab9ae-b155-4143-8661-8f53021af906")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Resources.Designer.cs b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Resources.Designer.cs new file mode 100644 index 0000000..b86d2a7 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion: 4.0.30319.42000 +// +// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn +// der Code neu generiert wird. +// +//------------------------------------------------------------------------------ + +namespace Test_OwnMessageBox.Properties +{ + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse + // über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test_OwnMessageBox.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Resources.resx b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Settings.Designer.cs b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Settings.Designer.cs new file mode 100644 index 0000000..b008854 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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 Test_OwnMessageBox.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Settings.settings b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Test_OwnMessageBox/Test_OwnMessageBox/Test_OwnMessageBox.csproj b/Test_OwnMessageBox/Test_OwnMessageBox/Test_OwnMessageBox.csproj new file mode 100644 index 0000000..8e8fee1 --- /dev/null +++ b/Test_OwnMessageBox/Test_OwnMessageBox/Test_OwnMessageBox.csproj @@ -0,0 +1,89 @@ + + + + + Debug + AnyCPU + {283AB9AE-B155-4143-8661-8F53021AF906} + WinExe + Test_OwnMessageBox + Test_OwnMessageBox + v4.6.1 + 512 + true + false + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {f421906f-d2c3-4ad2-9c1f-17150ac80e17} + OwnMessageBox + + + + \ No newline at end of file