Skip to content

Commit

Permalink
#12 Added Settings and bound CRT filter setting
Browse files Browse the repository at this point in the history
  • Loading branch information
hagronnestad committed Sep 21, 2019
1 parent f75bfcc commit da085da
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 23 deletions.
12 changes: 12 additions & 0 deletions ComputerSystems/Commodore64/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?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="Commodore64.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<userSettings>
<Commodore64.Properties.Settings>
<setting name="ApplyCrtFilter" serializeAs="String">
<value>True</value>
</setting>
</Commodore64.Properties.Settings>
</userSettings>
</configuration>
1 change: 1 addition & 0 deletions ComputerSystems/Commodore64/Commodore64.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
<EmbeddedResource Include="FormC64Screen.resx">
<DependentUpon>FormC64Screen.cs</DependentUpon>
</EmbeddedResource>
Expand Down
23 changes: 11 additions & 12 deletions ComputerSystems/Commodore64/FormC64Screen.Designer.cs

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

3 changes: 3 additions & 0 deletions ComputerSystems/Commodore64/FormC64Screen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.IO;
using System.Linq;
using System.Collections.Generic;
using Commodore64.Properties;

namespace ComputerSystem.Commodore64 {
public partial class FormC64Screen : Form {
Expand Down Expand Up @@ -170,6 +171,8 @@ private void FormC64Screen_FormClosing(object sender, FormClosingEventArgs e) {
_bC64ScreenOutputBuffer.Dispose();

C64.Stop();

Settings.Default.Save();
}

private async void BtnRestart_Click(object sender, EventArgs e) {
Expand Down
22 changes: 17 additions & 5 deletions ComputerSystems/Commodore64/Properties/Settings.Designer.cs

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

14 changes: 8 additions & 6 deletions ComputerSystems/Commodore64/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Commodore64.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ApplyCrtFilter" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
28 changes: 28 additions & 0 deletions ComputerSystems/Commodore64/Settings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Commodore64.Properties {


// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {

public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}

private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}

private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

0 comments on commit da085da

Please sign in to comment.