From a8de873159beb69889c2049afd5ccee0912c4435 Mon Sep 17 00:00:00 2001 From: Kittenji Date: Fri, 29 Dec 2023 16:43:52 -0500 Subject: [PATCH] Add Window Splitter --- App.config | 21 +++++++++++ Properties/Settings.Designer.cs | 62 +++++++++++++++++++++++++++++++++ Properties/Settings.settings | 15 ++++++++ ToNSaveManager.csproj | 12 +++++++ Windows/MainWindow.Designer.cs | 61 +++++++++++++++++++++++--------- Windows/MainWindow.cs | 32 +++++++++++++++-- 6 files changed, 185 insertions(+), 18 deletions(-) create mode 100644 App.config create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings diff --git a/App.config b/App.config new file mode 100644 index 0000000..8a4fe90 --- /dev/null +++ b/App.config @@ -0,0 +1,21 @@ + + + + +
+ + + + + + 0 + + + 0 + + + 0 + + + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..919aa8c --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,62 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ToNSaveManager.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int LastWindowWidth { + get { + return ((int)(this["LastWindowWidth"])); + } + set { + this["LastWindowWidth"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int LastWindowHeight { + get { + return ((int)(this["LastWindowHeight"])); + } + set { + this["LastWindowHeight"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int LastWindowSplit { + get { + return ((int)(this["LastWindowSplit"])); + } + set { + this["LastWindowSplit"] = value; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3454989 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,15 @@ + + + + + + 0 + + + 0 + + + 0 + + + \ No newline at end of file diff --git a/ToNSaveManager.csproj b/ToNSaveManager.csproj index 8c70228..bc1c432 100644 --- a/ToNSaveManager.csproj +++ b/ToNSaveManager.csproj @@ -43,6 +43,10 @@ + + SettingsSingleFileGenerator + Settings.Designer.cs + Always @@ -52,4 +56,12 @@ + + + True + True + Settings.settings + + + \ No newline at end of file diff --git a/Windows/MainWindow.Designer.cs b/Windows/MainWindow.Designer.cs index 4054fbf..4af7e69 100644 --- a/Windows/MainWindow.Designer.cs +++ b/Windows/MainWindow.Designer.cs @@ -46,13 +46,18 @@ private void InitializeComponent() btnSettings = new Button(); button1 = new Button(); button2 = new Button(); + splitContainer1 = new SplitContainer(); ctxMenuEntries.SuspendLayout(); ctxMenuKeys.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit(); + splitContainer1.Panel1.SuspendLayout(); + splitContainer1.Panel2.SuspendLayout(); + splitContainer1.SuspendLayout(); SuspendLayout(); // // listBoxKeys // - listBoxKeys.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; + listBoxKeys.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; listBoxKeys.BackColor = Color.FromArgb(59, 66, 82); listBoxKeys.BorderStyle = BorderStyle.FixedSingle; listBoxKeys.DrawMode = DrawMode.OwnerDrawFixed; @@ -60,9 +65,9 @@ private void InitializeComponent() listBoxKeys.FormattingEnabled = true; listBoxKeys.IntegralHeight = false; listBoxKeys.ItemHeight = 15; - listBoxKeys.Location = new Point(12, 12); + listBoxKeys.Location = new Point(0, 0); listBoxKeys.Name = "listBoxKeys"; - listBoxKeys.Size = new Size(192, 217); + listBoxKeys.Size = new Size(178, 217); listBoxKeys.TabIndex = 0; listBoxKeys.TabStop = false; listBoxKeys.DrawItem += listBoxEntries_DrawItem; @@ -79,9 +84,9 @@ private void InitializeComponent() listBoxEntries.FormattingEnabled = true; listBoxEntries.IntegralHeight = false; listBoxEntries.ItemHeight = 15; - listBoxEntries.Location = new Point(210, 12); + listBoxEntries.Location = new Point(0, 0); listBoxEntries.Name = "listBoxEntries"; - listBoxEntries.Size = new Size(307, 217); + listBoxEntries.Size = new Size(323, 217); listBoxEntries.TabIndex = 1; listBoxEntries.TabStop = false; listBoxEntries.DrawItem += listBoxEntries_DrawItem; @@ -167,14 +172,14 @@ private void InitializeComponent() // // btnSettings // - btnSettings.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + btnSettings.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; btnSettings.BackColor = Color.FromArgb(46, 52, 64); btnSettings.FlatAppearance.BorderColor = Color.FromArgb(122, 122, 122); btnSettings.FlatStyle = FlatStyle.Flat; btnSettings.ForeColor = Color.White; - btnSettings.Location = new Point(12, 235); + btnSettings.Location = new Point(0, 223); btnSettings.Name = "btnSettings"; - btnSettings.Size = new Size(192, 24); + btnSettings.Size = new Size(178, 24); btnSettings.TabIndex = 0; btnSettings.TabStop = false; btnSettings.Text = "Settings"; @@ -188,9 +193,9 @@ private void InitializeComponent() button1.FlatAppearance.BorderColor = Color.FromArgb(122, 122, 122); button1.FlatStyle = FlatStyle.Flat; button1.ForeColor = Color.White; - button1.Location = new Point(210, 235); + button1.Location = new Point(0, 223); button1.Name = "button1"; - button1.Size = new Size(243, 24); + button1.Size = new Size(259, 24); button1.TabIndex = 0; button1.TabStop = false; button1.Text = "Objectives"; @@ -204,7 +209,7 @@ private void InitializeComponent() button2.FlatAppearance.BorderColor = Color.FromArgb(122, 122, 122); button2.FlatStyle = FlatStyle.Flat; button2.ForeColor = Color.White; - button2.Location = new Point(459, 235); + button2.Location = new Point(265, 223); button2.Name = "button2"; button2.Size = new Size(58, 24); button2.TabIndex = 3; @@ -213,26 +218,49 @@ private void InitializeComponent() button2.UseVisualStyleBackColor = false; button2.Click += linkWiki_Clicked; // + // splitContainer1 + // + splitContainer1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + splitContainer1.Location = new Point(12, 12); + splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + splitContainer1.Panel1.Controls.Add(listBoxKeys); + splitContainer1.Panel1.Controls.Add(btnSettings); + // + // splitContainer1.Panel2 + // + splitContainer1.Panel2.Controls.Add(listBoxEntries); + splitContainer1.Panel2.Controls.Add(button1); + splitContainer1.Panel2.Controls.Add(button2); + splitContainer1.Size = new Size(505, 247); + splitContainer1.SplitterDistance = 178; + splitContainer1.TabIndex = 0; + splitContainer1.TabStop = false; + splitContainer1.SplitterMoved += splitContainer1_SplitterMoved; + // // MainWindow // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.FromArgb(46, 52, 64); ClientSize = new Size(529, 271); - Controls.Add(button2); - Controls.Add(button1); - Controls.Add(btnSettings); - Controls.Add(listBoxEntries); - Controls.Add(listBoxKeys); + Controls.Add(splitContainer1); Icon = (Icon)resources.GetObject("$this.Icon"); MaximizeBox = false; MinimumSize = new Size(412, 256); Name = "MainWindow"; Text = "ToN Save Manager"; + FormClosing += MainWindow_FormClosing; Load += mainWindow_Loaded; Shown += mainWindow_Shown; ctxMenuEntries.ResumeLayout(false); ctxMenuKeys.ResumeLayout(false); + splitContainer1.Panel1.ResumeLayout(false); + splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit(); + splitContainer1.ResumeLayout(false); ResumeLayout(false); } @@ -254,5 +282,6 @@ private void InitializeComponent() private Button btnSettings; private Button button1; private Button button2; + private SplitContainer splitContainer1; } } \ No newline at end of file diff --git a/Windows/MainWindow.cs b/Windows/MainWindow.cs index 2b49a0b..ec5d46d 100644 --- a/Windows/MainWindow.cs +++ b/Windows/MainWindow.cs @@ -40,8 +40,26 @@ public void SetTitle(string? title) this.Text = string.IsNullOrEmpty(title) ? OriginalTitle : OriginalTitle + " | " + title; } + private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) + { + Properties.Settings.Default.LastWindowWidth = this.Width; + Properties.Settings.Default.LastWindowHeight = this.Height; + Properties.Settings.Default.LastWindowSplit = splitContainer1.SplitterDistance; + Properties.Settings.Default.Save(); + } + private void mainWindow_Loaded(object sender, EventArgs e) { + if (Properties.Settings.Default.LastWindowWidth > this.Width && Properties.Settings.Default.LastWindowHeight > this.Height) + { + this.Width = Properties.Settings.Default.LastWindowWidth; + this.Height = Properties.Settings.Default.LastWindowHeight; + } + if (Properties.Settings.Default.LastWindowSplit > 0) + { + splitContainer1.SplitterDistance = Properties.Settings.Default.LastWindowSplit; + } + OriginalTitle = this.Text; this.Text = "Loading, please wait..."; @@ -354,6 +372,16 @@ internal static void OpenExternalLink(string url) } #endregion + #region Split Container + private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e) + { + if (splitContainer1.CanFocus) + splitContainer1.ActiveControl = listBoxEntries; + + listBoxKeys.Refresh(); + listBoxEntries.Refresh(); + } + #endregion #endregion #region Form Methods @@ -510,7 +538,8 @@ private bool HandleTerrorIndex(string line, DateTime timestamp, LogContext conte context.Rem(ROUND_RESULT_KEY); } return true; - } else + } + else { isOptedIn = context.Get(ROUND_PARTICIPATION_KEY); } @@ -670,6 +699,5 @@ private void CopyRecent() } #endregion - } } \ No newline at end of file