Initialize

This commit is contained in:
Eugen Höglinger 2024-10-09 09:20:55 +02:00
commit b2b6e0200a
11 changed files with 496 additions and 0 deletions

Binary file not shown.

25
EMessageBox.git.sln Normal file
View File

@ -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

View File

@ -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
}
}
}

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3E3B287E-A7F0-430B-A18A-064517BD4922}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Eugen.ESystem.Windows.Forms</RootNamespace>
<AssemblyName>hemessbox</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>false</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MessageForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MessageForm.Designer.cs">
<DependentUpon>MessageForm.cs</DependentUpon>
</Compile>
<Compile Include="EMessageBox.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

148
EMessageBox/MessageForm.Designer.cs generated Normal file
View File

@ -0,0 +1,148 @@
namespace Eugen.ESystem.Windows.Forms
{
partial class MessageForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

161
EMessageBox/MessageForm.cs Normal file
View File

@ -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
/// <summary>
/// Contains the name of the dll file.
/// </summary>
public static string DllName { private set; get; }
/// <summary>
/// Contains the version of the dll file.
/// </summary>
public static string DllVersion { private set; get; }
/// <summary>
/// Contains the copyright notice.
/// </summary>
public static string Copyright { private set; get; }
/// <summary>
/// Contains the name-, version- and copyright-information of the dll file.
/// </summary>
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;
}
}
}

View File

@ -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!

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]