Initialize

This commit is contained in:
Eugen Höglinger 2020-11-26 10:04:16 +01:00
parent 3fadc6fb9b
commit a1ecb1b40f

View File

@ -7,12 +7,12 @@ namespace CheckEnvironment
{
public partial class CheckEnvironment : Form
{
#region Version und Copyright
#region Version und Copyright
// Version und Copyright
string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
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 copyright = GenerateCopyright();
string icon = Application.StartupPath + "\\Info.bmp";
//Assembly Datum und Zeit
static DateTime value = AssemblyDateTime();
@ -25,11 +25,81 @@ namespace CheckEnvironment
//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 = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
//return startYear.Remove(0, startYear.LastIndexOf(" ") + 1);
string startYear = "";
if (((AssemblyCopyrightAttribute)attributes[0]).Copyright.Contains("Copyright © "))
{
startYear = ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace("Copyright © ", "");
while (startYear.StartsWith(" "))
{
startYear = startYear.Remove(0, 1);
}
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
{
//return String.Concat(((AssemblyCopyrightAttribute)attributes[0]).Copyright, "-", currentYear);
return ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace(startYear, String.Concat(startYear, "-", currentYear));
}
}
#endregion
#region Programm-Info
/// <summary>
/// Contains the name of the program file
/// </summary>
public static string ProgramName { set; get; }
/// <summary>
/// Contains the version of the program file
/// </summary>
public static string ProgramVersion { set; get; }
/// <summary>
/// Contains the copyright notice
/// </summary>
public static string Copyright { set; get; }
private void SetProgramInfo()
{
//Name, Version und Copyright setzen
ProgramName = programName;
ProgramVersion = programVersion;
Copyright = copyright;
}
#endregion
public CheckEnvironment()
{
InitializeComponent();
SetProgramInfo();
}
private void buttonClose_Click(object sender, EventArgs e)