diff --git a/NxEnvironment/NxEnvironment.cs b/NxEnvironment/NxEnvironment.cs
index b02100c..ba886dd 100644
--- a/NxEnvironment/NxEnvironment.cs
+++ b/NxEnvironment/NxEnvironment.cs
@@ -1,13 +1,108 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Forms;
+using Eugen.ESystem;
namespace Eugen.NX
{
public class NxEnvironment
{
+ #region Version und Copyright
+ // Version und Copyright
+ static string dllName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
+ static string dllVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
+ static object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
+ static 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 = "";
+ 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 ((AssemblyCopyrightAttribute)attributes[0]).Copyright.Replace(startYear, String.Concat(startYear, "-", currentYear));
+ }
+ }
+ #endregion
+
+ #region DLL-Info
+ ///
+ /// Contains the name of the program file
+ ///
+ public static string DllName { set; get; }
+
+ ///
+ /// Contains the version of the program file
+ ///
+ public static string DllVersion { set; get; }
+
+ ///
+ /// Contains the copyright notice
+ ///
+ public static string Copyright { set; get; }
+
+ private static void SetDllInfo()
+ {
+ //Name, Version und Copyright setzen
+ DllName = dllName;
+ DllVersion = dllVersion;
+ Copyright = copyright;
+ }
+ #endregion
+
+ static NxEnvironment()
+ {
+ SetDllInfo();
+ }
+
///
/// UGII_BASE_DIR. E.g.: C:\Program Files\Siemens\NX10.0
///
@@ -139,7 +234,7 @@ namespace Eugen.NX
{
try
{
- return VaribleThroughString.Replace(text, true);
+ return ReplaceVariableByValue.Replace(text, true);
}
catch (Exception ex)
{
diff --git a/NxEnvironment/NxEnvironment.csproj b/NxEnvironment/NxEnvironment.csproj
index a3b8871..7e1bad2 100644
--- a/NxEnvironment/NxEnvironment.csproj
+++ b/NxEnvironment/NxEnvironment.csproj
@@ -31,8 +31,12 @@
4
+
+ ..\..\ReplaceVariableByValue.git\ReplaceVariableByValue\bin\Debug\ReplaceVariableByValue.dll
+
+
@@ -48,7 +52,6 @@
-
diff --git a/Test_NxEnvironment/Form1.Designer.cs b/Test_NxEnvironment/Form1.Designer.cs
index e86df67..fa83631 100644
--- a/Test_NxEnvironment/Form1.Designer.cs
+++ b/Test_NxEnvironment/Form1.Designer.cs
@@ -32,6 +32,12 @@
this.buttonStart = new System.Windows.Forms.Button();
this.labelEnvironment = new System.Windows.Forms.Label();
this.labelReplace = new System.Windows.Forms.Label();
+ this.groupBoxProgramInfo = new System.Windows.Forms.GroupBox();
+ this.labelProgramInfo = new System.Windows.Forms.Label();
+ this.groupBoxDLLInfo = new System.Windows.Forms.GroupBox();
+ this.labelDLLInfo = new System.Windows.Forms.Label();
+ this.groupBoxProgramInfo.SuspendLayout();
+ this.groupBoxDLLInfo.SuspendLayout();
this.SuspendLayout();
//
// buttonStart
@@ -51,14 +57,45 @@
resources.ApplyResources(this.labelReplace, "labelReplace");
this.labelReplace.Name = "labelReplace";
//
+ // groupBoxProgramInfo
+ //
+ this.groupBoxProgramInfo.Controls.Add(this.labelProgramInfo);
+ resources.ApplyResources(this.groupBoxProgramInfo, "groupBoxProgramInfo");
+ this.groupBoxProgramInfo.Name = "groupBoxProgramInfo";
+ this.groupBoxProgramInfo.TabStop = false;
+ //
+ // labelProgramInfo
+ //
+ resources.ApplyResources(this.labelProgramInfo, "labelProgramInfo");
+ this.labelProgramInfo.Name = "labelProgramInfo";
+ //
+ // groupBoxDLLInfo
+ //
+ this.groupBoxDLLInfo.Controls.Add(this.labelDLLInfo);
+ resources.ApplyResources(this.groupBoxDLLInfo, "groupBoxDLLInfo");
+ this.groupBoxDLLInfo.Name = "groupBoxDLLInfo";
+ this.groupBoxDLLInfo.TabStop = false;
+ //
+ // labelDLLInfo
+ //
+ resources.ApplyResources(this.labelDLLInfo, "labelDLLInfo");
+ this.labelDLLInfo.Name = "labelDLLInfo";
+ //
// Form1
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.groupBoxProgramInfo);
+ this.Controls.Add(this.groupBoxDLLInfo);
this.Controls.Add(this.labelReplace);
this.Controls.Add(this.labelEnvironment);
this.Controls.Add(this.buttonStart);
this.Name = "Form1";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.groupBoxProgramInfo.ResumeLayout(false);
+ this.groupBoxProgramInfo.PerformLayout();
+ this.groupBoxDLLInfo.ResumeLayout(false);
+ this.groupBoxDLLInfo.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -69,6 +106,10 @@
private System.Windows.Forms.Button buttonStart;
private System.Windows.Forms.Label labelEnvironment;
private System.Windows.Forms.Label labelReplace;
+ private System.Windows.Forms.GroupBox groupBoxProgramInfo;
+ private System.Windows.Forms.Label labelProgramInfo;
+ private System.Windows.Forms.GroupBox groupBoxDLLInfo;
+ private System.Windows.Forms.Label labelDLLInfo;
}
}
diff --git a/Test_NxEnvironment/Form1.cs b/Test_NxEnvironment/Form1.cs
index 005bd99..a2c44ac 100644
--- a/Test_NxEnvironment/Form1.cs
+++ b/Test_NxEnvironment/Form1.cs
@@ -19,7 +19,7 @@ namespace Eugen.NX
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 copyright = GenerateCopyright();
string icon = Application.StartupPath + "\\Info.bmp";
//Assembly Datum und Zeit
static DateTime value = AssemblyDateTime();
@@ -32,6 +32,50 @@ namespace Eugen.NX
//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
@@ -65,12 +109,26 @@ namespace Eugen.NX
InitializeComponent();
}
+ private void Form1_Load(object sender, EventArgs e)
+ {
+ ShowInformation(); //Programm- und DLL-Information anzeigen
+ }
+
+ private void ShowInformation()
+ {
+ labelProgramInfo.Text = String.Concat(ProgramName, "\n", ProgramVersion, "\n", Copyright); //Programm-Information anzeigen
+
+ // DLL-Information anzeigen
+ labelDLLInfo.Text = String.Concat(NxEnvironment.DllName, "\n", NxEnvironment.DllVersion, "\n", NxEnvironment.Copyright);
+ }
+
private void buttonStart_Click(object sender, EventArgs e)
{
- SetEnv();
+ SetEnv(); //Die Variablen setzten
- labelEnvironment.Text = ShowEnv();
+ labelEnvironment.Text = ShowEnv(); //Die Variablen anzeigen
+ //Umgebungsvariable durch Wert ersetzen
labelReplace.Text = String.Concat("Aus ", NxEnvironment.Nx_Server_Dir, " wird ", NxEnvironment.ReplaceVariable(NxEnvironment.Nx_Server_Dir));
}
diff --git a/Test_NxEnvironment/Form1.de.resx b/Test_NxEnvironment/Form1.de.resx
new file mode 100644
index 0000000..156d6b4
--- /dev/null
+++ b/Test_NxEnvironment/Form1.de.resx
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
+ Umgebungsvariablen anzeigen
+
+
+ Umgebungsvariablen anzeigen
+
+
+ Programm Information
+
+
\ No newline at end of file
diff --git a/Test_NxEnvironment/Form1.en.resx b/Test_NxEnvironment/Form1.en.resx
index 2945b98..ecbd727 100644
--- a/Test_NxEnvironment/Form1.en.resx
+++ b/Test_NxEnvironment/Form1.en.resx
@@ -120,4 +120,10 @@
Show environment variable
+
+ Show environment variable
+
+
+ Program Information
+
\ No newline at end of file
diff --git a/Test_NxEnvironment/Form1.resx b/Test_NxEnvironment/Form1.resx
index a34c249..41ca076 100644
--- a/Test_NxEnvironment/Form1.resx
+++ b/Test_NxEnvironment/Form1.resx
@@ -123,10 +123,10 @@
- 304, 415
+ 12, 443
- 193, 23
+ 776, 23
@@ -145,13 +145,13 @@
$this
- 2
+ 4
True
- 13, 13
+ 12, 9
16, 13
@@ -161,6 +161,7 @@
...
+ @Invariant
labelEnvironment
@@ -172,13 +173,13 @@
$this
- 1
+ 3
True
- 13, 362
+ 12, 377
16, 13
@@ -188,6 +189,7 @@
...
+ @Invariant
labelReplace
@@ -199,6 +201,141 @@
$this
+ 2
+
+
+ labelProgramInfo
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ groupBoxProgramInfo
+
+
+ 0
+
+
+ 12, 472
+
+
+ 385, 66
+
+
+ 11
+
+
+ Programm Information
+
+
+ groupBoxProgramInfo
+
+
+ System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ 0
+
+
+ True
+
+
+ NoControl
+
+
+ 7, 20
+
+
+ 16, 13
+
+
+ 0
+
+
+ ...
+ @Invariant
+
+
+ labelProgramInfo
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ groupBoxProgramInfo
+
+
+ 0
+
+
+ labelDLLInfo
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ groupBoxDLLInfo
+
+
+ 0
+
+
+ 403, 472
+
+
+ 385, 66
+
+
+ 12
+
+
+ DLL Information
+ @Invariant
+
+
+ groupBoxDLLInfo
+
+
+ System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ $this
+
+
+ 1
+
+
+ True
+
+
+ NoControl
+
+
+ 7, 20
+
+
+ 16, 13
+
+
+ 0
+
+
+ ...
+ @Invariant
+
+
+ labelDLLInfo
+
+
+ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ groupBoxDLLInfo
+
+
0
@@ -208,10 +345,13 @@
6, 13
- 800, 450
+ 800, 550
+
+
+ NoControl
- Umgebungsvariablen anzeigen
+ Test_NxEnvironment
Form1
diff --git a/Test_NxEnvironment/Test_NxEnvironment.csproj b/Test_NxEnvironment/Test_NxEnvironment.csproj
index f2305e7..d832e6a 100644
--- a/Test_NxEnvironment/Test_NxEnvironment.csproj
+++ b/Test_NxEnvironment/Test_NxEnvironment.csproj
@@ -54,6 +54,9 @@
+
+ Form1.cs
+
Form1.cs