From 8118ac0199992ee37d5cebe2f80aa912de082021 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 10 Jun 2012 23:14:25 +0000 Subject: Finished config and app settings for keyboard joystick. --- wpspec/wpspec/Settings.cs | 89 ++++++++--- wpspec/wpspec/SettingsPage.xaml | 89 ++++++----- wpspec/wpspec/SettingsPage.xaml.cs | 25 +++- wpspec/wpspec/Spectrum/SpectrumKeySymbol.cs | 8 +- wpspec/wpspec/ViewModels/SettingsViewModel.cs | 207 ++++++++++++++++++++++++++ wpspec/wpspec/wpspec.csproj | 1 + 6 files changed, 345 insertions(+), 74 deletions(-) create mode 100644 wpspec/wpspec/ViewModels/SettingsViewModel.cs diff --git a/wpspec/wpspec/Settings.cs b/wpspec/wpspec/Settings.cs index 45d8a90..90be72d 100644 --- a/wpspec/wpspec/Settings.cs +++ b/wpspec/wpspec/Settings.cs @@ -19,7 +19,7 @@ namespace wpspec /// /// Holds global settings /// - public class Settings : BaseViewModel + public class Settings { /// /// Get/set whether sound is enabled. @@ -75,6 +75,60 @@ namespace wpspec set {joystickLock.Setting = value;} } + /// + /// Get/set the joystick up key. + /// + public SpectrumKeySymbol JoystickKeyUp + { + get {return joystickKeyUp.Setting;} + set {joystickKeyUp.Setting = value;} + } + + /// + /// Get/set the joystick down key. + /// + public SpectrumKeySymbol JoystickKeyDown + { + get {return joystickKeyDown.Setting;} + set {joystickKeyDown.Setting = value;} + } + + /// + /// Get/set the joystick left key. + /// + public SpectrumKeySymbol JoystickKeyLeft + { + get {return joystickKeyLeft.Setting;} + set {joystickKeyLeft.Setting = value;} + } + + /// + /// Get/set the joystick right key. + /// + public SpectrumKeySymbol JoystickKeyRight + { + get {return joystickKeyRight.Setting;} + set {joystickKeyRight.Setting = value;} + } + + /// + /// Get/set the joystick fire 1 key. + /// + public SpectrumKeySymbol JoystickKeyFire1 + { + get {return joystickKeyFire1.Setting;} + set {joystickKeyFire1.Setting = value;} + } + + /// + /// Get/set the joystick fire 2 key. + /// + public SpectrumKeySymbol JoystickKeyFire2 + { + get {return joystickKeyFire2.Setting;} + set {joystickKeyFire2.Setting = value;} + } + /// /// Get singleton instance of this class. /// @@ -89,22 +143,22 @@ namespace wpspec private Settings() { - sound = new SettingValue("Sound", true, this); - kempstonJoystick = new SettingValue("KempstonJoystick", true, this); - fullerJoystick = new SettingValue("FullerJoystick", true, this); - keyboardJoystick = new SettingValue("KeyboardJoystick", false, this); - joystickKeyUp = new SettingValue("JoystickKeyUp", SpectrumKeySymbol.Key7, this); - joystickKeyDown = new SettingValue("JoystickKeyDown", SpectrumKeySymbol.Key6, this); - joystickKeyLeft = new SettingValue("JoystickKeyLeft", SpectrumKeySymbol.Key5, this); - joystickKeyRight = new SettingValue("JoystickKeyRight", SpectrumKeySymbol.Key8, this); - joystickKeyFire1 = new SettingValue("JoystickKeyFire1", SpectrumKeySymbol.Key0, this); - joystickKeyFire2 = new SettingValue("JoystickKeyFire2", SpectrumKeySymbol.Key0, this); - joystickLock = new SettingValue("JoystickLock", JoystickLock.EightWay, this); + sound = new SettingValue("Sound", true); + kempstonJoystick = new SettingValue("KempstonJoystick", true); + fullerJoystick = new SettingValue("FullerJoystick", true); + keyboardJoystick = new SettingValue("KeyboardJoystick", false); + joystickKeyUp = new SettingValue("JoystickKeyUp", SpectrumKeySymbol.Key7); + joystickKeyDown = new SettingValue("JoystickKeyDown", SpectrumKeySymbol.Key6); + joystickKeyLeft = new SettingValue("JoystickKeyLeft", SpectrumKeySymbol.Key5); + joystickKeyRight = new SettingValue("JoystickKeyRight", SpectrumKeySymbol.Key8); + joystickKeyFire1 = new SettingValue("JoystickKeyFire1", SpectrumKeySymbol.Key0); + joystickKeyFire2 = new SettingValue("JoystickKeyFire2", SpectrumKeySymbol.Key0); + joystickLock = new SettingValue("JoystickLock", JoystickLock.EightWay); #if DEBUG - tapeUrl = new SettingValue("tapeurl", "http://noddybox.co.uk/spec", this); + tapeUrl = new SettingValue("tapeurl", "http://noddybox.co.uk/spec"); #else - tapeUrl = new SettingValue("tapeurl", "http://enter-a-url.here/possible-path", this); + tapeUrl = new SettingValue("tapeurl", "http://enter-a-url.here/possible-path"); #endif } @@ -112,7 +166,6 @@ namespace wpspec { private string name; private T setting; - private Settings parent; public T Setting { @@ -137,15 +190,13 @@ namespace wpspec } IsolatedStorageSettings.ApplicationSettings.Save(); - parent.NotifyPropertyChanged(name); } } } - public SettingValue(string name, T defaultValue, Settings parent) + public SettingValue(string name, T defaultValue) { this.name = name; - this.parent = parent; try { @@ -155,8 +206,6 @@ namespace wpspec { setting = defaultValue; } - - parent.NotifyPropertyChanged(name); } } diff --git a/wpspec/wpspec/SettingsPage.xaml b/wpspec/wpspec/SettingsPage.xaml index 6c12dda..a3857b1 100644 --- a/wpspec/wpspec/SettingsPage.xaml +++ b/wpspec/wpspec/SettingsPage.xaml @@ -40,20 +40,16 @@ - Eight Way - Four Way - Two Way Horizontal - Two Way Vertical - - + - - @@ -64,49 +60,47 @@ + - Test 1 - Test 2 - Test 3 - Test 4 - + ItemsSource="{Binding KeySymbolValues}" + SelectedIndex="{Binding JoystickKeyUp, Mode=TwoWay, Converter={StaticResource IntToEnum}}" + Grid.Row="0"/> - Test 1 - Test 2 - Test 3 - Test 4 - + ItemsSource="{Binding KeySymbolValues}" + SelectedIndex="{Binding JoystickKeyDown, Mode=TwoWay, Converter={StaticResource IntToEnum}}" + Grid.Row="1"/> - Test 1 - Test 2 - Test 3 - Test 4 - + ItemsSource="{Binding KeySymbolValues}" + SelectedIndex="{Binding JoystickKeyLeft, Mode=TwoWay, Converter={StaticResource IntToEnum}}" + Grid.Row="2"/> - Test 1 - Test 2 - Test 3 - Test 4 - + ItemsSource="{Binding KeySymbolValues}" + SelectedIndex="{Binding JoystickKeyRight, Mode=TwoWay, Converter={StaticResource IntToEnum}}" + Grid.Row="3"/> - Test 1 - Test 2 - Test 3 - Test 4 - + ItemsSource="{Binding KeySymbolValues}" + SelectedIndex="{Binding JoystickKeyFire1, Mode=TwoWay, Converter={StaticResource IntToEnum}}" + Grid.Row="4"/> - Test 1 - Test 2 - Test 3 - Test 4 - + ItemsSource="{Binding KeySymbolValues}" + SelectedIndex="{Binding JoystickKeyFire2, Mode=TwoWay, Converter={StaticResource IntToEnum}}" + Grid.Row="5"/> + + + + + + + + +