From 0050f5fab50b78b1871e38a1a2704d66a0befe71 Mon Sep 17 00:00:00 2001 From: Szymon Porwolik Date: Wed, 17 Feb 2021 23:33:33 +0100 Subject: [PATCH] Feature: see log button --- 02_Windows_App/Perun_v1/01_Classes/Globals.cs | 2 ++ .../Perun_v1/01_Classes/LogController.cs | 1 + .../Perun_v1/02_Forms/form_Main.Designer.cs | 15 +++++++++++++++ 02_Windows_App/Perun_v1/02_Forms/form_Main.cs | 13 +++++++++++++ 4 files changed, 31 insertions(+) diff --git a/02_Windows_App/Perun_v1/01_Classes/Globals.cs b/02_Windows_App/Perun_v1/01_Classes/Globals.cs index 8c43ff6..722b6af 100644 --- a/02_Windows_App/Perun_v1/01_Classes/Globals.cs +++ b/02_Windows_App/Perun_v1/01_Classes/Globals.cs @@ -78,6 +78,8 @@ internal class Globals public static string VersionDatabase = ""; // Version - Database public static string VersionPerun = "DEBUG"; // Version - Perun + public static string LastLogLocation = ""; // Last used log location + public static CurrentMissionClass CurrentMission = new CurrentMissionClass(); // Actual mission information single ton public static HardwareMonitorClass HardwareMonitor = new HardwareMonitorClass(); // Hardware monitor singleton diff --git a/02_Windows_App/Perun_v1/01_Classes/LogController.cs b/02_Windows_App/Perun_v1/01_Classes/LogController.cs index dcb210d..e7aee34 100644 --- a/02_Windows_App/Perun_v1/01_Classes/LogController.cs +++ b/02_Windows_App/Perun_v1/01_Classes/LogController.cs @@ -51,6 +51,7 @@ class LogController LogStreamWriter = new StreamWriter(LogFileStream); LogStreamWriter.WriteLine(strLog); LogStreamWriter.Close(); + Globals.LastLogLocation = LogFilePath; } catch { diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs index 1bb372d..6479982 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs @@ -100,6 +100,7 @@ this.label27 = new System.Windows.Forms.Label(); this.label20 = new System.Windows.Forms.Label(); this.tim_HW_status = new System.Windows.Forms.Timer(this.components); + this.con_Button_See_log = new System.Windows.Forms.Button(); this.con_GroupBox_1.SuspendLayout(); this.con_GroupBox_2.SuspendLayout(); this.con_GroupBox_3.SuspendLayout(); @@ -149,6 +150,7 @@ // // con_GroupBox_1 // + this.con_GroupBox_1.Controls.Add(this.con_Button_See_log); this.con_GroupBox_1.Controls.Add(this.label15); this.con_GroupBox_1.Controls.Add(this.con_com_loglevel); this.con_GroupBox_1.Controls.Add(this.con_List_Received); @@ -802,6 +804,18 @@ this.tim_HW_status.Interval = 1000; this.tim_HW_status.Tick += new System.EventHandler(this.tim_HW_status_Tick); // + // con_Button_See_log + // + this.con_Button_See_log.Enabled = false; + this.con_Button_See_log.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.con_Button_See_log.Location = new System.Drawing.Point(170, 12); + this.con_Button_See_log.Name = "con_Button_See_log"; + this.con_Button_See_log.Size = new System.Drawing.Size(56, 20); + this.con_Button_See_log.TabIndex = 24; + this.con_Button_See_log.Text = "See log"; + this.con_Button_See_log.UseVisualStyleBackColor = true; + this.con_Button_See_log.Click += new System.EventHandler(this.con_Button_See_log_Click); + // // form_Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -930,6 +944,7 @@ private System.Windows.Forms.Label label27; private System.Windows.Forms.Label label20; private System.Windows.Forms.Timer tim_HW_status; + private System.Windows.Forms.Button con_Button_See_log; } } diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs index dc7479b..70a38bb 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs @@ -504,6 +504,12 @@ namespace Perun_v1 // Do nothing , control does not require update } + // Enable see log button + if(Globals.LastLogLocation != "") + { + con_Button_See_log.Enabled = true; + } + // Update mission status if (Globals.CurrentMission.Mission != "") { @@ -763,5 +769,12 @@ namespace Perun_v1 con_Button_Listen_ON_Click(sender, e); // Simulate button click } + private void con_Button_See_log_Click(object sender, EventArgs e) + { + if (Globals.LastLogLocation != "") + { + Process.Start(Globals.LastLogLocation); + } + } } }