using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Resources { public partial class Test : 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 = GenerateCopyright(); 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; } 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); } 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); } } #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 Test() { SetProgramInfo(); InitializeComponent(); ResourceManagerEx.BaseName = "strings"; Button langDE = new Button(); langDE.Location = new Point(10, 10); langDE.Click += delegate (object sender, EventArgs e) { ResourceManagerEx.ResourceCulture = new CultureInfo("DE"); }; ResourceManagerEx.Items.Add(new ResourceItem(langDE, "langDE", ResourceManagerEx.ApplyTextToControl)); langDE.Parent = this; Button langEN = new Button(); langEN.Location = new Point(100, 10); langEN.Click += delegate (object sender, EventArgs e) { ResourceManagerEx.ResourceCulture = new CultureInfo("EN"); }; ResourceManagerEx.Items.Add(new ResourceItem(langEN, "langEN", ResourceManagerEx.ApplyTextToControl)); langEN.Parent = this; Button close = new Button(); close.Location = new Point(10, 50); close.Click += delegate (object sender, EventArgs e) { Close(); }; close.Parent = this; ResourceManagerEx.Items.Add(new ResourceItem(close, "closeButtonText", ResourceManagerEx.ApplyTextToControl)); ResourceManagerEx.Items.Add(new ResourceItem(this, "title", ResourceManagerEx.ApplyTextToControl)); } } }