BusynessNotification

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9ad29afdfa0e947fa3cf532ed73b86765a08f947
parent e427a2af23455c5d29ceefde621cd3d38da63ffb
Author: Minerva_juppiter <ryouturn@gmail.com>
Date:   Sat, 16 Mar 2024 12:08:37 +0900

設定の保存の追加

Diffstat:
MApp.config | 56+++++++++++++++++++++++++++++++++++++++++++++++++++++++-
MBusynessNotification.csproj | 9+++++++++
MMainWindow.xaml | 6+++---
MMainWindow.xaml.cs | 20+++++++++++++++++++-
AProperties/Settings.Designer.cs | 134+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AProperties/Settings.settings | 34++++++++++++++++++++++++++++++++++
DSettings1.Designer.cs | 38--------------------------------------
DSettings1.cs | 28----------------------------
DSettings1.settings | 10----------
9 files changed, 254 insertions(+), 81 deletions(-)

diff --git a/App.config b/App.config @@ -2,14 +2,68 @@ <configuration> <configSections> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > + <section name="BusynessNotification.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="BusynessNotification.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> </sectionGroup> </configSections> <userSettings> + <BusynessNotification.Properties.Settings> + <setting name="CheckCPU" serializeAs="String"> + <value>False</value> + </setting> + <setting name="CheckMemory" serializeAs="String"> + <value>False</value> + </setting> + <setting name="CheckDisk" serializeAs="String"> + <value>False</value> + </setting> + <setting name="SliderCPU" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SliderMemory" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SliderDisk" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SecCPU" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SecMemory" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SecDisk" serializeAs="String"> + <value>0</value> + </setting> + </BusynessNotification.Properties.Settings> <BusynessNotification.Settings1> - <setting name="DarkTheme" serializeAs="String"> + <setting name="CheckCPU" serializeAs="String"> + <value>False</value> + </setting> + <setting name="CheckMemory" serializeAs="String"> <value>False</value> </setting> + <setting name="CheckDisk" serializeAs="String"> + <value>False</value> + </setting> + <setting name="SliderCPU" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SliderMemory" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SliderDisk" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SecCPU" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SecMemory" serializeAs="String"> + <value>0</value> + </setting> + <setting name="SecDisk" serializeAs="String"> + <value>0</value> + </setting> </BusynessNotification.Settings1> </userSettings> </configuration> \ No newline at end of file diff --git a/BusynessNotification.csproj b/BusynessNotification.csproj @@ -13,6 +13,11 @@ </ItemGroup> <ItemGroup> + <Compile Update="Properties\Settings.Designer.cs"> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + </Compile> <Compile Update="Settings1.Designer.cs"> <DesignTimeSharedInput>True</DesignTimeSharedInput> <AutoGen>True</AutoGen> @@ -21,6 +26,10 @@ </ItemGroup> <ItemGroup> + <None Update="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> <None Update="Settings1.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings1.Designer.cs</LastGenOutput> diff --git a/MainWindow.xaml b/MainWindow.xaml @@ -21,9 +21,9 @@ <ColumnDefinition/> </Grid.ColumnDefinitions> <CheckBox x:Name="CPUcheck" Content="CPU" HorizontalAlignment="Center" VerticalAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/> - <CheckBox Content="Memory" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Center"/> - <CheckBox Content="Disk" HorizontalAlignment="Center" Grid.Row="2" VerticalAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/> - <Button x:Name="SaveSettingButton" Content="Save" Margin="83,0,84,0" Grid.Row="3" VerticalAlignment="Center"/> + <CheckBox x:Name="Memorycheck" Content="Memory" HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Center"/> + <CheckBox x:Name="Diskcheck" Content="Disk" HorizontalAlignment="Center" Grid.Row="2" VerticalAlignment="Center" d:LayoutOverrides="LeftPosition, RightPosition"/> + <Button x:Name="SaveSettingButton" Content="Save" Margin="110,0,110,0" Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" d:LayoutOverrides="Width" Click="SaveSettingButton_Click"/> <Slider x:Name="CPUSlider" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Width="150" ValueChanged="CPUSlider_ValueChanged" Maximum="100" Margin="0,0,58,0"/> <TextBox x:Name="TextBox_CPUSlider" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right" TextChanged="TextBox_CPUSlider_TextChanged" VerticalAlignment="Center" Text="0" MaxLines="4" MaxLength="3"/> diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using System.Text; +using System; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -92,7 +93,7 @@ namespace BusynessNotification MessageBoxResult result; result = MessageBox.Show(messageBoxText, caption, button, icon); - CPUSecTextBox. + CPUSecTextBox.Text = CPUSecValue.ToString(); } } } @@ -134,5 +135,22 @@ namespace BusynessNotification } } } + + private void SaveSettingButton_Click(object sender, RoutedEventArgs e) + { + Properties.Settings.Default.CheckCPU = CPUcheck.IsChecked.Value; + Properties.Settings.Default.CheckMemory = Memorycheck.IsChecked.Value; + Properties.Settings.Default.CheckDisk = Diskcheck.IsChecked.Value; + + Properties.Settings.Default.SliderCPU = CPUSlider.Value; + Properties.Settings.Default.SliderMemory = MemorySlider.Value; + Properties.Settings.Default.SliderDisk = DiskSlider.Value; + + Properties.Settings.Default.SecCPU = int.Parse(CPUSecTextBox.Text.ToString()); + Properties.Settings.Default.SecMemory = int.Parse(MemorySecTextBox.Text.ToString()); + Properties.Settings.Default.SecDisk = int.Parse(DiskSecTextBox.Text.ToString()); + + Properties.Settings.Default.Save(); + } } } \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs @@ -0,0 +1,134 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// このコードはツールによって生成されました。 +// ランタイム バージョン:4.0.30319.42000 +// +// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 +// コードが再生成されるときに損失したりします。 +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace BusynessNotification.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.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("False")] + public bool CheckCPU { + get { + return ((bool)(this["CheckCPU"])); + } + set { + this["CheckCPU"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool CheckMemory { + get { + return ((bool)(this["CheckMemory"])); + } + set { + this["CheckMemory"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool CheckDisk { + get { + return ((bool)(this["CheckDisk"])); + } + set { + this["CheckDisk"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public double SliderCPU { + get { + return ((double)(this["SliderCPU"])); + } + set { + this["SliderCPU"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public double SliderMemory { + get { + return ((double)(this["SliderMemory"])); + } + set { + this["SliderMemory"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public double SliderDisk { + get { + return ((double)(this["SliderDisk"])); + } + set { + this["SliderDisk"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int SecCPU { + get { + return ((int)(this["SecCPU"])); + } + set { + this["SecCPU"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int SecMemory { + get { + return ((int)(this["SecMemory"])); + } + set { + this["SecMemory"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int SecDisk { + get { + return ((int)(this["SecDisk"])); + } + set { + this["SecDisk"] = value; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings @@ -0,0 +1,33 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="BusynessNotification.Properties" GeneratedClassName="Settings"> + <Profiles /> + <Settings> + <Setting Name="CheckCPU" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">False</Value> + </Setting> + <Setting Name="CheckMemory" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">False</Value> + </Setting> + <Setting Name="CheckDisk" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">False</Value> + </Setting> + <Setting Name="SliderCPU" Type="System.Double" Scope="User"> + <Value Profile="(Default)">0</Value> + </Setting> + <Setting Name="SliderMemory" Type="System.Double" Scope="User"> + <Value Profile="(Default)">0</Value> + </Setting> + <Setting Name="SliderDisk" Type="System.Double" Scope="User"> + <Value Profile="(Default)">0</Value> + </Setting> + <Setting Name="SecCPU" Type="System.Int32" Scope="User"> + <Value Profile="(Default)">0</Value> + </Setting> + <Setting Name="SecMemory" Type="System.Int32" Scope="User"> + <Value Profile="(Default)">0</Value> + </Setting> + <Setting Name="SecDisk" Type="System.Int32" Scope="User"> + <Value Profile="(Default)">0</Value> + </Setting> + </Settings> +</SettingsFile>+ \ No newline at end of file diff --git a/Settings1.Designer.cs b/Settings1.Designer.cs @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// <auto-generated> -// このコードはツールによって生成されました。 -// ランタイム バージョン:4.0.30319.42000 -// -// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 -// コードが再生成されるときに損失したりします。 -// </auto-generated> -//------------------------------------------------------------------------------ - -namespace BusynessNotification { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] - internal sealed partial class Settings1 : global::System.Configuration.ApplicationSettingsBase { - - private static Settings1 defaultInstance = ((Settings1)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings1()))); - - public static Settings1 Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool DarkTheme { - get { - return ((bool)(this["DarkTheme"])); - } - set { - this["DarkTheme"] = value; - } - } - } -} diff --git a/Settings1.cs b/Settings1.cs @@ -1,28 +0,0 @@ -namespace BusynessNotification { - - - // このクラスでは設定クラスでの特定のイベントを処理することができます: - // SettingChanging イベントは、設定値が変更される前に発生します。 - // PropertyChanged イベントは、設定値が変更された後に発生します。 - // SettingsLoaded イベントは、設定値が読み込まれた後に発生します。 - // SettingsSaving イベントは、設定値が保存される前に発生します。 - internal sealed partial class Settings1 { - - public Settings1() { - // // 設定の保存と変更のイベント ハンドラーを追加するには、以下の行のコメントを解除します: - // - // this.SettingChanging += this.SettingChangingEventHandler; - // - // this.SettingsSaving += this.SettingsSavingEventHandler; - // - } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { - // SettingChangingEvent イベントを処理するコードをここに追加してください。 - } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { - // SettingsSaving イベントを処理するコードをここに追加してください。 - } - } -} diff --git a/Settings1.settings b/Settings1.settings @@ -1,9 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="BusynessNotification" GeneratedClassName="Settings1"> - <Profiles /> - <Settings> - <Setting Name="DarkTheme" Type="System.Boolean" Scope="User"> - <Value Profile="(Default)">False</Value> - </Setting> - </Settings> -</SettingsFile>- \ No newline at end of file