diff --git a/Console/.vscode/format-report.json b/Console/.vscode/format-report.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/Console/.vscode/format-report.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/Console/.vscode/launch.json b/Console/.vscode/launch.json new file mode 100644 index 0000000..74e815d --- /dev/null +++ b/Console/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/OI.Metrology.Console.dll", + "args": [ + "s", + "M", + "L:/Git/Notes-EC-Documentation/.EC-Documentation", + "-s", + "L:/Git/Notes-EC-Documentation/.EC-Documentation/port" + ], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/Console/.vscode/mklink.md b/Console/.vscode/mklink.md new file mode 100644 index 0000000..b6c5670 --- /dev/null +++ b/Console/.vscode/mklink.md @@ -0,0 +1,4 @@ +# mklink + +```bash +``` diff --git a/Console/.vscode/settings.json b/Console/.vscode/settings.json new file mode 100644 index 0000000..ed99375 --- /dev/null +++ b/Console/.vscode/settings.json @@ -0,0 +1,37 @@ +{ + "[markdown]": { + "editor.wordWrap": "off" + }, + "files.exclude": { + "**/.git": false, + "**/node_modules": true + }, + "files.watcherExclude": { + "**/node_modules": true + }, + "cSpell.words": [ + "ASPNETCORE", + "BIRT", + "CHIL", + "DEAT", + "endianness", + "FAMC", + "FAMS", + "GIVN", + "HUSB", + "INDI", + "Infineon", + "Kanban", + "kanbn", + "Kofax", + "NSFX", + "OBJE", + "onenote", + "pged", + "Phares", + "Serilog", + "SUBM", + "SURN", + "SYSLIB" + ] +} \ No newline at end of file diff --git a/Console/.vscode/tasks.json b/Console/.vscode/tasks.json new file mode 100644 index 0000000..c1a74aa --- /dev/null +++ b/Console/.vscode/tasks.json @@ -0,0 +1,99 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "User Secrets Init", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/OI.Metrology.Console.csproj", + "init" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "User Secrets Set", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/OI.Metrology.Console.csproj", + "set", + "asdf", + "123" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "Format", + "command": "dotnet", + "type": "process", + "args": [ + "format", + "--report", + ".vscode", + "--verbosity", + "detailed", + "--severity", + "warn" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/OI.Metrology.Console.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/OI.Metrology.Console.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/OI.Metrology.Console.csproj" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "Publish AOT", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "-r", + "win-x64", + "-c", + "Release", + "-p:PublishAot=true", + "${workspaceFolder}/OI.Metrology.Console.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Console/Models/AppSettings.cs b/Console/Models/AppSettings.cs new file mode 100644 index 0000000..12eb515 --- /dev/null +++ b/Console/Models/AppSettings.cs @@ -0,0 +1,21 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace OI.Metrology.Console.Models; + +public record AppSettings(string Company) +{ + + public override string ToString() + { + string result = JsonSerializer.Serialize(this, AppSettingsSourceGenerationContext.Default.AppSettings); + return result; + } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(AppSettings))] +internal partial class AppSettingsSourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Console/Models/Binder/.editorconfig b/Console/Models/Binder/.editorconfig new file mode 100644 index 0000000..1c444cd --- /dev/null +++ b/Console/Models/Binder/.editorconfig @@ -0,0 +1,2 @@ +[*.cs] +csharp_preserve_single_line_statements = true \ No newline at end of file diff --git a/Console/Models/Binder/AppSettings.cs b/Console/Models/Binder/AppSettings.cs new file mode 100644 index 0000000..31c0c53 --- /dev/null +++ b/Console/Models/Binder/AppSettings.cs @@ -0,0 +1,61 @@ +using Microsoft.Extensions.Configuration; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace OI.Metrology.Console.Models.Binder; + +public class AppSettings +{ + + public string? Company { get; set; } + + public override string ToString() + { + string result = JsonSerializer.Serialize(this, BinderAppSettingsSourceGenerationContext.Default.AppSettings); + return result; + } + + private static void PreVerify(IConfigurationRoot configurationRoot, AppSettings? appSettings) + { + if (appSettings?.Company is null) + { + List paths = []; + foreach (IConfigurationProvider configurationProvider in configurationRoot.Providers) + { + if (configurationProvider is not Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider jsonConfigurationProvider) + continue; + if (jsonConfigurationProvider.Source.FileProvider is not Microsoft.Extensions.FileProviders.PhysicalFileProvider physicalFileProvider) + continue; + paths.Add(physicalFileProvider.Root); + } + throw new NotSupportedException($"Not found!{Environment.NewLine}{string.Join(Environment.NewLine, paths.Distinct())}"); + } + } + + private static Models.AppSettings Get(AppSettings? appSettings) + { + Models.AppSettings result; + if (appSettings is null) throw new NullReferenceException(nameof(appSettings)); + if (appSettings.Company is null) throw new NullReferenceException(nameof(Company)); + result = new(appSettings.Company); + return result; + } + + public static Models.AppSettings Get(IConfigurationRoot configurationRoot) + { + Models.AppSettings result; +#pragma warning disable IL3050, IL2026 + AppSettings? appSettings = configurationRoot.Get(); +#pragma warning restore IL3050, IL2026 + PreVerify(configurationRoot, appSettings); + result = Get(appSettings); + return result; + } + +} + +[JsonSourceGenerationOptions(WriteIndented = true)] +[JsonSerializable(typeof(AppSettings))] +internal partial class BinderAppSettingsSourceGenerationContext : JsonSerializerContext +{ +} \ No newline at end of file diff --git a/Console/Models/WorkingDirectory.cs b/Console/Models/WorkingDirectory.cs new file mode 100644 index 0000000..39afb86 --- /dev/null +++ b/Console/Models/WorkingDirectory.cs @@ -0,0 +1,50 @@ +namespace OI.Metrology.Console.Models; + +internal abstract class WorkingDirectory +{ + + internal static string GetWorkingDirectory(string? executingAssemblyName, string subDirectoryName) + { + string result = string.Empty; + if (executingAssemblyName is null) + throw new Exception(); + string traceFile; + List directories = []; + Environment.SpecialFolder[] specialFolders = + [ + Environment.SpecialFolder.LocalApplicationData, + Environment.SpecialFolder.ApplicationData, + Environment.SpecialFolder.History, + Environment.SpecialFolder.CommonApplicationData, + Environment.SpecialFolder.InternetCache + ]; + foreach (Environment.SpecialFolder specialFolder in specialFolders) + directories.Add(Path.Combine(Environment.GetFolderPath(specialFolder), subDirectoryName, executingAssemblyName)); + foreach (string directory in directories) + { + for (int i = 1; i < 3; i++) + { + if (i == 1) + result = directory; + else + result = string.Concat("D", directory[1..]); + try + { + if (!Directory.Exists(result)) + _ = Directory.CreateDirectory(result); + traceFile = string.Concat(result, @"\", DateTime.Now.Ticks, ".txt"); + File.WriteAllText(traceFile, traceFile); + File.Delete(traceFile); + break; + } + catch (Exception) { result = string.Empty; } + } + if (!string.IsNullOrEmpty(result)) + break; + } + if (string.IsNullOrEmpty(result)) + throw new Exception("Unable to set working directory!"); + return result; + } + +} \ No newline at end of file diff --git a/Console/OI.Metrology.Console.csproj b/Console/OI.Metrology.Console.csproj new file mode 100644 index 0000000..741d62e --- /dev/null +++ b/Console/OI.Metrology.Console.csproj @@ -0,0 +1,16 @@ + + + enable + enable + Exe + win-x64 + net8.0 + d9488860-fd41-4dd8-9448-19f1dde7a0f7 + + + + + + + + \ No newline at end of file diff --git a/Console/Program.cs b/Console/Program.cs new file mode 100644 index 0000000..d0e33a8 --- /dev/null +++ b/Console/Program.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using OI.Metrology.Console.Models; + +namespace OI.Metrology.Console; + +internal class Program +{ + + public static void Main(string[] args) + { +#pragma warning disable IL3050 + HostApplicationBuilder builder = Host.CreateApplicationBuilder(args); +#pragma warning restore IL3050 + _ = builder.Configuration.AddEnvironmentVariables(); + _ = builder.Configuration.AddUserSecrets(); + _ = builder.Services.AddSingleton(args.ToList()); + AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration); + _ = builder.Services.AddSingleton(appSettings); + _ = builder.Services.AddHostedService(); + using IHost host = builder.Build(); + ILogger logger = host.Services.GetRequiredService>(); + logger.LogCritical("{appSettings.Company}", appSettings.Company); + host.Run(); + } + +} \ No newline at end of file diff --git a/Console/Worker.cs b/Console/Worker.cs new file mode 100644 index 0000000..a9ea62d --- /dev/null +++ b/Console/Worker.cs @@ -0,0 +1,67 @@ +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using OI.Metrology.Console.Models; +using System.Diagnostics; + +namespace OI.Metrology.Console; + +public class Worker : BackgroundService +{ + + private readonly List _Args; + private readonly ILogger _Logger; + private readonly AppSettings _AppSettings; + private readonly IHostApplicationLifetime _Lifetime; + + public Worker(ILogger logger, IHostApplicationLifetime lifetime, List args, AppSettings appSettings) + { + _Args = args; + _Logger = logger; + _Lifetime = lifetime; + _AppSettings = appSettings; + } + + public override Task StartAsync(CancellationToken cancellationToken) => + base.StartAsync(cancellationToken); + + public override Task StopAsync(CancellationToken cancellationToken) => + base.StopAsync(cancellationToken); + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + if (!stoppingToken.IsCancellationRequested) + await Task.Delay(500, stoppingToken); + if (_AppSettings is null) + throw new NullReferenceException(nameof(_AppSettings)); + try + { + _Logger.LogInformation("BaseDirectory: <{BaseDirectory}>", AppContext.BaseDirectory); + _Logger.LogInformation("CurrentDirectory: <{CurrentDirectory}>", Environment.CurrentDirectory); + _Logger.LogInformation("Press Escape key to get -1, Enter key to get 0, y key to get 1 and n key to get 2 exit code"); + ConsoleKeyInfo consoleKeyInfo = System.Console.ReadKey(); + if (consoleKeyInfo.Key == ConsoleKey.W) + { + Process process = Process.Start("L:/DevOps/Mesa_FI/OI-Metrology/WinForms/bin/Debug/net8.0-windows/win-x64/OI.Metrology.WinForms.exe", "Mike"); + process.WaitForExit(); + _Logger.LogInformation("ExitCode: <{ExitCode}>", process.ExitCode); + } + else + { + Environment.ExitCode = consoleKeyInfo.Key switch + { + ConsoleKey.Escape => -1, + ConsoleKey.Enter => 0, + ConsoleKey.Y => 1, + ConsoleKey.N => 2, + _ => 9 + }; + } + } + catch (Exception ex) + { _Logger.LogError("{Message}{NewLine}{StackTrace}", ex.Message, Environment.NewLine, ex.StackTrace); } + _Logger.LogInformation("Done. Press 'Enter' to end"); + _ = System.Console.ReadLine(); + _Lifetime.StopApplication(); + } + +} \ No newline at end of file diff --git a/Console/secrets.json b/Console/secrets.json new file mode 100644 index 0000000..e1bc030 --- /dev/null +++ b/Console/secrets.json @@ -0,0 +1,3 @@ +{ + "Company": "Infineon Technologies Americas Corp." +} \ No newline at end of file diff --git a/WinForms/.vscode/format-report.json b/WinForms/.vscode/format-report.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/WinForms/.vscode/format-report.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/WinForms/.vscode/launch.json b/WinForms/.vscode/launch.json new file mode 100644 index 0000000..4d5c047 --- /dev/null +++ b/WinForms/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/net8.0-windows/win-x64/OI.Metrology.WinForms.dll", + "args": [ + "s", + "M", + "L:/Git/Notes-EC-Documentation/.EC-Documentation", + "-s", + "L:/Git/Notes-EC-Documentation/.EC-Documentation/port" + ], + "cwd": "${workspaceFolder}", + "console": "integratedTerminal", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/WinForms/.vscode/mklink.md b/WinForms/.vscode/mklink.md new file mode 100644 index 0000000..b6c5670 --- /dev/null +++ b/WinForms/.vscode/mklink.md @@ -0,0 +1,4 @@ +# mklink + +```bash +``` diff --git a/WinForms/.vscode/settings.json b/WinForms/.vscode/settings.json new file mode 100644 index 0000000..ed99375 --- /dev/null +++ b/WinForms/.vscode/settings.json @@ -0,0 +1,37 @@ +{ + "[markdown]": { + "editor.wordWrap": "off" + }, + "files.exclude": { + "**/.git": false, + "**/node_modules": true + }, + "files.watcherExclude": { + "**/node_modules": true + }, + "cSpell.words": [ + "ASPNETCORE", + "BIRT", + "CHIL", + "DEAT", + "endianness", + "FAMC", + "FAMS", + "GIVN", + "HUSB", + "INDI", + "Infineon", + "Kanban", + "kanbn", + "Kofax", + "NSFX", + "OBJE", + "onenote", + "pged", + "Phares", + "Serilog", + "SUBM", + "SURN", + "SYSLIB" + ] +} \ No newline at end of file diff --git a/WinForms/.vscode/tasks.json b/WinForms/.vscode/tasks.json new file mode 100644 index 0000000..d2649ae --- /dev/null +++ b/WinForms/.vscode/tasks.json @@ -0,0 +1,83 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "User Secrets Init", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/OI.Metrology.WinForms.csproj", + "init" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "User Secrets Set", + "command": "dotnet", + "type": "process", + "args": [ + "user-secrets", + "-p", + "${workspaceFolder}/OI.Metrology.WinForms.csproj", + "set", + "asdf", + "123" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "Format", + "command": "dotnet", + "type": "process", + "args": [ + "format", + "--report", + ".vscode", + "--verbosity", + "detailed", + "--severity", + "warn" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/OI.Metrology.WinForms.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/OI.Metrology.WinForms.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary", + "-p:PublishSingleFile=true" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/OI.Metrology.WinForms.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/WinForms/Form1.Designer.cs b/WinForms/Form1.Designer.cs new file mode 100644 index 0000000..82c2f56 --- /dev/null +++ b/WinForms/Form1.Designer.cs @@ -0,0 +1,136 @@ +namespace WinForms; + +partial class Form1 +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + this._Go = new System.Windows.Forms.Button(); + this._NoGo = new System.Windows.Forms.Button(); + this._Cancel = new System.Windows.Forms.Button(); + this._BaseDirectory = new System.Windows.Forms.Label(); + this._CommandLineArgs = new System.Windows.Forms.Label(); + this._WebBrowser = new System.Windows.Forms.WebBrowser(); + this._CurrentDirectory = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // _Go + // + this._Go.AutoSize = true; + this._Go.Location = new System.Drawing.Point(5, 5); + this._Go.Name = "Go"; + this._Go.Size = new System.Drawing.Size(68, 16); + this._Go.Text = "Go"; + this._Go.ForeColor = Color.White; + this._Go.Click += new EventHandler(this.Go_Click); + // + // _NoGo + // + this._NoGo.AutoSize = true; + this._NoGo.Location = new System.Drawing.Point(105, 5); + this._NoGo.Name = "NoGo"; + this._NoGo.Size = new System.Drawing.Size(68, 16); + this._NoGo.Text = "NoGo"; + this._NoGo.ForeColor = Color.White; + this._NoGo.Click += new EventHandler(this.NoGo_Click); + // + // _Cancel + // + this._Cancel.AutoSize = true; + this._Cancel.Location = new System.Drawing.Point(205, 5); + this._Cancel.Name = "Cancel"; + this._Cancel.Size = new System.Drawing.Size(68, 16); + this._Cancel.Text = "Cancel"; + this._Cancel.ForeColor = Color.White; + this._Cancel.Click += new EventHandler(this.Cancel_Click); + // + // _BaseDirectory + // + this._BaseDirectory.AutoSize = true; + this._BaseDirectory.Location = new System.Drawing.Point(5, 55); + this._BaseDirectory.Name = "BaseDirectory"; + this._BaseDirectory.Size = new System.Drawing.Size(68, 16); + this._BaseDirectory.Text = "BaseDirectory"; + this._BaseDirectory.ForeColor = Color.White; + // + // _CommandLineArgs + // + this._CommandLineArgs.AutoSize = true; + this._CommandLineArgs.Location = new System.Drawing.Point(5, 105); + this._CommandLineArgs.Name = "CurrentDirectory"; + this._CommandLineArgs.Size = new System.Drawing.Size(68, 16); + this._CommandLineArgs.Text = "CurrentDirectory"; + this._CommandLineArgs.ForeColor = Color.White; + // + // _CurrentDirectory + // + this._CurrentDirectory.AutoSize = true; + this._CurrentDirectory.Location = new System.Drawing.Point(5, 155); + this._CurrentDirectory.Name = "CurrentDirectory"; + this._CurrentDirectory.Size = new System.Drawing.Size(68, 16); + this._CurrentDirectory.Text = "CurrentDirectory"; + this._CurrentDirectory.ForeColor = Color.White; + // + // _WebBrowser + // + this._WebBrowser.Location = new System.Drawing.Point(5, 205); + this._WebBrowser.MinimumSize = new System.Drawing.Size(20, 20); + this._WebBrowser.Name = "WebBrowser"; + this._WebBrowser.ScriptErrorsSuppressed = true; + this._WebBrowser.Size = new System.Drawing.Size(1008, 729); + this._WebBrowser.Visible = false; + this._WebBrowser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.WebBrowser_DocumentCompleted); + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(43)))), ((int)(((byte)(48))))); + this.ClientSize = new System.Drawing.Size(1008, 729); + this.Controls.Add(this._Go); + this.Controls.Add(this._NoGo); + this.Controls.Add(this._Cancel); + this.Controls.Add(this._WebBrowser); + this.Controls.Add(this._BaseDirectory); + this.Controls.Add(this._CommandLineArgs); + this.Controls.Add(this._CurrentDirectory); + this.Font = new System.Drawing.Font("Tahoma", 9.75F); + this.Load += new System.EventHandler(this.Form_Load); + this.ResumeLayout(false); + this.PerformLayout(); + } + + internal System.Windows.Forms.Button _Go; + internal System.Windows.Forms.Button _NoGo; + internal System.Windows.Forms.Button _Cancel; + internal System.Windows.Forms.Label _BaseDirectory; + internal System.Windows.Forms.Label _CommandLineArgs; + internal System.Windows.Forms.WebBrowser _WebBrowser; + internal System.Windows.Forms.Label _CurrentDirectory; + + #endregion +} diff --git a/WinForms/Form1.cs b/WinForms/Form1.cs new file mode 100644 index 0000000..83a55e3 --- /dev/null +++ b/WinForms/Form1.cs @@ -0,0 +1,62 @@ +namespace WinForms; + +public partial class Form1 : Form +{ + public Form1() => + InitializeComponent(); + + private void Form_Load(object sender, EventArgs e) + { + try + { + _BaseDirectory.Text = AppContext.BaseDirectory; + _CurrentDirectory.Text = Environment.CurrentDirectory; + _CommandLineArgs.Text = string.Join(' ', Environment.GetCommandLineArgs()); + _WebBrowser.Navigate("https://oi-metrology-viewer-prod.mes.infineon.com/Export"); + } + catch (Exception ex) { CatchException(ex); } + } + + private static void CatchException(Exception ex) => + _ = MessageBox.Show(ex.StackTrace, ex.Message); + + private void Go_Click(object sender, EventArgs e) + { + try + { + Environment.ExitCode = 1; + Application.Exit(); + } + catch (Exception ex) { CatchException(ex); } + } + + private void NoGo_Click(object sender, EventArgs e) + { + try + { + Environment.ExitCode = 2; + Application.Exit(); + } + catch (Exception ex) { CatchException(ex); } + } + + private void Cancel_Click(object sender, EventArgs e) + { + try + { + Environment.ExitCode = -1; + Application.Exit(); + } + catch (Exception ex) { CatchException(ex); } + } + + private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) + { + try + { + _WebBrowser.Visible = true; + } + catch (Exception ex) { CatchException(ex); } + } + +} diff --git a/WinForms/OI.Metrology.WinForms.csproj b/WinForms/OI.Metrology.WinForms.csproj new file mode 100644 index 0000000..119b724 --- /dev/null +++ b/WinForms/OI.Metrology.WinForms.csproj @@ -0,0 +1,11 @@ + + + WinExe + net8.0-windows + enable + win-x64 + true + enable + a98b14f0-fc21-4f31-a1e4-1337f6c60100 + + \ No newline at end of file diff --git a/WinForms/Program.cs b/WinForms/Program.cs new file mode 100644 index 0000000..7742bc5 --- /dev/null +++ b/WinForms/Program.cs @@ -0,0 +1,16 @@ +namespace WinForms; + +static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } +} \ No newline at end of file