From ccbdafbc889ee857f70fc204c33f503e5ace4416 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 8 Aug 2015 15:10:18 -0600 Subject: [PATCH] Save size of main window between uses. Deal with minimized windows (do not save status when minimized) --- EduNetworkBuilder/App.config | 12 +++++ EduNetworkBuilder/NetTestEditor.cs | 6 ++- EduNetworkBuilder/NetworkBuilder.cs | 33 +++++++++---- .../Properties/Settings.Designer.cs | 48 +++++++++++++++++++ .../Properties/Settings.settings | 12 +++++ EduNetworkBuilder/Resources/Help.rtf | 3 +- 6 files changed, 104 insertions(+), 10 deletions(-) diff --git a/EduNetworkBuilder/App.config b/EduNetworkBuilder/App.config index 83e42c8..0e0349b 100644 --- a/EduNetworkBuilder/App.config +++ b/EduNetworkBuilder/App.config @@ -22,6 +22,18 @@ False + + -1 + + + -1 + + + -1 + + + -1 + \ No newline at end of file diff --git a/EduNetworkBuilder/NetTestEditor.cs b/EduNetworkBuilder/NetTestEditor.cs index 40f5085..29ae606 100644 --- a/EduNetworkBuilder/NetTestEditor.cs +++ b/EduNetworkBuilder/NetTestEditor.cs @@ -105,7 +105,11 @@ namespace EduNetworkBuilder else if (ToEdit.TheTest == NetTestType.ReadContextHelp) { cbSource.Items.Clear(); - foreach (string ContextHelp in Enum.GetNames(typeof(HelpTopics))) + List theNames = new List(); + theNames.AddRange(Enum.GetNames(typeof(HelpTopics))); + theNames.Sort(); + theNames.Remove("None"); + foreach (string ContextHelp in theNames) { cbSource.Items.Add(ContextHelp); } diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 25ae630..909d3f4 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -904,11 +904,14 @@ namespace EduNetworkBuilder private void BuilderWindow_Resize(object sender, EventArgs e) { - //size limits go here - int smallestX = 400; - int smallestY = 300; - if (Width < smallestX) Width = smallestX; - if (Height < smallestY) Height = smallestY; + if (WindowState == FormWindowState.Normal) + { + //size limits go here + int smallestX = 400; + int smallestY = 300; + if (Width < smallestX) Width = smallestX; + if (Height < smallestY) Height = smallestY; + } } private void BuilderWindow_ResizeEnd(object sender, EventArgs e) @@ -925,9 +928,7 @@ namespace EduNetworkBuilder private void helpToolStripMenuItem1_Click(object sender, EventArgs e) { - RTFWindow mywindow = new RTFWindow(RTFWindowContents.help); - mywindow.ShowDialog(); - + NB.ReadContextHelp(HelpTopics.None); } private void releaseNotesToolStripMenuItem_Click(object sender, EventArgs e) @@ -950,6 +951,13 @@ namespace EduNetworkBuilder { Properties.Settings.Default.ChosenLanguage = ChosenLanguage; Properties.Settings.Default.LastPath = LastPath; + if (WindowState == FormWindowState.Normal) + { + Properties.Settings.Default.MainWindowHeight = Height; + Properties.Settings.Default.MainWindowWidth = Width; + Properties.Settings.Default.MainWindowX = Location.X; + Properties.Settings.Default.MainWindowY = Location.Y; + } Properties.Settings.Default.Save(); } @@ -1103,6 +1111,15 @@ namespace EduNetworkBuilder puzzlesToolStripMenuItem_Click(null, null); } } + if (Properties.Settings.Default.MainWindowX != -1 && Properties.Settings.Default.MainWindowY != -1) + { + Location = new Point(Properties.Settings.Default.MainWindowX, Properties.Settings.Default.MainWindowY); + } + if (Properties.Settings.Default.MainWindowHeight != -1 && Properties.Settings.Default.MainWindowWidth != -1) + { + Height = Properties.Settings.Default.MainWindowHeight; + Width = Properties.Settings.Default.MainWindowWidth; + } } private void btnHelp_Click(object sender, EventArgs e) diff --git a/EduNetworkBuilder/Properties/Settings.Designer.cs b/EduNetworkBuilder/Properties/Settings.Designer.cs index a47cf45..9ceefb0 100644 --- a/EduNetworkBuilder/Properties/Settings.Designer.cs +++ b/EduNetworkBuilder/Properties/Settings.Designer.cs @@ -81,5 +81,53 @@ namespace EduNetworkBuilder.Properties { this["LanguageHasBeenChosen"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("-1")] + public int MainWindowX { + get { + return ((int)(this["MainWindowX"])); + } + set { + this["MainWindowX"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("-1")] + public int MainWindowY { + get { + return ((int)(this["MainWindowY"])); + } + set { + this["MainWindowY"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("-1")] + public int MainWindowWidth { + get { + return ((int)(this["MainWindowWidth"])); + } + set { + this["MainWindowWidth"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("-1")] + public int MainWindowHeight { + get { + return ((int)(this["MainWindowHeight"])); + } + set { + this["MainWindowHeight"] = value; + } + } } } diff --git a/EduNetworkBuilder/Properties/Settings.settings b/EduNetworkBuilder/Properties/Settings.settings index 1c470e6..9c65c3b 100644 --- a/EduNetworkBuilder/Properties/Settings.settings +++ b/EduNetworkBuilder/Properties/Settings.settings @@ -17,5 +17,17 @@ False + + -1 + + + -1 + + + -1 + + + -1 + \ No newline at end of file diff --git a/EduNetworkBuilder/Resources/Help.rtf b/EduNetworkBuilder/Resources/Help.rtf index 6e132c6..81a7242 100644 --- a/EduNetworkBuilder/Resources/Help.rtf +++ b/EduNetworkBuilder/Resources/Help.rtf @@ -1,7 +1,8 @@ {\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}{\f1\fnil\fcharset0 Courier New;}{\f2\fnil\fcharset0 Calibri;}{\f3\fmodern\fprq1\fcharset0 Consolas;}} {\colortbl ;\red0\green0\blue255;} {\*\generator Riched20 6.3.9600}\viewkind4\uc1 -\pard\widctlpar\sa200\sl276\slmult1\f0\fs22\lang9 This is a basic help document for EduNetworkBuilder\par +\pard\widctlpar\sa200\sl276\slmult1\b\f0\fs22\lang9 Help:\b0\par +This is a basic help document for EduNetworkBuilder. You can get to this by going to "Help" -> "Help" from the main network-builder window. Or, if you are working on a puzzle, the number buttons on the right-side should open context help. (Help topics that somehow relate to the specific puzzle).\par \b Overview\par \b0 EduNetworkBuilder is meant to represent fairly truthfully how a network functions while removing the complexity of configuration. It focuses on IP addresses, Netmasks, Gateways, and Routes.\par \b The Items & Terminology\b0\par