From b73a03683cbf108799e5943bef2b52e4f38e85f1 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 20 May 2020 23:46:36 +0100 Subject: [PATCH] Added: autosave --- LinearAppLauncher.csproj | 4 ++- MainForm.Designer.cs | 49 +++++++++++++++++++++++++++++---- MainForm.cs | 51 ++++++++++++++++++++++++---------- Models/LauncherSession.cs | 9 +++++- Properties/AssemblyInfo.cs | 4 +-- Windows/Forms/AForm.cs | 2 +- Windows/Forms/OptionsForm.cs | 53 +++++++++++++++++++++++++++++++++--- 7 files changed, 143 insertions(+), 29 deletions(-) diff --git a/LinearAppLauncher.csproj b/LinearAppLauncher.csproj index d78ccd1..f84d7eb 100644 --- a/LinearAppLauncher.csproj +++ b/LinearAppLauncher.csproj @@ -22,15 +22,17 @@ DEBUG;TRACE prompt 4 + false AnyCPU - pdbonly + none true bin\Release\ TRACE prompt 4 + false true diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index fcbaedd..e535976 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -45,9 +45,13 @@ this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem9 = new System.Windows.Forms.ToolStripMenuItem(); this.optionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.viewHelpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); ((System.ComponentModel.ISupportInitialize)(this.imageBox3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.imageBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.imageBox1)).BeginInit(); @@ -77,9 +81,10 @@ this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem4, this.toolStripMenuItem3, - this.toolStripMenuItem9}); + this.toolStripMenuItem9, + this.helpToolStripMenuItem}); this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(102, 70); + this.contextMenuStrip1.Size = new System.Drawing.Size(181, 114); this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); // // toolStripMenuItem4 @@ -95,7 +100,7 @@ this.toolStripMenuItem10, this.exitToolStripMenuItem}); this.toolStripMenuItem4.Name = "toolStripMenuItem4"; - this.toolStripMenuItem4.Size = new System.Drawing.Size(101, 22); + this.toolStripMenuItem4.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItem4.Text = "&File"; // // toolStripMenuItem5 @@ -160,7 +165,7 @@ this.toolStripMenuItem3.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem1}); this.toolStripMenuItem3.Name = "toolStripMenuItem3"; - this.toolStripMenuItem3.Size = new System.Drawing.Size(101, 22); + this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItem3.Text = "&View"; // // toolStripMenuItem1 @@ -175,7 +180,7 @@ this.toolStripMenuItem9.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.optionToolStripMenuItem}); this.toolStripMenuItem9.Name = "toolStripMenuItem9"; - this.toolStripMenuItem9.Size = new System.Drawing.Size(101, 22); + this.toolStripMenuItem9.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItem9.Text = "&Tools"; // // optionToolStripMenuItem @@ -185,6 +190,30 @@ this.optionToolStripMenuItem.Text = "&Options"; this.optionToolStripMenuItem.Click += new System.EventHandler(this.optionToolStripMenuItem_Click); // + // helpToolStripMenuItem + // + this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.viewHelpToolStripMenuItem, + this.toolStripSeparator1, + this.aboutToolStripMenuItem}); + this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; + this.helpToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.helpToolStripMenuItem.Text = "&Help"; + // + // viewHelpToolStripMenuItem + // + this.viewHelpToolStripMenuItem.Name = "viewHelpToolStripMenuItem"; + this.viewHelpToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.viewHelpToolStripMenuItem.Text = "&View Help"; + this.viewHelpToolStripMenuItem.Click += new System.EventHandler(this.viewHelpToolStripMenuItem_Click); + // + // aboutToolStripMenuItem + // + this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + this.aboutToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.aboutToolStripMenuItem.Text = "&About"; + this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); + // // flowLayoutPanel1 // this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -210,6 +239,11 @@ this.openFileDialog1.Filter = "Session files|*.jsonfig"; this.openFileDialog1.Title = "Choose session file"; // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -223,7 +257,6 @@ this.MinimumSize = new System.Drawing.Size(633, 280); this.Name = "MainForm"; this.Text = "Launcher"; - this.Visible = false; this.TitleContextMenuStrip = this.contextMenuStrip1; this.Controls.SetChildIndex(this.flowLayoutPanel1, 0); this.Controls.SetChildIndex(this.imageBox3, 0); @@ -256,6 +289,10 @@ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9; private System.Windows.Forms.ToolStripMenuItem optionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem viewHelpToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; } } diff --git a/MainForm.cs b/MainForm.cs index 7cc1988..cd8f188 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -61,28 +61,37 @@ namespace AppLauncher { base.OnClosing(e); + if (this.CurrentSession == null) this.CurrentSession = new LauncherSession(); + if (string.IsNullOrWhiteSpace(sessionFilename)) { // do nothing } else { - DialogResult dr = MessageBox.Show("Save existing session?", "Exit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); - if (dr == DialogResult.Yes) + if (this.CurrentSession.AutoSave == LauncherSession.AutoSaveOption.Prompt) { - bool rv = saveFile(sessionFilename, false); - if (!rv) + DialogResult dr = MessageBox.Show("Save existing session?", "Exit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (dr == DialogResult.Yes) + { + bool rv = saveFile(sessionFilename, false); + if (!rv) + { + e.Cancel = true; + } + } + else if (dr == DialogResult.No) + { + // do nothing + } + else if (dr == DialogResult.Cancel) { e.Cancel = true; } } - else if (dr == DialogResult.No) + else if (this.CurrentSession.AutoSave == LauncherSession.AutoSaveOption.Yes) { - // do nothing - } - else if (dr == DialogResult.Cancel) - { - e.Cancel = true; + saveFile(sessionFilename, false); } } @@ -155,13 +164,13 @@ namespace AppLauncher /// /// /// - private void toolStripMenuItem7_Click(object sender, EventArgs e) + private async void toolStripMenuItem7_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(sessionFilename)) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { - loadFile(openFileDialog1.FileName); + await loadFile(openFileDialog1.FileName); } } else @@ -174,7 +183,7 @@ namespace AppLauncher { if (openFileDialog1.ShowDialog() == DialogResult.OK) { - loadFile(openFileDialog1.FileName); + await loadFile(openFileDialog1.FileName); } } } @@ -182,7 +191,7 @@ namespace AppLauncher { if (openFileDialog1.ShowDialog() == DialogResult.OK) { - loadFile(openFileDialog1.FileName); + await loadFile(openFileDialog1.FileName); } } else if (dr == DialogResult.Cancel) @@ -550,5 +559,19 @@ namespace AppLauncher toolStripMenuItem6.Enabled = !string.IsNullOrWhiteSpace(sessionFilename); } + private void viewHelpToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + System.Diagnostics.Process.Start("https://www.hiimray.co.uk/software-fizzy-launcher"); + } + catch + { + // do nothing + } + } + + private void aboutToolStripMenuItem_Click(object sender, EventArgs e) => MessageBox.Show(Application.ProductName + " v" + Application.ProductVersion, "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + } } diff --git a/Models/LauncherSession.cs b/Models/LauncherSession.cs index ccf295a..f23c889 100644 --- a/Models/LauncherSession.cs +++ b/Models/LauncherSession.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Drawing; namespace AppLauncher.Models { @@ -15,7 +14,13 @@ namespace AppLauncher.Models public int ModifierCode => ((this.IsAlt ? 1 : 0) + (this.IsCtrl ? 2 : 0) + (this.IsShift ? 4 : 0)); public System.Windows.Forms.Keys KeyCode => (System.Windows.Forms.Keys)this.Key; + } + public enum AutoSaveOption + { + Prompt = 0, + Yes, + No } public int DefaultHeight { get; set; } = 280; @@ -23,6 +28,7 @@ namespace AppLauncher.Models public bool AlwaysOnTop { get; set; } = false; public bool HideOnClose { get; set; } = false; public bool HideOnClick { get; set; } = false; + public AutoSaveOption AutoSave { get; set; } = AutoSaveOption.Prompt; public List Groups { get; set; } = new List(); public LauncherSession ToSimple() @@ -34,6 +40,7 @@ namespace AppLauncher.Models AlwaysOnTop = this.AlwaysOnTop, HideOnClose = this.HideOnClose, HideOnClick = this.HideOnClick, + AutoSave = this.AutoSave, Groups = null }; } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 1308be5..11696d9 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.1.064")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("0.1.1.107")] diff --git a/Windows/Forms/AForm.cs b/Windows/Forms/AForm.cs index 2980e7a..29fb1e3 100644 --- a/Windows/Forms/AForm.cs +++ b/Windows/Forms/AForm.cs @@ -149,7 +149,7 @@ namespace AppLauncher.Windows.Forms g.DrawImageUnscaled(Properties.Resources.app_icon_24, 17, 17); - TextRenderer.DrawText(g, "Fizzy Launcher", new Font(this.Font.FontFamily, 14F), new Point(58, 17), Color.FromArgb(156, 158, 171)); + TextRenderer.DrawText(g, Application.ProductName, new Font(this.Font.FontFamily, 14F), new Point(58, 17), Color.FromArgb(156, 158, 171)); } diff --git a/Windows/Forms/OptionsForm.cs b/Windows/Forms/OptionsForm.cs index 8faa35a..5639385 100644 --- a/Windows/Forms/OptionsForm.cs +++ b/Windows/Forms/OptionsForm.cs @@ -23,6 +23,8 @@ namespace AppLauncher.Windows.Forms private System.Windows.Forms.Label label6; private TYesNoPickerBox pickerBox5; private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private TPickerBox pickerBox6; public MainForm parentForm { get; set; } = null; protected LauncherSession.HotKeyOptions hotKeyOptions = null; @@ -36,6 +38,15 @@ namespace AppLauncher.Windows.Forms textBox1.InnerTextBox.ReadOnly = true; textBox1.InnerTextBox.BackColor = Color.White; textBox1.InnerTextBox.KeyUp += textBox1_KeyUp; + + pickerBox6.ComboBox.Items.Clear(); + foreach (string item in Enum.GetNames(typeof(LauncherSession.AutoSaveOption))) + { + pickerBox6.ComboBox.Items.Add(item); + } + + if (pickerBox6.ComboBox.Items.Count > 0) pickerBox6.ComboBox.SelectedIndex = 0; + } private void InitializeComponent() @@ -56,6 +67,8 @@ namespace AppLauncher.Windows.Forms this.label6 = new System.Windows.Forms.Label(); this.pickerBox5 = new RyzStudio.Windows.ThemedForms.TYesNoPickerBox(); this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.pickerBox6 = new RyzStudio.Windows.ThemedForms.TPickerBox(); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).BeginInit(); this.SuspendLayout(); // @@ -226,7 +239,7 @@ namespace AppLauncher.Windows.Forms | System.Windows.Forms.AnchorStyles.Right))); this.pickerBox4.BackColor = System.Drawing.Color.Transparent; this.pickerBox4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.pickerBox4.Location = new System.Drawing.Point(159, 259); + this.pickerBox4.Location = new System.Drawing.Point(159, 300); this.pickerBox4.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4); this.pickerBox4.Name = "pickerBox4"; this.pickerBox4.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5); @@ -239,7 +252,7 @@ namespace AppLauncher.Windows.Forms // this.label6.BackColor = System.Drawing.Color.Transparent; this.label6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(95)))), ((int)(((byte)(99)))), ((int)(((byte)(104))))); - this.label6.Location = new System.Drawing.Point(18, 259); + this.label6.Location = new System.Drawing.Point(18, 300); this.label6.Margin = new System.Windows.Forms.Padding(0); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(131, 32); @@ -253,7 +266,7 @@ namespace AppLauncher.Windows.Forms | System.Windows.Forms.AnchorStyles.Right))); this.pickerBox5.BackColor = System.Drawing.Color.Transparent; this.pickerBox5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.pickerBox5.Location = new System.Drawing.Point(159, 300); + this.pickerBox5.Location = new System.Drawing.Point(159, 341); this.pickerBox5.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4); this.pickerBox5.Name = "pickerBox5"; this.pickerBox5.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5); @@ -266,7 +279,7 @@ namespace AppLauncher.Windows.Forms // this.label7.BackColor = System.Drawing.Color.Transparent; this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(95)))), ((int)(((byte)(99)))), ((int)(((byte)(104))))); - this.label7.Location = new System.Drawing.Point(18, 300); + this.label7.Location = new System.Drawing.Point(18, 341); this.label7.Margin = new System.Windows.Forms.Padding(0); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(131, 32); @@ -274,9 +287,37 @@ namespace AppLauncher.Windows.Forms this.label7.Text = "Hide On Click"; this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // + // label8 + // + this.label8.BackColor = System.Drawing.Color.Transparent; + this.label8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(95)))), ((int)(((byte)(99)))), ((int)(((byte)(104))))); + this.label8.Location = new System.Drawing.Point(18, 259); + this.label8.Margin = new System.Windows.Forms.Padding(0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(131, 32); + this.label8.TabIndex = 186; + this.label8.Text = "Auto Save"; + this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // pickerBox6 + // + this.pickerBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pickerBox6.BackColor = System.Drawing.Color.Transparent; + this.pickerBox6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); + this.pickerBox6.Location = new System.Drawing.Point(159, 259); + this.pickerBox6.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4); + this.pickerBox6.Name = "pickerBox6"; + this.pickerBox6.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5); + this.pickerBox6.Size = new System.Drawing.Size(220, 32); + this.pickerBox6.SubmitButton = null; + this.pickerBox6.TabIndex = 187; + // // OptionsForm // this.ClientSize = new System.Drawing.Size(400, 480); + this.Controls.Add(this.pickerBox6); + this.Controls.Add(this.label8); this.Controls.Add(this.pickerBox5); this.Controls.Add(this.label7); this.Controls.Add(this.pickerBox4); @@ -312,6 +353,8 @@ namespace AppLauncher.Windows.Forms this.Controls.SetChildIndex(this.pickerBox4, 0); this.Controls.SetChildIndex(this.label7, 0); this.Controls.SetChildIndex(this.pickerBox5, 0); + this.Controls.SetChildIndex(this.label8, 0); + this.Controls.SetChildIndex(this.pickerBox6, 0); ((System.ComponentModel.ISupportInitialize)(this.imgbxClose)).EndInit(); this.ResumeLayout(false); @@ -350,6 +393,7 @@ namespace AppLauncher.Windows.Forms pickerBox4.Value = parentForm.CurrentSession.HideOnClose; pickerBox5.Value = parentForm.CurrentSession.HideOnClick; + pickerBox6.ComboBox.SelectedIndex = (int)parentForm.CurrentSession.AutoSave; } @@ -369,6 +413,7 @@ namespace AppLauncher.Windows.Forms parentForm.CurrentSession.HideOnClose = pickerBox4.Value; parentForm.CurrentSession.HideOnClick = pickerBox5.Value; + parentForm.CurrentSession.AutoSave = (LauncherSession.AutoSaveOption)pickerBox6.ComboBox.SelectedIndex; }