Skip to content

Commit

Permalink
Add Window Splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisFeline committed Dec 29, 2023
1 parent f096c7c commit a8de873
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 18 deletions.
21 changes: 21 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ToNSaveManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<ToNSaveManager.Properties.Settings>
<setting name="LastWindowWidth" serializeAs="String">
<value>0</value>
</setting>
<setting name="LastWindowHeight" serializeAs="String">
<value>0</value>
</setting>
<setting name="LastWindowSplit" serializeAs="String">
<value>0</value>
</setting>
</ToNSaveManager.Properties.Settings>
</userSettings>
</configuration>
62 changes: 62 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ToNSaveManager.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="LastWindowWidth" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="LastWindowHeight" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="LastWindowSplit" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
12 changes: 12 additions & 0 deletions ToNSaveManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
</ItemGroup>

<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Update="update.bat">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand All @@ -52,4 +56,12 @@
<Folder Include="Properties\DataSources\" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>

</Project>
61 changes: 45 additions & 16 deletions Windows/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 30 additions & 2 deletions Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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...";

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<bool>(ROUND_PARTICIPATION_KEY);
}
Expand Down Expand Up @@ -670,6 +699,5 @@ private void CopyRecent()
}

#endregion

}
}

0 comments on commit a8de873

Please sign in to comment.