diff --git a/YAMDCC.GUI/MainWindow.Designer.cs b/YAMDCC.GUI/MainWindow.Designer.cs index 95f08a0..6021230 100644 --- a/YAMDCC.GUI/MainWindow.Designer.cs +++ b/YAMDCC.GUI/MainWindow.Designer.cs @@ -72,7 +72,7 @@ private void InitializeComponent() this.tsiProfRename = new System.Windows.Forms.ToolStripMenuItem(); this.tsiProfChangeDesc = new System.Windows.Forms.ToolStripMenuItem(); this.tsiProfDel = new System.Windows.Forms.ToolStripMenuItem(); - this.tsiGetDefaultCurve = new System.Windows.Forms.ToolStripMenuItem(); + this.tsiECtoConf = new System.Windows.Forms.ToolStripMenuItem(); this.tsiECMon = new System.Windows.Forms.ToolStripMenuItem(); this.tsiStopSvc = new System.Windows.Forms.ToolStripMenuItem(); this.tsiUninstall = new System.Windows.Forms.ToolStripMenuItem(); @@ -169,45 +169,45 @@ private void InitializeComponent() // tsiLoadConf // this.tsiLoadConf.Name = "tsiLoadConf"; - this.tsiLoadConf.Size = new System.Drawing.Size(180, 22); + this.tsiLoadConf.Size = new System.Drawing.Size(154, 22); this.tsiLoadConf.Text = "Load config"; this.tsiLoadConf.Click += new System.EventHandler(this.tsiLoadConf_Click); // // tsiSaveConf // this.tsiSaveConf.Name = "tsiSaveConf"; - this.tsiSaveConf.Size = new System.Drawing.Size(180, 22); + this.tsiSaveConf.Size = new System.Drawing.Size(154, 22); this.tsiSaveConf.Text = "Save config"; this.tsiSaveConf.Click += new System.EventHandler(this.tsiSaveConf_Click); // // sep1 // sep1.Name = "sep1"; - sep1.Size = new System.Drawing.Size(177, 6); + sep1.Size = new System.Drawing.Size(151, 6); // // tsiApply // this.tsiApply.Name = "tsiApply"; - this.tsiApply.Size = new System.Drawing.Size(180, 22); + this.tsiApply.Size = new System.Drawing.Size(154, 22); this.tsiApply.Text = "Apply changes"; this.tsiApply.Click += new System.EventHandler(this.tsiApply_Click); // // tsiRevert // this.tsiRevert.Name = "tsiRevert"; - this.tsiRevert.Size = new System.Drawing.Size(180, 22); + this.tsiRevert.Size = new System.Drawing.Size(154, 22); this.tsiRevert.Text = "Revert changes"; this.tsiRevert.Click += new System.EventHandler(this.tsiRevert_Click); // // sep2 // sep2.Name = "sep2"; - sep2.Size = new System.Drawing.Size(177, 6); + sep2.Size = new System.Drawing.Size(151, 6); // // tsiExit // this.tsiExit.Name = "tsiExit"; - this.tsiExit.Size = new System.Drawing.Size(180, 22); + this.tsiExit.Size = new System.Drawing.Size(154, 22); this.tsiExit.Text = "Exit"; this.tsiExit.Click += new System.EventHandler(this.tsiExit_Click); // @@ -216,7 +216,7 @@ private void InitializeComponent() this.tsiOptions.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tsiProfAdd, this.tsiProfEdit, - this.tsiGetDefaultCurve, + this.tsiECtoConf, sep4, this.tsiECMon, sep5, @@ -270,12 +270,12 @@ private void InitializeComponent() this.tsiProfDel.Text = "Delete"; this.tsiProfDel.Click += new System.EventHandler(this.tsiProfDel_Click); // - // tsiGetDefaultCurve + // tsiECtoConf // - this.tsiGetDefaultCurve.Name = "tsiGetDefaultCurve"; - this.tsiGetDefaultCurve.Size = new System.Drawing.Size(244, 22); - this.tsiGetDefaultCurve.Text = "Get default fan profile from EC..."; - this.tsiGetDefaultCurve.Click += new System.EventHandler(this.tsiGetDefaultCurve_Click); + this.tsiECtoConf.Name = "tsiECtoConf"; + this.tsiECtoConf.Size = new System.Drawing.Size(244, 22); + this.tsiECtoConf.Text = "Get default fan profile from EC..."; + this.tsiECtoConf.Click += new System.EventHandler(this.tsiECtoConf_Click); // // sep4 // @@ -567,7 +567,7 @@ private void InitializeComponent() tabOptions.Controls.Add(tblExtra); tabOptions.Location = new System.Drawing.Point(4, 24); tabOptions.Name = "tabOptions"; - tabOptions.Size = new System.Drawing.Size(526, 364); + tabOptions.Size = new System.Drawing.Size(526, 366); tabOptions.TabIndex = 1; tabOptions.Text = "Extras"; // @@ -593,7 +593,7 @@ private void InitializeComponent() tblExtra.RowStyles.Add(new System.Windows.Forms.RowStyle()); tblExtra.RowStyles.Add(new System.Windows.Forms.RowStyle()); tblExtra.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - tblExtra.Size = new System.Drawing.Size(526, 368); + tblExtra.Size = new System.Drawing.Size(526, 366); tblExtra.TabIndex = 4; // // lblChgLim @@ -847,7 +847,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem tsiAbout; private System.Windows.Forms.ToolStripMenuItem tsiSource; private System.Windows.Forms.ToolStripMenuItem tsiUninstall; - private System.Windows.Forms.ToolStripMenuItem tsiProfAdd; private System.Windows.Forms.ToolStripMenuItem tsiProfEdit; private System.Windows.Forms.ToolStripMenuItem tsiProfRename; private System.Windows.Forms.ToolStripMenuItem tsiProfChangeDesc; @@ -876,6 +875,7 @@ private void InitializeComponent() private System.Windows.Forms.Label lblPerfMode; private System.Windows.Forms.Label lblWinFnSwap; private System.Windows.Forms.Label lblKeyLight; - private System.Windows.Forms.ToolStripMenuItem tsiGetDefaultCurve; + private System.Windows.Forms.ToolStripMenuItem tsiProfAdd; + private System.Windows.Forms.ToolStripMenuItem tsiECtoConf; } } diff --git a/YAMDCC.GUI/MainWindow.cs b/YAMDCC.GUI/MainWindow.cs index 2ce4dfa..c0c5088 100644 --- a/YAMDCC.GUI/MainWindow.cs +++ b/YAMDCC.GUI/MainWindow.cs @@ -200,26 +200,26 @@ private void MainWindow_Load(object sender, EventArgs e) return; } - LoadConf(Constants.CurrentConfigPath); + LoadConf(Paths.CurrentConfig); if (Config is not null && Config.KeyLightConf is not null) { SendServiceMessage(new ServiceCommand(Command.GetKeyLightBright, "")); } - if (File.Exists(Path.Combine(Constants.DataPath, "ECToConfFail"))) + if (File.Exists(Paths.ECToConfFail)) { - Utils.ShowError(Strings.GetString("dlgECtoConfError", Constants.LogPath)); + Utils.ShowError(Strings.GetString("dlgECtoConfError", Paths.Logs)); } - else if (File.Exists(Path.Combine(Constants.DataPath, "ECToConfSuccess"))) + else if (File.Exists(Paths.ECToConfSuccess)) { MessageBox.Show(Strings.GetString("dlgECtoConfSuccess"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } try { - File.Delete(Path.Combine(Constants.DataPath, "ECToConfSuccess")); - File.Delete(Path.Combine(Constants.DataPath, "ECToConfFail")); + File.Delete(Paths.ECToConfSuccess); + File.Delete(Paths.ECToConfFail); } catch (DirectoryNotFoundException) { } } @@ -445,13 +445,13 @@ private void tsiProfDel_Click(object sender, EventArgs e) DelFanProfile(); } - private void tsiGetDefaultCurve_Click(object sender, EventArgs e) + private void tsiECtoConf_Click(object sender, EventArgs e) { if (MessageBox.Show(Strings.GetString("dlgECtoConfStart"), "Default fan profile from EC?", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { - StreamWriter sw = new(Path.Combine(Constants.DataPath, "ECToConfPending"), false); + StreamWriter sw = new(Paths.ECToConfPending, false); try { sw.Write(1); @@ -507,7 +507,7 @@ private void tsiUninstall_Click(object sender, EventArgs e) MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { bool delData = MessageBox.Show( - Strings.GetString("dlgSvcDelData", Constants.DataPath), + Strings.GetString("dlgSvcDelData", Paths.Data), "Delete configuration data?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes; @@ -525,7 +525,7 @@ private void tsiUninstall_Click(object sender, EventArgs e) // service uninstalled successfully if (delData) { - Directory.Delete(Constants.DataPath, true); + Directory.Delete(Paths.Data, true); } } else @@ -853,6 +853,7 @@ private void LoadConf(YAMDCC_Config config) btnProfAdd.Enabled = tsiProfAdd.Enabled = true; tsiProfRename.Enabled = tsiProfChangeDesc.Enabled = true; + tsiECtoConf.Enabled = true; cboFanSel.Enabled = true; cboFanSel.SelectedIndex = 0; tsiECMon.Enabled = true; @@ -863,7 +864,7 @@ private void LoadConf(YAMDCC_Config config) private void ApplyConf() { // Save the updated config - Config.Save(Constants.CurrentConfigPath); + Config.Save(Paths.CurrentConfig); // Tell the service to reload and apply the updated config SendServiceMessage(new ServiceCommand(Command.ApplyConfig, null)); @@ -964,7 +965,7 @@ private void DelFanProfile() private static string GetLastConfPath() { - StreamReader sr = new(Constants.LastConfigPath, Encoding.UTF8); + StreamReader sr = new(Paths.LastConfig, Encoding.UTF8); try { string path = sr.ReadLine(); @@ -978,7 +979,7 @@ private static string GetLastConfPath() private static void SetLastConfPath(string path) { - StreamWriter sw = new(Constants.LastConfigPath, false, Encoding.UTF8); + StreamWriter sw = new(Paths.LastConfig, false, Encoding.UTF8); try { sw.WriteLine(path); @@ -1043,12 +1044,13 @@ private void DisableAll() tbKeyLight.Enabled = false; tsiApply.Enabled = false; - tsiECMon.Enabled = false; + tsiRevert.Enabled = false; tsiProfAdd.Enabled = false; tsiProfChangeDesc.Enabled = false; tsiProfRename.Enabled = false; tsiProfDel.Enabled = false; - tsiRevert.Enabled = false; + tsiECtoConf.Enabled = false; + tsiECMon.Enabled = false; for (int i = 0; i < tbFanSpds.Length; i++) { diff --git a/YAMDCC.GUI/MainWindow.resx b/YAMDCC.GUI/MainWindow.resx index a101ca2..79c2079 100644 --- a/YAMDCC.GUI/MainWindow.resx +++ b/YAMDCC.GUI/MainWindow.resx @@ -138,12 +138,33 @@ False + + False + + + False + + + False + False False + + False + + + False + + + False + + + False + False @@ -156,6 +177,12 @@ False + + False + + + False + False @@ -165,6 +192,12 @@ False + + False + + + False + False diff --git a/YAMDCC.GUI/Constants.cs b/YAMDCC.GUI/Paths.cs similarity index 74% rename from YAMDCC.GUI/Constants.cs rename to YAMDCC.GUI/Paths.cs index 81d38dc..cc980bc 100644 --- a/YAMDCC.GUI/Constants.cs +++ b/YAMDCC.GUI/Paths.cs @@ -19,7 +19,7 @@ namespace YAMDCC.GUI { - internal static class Constants + internal static class Paths { /// /// The path where program data is stored. @@ -27,7 +27,7 @@ internal static class Constants /// /// (C:\ProgramData\Sparronator9999\YAMDCC on Windows) /// - public static readonly string DataPath = Path.Combine( + public static readonly string Data = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Sparronator9999", "YAMDCC"); @@ -37,7 +37,7 @@ internal static class Constants /// /// (C:\ProgramData\Sparronator9999\YAMDCC\Logs on Windows) /// - public static readonly string LogPath = Path.Combine(DataPath, "Logs"); + public static readonly string Logs = Path.Combine(Data, "Logs"); /// /// The path where the currently applied YAMDCC config is saved. @@ -45,7 +45,7 @@ internal static class Constants /// /// (C:\ProgramData\Sparronator9999\YAMDCC\CurrentConfig.xml on Windows) /// - public static readonly string CurrentConfigPath = Path.Combine(DataPath, "CurrentConfig.xml"); + public static readonly string CurrentConfig = Path.Combine(Data, "CurrentConfig.xml"); /// /// The path where the path to the last saved YAMDCC config is saved. @@ -53,7 +53,10 @@ internal static class Constants /// /// (C:\ProgramData\Sparronator9999\YAMDCC\CurrentConfig.xml on Windows) /// - public static readonly string LastConfigPath = Path.Combine(DataPath, "LastConfig"); + public static readonly string LastConfig = Path.Combine(Data, "LastConfig"); + public static readonly string ECToConfSuccess = Path.Combine(Data, "ECToConfSuccess"); + public static readonly string ECToConfFail = Path.Combine(Data, "ECToConfFail"); + public static readonly string ECToConfPending = Path.Combine(Data, "ECToConfPending"); } } diff --git a/YAMDCC.GUI/Program.cs b/YAMDCC.GUI/Program.cs index c26ccd6..21b6222 100644 --- a/YAMDCC.GUI/Program.cs +++ b/YAMDCC.GUI/Program.cs @@ -43,7 +43,7 @@ private static void Main() // Make sure the application data directory structure is set up // because apparently windows services don't know how to create // directories: - Directory.CreateDirectory(Constants.LogPath); + Directory.CreateDirectory(Paths.Logs); if (!IsAdmin()) { @@ -132,7 +132,7 @@ private static void Start() int rebootFlag = -1; try { - StreamReader sr = new(Path.Combine(Constants.DataPath, "ECToConfPending")); + StreamReader sr = new(Paths.ECToConfPending); if (int.TryParse(sr.ReadToEnd(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int value)) { rebootFlag = value; @@ -150,7 +150,7 @@ private static void Start() { try { - File.Delete(Path.Combine(Constants.DataPath, "ECToConfPending")); + File.Delete(Paths.ECToConfPending); } catch (DirectoryNotFoundException) { } } diff --git a/YAMDCC.GUI/Utils.cs b/YAMDCC.GUI/Utils.cs index 712b433..0340d37 100644 --- a/YAMDCC.GUI/Utils.cs +++ b/YAMDCC.GUI/Utils.cs @@ -37,7 +37,7 @@ internal static class Utils /// /// One of the values. /// - internal static DialogResult ShowError(string message) + public static DialogResult ShowError(string message) { return MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/YAMDCC.Service/FanControlService.cs b/YAMDCC.Service/FanControlService.cs index 8875139..8980bd1 100644 --- a/YAMDCC.Service/FanControlService.cs +++ b/YAMDCC.Service/FanControlService.cs @@ -119,7 +119,7 @@ protected override void OnStart(string[] args) int rebootFlag = -1; try { - StreamReader sr = new(Constants.ECtoConfPendingPath); + StreamReader sr = new(Paths.ECtoConfPending); if (int.TryParse(sr.ReadToEnd(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int value)) { rebootFlag = value; @@ -129,7 +129,7 @@ protected override void OnStart(string[] args) if (rebootFlag == 0) { FanCurveECToConf(); - File.Delete(Constants.ECtoConfPendingPath); + File.Delete(Paths.ECtoConfPending); } } catch (FileNotFoundException) { } @@ -155,7 +155,7 @@ protected override void OnShutdown() int rebootFlag = -1; try { - StreamReader sr = new(Constants.ECtoConfPendingPath); + StreamReader sr = new(Paths.ECtoConfPending); if (int.TryParse(sr.ReadToEnd(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int value)) { rebootFlag = value; @@ -164,7 +164,7 @@ protected override void OnShutdown() if (rebootFlag == 1) { - StreamWriter sw = new(Constants.ECtoConfPendingPath); + StreamWriter sw = new(Paths.ECtoConfPending); try { sw.Write(0); @@ -350,7 +350,7 @@ private void LoadConf() { Log.Info(Strings.GetString("cfgLoading")); - string confPath = Constants.CurrentConfigPath; + string confPath = Paths.CurrentConfig; try { @@ -786,14 +786,14 @@ private void FanCurveECToConf() } Log.Debug("Saving config..."); - Config.Save(Constants.CurrentConfigPath); + Config.Save(Paths.CurrentConfig); - FileStream fs = File.Create(Path.Combine(Constants.DataPath, "ECToConfSuccess")); + FileStream fs = File.Create(Paths.ECToConfSuccess); fs.Close(); } catch { - FileStream fs = File.Create(Path.Combine(Constants.DataPath, "ECToConfFail")); + FileStream fs = File.Create(Paths.ECToConfFail); fs.Close(); } } diff --git a/YAMDCC.Service/Constants.cs b/YAMDCC.Service/Paths.cs similarity index 75% rename from YAMDCC.Service/Constants.cs rename to YAMDCC.Service/Paths.cs index d7c7828..448e84b 100644 --- a/YAMDCC.Service/Constants.cs +++ b/YAMDCC.Service/Paths.cs @@ -19,7 +19,7 @@ namespace YAMDCC.Service { - internal static class Constants + internal static class Paths { /// /// The path where program data is stored. @@ -27,7 +27,7 @@ internal static class Constants /// /// (C:\ProgramData\Sparronator9999\YAMDCC on Windows) /// - public static readonly string DataPath = Path.Combine( + public static readonly string Data = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Sparronator9999", "YAMDCC"); @@ -37,7 +37,7 @@ internal static class Constants /// /// (C:\ProgramData\Sparronator9999\YAMDCC\Logs on Windows) /// - public static readonly string LogPath = Path.Combine(DataPath, "Logs"); + public static readonly string Logs = Path.Combine(Data, "Logs"); /// /// The path where the currently applied YAMDCC config is saved. @@ -45,8 +45,10 @@ internal static class Constants /// /// (C:\ProgramData\Sparronator9999\YAMDCC\CurrentConfig.xml on Windows) /// - public static readonly string CurrentConfigPath = Path.Combine(DataPath, "CurrentConfig.xml"); + public static readonly string CurrentConfig = Path.Combine(Data, "CurrentConfig.xml"); - public static readonly string ECtoConfPendingPath = Path.Combine(DataPath, "ECToConfPending"); + public static readonly string ECToConfSuccess = Path.Combine(Data, "ECToConfSuccess"); + public static readonly string ECToConfFail = Path.Combine(Data, "ECToConfFail"); + public static readonly string ECtoConfPending = Path.Combine(Data, "ECToConfPending"); } }