commit b2b6e0200acdd1b082e9d74aece28b55ecebdf41 Author: Eugen Höglinger Date: Wed Oct 9 09:20:55 2024 +0200 Initialize diff --git a/.vs/EMessageBox.git/v17/.suo b/.vs/EMessageBox.git/v17/.suo new file mode 100644 index 0000000..832653e Binary files /dev/null and b/.vs/EMessageBox.git/v17/.suo differ diff --git a/EMessageBox.git.sln b/EMessageBox.git.sln new file mode 100644 index 0000000..496bebd --- /dev/null +++ b/EMessageBox.git.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32421.90 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EMessageBox", "EMessageBox\EMessageBox.csproj", "{3E3B287E-A7F0-430B-A18A-064517BD4922}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3E3B287E-A7F0-430B-A18A-064517BD4922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E3B287E-A7F0-430B-A18A-064517BD4922}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E3B287E-A7F0-430B-A18A-064517BD4922}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E3B287E-A7F0-430B-A18A-064517BD4922}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {95A19E3E-6E92-4139-AE64-EE31B87FF563} + EndGlobalSection +EndGlobal diff --git a/EMessageBox/EMessageBox.cs b/EMessageBox/EMessageBox.cs new file mode 100644 index 0000000..1c23c5d --- /dev/null +++ b/EMessageBox/EMessageBox.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Eugen.ESystem.Windows.Forms +{ + public static class EMessageBox + { + public static DialogResult Show(string Text, string Title, eDialogButtons Buttons, Image Image) + { + MessageForm message = new MessageForm(); + message.Text = Title; + + if (Image.Height < 0 || Image.Height > 64) + throw new Exception("Invalid image height. Valid height ranges from 0 to 64."); + else if (Image.Width < 0 || Image.Width > 64) + throw new Exception("Invalid image width. Valid width ranges from 0 to 64."); + else + { + + message.picImage.Image = Image; + message.lblText.Text = Text; + + switch (Buttons) + { + case eDialogButtons.OK: + message.btnYes.Visible = false; + message.btnNo.Visible = false; + message.btnCancel.Visible = false; + message.btnOK.Location = message.btnCancel.Location; + break; + case eDialogButtons.OKCancel: + message.btnYes.Visible = false; + message.btnNo.Visible = false; + break; + case eDialogButtons.YesNo: + message.btnOK.Visible = false; + message.btnCancel.Visible = false; + message.btnYes.Location = message.btnOK.Location; + message.btnNo.Location = message.btnCancel.Location; + break; + case eDialogButtons.YesNoCancel: + message.btnOK.Visible = false; + break; + } + + if (message.lblText.Height > 64) + message.Height = (message.lblText.Top + message.lblText.Height) + 78; + + return (message.ShowDialog()); + } + } + + public enum eDialogButtons + { + OK, + OKCancel, + YesNo, + YesNoCancel + } + } +} diff --git a/EMessageBox/EMessageBox.csproj b/EMessageBox/EMessageBox.csproj new file mode 100644 index 0000000..bb76e86 --- /dev/null +++ b/EMessageBox/EMessageBox.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {3E3B287E-A7F0-430B-A18A-064517BD4922} + Library + Properties + Eugen.ESystem.Windows.Forms + hemessbox + v4.7.2 + 512 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + MessageForm.cs + + + + + + \ No newline at end of file diff --git a/EMessageBox/MessageForm.Designer.cs b/EMessageBox/MessageForm.Designer.cs new file mode 100644 index 0000000..e05cb44 --- /dev/null +++ b/EMessageBox/MessageForm.Designer.cs @@ -0,0 +1,148 @@ +namespace Eugen.ESystem.Windows.Forms +{ + partial class MessageForm + { + /// + /// 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.picImage = new System.Windows.Forms.PictureBox(); + this.lblText = new System.Windows.Forms.Label(); + this.btnYes = new Dark.WinForms.Controls.dButton(); + this.btnNo = new Dark.WinForms.Controls.dButton(); + this.btnCancel = new Dark.WinForms.Controls.dButton(); + this.btnOK = new Dark.WinForms.Controls.dButton(); + ((System.ComponentModel.ISupportInitialize)(this.picImage)).BeginInit(); + this.SuspendLayout(); + // + // picImage + // + this.picImage.ErrorImage = null; + this.picImage.InitialImage = null; + this.picImage.Location = new System.Drawing.Point(15, 15); + this.picImage.Name = "picImage"; + this.picImage.Size = new System.Drawing.Size(64, 64); + this.picImage.TabIndex = 0; + this.picImage.TabStop = false; + // + // lblText + // + this.lblText.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.lblText.AutoSize = true; + this.lblText.Location = new System.Drawing.Point(85, 15); + this.lblText.MaximumSize = new System.Drawing.Size(294, 0); + this.lblText.Name = "lblText"; + this.lblText.Size = new System.Drawing.Size(28, 13); + this.lblText.TabIndex = 0; + this.lblText.Text = "Text"; + // + // btnYes + // + this.btnYes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnYes.FocusDuesEnabled = false; + this.btnYes.Location = new System.Drawing.Point(139, 88); + this.btnYes.Name = "btnYes"; + this.btnYes.Size = new System.Drawing.Size(75, 23); + this.btnYes.TabIndex = 2; + this.btnYes.Text = "Yes"; + this.btnYes.Tooltip = ""; + this.btnYes.UseVisualStyleBackColor = true; + this.btnYes.Click += new System.EventHandler(this.btnYes_Click); + // + // btnNo + // + this.btnNo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnNo.FocusDuesEnabled = false; + this.btnNo.Location = new System.Drawing.Point(220, 88); + this.btnNo.Name = "btnNo"; + this.btnNo.Size = new System.Drawing.Size(75, 23); + this.btnNo.TabIndex = 3; + this.btnNo.Text = "No"; + this.btnNo.Tooltip = ""; + this.btnNo.UseVisualStyleBackColor = true; + this.btnNo.Click += new System.EventHandler(this.btnNo_Click); + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.FocusDuesEnabled = false; + this.btnCancel.Location = new System.Drawing.Point(301, 88); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 1; + this.btnCancel.Text = "Cancel"; + this.btnCancel.Tooltip = ""; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnOK + // + this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnOK.FocusDuesEnabled = false; + this.btnOK.Location = new System.Drawing.Point(220, 88); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 4; + this.btnOK.Text = "OK"; + this.btnOK.Tooltip = ""; + this.btnOK.UseVisualStyleBackColor = true; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // MessageForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(394, 129); + this.Controls.Add(this.btnYes); + this.Controls.Add(this.btnNo); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.picImage); + this.Controls.Add(this.lblText); + this.Controls.Add(this.btnOK); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "MessageForm"; + this.Padding = new System.Windows.Forms.Padding(15); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Title"; + ((System.ComponentModel.ISupportInitialize)(this.picImage)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal Dark.WinForms.Controls.dButton btnCancel; + internal Dark.WinForms.Controls.dButton btnNo; + internal Dark.WinForms.Controls.dButton btnYes; + internal Dark.WinForms.Controls.dButton btnOK; + internal System.Windows.Forms.PictureBox picImage; + internal System.Windows.Forms.Label lblText; + } +} \ No newline at end of file diff --git a/EMessageBox/MessageForm.cs b/EMessageBox/MessageForm.cs new file mode 100644 index 0000000..932bd57 --- /dev/null +++ b/EMessageBox/MessageForm.cs @@ -0,0 +1,161 @@ +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 Eugen.ESystem.Windows.Forms +{ + internal partial class MessageForm : Form + { + #region Version und Copyright + // Version und Copyright + string dllName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen + string dllVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); + string copyright = GenerateCopyright(); + + //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; + } + + private static string CurrentYear() + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + + private static string StartYear() + { + string startYear = ""; + if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © ")) + { + startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", ""); + while (startYear.StartsWith(" ")) + { + startYear = startYear.Remove(0, 1); + } + + if (startYear.Contains("-")) + { + startYear = startYear.Remove(startYear.IndexOf("-")); + } + else + { + startYear = startYear.Remove(startYear.IndexOf(" ")); + } + return startYear; + } + else + { + DateTime dtn = DateTime.Now; + return dtn.Year.ToString(); + } + } + + private static string GenerateCopyright() + { + string startYear = StartYear(); + string currentYear = CurrentYear(); + + if (startYear == currentYear) + { + return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + } + else + { + string temp = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; + string start = temp.Remove(temp.IndexOf(startYear) - 1); + string end = (temp.Remove(0, temp.IndexOf(" by"))); + + return String.Concat(start, " ", startYear, "-", currentYear, end); + } + } + #endregion + + #region DLL-Info + /// + /// Contains the name of the dll file. + /// + public static string DllName { private set; get; } + + /// + /// Contains the version of the dll file. + /// + public static string DllVersion { private set; get; } + + /// + /// Contains the copyright notice. + /// + public static string Copyright { private set; get; } + + /// + /// Contains the name-, version- and copyright-information of the dll file. + /// + public static string[] DllInfo { private set; get; } + + private void SetDllInfo() + { + //Name, Version und Copyright setzen + DllName = dllName; + DllVersion = dllVersion; + Copyright = this.copyright; + + string[] dllInfo = new string[3]; + dllInfo[0] = dllName; + dllInfo[1] = dllVersion; + dllInfo[2] = this.copyright; + DllInfo = dllInfo; + } + + protected string ProgramName { private set; get; } + protected string ProgramVersion { private set; get; } + protected string ProgramCopyright { private set; get; } + #endregion + //public MessageForm() + //{ + // SetDllInfo(); + //} + + internal MessageForm() + { + InitializeComponent(); + } + + private void btnYes_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Yes; + } + + private void btnNo_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.No; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + } + + private void btnOK_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.OK; + } + } +} diff --git a/EMessageBox/Properties/AssemblyInfo.cs b/EMessageBox/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..965af11 --- /dev/null +++ b/EMessageBox/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("EMessageBox")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EMessageBox")] +[assembly: AssemblyCopyright("Copyright © 2022 by Eugen Höglinger")] +[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("3e3b287e-a7f0-430b-a18a-064517bd4922")] + +// 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, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.*")] +//[assembly: AssemblyFileVersion("1.0.0.0")] //Wenn auskommentiert, dann gleich wie AssemblyVersion! diff --git a/EMessageBox/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs b/EMessageBox/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs new file mode 100644 index 0000000..3871b18 --- /dev/null +++ b/EMessageBox/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] diff --git a/EMessageBox/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/EMessageBox/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..2d8a026 Binary files /dev/null and b/EMessageBox/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/EMessageBox/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/EMessageBox/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..9eac292 Binary files /dev/null and b/EMessageBox/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/EMessageBox/obj/Debug/EMessageBox.csproj.AssemblyReference.cache b/EMessageBox/obj/Debug/EMessageBox.csproj.AssemblyReference.cache new file mode 100644 index 0000000..a129b21 Binary files /dev/null and b/EMessageBox/obj/Debug/EMessageBox.csproj.AssemblyReference.cache differ