From 7477c6032e8e3cb010e200fe22dc5a60cb2aab95 Mon Sep 17 00:00:00 2001 From: Bjorn Date: Wed, 28 Sep 2016 14:56:38 +0200 Subject: [PATCH] display version info in the settings --- FloatingGlucose/Classes/AppShared.cs | 18 ++++++ .../FormGlucoseSettings.Designer.cs | 55 ++++++++++++------- FloatingGlucose/FormGlucoseSettings.cs | 10 ++++ 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/FloatingGlucose/Classes/AppShared.cs b/FloatingGlucose/Classes/AppShared.cs index 4b863ec..2b9898e 100644 --- a/FloatingGlucose/Classes/AppShared.cs +++ b/FloatingGlucose/Classes/AppShared.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using System.Text; @@ -12,6 +13,23 @@ class AppShared { public static bool IsWorkStationLocked = false; public static readonly string AppName = typeof(Program).Assembly.GetName().Name; + public static string AppVersion { + get + { + try + { + using (var reader = File.OpenText(Path.Combine(AppShared.ExecutableDir, "version.txt"))) + { + return reader.ReadToEnd(); + } + } catch (IOException) { + return "unknown"; + } + } + + } + public static string ExecutableDir => Path.GetDirectoryName(Application.ExecutablePath); + public static bool SettingsFormShouldFocusAdvancedSettings = false; public static bool SettingsUpdatedSuccessfully = false; diff --git a/FloatingGlucose/FormGlucoseSettings.Designer.cs b/FloatingGlucose/FormGlucoseSettings.Designer.cs index d85351a..3a9971b 100644 --- a/FloatingGlucose/FormGlucoseSettings.Designer.cs +++ b/FloatingGlucose/FormGlucoseSettings.Designer.cs @@ -60,6 +60,8 @@ private void InitializeComponent() this.tabPageBasic = new System.Windows.Forms.TabPage(); this.tabPageAdvanced = new System.Windows.Forms.TabPage(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.chkAllowFileURIScheme = new System.Windows.Forms.CheckBox(); + this.label19 = new System.Windows.Forms.Label(); this.label18 = new System.Windows.Forms.Label(); this.numOpacity = new System.Windows.Forms.NumericUpDown(); this.label17 = new System.Windows.Forms.Label(); @@ -73,8 +75,7 @@ private void InitializeComponent() this.label8 = new System.Windows.Forms.Label(); this.numRefreshInterval = new System.Windows.Forms.NumericUpDown(); this.label7 = new System.Windows.Forms.Label(); - this.label19 = new System.Windows.Forms.Label(); - this.chkAllowFileURIScheme = new System.Windows.Forms.CheckBox(); + this.lblVersionInfo = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.panel2.SuspendLayout(); this.grpAlarmSettings.SuspendLayout(); @@ -542,6 +543,25 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "Advanced application settings (requires restart)"; // + // chkAllowFileURIScheme + // + this.chkAllowFileURIScheme.AutoSize = true; + this.chkAllowFileURIScheme.Location = new System.Drawing.Point(546, 270); + this.chkAllowFileURIScheme.Name = "chkAllowFileURIScheme"; + this.chkAllowFileURIScheme.Size = new System.Drawing.Size(18, 17); + this.chkAllowFileURIScheme.TabIndex = 20; + this.chkAllowFileURIScheme.UseVisualStyleBackColor = true; + // + // label19 + // + this.label19.AutoSize = true; + this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label19.Location = new System.Drawing.Point(38, 267); + this.label19.Name = "label19"; + this.label19.Size = new System.Drawing.Size(416, 20); + this.label19.TabIndex = 19; + this.label19.Text = "Debugging: Allow file:// URI schemes as nightscout url"; + // // label18 // this.label18.AutoSize = true; @@ -686,30 +706,23 @@ private void InitializeComponent() this.label7.TabIndex = 1; this.label7.Text = "GUI Refresh interval"; // - // label19 - // - this.label19.AutoSize = true; - this.label19.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label19.Location = new System.Drawing.Point(38, 267); - this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(416, 20); - this.label19.TabIndex = 19; - this.label19.Text = "Debugging: Allow file:// URI schemes as nightscout url"; - // - // chkAllowFileURIScheme + // lblVersionInfo // - this.chkAllowFileURIScheme.AutoSize = true; - this.chkAllowFileURIScheme.Location = new System.Drawing.Point(546, 270); - this.chkAllowFileURIScheme.Name = "chkAllowFileURIScheme"; - this.chkAllowFileURIScheme.Size = new System.Drawing.Size(18, 17); - this.chkAllowFileURIScheme.TabIndex = 20; - this.chkAllowFileURIScheme.UseVisualStyleBackColor = true; + this.lblVersionInfo.AutoSize = true; + this.lblVersionInfo.Enabled = false; + this.lblVersionInfo.ForeColor = System.Drawing.Color.SeaGreen; + this.lblVersionInfo.Location = new System.Drawing.Point(12, 658); + this.lblVersionInfo.Name = "lblVersionInfo"; + this.lblVersionInfo.Size = new System.Drawing.Size(93, 17); + this.lblVersionInfo.TabIndex = 4; + this.lblVersionInfo.Text = "lblVersionInfo"; // // FormGlucoseSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(938, 672); + this.ClientSize = new System.Drawing.Size(967, 687); + this.Controls.Add(this.lblVersionInfo); this.Controls.Add(this.label6); this.Controls.Add(this.tabSettings); this.Controls.Add(this.btnVerifySubmit); @@ -737,6 +750,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.numScaling)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numRefreshInterval)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -789,5 +803,6 @@ private void InitializeComponent() private System.Windows.Forms.Label label18; private System.Windows.Forms.CheckBox chkAllowFileURIScheme; private System.Windows.Forms.Label label19; + private System.Windows.Forms.Label lblVersionInfo; } } \ No newline at end of file diff --git a/FloatingGlucose/FormGlucoseSettings.cs b/FloatingGlucose/FormGlucoseSettings.cs index c5913b6..d6935b7 100644 --- a/FloatingGlucose/FormGlucoseSettings.cs +++ b/FloatingGlucose/FormGlucoseSettings.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -110,6 +111,12 @@ private void FormGlucoseSettings_Load(object sender, EventArgs e) this.updateFormControlsFromSettings(); this.FormClosing += this.OnClosing; + + this.lblVersionInfo.Text = "Version: " + AppShared.AppVersion; + this.lblVersionInfo.Enabled = true; + + + //different increments for mmol/L and mg/dL var controls = this.grpAlarmSettings.Controls.OfType() .Where(x=> x.DecimalPlaces == 1).ToList(); @@ -118,6 +125,9 @@ private void FormGlucoseSettings_Load(object sender, EventArgs e) x.ValueChanged += new System.EventHandler(this.NumericUpDowns_Value_Changed); }); + + + if (AppShared.SettingsFormShouldFocusAdvancedSettings) { AppShared.SettingsFormShouldFocusAdvancedSettings = false;