Skip to content

Commit

Permalink
Added options window
Browse files Browse the repository at this point in the history
  • Loading branch information
Axadiw committed Dec 19, 2016
1 parent e1332ba commit 8d2336f
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 30 deletions.
6 changes: 6 additions & 0 deletions MFIGamepadFeeder/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
<setting name="ControllerActive4" serializeAs="String">
<value>False</value>
</setting>
<setting name="StartMinimized" serializeAs="String">
<value>False</value>
</setting>
<setting name="AutoPlugIn" serializeAs="String">
<value>False</value>
</setting>
</MFIGamepadFeeder.Properties.Settings>
</userSettings>
<runtime>
Expand Down
16 changes: 11 additions & 5 deletions MFIGamepadFeeder/MFIGamepadFeeder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>D:\Users\axadiw\Desktop\MFIGamepad\</PublishUrl>
<HockeyAppResourceId>11e577087eab47da8e602d846426c923</HockeyAppResourceId>
<PublishUrl>C:\Repos\MFIGamepadRelease\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
Expand All @@ -25,13 +26,11 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<AutorunEnabled>true</AutorunEnabled>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<HockeyAppResourceId>11e577087eab47da8e602d846426c923</HockeyAppResourceId>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
Expand All @@ -43,7 +42,7 @@
<ManifestKeyFile>MFIGamepadFeeder_1_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
Expand Down Expand Up @@ -225,9 +224,16 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="OptionsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MainWindowViewModel.cs" />
<Compile Include="OptionsWindow.xaml.cs">
<DependentUpon>OptionsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
Expand Down
18 changes: 16 additions & 2 deletions MFIGamepadFeeder/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
mc:Ignorable="d"
Title="MFI Gamepad Feeder" Width="800" Height="350"
ResizeMode="CanResizeWithGrip" Icon="icon.ico" Closing="Window_Closing" WindowStartupLocation="CenterScreen"
StateChanged="Window_StateChanged" MinWidth="500" MinHeight="250">
StateChanged="Window_StateChanged" MinWidth="500" MinHeight="250"
>
<Grid Loaded="Grid_Loaded">
<DockPanel>
<tb:TaskbarIcon x:Name="NotifyIcon"
Expand Down Expand Up @@ -90,7 +91,20 @@
Unchecked="ControllerActiveCheckbox_IsCheckedChanged" />
</Grid>

<Button x:Name="StartButton" Content="Start" Margin="10" Click="StartButton_Click" DockPanel.Dock="Top" />
<Grid DockPanel.Dock="Top" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Button x:Name="StartButton" Content="Start" Click="StartButton_Click" />
<Button x:Name="EditorButton" Content="Mapping editor" Click="EditorButton_Click" Grid.Column="1" Margin="10,0"/>
<Button x:Name="OptionsButton" Content="Options" Click="OptionsButton_Click" Grid.Column="2" />
</Grid>

<TextBox x:Name="LogLabel" Text="" Background="#FFF3F3F3" DockPanel.Dock="Bottom" TextWrapping="Wrap"
ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True"
HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" IsReadOnly="True" />
Expand Down
108 changes: 85 additions & 23 deletions MFIGamepadFeeder/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -61,7 +60,10 @@ private void SetupUi()

private void Grid_Loaded(object sender, RoutedEventArgs e)
{
// WindowState = WindowState.Minimized;
if (Settings.Default.StartMinimized)
{
WindowState = WindowState.Minimized;
}

HidDeviceCombobox1.ItemsSource = ViewModel.HidManager.FoundDevices;
HidDeviceCombobox2.ItemsSource = ViewModel.HidManager.FoundDevices;
Expand Down Expand Up @@ -108,16 +110,33 @@ private void Grid_Loaded(object sender, RoutedEventArgs e)
ControllerActiveCheckbox2.IsChecked = Settings.Default.ControllerActive2;
ControllerActiveCheckbox3.IsChecked = Settings.Default.ControllerActive3;
ControllerActiveCheckbox4.IsChecked = Settings.Default.ControllerActive4;

if (Settings.Default.AutoPlugIn)
{
StartButton_Click(null, null);
}
}

private void DeviceId_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
if (DeviceIdComboBox1.SelectedItem != null && ReferenceEquals(sender, DeviceIdComboBox1)) Settings.Default.SelectedControllerId1 = (uint)DeviceIdComboBox1.SelectedItem;
if (DeviceIdComboBox2.SelectedItem != null && ReferenceEquals(sender, DeviceIdComboBox2)) Settings.Default.SelectedControllerId2 = (uint)DeviceIdComboBox2.SelectedItem;
if (DeviceIdComboBox3.SelectedItem != null && ReferenceEquals(sender, DeviceIdComboBox3)) Settings.Default.SelectedControllerId3 = (uint)DeviceIdComboBox3.SelectedItem;
if (DeviceIdComboBox4.SelectedItem != null && ReferenceEquals(sender, DeviceIdComboBox4)) Settings.Default.SelectedControllerId4 = (uint)DeviceIdComboBox4.SelectedItem;
if ((DeviceIdComboBox1.SelectedItem != null) && ReferenceEquals(sender, DeviceIdComboBox1))
{
Settings.Default.SelectedControllerId1 = (uint) DeviceIdComboBox1.SelectedItem;
}
if ((DeviceIdComboBox2.SelectedItem != null) && ReferenceEquals(sender, DeviceIdComboBox2))
{
Settings.Default.SelectedControllerId2 = (uint) DeviceIdComboBox2.SelectedItem;
}
if ((DeviceIdComboBox3.SelectedItem != null) && ReferenceEquals(sender, DeviceIdComboBox3))
{
Settings.Default.SelectedControllerId3 = (uint) DeviceIdComboBox3.SelectedItem;
}
if ((DeviceIdComboBox4.SelectedItem != null) && ReferenceEquals(sender, DeviceIdComboBox4))
{
Settings.Default.SelectedControllerId4 = (uint) DeviceIdComboBox4.SelectedItem;
}

Settings.Default.Save();
}
Expand All @@ -129,28 +148,64 @@ private void DeviceId_SelectionChanged(object sender, SelectionChangedEventArgs

private void ControllerActiveCheckbox_IsCheckedChanged(object sender, RoutedEventArgs routedEventArgs)
{
if (ControllerActiveCheckbox1.IsChecked != null && ReferenceEquals(sender, ControllerActiveCheckbox1)) Settings.Default.ControllerActive1 = ControllerActiveCheckbox1.IsChecked.Value;
if (ControllerActiveCheckbox2.IsChecked != null && ReferenceEquals(sender, ControllerActiveCheckbox2)) Settings.Default.ControllerActive2 = ControllerActiveCheckbox2.IsChecked.Value;
if (ControllerActiveCheckbox3.IsChecked != null && ReferenceEquals(sender, ControllerActiveCheckbox3)) Settings.Default.ControllerActive3 = ControllerActiveCheckbox3.IsChecked.Value;
if (ControllerActiveCheckbox4.IsChecked != null && ReferenceEquals(sender, ControllerActiveCheckbox4)) Settings.Default.ControllerActive4 = ControllerActiveCheckbox4.IsChecked.Value;
if ((ControllerActiveCheckbox1.IsChecked != null) && ReferenceEquals(sender, ControllerActiveCheckbox1))
{
Settings.Default.ControllerActive1 = ControllerActiveCheckbox1.IsChecked.Value;
}
if ((ControllerActiveCheckbox2.IsChecked != null) && ReferenceEquals(sender, ControllerActiveCheckbox2))
{
Settings.Default.ControllerActive2 = ControllerActiveCheckbox2.IsChecked.Value;
}
if ((ControllerActiveCheckbox3.IsChecked != null) && ReferenceEquals(sender, ControllerActiveCheckbox3))
{
Settings.Default.ControllerActive3 = ControllerActiveCheckbox3.IsChecked.Value;
}
if ((ControllerActiveCheckbox4.IsChecked != null) && ReferenceEquals(sender, ControllerActiveCheckbox4))
{
Settings.Default.ControllerActive4 = ControllerActiveCheckbox4.IsChecked.Value;
}
Settings.Default.Save();
}

private void HidDeviceCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ReferenceEquals(sender, HidDeviceCombobox1)) Settings.Default.SelectedHidDevice1 = JsonConvert.SerializeObject(HidDeviceCombobox1.SelectedItem);
if (ReferenceEquals(sender, HidDeviceCombobox2)) Settings.Default.SelectedHidDevice2 = JsonConvert.SerializeObject(HidDeviceCombobox2.SelectedItem);
if (ReferenceEquals(sender, HidDeviceCombobox3)) Settings.Default.SelectedHidDevice3 = JsonConvert.SerializeObject(HidDeviceCombobox3.SelectedItem);
if (ReferenceEquals(sender, HidDeviceCombobox4)) Settings.Default.SelectedHidDevice4 = JsonConvert.SerializeObject(HidDeviceCombobox4.SelectedItem);
if (ReferenceEquals(sender, HidDeviceCombobox1))
{
Settings.Default.SelectedHidDevice1 = JsonConvert.SerializeObject(HidDeviceCombobox1.SelectedItem);
}
if (ReferenceEquals(sender, HidDeviceCombobox2))
{
Settings.Default.SelectedHidDevice2 = JsonConvert.SerializeObject(HidDeviceCombobox2.SelectedItem);
}
if (ReferenceEquals(sender, HidDeviceCombobox3))
{
Settings.Default.SelectedHidDevice3 = JsonConvert.SerializeObject(HidDeviceCombobox3.SelectedItem);
}
if (ReferenceEquals(sender, HidDeviceCombobox4))
{
Settings.Default.SelectedHidDevice4 = JsonConvert.SerializeObject(HidDeviceCombobox4.SelectedItem);
}
Settings.Default.Save();
}

private void MappingFileCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ReferenceEquals(sender, MappingFileCombobox1)) Settings.Default.SelectedConfigFile1 = MappingFileCombobox1.SelectedItem as string;
if (ReferenceEquals(sender, MappingFileCombobox2)) Settings.Default.SelectedConfigFile2 = MappingFileCombobox2.SelectedItem as string;
if (ReferenceEquals(sender, MappingFileCombobox3)) Settings.Default.SelectedConfigFile3 = MappingFileCombobox3.SelectedItem as string;
if (ReferenceEquals(sender, MappingFileCombobox4)) Settings.Default.SelectedConfigFile4 = MappingFileCombobox4.SelectedItem as string;
if (ReferenceEquals(sender, MappingFileCombobox1))
{
Settings.Default.SelectedConfigFile1 = MappingFileCombobox1.SelectedItem as string;
}
if (ReferenceEquals(sender, MappingFileCombobox2))
{
Settings.Default.SelectedConfigFile2 = MappingFileCombobox2.SelectedItem as string;
}
if (ReferenceEquals(sender, MappingFileCombobox3))
{
Settings.Default.SelectedConfigFile3 = MappingFileCombobox3.SelectedItem as string;
}
if (ReferenceEquals(sender, MappingFileCombobox4))
{
Settings.Default.SelectedConfigFile4 = MappingFileCombobox4.SelectedItem as string;
}

Settings.Default.Save();
}
Expand All @@ -167,13 +222,10 @@ private void Log(string message)
LogLabel.Text += $"{DateTime.Now}: {message}{Environment.NewLine}";
LogLabel.ScrollToEnd();
});
}
}

private void StartButton_Click(object sender, RoutedEventArgs e)
{
StartButton.Content = "Processing...";
StartButton.UpdateLayout();

if (!ViewModel.IsRunning.Value)
{
var activeGamepads = GamepadControls.Keys.Where(box => (box.IsChecked != null) && box.IsChecked.Value).ToList();
Expand Down Expand Up @@ -206,7 +258,7 @@ private void StartButton_Click(object sender, RoutedEventArgs e)
{
ViewModel.Stop();
}
}
}


private void Window_Closing(object sender, CancelEventArgs e)
Expand Down Expand Up @@ -235,5 +287,15 @@ private void Window_StateChanged(object sender, EventArgs e)
}
}

private void OptionsButton_Click(object sender, RoutedEventArgs e)
{
var optionsWindow = new OptionsWindow();
optionsWindow.ShowDialog();
}

private void EditorButton_Click(object sender, RoutedEventArgs e)
{

}
}
}
25 changes: 25 additions & 0 deletions MFIGamepadFeeder/OptionsWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Window x:Class="MFIGamepadFeeder.OptionsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MFIGamepadFeeder"
mc:Ignorable="d"
Title="OptionsWindow" Height="130" Width="300" ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
>
<Grid Loaded="Grid_Loaded">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" >
<CheckBox x:Name="StartMinimizedCheckBox" VerticalAlignment="Center"></CheckBox>
<Label Content="Start minimized" VerticalAlignment="Center" MouseDown="StartMinimized_MouseDown"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<CheckBox x:Name="AutoPlugInCheckBox" VerticalAlignment="Center"></CheckBox>
<Label Content="Automatically plugin all controllers at launch" VerticalAlignment="Center" MouseDown="AutoPlugIn_MouseDown"></Label>
</StackPanel>

<Button x:Name="SaveButton" Content="Save" HorizontalAlignment="Center" Margin="0,10,0,0" Click="SaveButton_Click"></Button>
</StackPanel>
</Grid>
</Window>
52 changes: 52 additions & 0 deletions MFIGamepadFeeder/OptionsWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MFIGamepadFeeder.Properties;

namespace MFIGamepadFeeder
{
/// <summary>
/// Interaction logic for OptionsWindow.xaml
/// </summary>
public partial class OptionsWindow : Window
{
public OptionsWindow()
{
InitializeComponent();
}

private void Grid_Loaded(object sender, RoutedEventArgs e)
{
AutoPlugInCheckBox.IsChecked = Settings.Default.AutoPlugIn;
StartMinimizedCheckBox.IsChecked = Settings.Default.StartMinimized;
}

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
if (AutoPlugInCheckBox.IsChecked != null) Settings.Default.AutoPlugIn = AutoPlugInCheckBox.IsChecked.Value;
if (StartMinimizedCheckBox.IsChecked != null) Settings.Default.StartMinimized = StartMinimizedCheckBox.IsChecked.Value;
Settings.Default.Save();
Close();
}

private void StartMinimized_MouseDown(object sender, MouseButtonEventArgs e)
{
StartMinimizedCheckBox.IsChecked = !StartMinimizedCheckBox.IsChecked;
}

private void AutoPlugIn_MouseDown(object sender, MouseButtonEventArgs e)
{
AutoPlugInCheckBox.IsChecked = !AutoPlugInCheckBox.IsChecked;
}
}
}
24 changes: 24 additions & 0 deletions MFIGamepadFeeder/Properties/Settings.Designer.cs

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

6 changes: 6 additions & 0 deletions MFIGamepadFeeder/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,11 @@
<Setting Name="ControllerActive4" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="StartMinimized" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="AutoPlugIn" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit 8d2336f

Please sign in to comment.