- Control mit dem Tabellen bearbeitet werden können - Bei Auswahl von Elementen wird ein Event ausgelöst - Das Event behandelt dann ein Ergebnis im Hauptprogramm
249 lines
9.4 KiB
C#
249 lines
9.4 KiB
C#
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.Reflection.Emit;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Xml.Linq;
|
|
using Test_UserControl;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
|
|
|
|
namespace HE_Test_Dll
|
|
{
|
|
public partial class Form1 : 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 = System.Reflection.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);
|
|
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 Form1()
|
|
{
|
|
SetProgramInfo();
|
|
InitializeComponent();
|
|
}
|
|
|
|
//Prüft ob der Initialisierungsprozess läuft.
|
|
//Nach der Initialisierung wird der Wert auf 'true' gesetzt.
|
|
bool initialized = false;
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
//Programm-Information ausgeben
|
|
labelProgramInfo.Text = String.Concat(ProgramName, "\r\n", ProgramVersion, "\r\n", Copyright); // Zeigt die Programm-Information an
|
|
|
|
//DLL-Information ausgeben
|
|
labelDLLInfo.Text = String.Concat(Test_UserControl.UserControl1.DllName, "\r\n", Test_UserControl.UserControl1.DllVersion, "\r\n", Test_UserControl.UserControl1.Copyright); // Zeigt die DLL-Information an
|
|
|
|
//Ereignisse abbonieren
|
|
userControl1.ButtonUpClick += DoMoveUp;
|
|
userControl1.ButtonDownClick += DoMoveDown;
|
|
userControl1.ButtonAddSeparatorClick += DoAddSeperator;
|
|
userControl1.CheckboxEncryptCheck += DoEncrypt;
|
|
userControl1.CheckboxStandardCheck += DoStandard;
|
|
|
|
//Das Aussehen des Controlls setzen
|
|
InitializeUserControl();
|
|
|
|
initialized = true;
|
|
}
|
|
|
|
private void InitializeUserControl()
|
|
{
|
|
userControl1.ButtonUpAvailability = (int)Availability.Enabled;
|
|
userControl1.ButtonUpVisibility = (int)Visibility.Visible;
|
|
userControl1.ButtonDownAvailability = (int)Availability.Enabled;
|
|
userControl1.ButtonDownVisibility = (int)Visibility.Visible;
|
|
userControl1.ButtonAddSeparatorAvailability = (int)Availability.Enabled;
|
|
userControl1.ButtonAddSeparatorVisibility = (int)Visibility.Visible;
|
|
userControl1.CheckBoxEncryptAvailability = (int)Availability.Enabled;
|
|
userControl1.CheckBoxEncryptVisibility = (int)Visibility.Visible;
|
|
userControl1.CheckBoxEncryptStatusSelected = (bool)true;
|
|
userControl1.CheckBoxStandardAvailability = (int)Availability.Enabled;
|
|
userControl1.CheckBoxStandardVisibility = (int)Visibility.Visible;
|
|
userControl1.CheckBoxStandardStatusSelected = (bool)true;
|
|
userControl1.SizeX = 90;
|
|
userControl1.SizeY = 127;
|
|
userControl1.SetVisibility();
|
|
}
|
|
|
|
private void buttonShowInfo_Click(object sender, EventArgs e)
|
|
{
|
|
//
|
|
// Diese Zeilen gehört in das Programm kopiert
|
|
//
|
|
//
|
|
|
|
//Hat bei diesem Programm keine Funktion !!!
|
|
MessageBox.Show("Hat bei diesem Programm keine Funktion !!!");
|
|
|
|
//
|
|
//
|
|
}
|
|
|
|
#region Ereignisse
|
|
//Die Ereignisse werden nach betätigen eines Elementes aufgerufen
|
|
private void DoMoveUp(object source, EventArgs e)
|
|
{
|
|
//Weil sich Zustände der Elemente während der Initialisierung ändern,
|
|
//wird die Ausführung der folgenden Aktionen unterdrückt
|
|
if (initialized)
|
|
{
|
|
MessageBox.Show("Juhu, hat funktioniert");
|
|
labelResult.Text = "Button Up gedrückt";
|
|
}
|
|
}
|
|
|
|
private void DoMoveDown(object source, EventArgs e)
|
|
{
|
|
//Weil sich Zustände der Elemente während der Initialisierung ändern,
|
|
//wird die Ausführung der folgenden Aktionen unterdrückt
|
|
if (initialized)
|
|
{
|
|
MessageBox.Show("Juhu, hat funktioniert");
|
|
labelResult.Text = "Button Down gedrückt";
|
|
}
|
|
}
|
|
|
|
private void DoAddSeperator(object source, EventArgs e)
|
|
{
|
|
//Weil sich Zustände der Elemente während der Initialisierung ändern,
|
|
//wird die Ausführung der folgenden Aktionen unterdrückt
|
|
if (initialized)
|
|
{
|
|
MessageBox.Show("Juhu, hat funktioniert");
|
|
labelResult.Text = "Button AddSeperator gedrückt";
|
|
}
|
|
}
|
|
|
|
private void DoEncrypt(object source, EventArgs e)
|
|
{
|
|
//Weil sich Zustände der Elemente während der Initialisierung ändern,
|
|
//wird die Ausführung der folgenden Aktionen unterdrückt
|
|
if (initialized)
|
|
{
|
|
MessageBox.Show("Juhu, hat funktioniert");
|
|
if (userControl1.CheckBoxEncryptStatusSelected == false)
|
|
{
|
|
labelResult.Text = "Checkbox Chiffrieren angewählt";
|
|
}
|
|
else
|
|
{
|
|
labelResult.Text = "Checkbox Chiffrieren abgewählt";
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DoStandard(object source, EventArgs e)
|
|
{
|
|
//Weil sich Zustände der Elemente während der Initialisierung ändern,
|
|
//wird die Ausführung der folgenden Aktionen unterdrückt
|
|
if (initialized)
|
|
{
|
|
MessageBox.Show("Juhu, hat funktioniert");
|
|
if (userControl1.CheckBoxStandardStatusSelected == false)
|
|
{
|
|
labelResult.Text = "Checkbox Standard angewählt";
|
|
}
|
|
else
|
|
{
|
|
labelResult.Text = "Checkbox Standard abgewählt";
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|