Adding configuration GUI and sphinx documentation to repository.

This commit is contained in:
emb
2015-01-03 22:47:53 -06:00
parent 44745f0fd2
commit 9f6ddde34c
69 changed files with 5572 additions and 2 deletions

View File

@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configuration", "Configuration\Configuration.csproj", "{90F163C8-2147-46C9-8BF5-C51116856F62}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{90F163C8-2147-46C9-8BF5-C51116856F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90F163C8-2147-46C9-8BF5-C51116856F62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90F163C8-2147-46C9-8BF5-C51116856F62}.Debug|x86.ActiveCfg = Debug|x86
{90F163C8-2147-46C9-8BF5-C51116856F62}.Debug|x86.Build.0 = Debug|x86
{90F163C8-2147-46C9-8BF5-C51116856F62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90F163C8-2147-46C9-8BF5-C51116856F62}.Release|Any CPU.Build.0 = Release|Any CPU
{90F163C8-2147-46C9-8BF5-C51116856F62}.Release|x86.ActiveCfg = Release|x86
{90F163C8-2147-46C9-8BF5-C51116856F62}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@@ -0,0 +1,42 @@
<Application x:Class="Configuration.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="Button">
<Setter Property="Margin" Value="3,3,3,3"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="Margin" Value="3,3,3,3"/>
</Style>
<Style TargetType="CheckBox">
<Setter Property="Margin" Value="3,3,3,3"/>
</Style>
<Style TargetType="ComboBox">
<Setter Property="Margin" Value="3,3,3,3"/>
</Style>
<Style TargetType="TabItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border Name="Border" BorderThickness="1,1,1,0" BorderBrush="Gainsboro" CornerRadius="4,4,0,0" Margin="2,0">
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="10,2"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="GhostWhite" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Configuration
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -0,0 +1,147 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Configuration.ViewModel;
using System.IO;
namespace Configuration
{
public class Builder
{
public void LoadMain(ref MainVM main, ObservableCollection<string>layouts, ObservableCollection<CollectionVM> collections)
{
//todo :make paths relative
ConfFileParser ini = new ConfFileParser(RetroFE.GetAbsolutePath() + "/Settings.conf");
main.IsFullscreen = ToBool(ini.GetSetting("fullscreen"));
main.IsHorizontalStretch = ToBool(ini.GetSetting("horizontal"));
main.IsVerticalStretch = ToBool(ini.GetSetting("vertical"));
if (!main.IsHorizontalStretch)
{
main.HorizontalResolution = Convert.ToInt32(ini.GetSetting("horizontal"));
}
if (!main.IsVerticalStretch)
{
main.VerticalResolution = Convert.ToInt32(ini.GetSetting("vertical"));
}
main.Layout = layouts.FirstOrDefault(row => row == ini.GetSetting("layout"));
main.IsMouseHidden = ToBool(ini.GetSetting("hideMouse"));
main.IsParenthesisVisible = !ToBool(ini.GetSetting("showParenthesis"));
main.IsBracesVisible = !ToBool(ini.GetSetting("showSquareBrackets"));
string firstCollection = ini.GetSetting("firstCollection");
if(firstCollection == "")
{
firstCollection = "Main";
}
main.FirstCollection = collections.FirstOrDefault(row => row.Name == firstCollection);
main.IsVideoEnabled = ToBool(ini.GetSetting("videoEnable"));
main.VideoLoop = Convert.ToInt32(ini.GetSetting("videoLoop"));
main.IsInfiniteLoop = (main.VideoLoop == 0);
main.IsExitOnFirstBack = ToBool(ini.GetSetting("exitOnFirstPageBack"));
main.AttractModeTime = Convert.ToInt32(ini.GetSetting("attractModeTime"));
main.IsAttractModeEnabled = (main.AttractModeTime != 0);
}
public void LoadController(ref ControllerVM vm)
{
//todo :make paths relative
ConfFileParser ini = new ConfFileParser(RetroFE.GetAbsolutePath() + "/Controls.conf");
vm.ScrollNext = ini.GetSetting("nextItem");
vm.ScrollPrevious = ini.GetSetting("previousItem");
vm.PageUp = ini.GetSetting("pageUp");
vm.PageDown = ini.GetSetting("pageDown");
vm.SelectItem = ini.GetSetting("select");
vm.Back = ini.GetSetting("back");
vm.Quit = ini.GetSetting("quit");
}
public ObservableCollection<LauncherVM> LoadLaunchers()
{
//todo :make paths relative
ObservableCollection<LauncherVM> launchers = new ObservableCollection<LauncherVM>();
string[] files = Directory.GetFiles(RetroFE.GetAbsolutePath() + "/Launchers", "*.conf");
foreach (string file in files)
{
LauncherVM vm = new LauncherVM();
ConfFileParser ini = new ConfFileParser(file);
vm.Name = System.IO.Path.GetFileNameWithoutExtension(file);
vm.ExecutablePath = ini.GetSetting("executable");
vm.Arguments = ini.GetSetting("arguments");
launchers.Add(vm);
}
return launchers;
}
public ObservableCollection<CollectionVM> LoadCollections(ObservableCollection<LauncherVM> launchers)
{
//todo :make paths relative
ObservableCollection<CollectionVM> collections = new ObservableCollection<CollectionVM>();
string[] dirs = Directory.GetDirectories(RetroFE.GetAbsolutePath() + "/Collections");
foreach (string dir in dirs)
{
string settingsFile = Path.Combine(dir, "Settings.conf");
string menuFile = Path.Combine(dir, "Menu.xml");
CollectionVM vm = new CollectionVM();
ConfFileParser ini = new ConfFileParser(settingsFile);
MenuParser mp = new MenuParser();
string launcher = ini.GetSetting("launcher");
vm.Name = System.IO.Path.GetFileNameWithoutExtension(dir);
vm.Launcher = launchers.FirstOrDefault(row => row.Name == launcher);
vm.ListPath = ini.GetSetting("list.path");
vm.Layout = ini.GetSetting("layout");
if (vm.Layout == "")
{
vm.IsDefaultLayout = true;
}
vm.FileExtensions = ini.GetSetting("list.extensions");
vm.MediaPathVideo = ini.GetSetting("media.video");
vm.MediaPathTitle = ini.GetSetting("media.title");
vm.MediaPathLogo = ini.GetSetting("media.logo");
vm.MediaPathTitle = ini.GetSetting("media.title");
vm.MediaPathSnap = ini.GetSetting("media.snap");
vm.MediaPathBox = ini.GetSetting("media.box");
vm.MediaPathCart = ini.GetSetting("media.cart");
//todo: read submenus
vm.Submenus = mp.ReadCollections(menuFile);
collections.Add(vm);
}
return collections;
}
public ObservableCollection<string> LoadLayouts()
{
//todo :make paths relative
ObservableCollection<string> layouts = new ObservableCollection<string>();
string[] dirs = Directory.GetDirectories(RetroFE.GetAbsolutePath() + "/Layouts");
foreach (string dir in dirs)
{
string layout = System.IO.Path.GetFileNameWithoutExtension(dir);
layouts.Add(layout);
}
return layouts;
}
private bool ToBool(string value)
{
value = value.Trim().ToLower();
return (value == "yes" || value == "true" || value == "stretch");
}
}
}

View File

@@ -0,0 +1,146 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
public class ConfFileParser
{
private Dictionary<string, string> keyPairs = new Dictionary<string,string>();
private String FilePath;
/// <summary>
/// Opens the INI file at the given path and enumerates the values in the IniParser.
/// </summary>
/// <param name="iniPath">Full path to INI file.</param>
public ConfFileParser(String filePath)
{
TextReader iniFile = null;
String strLine = null;
FilePath = filePath;
if (File.Exists(filePath))
{
try
{
iniFile = new StreamReader(filePath);
strLine = iniFile.ReadLine();
while (strLine != null)
{
strLine = strLine.Trim();
if (strLine != "")
{
int commentStart = strLine.IndexOf("#");
if(commentStart > 0)
{
strLine = strLine.Substring(0, commentStart-1);
}
string[] propertyPair = strLine.Split(new char[] { '=' }, 2);
if (propertyPair.Length > 1)
{
string key = propertyPair[0].Trim();
string value = propertyPair[1].Trim();
keyPairs.Add(key, value);
}
}
strLine = iniFile.ReadLine();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (iniFile != null)
iniFile.Close();
}
}
else
throw new FileNotFoundException("Unable to locate " + filePath);
}
/// <summary>
/// Returns the value for the given section, key pair.
/// </summary>
/// <param name="sectionName">Section name.</param>
/// <param name="settingName">Key name.</param>
public String GetSetting(String settingName)
{
if(keyPairs.ContainsKey(settingName))
return (String)keyPairs[settingName];
return "";
}
/// <summary>
/// Adds or replaces a setting to the table to be saved.
/// </summary>
/// <param name="sectionName">Section to add under.</param>
/// <param name="settingName">Key name to add.</param>
/// <param name="settingValue">Value of key.</param>
public void AddSetting(String settingName, String settingValue)
{
keyPairs[settingName] = settingValue;
}
/// <summary>
/// Remove a setting.
/// </summary>
/// <param name="sectionName">Section to add under.</param>
/// <param name="settingName">Key name to add.</param>
public void DeleteSetting(String settingName)
{
if (keyPairs.ContainsKey(settingName))
keyPairs.Remove(settingName);
}
/// <summary>
/// Save settings to new file.
/// </summary>
/// <param name="newFilePath">New file path.</param>
public void SaveSettings(String newFilePath)
{
String tmpValue = "";
String strToSave = "";
foreach (string property in keyPairs.Keys)
{
tmpValue = (String)keyPairs[property];
if (tmpValue != null)
tmpValue = "=" + tmpValue;
strToSave += (property + tmpValue + "\r\n");
}
strToSave += "\r\n";
try
{
TextWriter tw = new StreamWriter(newFilePath);
tw.Write(strToSave);
tw.Close();
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// Save settings back to ini file.
/// </summary>
public void SaveSettings()
{
SaveSettings(FilePath);
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Configuration
{
class ConfFileSaver
{
public void AddOption(string key, string value)
{
Options.Add(key, value);
}
public void AddOption(string key, bool value)
{
string strValue = (value) ? "yes" : "no";
Options.Add(key, strValue);
}
public void AddOption(string key, int value)
{
string strValue = Convert.ToString(value);
Options.Add(key, strValue);
}
public void Save(string filePath)
{
TextWriter iniFile = null;
try
{
iniFile = new StreamWriter(filePath);
foreach (KeyValuePair<string, string> option in Options)
{
iniFile.Write(option.Key + " = " + option.Value + Environment.NewLine);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (iniFile != null)
iniFile.Close();
}
}
private Dictionary<string, string> Options = new Dictionary<string,string>();
}
}

View File

@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{90F163C8-2147-46C9-8BF5-C51116856F62}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Configuration</RootNamespace>
<AssemblyName>Configuration</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Builder.cs" />
<Compile Include="ConfFileParser.cs" />
<Compile Include="ConfFileSaver.cs" />
<Compile Include="Converter\CollectionExistsConverter.cs" />
<Compile Include="Converter\InverseBooleanConverter.cs" />
<Compile Include="Converter\InverseBooleanToVisibilityConverter.cs" />
<Compile Include="Converter\NullToVisibilityConverter.cs" />
<Compile Include="MenuParser.cs" />
<Compile Include="RetroFE.cs" />
<Compile Include="ViewModel\CollectionListVM.cs" />
<Compile Include="ViewModel\CollectionVM.cs" />
<Compile Include="ViewModel\ControllerVM.cs" />
<Compile Include="ViewModel\LauncherVM.cs" />
<Compile Include="RelayCommand.cs" />
<Compile Include="ViewModel\LauncherListVM.cs" />
<Compile Include="ViewModel\MainVM.cs" />
<Compile Include="View\AddRemoveList.xaml.cs">
<DependentUpon>AddRemoveList.xaml</DependentUpon>
</Compile>
<Compile Include="View\Collection.xaml.cs">
<DependentUpon>Collection.xaml</DependentUpon>
</Compile>
<Compile Include="View\ControlInput.xaml.cs">
<DependentUpon>ControlInput.xaml</DependentUpon>
</Compile>
<Compile Include="View\Launcher.xaml.cs">
<DependentUpon>Launcher.xaml</DependentUpon>
</Compile>
<Compile Include="View\MainSettings.xaml.cs">
<DependentUpon>MainSettings.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="View\AddRemoveList.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\Collection.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="View\ControlInput.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\Launcher.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\MainSettings.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="Assets\Icons\Add.png" />
<Resource Include="Assets\Icons\Delete.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,23 @@
using System;
using System.Windows.Data;
namespace Configuration.Converter
{
public class CollectionExistsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
// if (targetType != typeof(bool))
// throw new InvalidOperationException("The target is not a bool");
return true;
// return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Windows.Data;
namespace Configuration.Converter
{
[ValueConversion(typeof(bool), typeof(bool))]
public class InverseBooleanConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target is not a bool");
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Windows;
using System.Windows.Data;
namespace Configuration.Converter
{
public class InverseBooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (targetType != typeof(Visibility))
throw new InvalidOperationException("The target is not a visibility type");
return (!(bool)value) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Windows;
using System.Windows.Data;
namespace Configuration.Converter
{
public class NullToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if (targetType != typeof(Visibility))
throw new InvalidOperationException("The target is not of type bool");
return ((object)value != null) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}

View File

@@ -0,0 +1,74 @@
<Window x:Class="Configuration.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:v="clr-namespace:Configuration.View"
xmlns:vm="clr-namespace:Configuration.ViewModel"
xmlns:c="clr-namespace:Configuration.Converter"
Title="RetroFE Configuration" Height="550" Width="600"
Closing="Window_Closing"
>
<Window.Resources>
<vm:LauncherListVM x:Key="LauncherConfig"/>
<vm:CollectionListVM x:Key="CollectionConfig"/>
<vm:MainVM x:Key="MainConfig"/>
<vm:ControllerVM x:Key="ControllerConfig"/>
<c:NullToVisibilityConverter x:Key="NullVisibilityConverter"/>
</Window.Resources>
<TabControl Name="ConfigurationTabControl" SelectionChanged="TabControl_SelectionChanged" FocusableChanged="TabControl_FocusableChanged">
<TabItem Header="General">
<v:MainSettings
Data="{Binding Mode=TwoWay, Source={StaticResource MainConfig}, Path=.}"
Launchers="{Binding LauncherCollection, Source={StaticResource LauncherConfig}}"
Collections="{Binding CollectionList, Source={StaticResource CollectionConfig}}"
/>
</TabItem>
<TabItem Header="Controller">
<v:ControlInput Data="{Binding Mode=TwoWay, Source={StaticResource ControllerConfig}, Path=.}" />
</TabItem>
<TabItem Header="Launchers">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<v:AddRemoveList Grid.Column="0"
SelectedItem="{Binding SelectedLauncher, Mode=TwoWay, Source={StaticResource LauncherConfig}}"
ListDisplayMemberPath="Name"
ListItemsSource="{Binding LauncherCollection, Source={StaticResource LauncherConfig}}"
AddListItemCommand="{Binding AddListItemCommand, Source={StaticResource LauncherConfig}}"
RemoveListItemCommand="{Binding RemoveListItemCommand, Source={StaticResource LauncherConfig}}"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Visibility="{Binding SelectedLauncher, Mode=TwoWay, Source={StaticResource LauncherConfig}, Converter={StaticResource NullVisibilityConverter}}">
<v:Launcher Data="{Binding SelectedLauncher, Mode=TwoWay, Source={StaticResource LauncherConfig}}"/>
</StackPanel>
</Grid>
</TabItem>
<TabItem Header="Collections">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<v:AddRemoveList Grid.Column="0"
SelectedItem="{Binding SelectedCollection, Mode=TwoWay, Source={StaticResource CollectionConfig}}"
ListDisplayMemberPath="Name"
ListItemsSource="{Binding CollectionList, Source={StaticResource CollectionConfig}}"
AddListItemCommand="{Binding AddListItemCommand, Source={StaticResource CollectionConfig}}"
RemoveListItemCommand="{Binding RemoveListItemCommand, Source={StaticResource CollectionConfig}}"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Visibility="{Binding SelectedCollection, Mode=TwoWay, Source={StaticResource CollectionConfig}, Converter={StaticResource NullVisibilityConverter}}">
<v:Collection
Data="{Binding SelectedCollection, Mode=TwoWay, Source={StaticResource CollectionConfig}}"
Layouts="{Binding Mode=TwoWay, Source={StaticResource MainConfig}, Path=Layouts}"
Collections="{Binding CollectionList, Source={StaticResource CollectionConfig}}"
LauncherCollection="{Binding LauncherCollection, Source={StaticResource LauncherConfig}, Mode=TwoWay}" />
</StackPanel>
</Grid>
</TabItem>
</TabControl>
</Window>

View File

@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
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.Navigation;
using System.Windows.Shapes;
using Configuration.ViewModel;
namespace Configuration
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
private TabItem LastSelectedTabItem;
public MainWindow()
{
InitializeComponent();
if (!File.Exists(RetroFE.GetAbsolutePath() + "/Core/RetroFE.exe"))
{
MessageBox.Show("Could not find RetroFE executable. Exiting.");
Close();
}
else
{
MessageBox.Show("This tool has not had a lot of testing. " + Environment.NewLine + Environment.NewLine + "Back up your files and use at your own risk before using this tool.");
ObservableCollection<string> layouts = new ObservableCollection<string>();
LauncherListVM launcher = this.TryFindResource("LauncherConfig") as LauncherListVM;
CollectionListVM collection = this.TryFindResource("CollectionConfig") as CollectionListVM;
ControllerVM controller = this.TryFindResource("ControllerConfig") as ControllerVM;
MainVM main = this.TryFindResource("MainConfig") as MainVM;
Builder b = new Builder();
launcher.LauncherCollection = b.LoadLaunchers();
collection.CollectionList = b.LoadCollections(launcher.LauncherCollection);
main.Layouts = b.LoadLayouts();
b.LoadMain(ref main, main.Layouts, collection.CollectionList);
b.LoadController(ref controller);
}
}
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TabControl control = sender as TabControl;
if (LastSelectedTabItem != null)
{
LastSelectedTabItem.Focus();
Save((string)LastSelectedTabItem.Header);
}
if (control != null && control.SelectedValue != null)
{
LastSelectedTabItem = control.SelectedItem as TabItem;
}
}
private void TabControl_FocusableChanged(object sender, DependencyPropertyChangedEventArgs e)
{
TabControl control = sender as TabControl;
if(control.SelectedItem != null)
{
TabItem item = control.SelectedItem as TabItem;
item.Focus();
Save((string)item.Header);
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (ConfigurationTabControl.SelectedItem != null)
{
TabItem item = ConfigurationTabControl.SelectedItem as TabItem;
item.Focus();
Save((string)item.Header);
}
}
private void Save(string tabItem)
{
if (tabItem == "General")
{
MainVM main = this.TryFindResource("MainConfig") as MainVM;
main.Save();
}
else if (tabItem == "Controller")
{
ControllerVM vm = this.TryFindResource("ControllerConfig") as ControllerVM;
vm.Save();
}
else if (tabItem == "Launchers")
{
LauncherListVM vm = this.TryFindResource("LauncherConfig") as LauncherListVM;
vm.Save(vm.SelectedLauncher);
}
else if (tabItem == "Collections")
{
CollectionListVM vm = this.TryFindResource("CollectionConfig") as CollectionListVM;
vm.Save(vm.SelectedCollection);
}
}
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Xml;
public class MenuParser
{
public ObservableCollection<string> ReadCollections(string filePath)
{
ObservableCollection<string> list = new ObservableCollection<string>();
if (File.Exists(filePath))
{
try
{
XmlReader reader = XmlReader.Create(filePath);
XmlDocument doc = new XmlDocument();
reader.Read();
doc.Load(reader);
XmlNodeList items = doc.GetElementsByTagName("item");
foreach (XmlNode item in items)
{
XmlAttribute name = item.Attributes["collection"];
if(name != null)
{
list.Add(name.Value);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
return list;
}
/// <summary>
/// Save settings back to ini file.
/// </summary>
public void Save(ObservableCollection<string> list, string filePath)
{
try
{
XmlDocument doc = new XmlDocument();
XmlElement menu = doc.CreateElement("menu");
doc.AppendChild(menu);
foreach (string item in list)
{
XmlElement node = doc.CreateElement("item");
XmlAttribute attrib = doc.CreateAttribute("collection");
attrib.Value = item;
menu.AppendChild(node);
node.AppendChild(attrib);
}
doc.Save(filePath);
}
catch (Exception ex)
{
throw ex;
}
// SaveSettings(_FilePath);
}
}

View File

@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Configuration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Deere & Company")]
[assembly: AssemblyProduct("Configuration")]
[assembly: AssemblyCopyright("Copyright © Deere & Company 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Configuration.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Configuration.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Configuration.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.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;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Configuration
{
public class RelayCommand : ICommand
{
#region Fields
readonly Action<object> _execute;
readonly Predicate<object> _canExecute;
#endregion // Fields
#region Constructors
/// <summary>
/// Creates a new command that can always execute.
/// </summary>
/// <param name="execute">The execution logic.</param>
public RelayCommand(Action<object> execute)
: this(execute, null)
{
}
/// <summary>
/// Creates a new command.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <param name="canExecute">The execution status logic.</param>
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
#endregion // Constructors
#region ICommand Members
public bool CanExecute(object parameters)
{
return _canExecute == null ? true : _canExecute(parameters);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameters)
{
_execute(parameters);
}
#endregion // ICommand Members
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Configuration
{
class RetroFE
{
public static string GetAbsolutePath()
{
string path = Environment.GetEnvironmentVariable("RETROFE_PATH");
if (path == null)
{
path = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).Directory.FullName;
}
return path;
}
}
}

View File

@@ -0,0 +1,75 @@
<UserControl x:Class="Configuration.View.AddRemoveList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ImageSource x:Key="AddIcon">/Assets/Icons/Add.png</ImageSource>
<ImageSource x:Key="DeleteIcon">/Assets/Icons/Delete.png</ImageSource>
<Style x:Key="AddButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Padding" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource AddIcon}" Height="15"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DeleteButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Padding" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource DeleteIcon}" Height="15"/>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0"
SelectionMode="Single"
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=ListItemsSource, Mode=TwoWay}"
DisplayMemberPath="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=ListDisplayMemberPath}"
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=SelectedItem,Mode=TwoWay}"
Name="List" />
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Popup Name="AddPopup" IsOpen="{Binding IsChecked, ElementName=AddButton, Mode=TwoWay}">
<Border Background="White" BorderThickness="1" BorderBrush="Black">
<StackPanel Orientation="Horizontal">
<TextBlock>Name</TextBlock>
<TextBox Width="100" Name="AddName"/>
<Button Content="Add"
Click="HideAddPopup"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=AddListItemCommand}"
CommandParameter="{Binding Text, ElementName=AddName}">
</Button>
</StackPanel>
</Border>
</Popup>
<ToggleButton Name="AddButton" Style="{StaticResource AddButtonStyle}"/>
<Button Style="{StaticResource DeleteButtonStyle}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=RemoveListItemCommand}" />
</StackPanel>
</Grid>
</UserControl>

View File

@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Navigation;
using System.Windows.Shapes;
using Configuration.ViewModel;
namespace Configuration.View
{
/// <summary>
/// Interaction logic for AddRemoveList.xaml
/// </summary>
public partial class AddRemoveList : UserControl
{
public ICommand AddListItemCommand
{
get { return (ICommand)GetValue(AddListItemCommandProperty); }
set { SetValue(ListItemsSourceProperty, value); }
}
public static DependencyProperty AddListItemCommandProperty = DependencyProperty.Register("AddListItemCommand", typeof(ICommand), typeof(AddRemoveList));
public ICommand RemoveListItemCommand
{
get { return (ICommand)GetValue(RemoveListItemCommandProperty); }
set { SetValue(ListItemsSourceProperty, value); }
}
public static DependencyProperty RemoveListItemCommandProperty = DependencyProperty.Register("RemoveListItemCommand", typeof(ICommand), typeof(AddRemoveList));
public System.Collections.IEnumerable ListItemsSource
{
get { return (ObservableCollection<System.Collections.IEnumerable>)GetValue(ListItemsSourceProperty); }
set { SetValue(ListItemsSourceProperty, value); }
}
public static DependencyProperty ListItemsSourceProperty = DependencyProperty.Register("ListItemsSource", typeof(System.Collections.IEnumerable), typeof(AddRemoveList));
public object SelectedItem
{
get { return (object)GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
}
public static DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(object), typeof(AddRemoveList));
public String ListDisplayMemberPath
{
get { return (String)GetValue(ListDisplayMemberPathProperty); }
set { SetValue(ListDisplayMemberPathProperty, value); }
}
public static DependencyProperty ListDisplayMemberPathProperty = DependencyProperty.Register("ListDisplayMemberPath", typeof(String), typeof(AddRemoveList));
public AddRemoveList()
{
InitializeComponent();
}
private void HideAddPopup(object sender, RoutedEventArgs e)
{
AddPopup.IsOpen = false;
// AddName.Text = "";
}
}
}

View File

@@ -0,0 +1,161 @@
<UserControl x:Class="Configuration.View.Collection"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:c="clr-namespace:Configuration.Converter"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<c:InverseBooleanConverter x:Key="InverseBoolConverter"/>
<BooleanToVisibilityConverter x:Key="BoolVisibilityConverter"/>
<c:InverseBooleanToVisibilityConverter x:Key="InverseBoolVisibilityConverter"/>
<c:CollectionExistsConverter x:Key="CollectionExistsConvert"/>
<ImageSource x:Key="AddIcon">/Assets/Icons/Add.png</ImageSource>
<ImageSource x:Key="DeleteIcon">/Assets/Icons/Delete.png</ImageSource>
<Style x:Key="AddButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Padding" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource AddIcon}" Height="15"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DeleteButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Padding" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource DeleteIcon}" Height="15"/>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<StackPanel Orientation="Vertical">
<GroupBox Header="Execution">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Item (ROM) Folder" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.ListPath}"/>
<Button Grid.Row="0" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFolderCommand}" CommandParameter="Item" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="File Extensions" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.FileExtensions}"/>
<TextBlock Grid.Row="1" Grid.Column="2" Text="(comma separated)" VerticalAlignment="Center"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Launcher" VerticalAlignment="Center"/>
<ComboBox Grid.Row="2" Grid.Column="1"
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=LauncherCollection}"
DisplayMemberPath="Name"
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Launcher}"
/>
</Grid>
</GroupBox>
<GroupBox Header="Graphics">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Layout" VerticalAlignment="Center"/>
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
<ComboBox
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Layouts}"
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Layout}"
IsEnabled="{Binding ElementName=DefaultLayout, Path=IsChecked, Converter={StaticResource InverseBoolConverter}}"
Visibility="{Binding ElementName=DefaultLayout, Path=IsChecked, Converter={StaticResource InverseBoolVisibilityConverter}}"/>
<CheckBox Content="Use default layout"
VerticalAlignment="Center"
Name="DefaultLayout"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsDefaultLayout}"/>
</StackPanel>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Video" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.MediaPathVideo}"/>
<Button Grid.Row="1" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFolderCommand}" CommandParameter="Video" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="Title" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.MediaPathTitle}"/>
<Button Grid.Row="2" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFolderCommand}" CommandParameter="Title" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="Logo" VerticalAlignment="Center"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.MediaPathLogo}"/>
<Button Grid.Row="3" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFolderCommand}" CommandParameter="Logo" />
<TextBlock Grid.Row="4" Grid.Column="0" Text="Box" VerticalAlignment="Center"/>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.MediaPathBox}"/>
<Button Grid.Row="4" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFolderCommand}" CommandParameter="Box" />
<TextBlock Grid.Row="5" Grid.Column="0" Text="Cart" VerticalAlignment="Center"/>
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.MediaPathCart}"/>
<Button Grid.Row="5" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFolderCommand}" CommandParameter="Cart" />
<TextBlock Grid.Row="6" Grid.Column="0" Text="Snap" VerticalAlignment="Center"/>
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.MediaPathSnap}"/>
<Button Grid.Row="6" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFolderCommand}" CommandParameter="Snap" />
</Grid>
</GroupBox>
<GroupBox Header="Submenus">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource AddButtonStyle}" HorizontalAlignment="Left"/>
<Button Style="{StaticResource DeleteButtonStyle}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.RemoveSubmenuCommand}" />
</StackPanel>
<DataGrid DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ItemsSource="{Binding Data.Submenus}"
AutoGenerateColumns="False" CanUserAddRows="True" Margin="0,0,0,90" IsEnabled="True" ScrollViewer.CanContentScroll="True">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Collection">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Collections}"
SelectedValuePath="Name"
SelectedValue="{Binding .}"
DisplayMemberPath="Name"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Flatten">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</GroupBox>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Navigation;
using System.Windows.Shapes;
using Configuration.ViewModel;
namespace Configuration.View
{
/// <summary>
/// Interaction logic for Collection.xaml
/// </summary>
public partial class Collection : UserControl
{
public CollectionVM Data
{
get { return (CollectionVM)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
public static DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(CollectionVM), typeof(Collection));
public System.Collections.IEnumerable LauncherCollection
{
get { return (System.Collections.IEnumerable)GetValue(LauncherCollectionProperty); }
set { SetValue(LauncherCollectionProperty, value); }
}
public static DependencyProperty LauncherCollectionProperty = DependencyProperty.Register("LauncherCollection", typeof(System.Collections.IEnumerable), typeof(Collection));
public System.Collections.IEnumerable Layouts
{
get { return (System.Collections.IEnumerable)GetValue(LayoutsProperty); }
set { SetValue(LayoutsProperty, value); }
}
public static DependencyProperty LayoutsProperty = DependencyProperty.Register("Layouts", typeof(System.Collections.IEnumerable), typeof(Collection));
public System.Collections.IEnumerable Collections
{
get { return (System.Collections.IEnumerable)GetValue(CollectionsProperty); }
set { SetValue(CollectionsProperty, value); }
}
public static DependencyProperty CollectionsProperty = DependencyProperty.Register("Collections", typeof(System.Collections.IEnumerable), typeof(Collection));
public Collection()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,39 @@
<UserControl x:Class="Configuration.View.ControlInput"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBox Width="100" PreviewKeyDown="TextBlock_PreviewKeyDown" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.ScrollPrevious}"/>
<TextBlock Text="Scroll Previous" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Width="100" PreviewKeyDown="TextBlock_PreviewKeyDown" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.ScrollNext}"/>
<TextBlock Text="Scroll Next" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Width="100" PreviewKeyDown="TextBlock_PreviewKeyDown" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.PageUp}"/>
<TextBlock Text="Page Up" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Width="100" PreviewKeyDown="TextBlock_PreviewKeyDown" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.PageDown}"/>
<TextBlock Text="Page Down" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Width="100" PreviewKeyDown="TextBlock_PreviewKeyDown" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.SelectItem}"/>
<TextBlock Text="Select Item" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Width="100" PreviewKeyDown="TextBlock_PreviewKeyDown" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Back}"/>
<TextBlock Text="Back" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Width="100" PreviewKeyDown="TextBlock_PreviewKeyDown" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Quit}" />
<TextBlock Text="Quit" />
</StackPanel>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,177 @@
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.Navigation;
using System.Windows.Shapes;
using Configuration.ViewModel;
namespace Configuration.View
{
/// <summary>
/// Interaction logic for ControlInput.xaml
/// </summary>
public partial class ControlInput : UserControl
{
Dictionary<int, string> SDLAsciiDescMap = new Dictionary<int, string>();
public ControlInput()
{
InitializeComponent();
SDLAsciiDescMap[0x8] = "Backspace";
SDLAsciiDescMap[0x9] = "Tab";
SDLAsciiDescMap[0x0C] = "Clear";
SDLAsciiDescMap[0x0D] = "Return";
SDLAsciiDescMap[0x13] = "Pause";
SDLAsciiDescMap[0x14] = "CapsLock";
SDLAsciiDescMap[0x1B] = "Escape";
SDLAsciiDescMap[0x20] = "Space";
SDLAsciiDescMap[0x21] = "PageUp";
SDLAsciiDescMap[0x22] = "PageDown";
SDLAsciiDescMap[0x23] = "End";
SDLAsciiDescMap[0x24] = "Home";
SDLAsciiDescMap[0x25] = "Left";
SDLAsciiDescMap[0x26] = "Up";
SDLAsciiDescMap[0x27] = "Right";
SDLAsciiDescMap[0x28] = "Down";
SDLAsciiDescMap[0x29] = "Select";
SDLAsciiDescMap[0x2B] = "Execute";
SDLAsciiDescMap[0x2C] = "PrintScreen";
SDLAsciiDescMap[0x2D] = "Insert";
SDLAsciiDescMap[0x2E] = "Delete";
SDLAsciiDescMap[0x2F] = "Help";
SDLAsciiDescMap[0x30] = "0";
SDLAsciiDescMap[0x31] = "1";
SDLAsciiDescMap[0x32] = "2";
SDLAsciiDescMap[0x33] = "3";
SDLAsciiDescMap[0x34] = "4";
SDLAsciiDescMap[0x35] = "5";
SDLAsciiDescMap[0x36] = "6";
SDLAsciiDescMap[0x37] = "7";
SDLAsciiDescMap[0x38] = "8";
SDLAsciiDescMap[0x39] = "9";
SDLAsciiDescMap[0x41] = "A";
SDLAsciiDescMap[0x42] = "B";
SDLAsciiDescMap[0x43] = "C";
SDLAsciiDescMap[0x44] = "D";
SDLAsciiDescMap[0x45] = "E";
SDLAsciiDescMap[0x46] = "F";
SDLAsciiDescMap[0x47] = "G";
SDLAsciiDescMap[0x48] = "H";
SDLAsciiDescMap[0x49] = "I";
SDLAsciiDescMap[0x4A] = "J";
SDLAsciiDescMap[0x4B] = "K";
SDLAsciiDescMap[0x4C] = "L";
SDLAsciiDescMap[0x4D] = "M";
SDLAsciiDescMap[0x4E] = "N";
SDLAsciiDescMap[0x4F] = "O";
SDLAsciiDescMap[0x50] = "P";
SDLAsciiDescMap[0x51] = "Q";
SDLAsciiDescMap[0x52] = "R";
SDLAsciiDescMap[0x53] = "S";
SDLAsciiDescMap[0x54] = "T";
SDLAsciiDescMap[0x55] = "U";
SDLAsciiDescMap[0x56] = "V";
SDLAsciiDescMap[0x57] = "W";
SDLAsciiDescMap[0x58] = "X";
SDLAsciiDescMap[0x59] = "Y";
SDLAsciiDescMap[0x5A] = "Z";
SDLAsciiDescMap[0x5B] = "Left GUI";
SDLAsciiDescMap[0x5C] = "Right GUI";
SDLAsciiDescMap[0x5D] = "Application";
SDLAsciiDescMap[0x5F] = "Sleep";
SDLAsciiDescMap[0x60] = "Keypad 0";
SDLAsciiDescMap[0x61] = "Keypad 1";
SDLAsciiDescMap[0x62] = "Keypad 2";
SDLAsciiDescMap[0x63] = "Keypad 3";
SDLAsciiDescMap[0x64] = "Keypad 4";
SDLAsciiDescMap[0x65] = "Keypad 5";
SDLAsciiDescMap[0x66] = "Keypad 6";
SDLAsciiDescMap[0x67] = "Keypad 7";
SDLAsciiDescMap[0x68] = "Keypad 8";
SDLAsciiDescMap[0x69] = "Keypad 9";
SDLAsciiDescMap[0x6A] = "*";
SDLAsciiDescMap[0x6B] = "+";
SDLAsciiDescMap[0x6C] = "Separator";
SDLAsciiDescMap[0x6D] = "-";
SDLAsciiDescMap[0x6E] = ".";
SDLAsciiDescMap[0x6F] = "/";
SDLAsciiDescMap[0x70] = "F1";
SDLAsciiDescMap[0x71] = "F2";
SDLAsciiDescMap[0x72] = "F3";
SDLAsciiDescMap[0x73] = "F4";
SDLAsciiDescMap[0x74] = "F5";
SDLAsciiDescMap[0x75] = "F6";
SDLAsciiDescMap[0x76] = "F7";
SDLAsciiDescMap[0x77] = "F8";
SDLAsciiDescMap[0x78] = "F9";
SDLAsciiDescMap[0x79] = "F10";
SDLAsciiDescMap[0x7A] = "F11";
SDLAsciiDescMap[0x7B] = "F12";
SDLAsciiDescMap[0x7C] = "F13";
SDLAsciiDescMap[0x7D] = "F14";
SDLAsciiDescMap[0x7E] = "F15";
SDLAsciiDescMap[0x7F] = "F16";
SDLAsciiDescMap[0x80] = "F17";
SDLAsciiDescMap[0x81] = "F18";
SDLAsciiDescMap[0x82] = "F19";
SDLAsciiDescMap[0x83] = "F20";
SDLAsciiDescMap[0x84] = "F21";
SDLAsciiDescMap[0x85] = "F22";
SDLAsciiDescMap[0x86] = "F23";
SDLAsciiDescMap[0x87] = "F24";
SDLAsciiDescMap[0x90] = "Numlock";
SDLAsciiDescMap[0x91] = "ScrollLock";
SDLAsciiDescMap[0xA0] = "Left Shift";
SDLAsciiDescMap[0xA1] = "Right Shift";
SDLAsciiDescMap[0xA2] = "Left Ctrl";
SDLAsciiDescMap[0xA3] = "Right Ctrl";
SDLAsciiDescMap[0xA4] = "Left Menu";
SDLAsciiDescMap[0xA5] = "Right Menu";
SDLAsciiDescMap[0xC0] = "`";
}
public ControllerVM Data
{
get { return (ControllerVM)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
public static DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(ControllerVM), typeof(ControlInput));
private void TextBlock_PreviewKeyDown(object sender, KeyEventArgs e)
{
TextBox tb = sender as TextBox;
System.Windows.Forms.KeysConverter kc = new System.Windows.Forms.KeysConverter();
int key = System.Windows.Input.KeyInterop.VirtualKeyFromKey(e.Key);
int systemKey = System.Windows.Input.KeyInterop.VirtualKeyFromKey(e.SystemKey);
if (SDLAsciiDescMap.ContainsKey(key))
{
tb.Text = SDLAsciiDescMap[key];
}
else
if (SDLAsciiDescMap.ContainsKey(systemKey))
{
tb.Text = SDLAsciiDescMap[systemKey];
}
else
{
tb.Text = key + " " + e.SystemKey + " (none)";
}
//todo, implement a map
e.Handled = true;
}
}
}

View File

@@ -0,0 +1,24 @@
<UserControl x:Class="Configuration.View.Launcher"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Executable Path" VerticalAlignment="Center"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.ExecutablePath}"/>
<Button Grid.Row="0" Grid.Column="2" Content="Browse" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.BrowseFileCommand}" CommandParameter="Item" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="Arguments" VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Arguments}"/>
</Grid>
</UserControl>

View File

@@ -0,0 +1,39 @@
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.Navigation;
using System.Windows.Shapes;
using Configuration.ViewModel;
namespace Configuration.View
{
/// <summary>
/// Interaction logic for Launcher.xaml
/// </summary>
public partial class Launcher : UserControl
{
public Launcher()
{
InitializeComponent();
}
public LauncherVM Data
{
get { return (LauncherVM)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
public static DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(LauncherVM), typeof(Launcher));
}
}

View File

@@ -0,0 +1,109 @@
<UserControl x:Class="Configuration.View.MainSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:c="clr-namespace:Configuration.Converter"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<c:InverseBooleanConverter x:Key="InverseBoolConverter"/>
<BooleanToVisibilityConverter x:Key="BoolVisibilityConverter"/>
<c:InverseBooleanToVisibilityConverter x:Key="InverseBoolVisibilityConverter"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<GroupBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Header="Display">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="Horizontal resolution" />
<TextBox Grid.Row="0" Grid.Column="1" Width="50"
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.HorizontalResolution}"
IsEnabled="{Binding ElementName=HorizontalStretch, Path=IsChecked, Converter={StaticResource InverseBoolConverter}}"
/>
<CheckBox Grid.Row="0" Grid.Column="2" Name="HorizontalStretch" Content="Stretch (use OS defaults)" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsHorizontalStretch}"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="Vertical resolution" />
<TextBox Grid.Row="2" Grid.Column="1" Width="50"
Text ="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.VerticalResolution}"
IsEnabled="{Binding ElementName=VerticalStretch, Path=IsChecked, Converter={StaticResource InverseBoolConverter}}"
/>
<CheckBox Grid.Row="2" Grid.Column="2" Name="VerticalStretch" Content="Stretch (use OS defaults)" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsVerticalStretch}"/>
<CheckBox Grid.Row="4" Grid.Column="0" Content="Fullscreen" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsFullscreen}"/>
</Grid>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="0" Header="Navigation and Layout">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<ComboBox ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Layouts}" SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Layout}"/>
<TextBlock Text="Default layout" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<ComboBox DisplayMemberPath="Name" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Collections}" SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.FirstCollection}"/>
<TextBlock Text="First collection to show on startup" />
</StackPanel>
<CheckBox Content="Exit if 'back' key is pressed on first menu" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsExitOnFirstBack}"/>
</StackPanel>
</GroupBox>
<GroupBox Grid.Row="1" Grid.Column="1" Header="Video">
<StackPanel Orientation="Vertical">
<CheckBox Content="Enable video playback" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsVideoEnabled}"/>
<StackPanel Orientation="Horizontal">
<TextBox Width="40" IsEnabled="{Binding ElementName=VideoLoopInfinite, Path=IsChecked, Converter={StaticResource InverseBoolConverter}}" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.VideoLoop}"/>
<TextBlock Text="# Times to play" />
</StackPanel>
<CheckBox Name="VideoLoopInfinite" Content="Loop Infinite" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsInfiniteLoop}" />
</StackPanel>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="0" Header="Attract Mode">
<StackPanel Orientation="Vertical">
<CheckBox Name="EnableAttractMode" Content="Enable attract mode" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsAttractModeEnabled}"/>
<StackPanel Orientation="Horizontal">
<TextBox Width="40"
Text ="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.AttractModeTime}"
IsEnabled="{Binding ElementName=EnableAttractMode, Path=IsChecked}"
/>
<TextBlock Text="Idle time" />
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox Grid.Row="2" Grid.Column="1" Header="Hiding">
<StackPanel Orientation="Vertical">
<CheckBox Content="Hide mouse" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsMouseHidden}"/>
<CheckBox Content="Hide parenthesis '()' in titles" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsParenthesisVisible}"/>
<CheckBox Content="Hide braces '[]' in titles" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsBracesVisible}"/>
</StackPanel>
</GroupBox>
</Grid>
</UserControl>

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Navigation;
using System.Windows.Shapes;
using Configuration.ViewModel;
namespace Configuration.View
{
/// <summary>
/// Interaction logic for MainSettings.xaml
/// </summary>
public partial class MainSettings : UserControl
{
public MainVM Data
{
get { return (MainVM)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
public static DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(MainVM), typeof(MainSettings));
public System.Collections.IEnumerable Launchers
{
get { return (System.Collections.IEnumerable)GetValue(LaunchersProperty); }
set { SetValue(LaunchersProperty, value); }
}
public static DependencyProperty LaunchersProperty = DependencyProperty.Register("Launchers", typeof(System.Collections.IEnumerable), typeof(MainSettings));
public System.Collections.IEnumerable Collections
{
get { return (System.Collections.IEnumerable)GetValue(CollectionsProperty); }
set { SetValue(CollectionsProperty, value); }
}
public static DependencyProperty CollectionsProperty = DependencyProperty.Register("Collections", typeof(System.Collections.IEnumerable), typeof(MainSettings));
public MainSettings()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,160 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Configuration;
namespace Configuration.ViewModel
{
class CollectionListVM : INotifyPropertyChanged
{
ObservableCollection<CollectionVM> _CollectionList = new ObservableCollection<CollectionVM>();
public ObservableCollection<CollectionVM> CollectionList
{
get { return _CollectionList; }
set { _CollectionList = value; NotifyPropertyChanged("CollectionList"); }
}
CollectionVM _SelectedCollection = null;
public CollectionVM SelectedCollection
{
get { return _SelectedCollection; }
set {
if (_SelectedCollection != null)
{
Save(_SelectedCollection);
}
_SelectedCollection = value;
NotifyPropertyChanged("SelectedCollection");
}
}
ICommand _AddListItemCommand;
public ICommand AddListItemCommand
{
get
{
if (_AddListItemCommand == null)
{
_AddListItemCommand = new RelayCommand(param => this.AddCollection(param), param => this.CanAdd());
}
return _AddListItemCommand;
}
}
ICommand _RemoveListItemCommand;
public ICommand RemoveListItemCommand
{
get
{
if (_RemoveListItemCommand == null)
{
_RemoveListItemCommand = new RelayCommand(param => this.RemoveCollection(), param => this.CanDelete());
}
return _RemoveListItemCommand;
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private bool CanAdd()
{
return true;
}
private bool CanDelete()
{
return (SelectedCollection != null);
}
private void AddCollection(object param)
{
CollectionVM cvm = new CollectionVM();
cvm.Name = param as String;
NotifyPropertyChanged("CollectionList");
ConfFileSaver settings = new ConfFileSaver();
ConfFileSaver include = new ConfFileSaver();
ConfFileSaver exclude = new ConfFileSaver();
MenuParser menu = new MenuParser();
//todo change path
string path = RetroFE.GetAbsolutePath() + "/Collections/" + cvm.Name;
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
if (!File.Exists(path + "/Settings.conf"))
{
CollectionList.Add(cvm);
settings.Save(path + "/Settings.conf");
if (!File.Exists(path + "/Include.txt"))
{
include.Save(path + "/Include.txt");
}
if (!File.Exists(path + "/Exclude.txt"))
{
exclude.Save(path + "/Exclude.txt");
}
//menu.Save(path + "/Menu.xml");
}
}
public void Save(CollectionVM cvm)
{
if (cvm == null) return;
ConfFileSaver s = new ConfFileSaver();
if (!cvm.IsDefaultLayout)
{
s.AddOption("layout", cvm.Layout);
}
s.AddOption("launcher", (cvm.Launcher == null) ? "" : cvm.Launcher.Name);
s.AddOption("list.path", cvm.ListPath);
s.AddOption("list.extensions", cvm.FileExtensions);
s.AddOption("media.box", cvm.MediaPathBox);
s.AddOption("media.cart", cvm.MediaPathCart);
s.AddOption("media.logo", cvm.MediaPathLogo);
s.AddOption("media.snap", cvm.MediaPathSnap);
s.AddOption("media.title", cvm.MediaPathTitle);
s.AddOption("media.video", cvm.MediaPathVideo);
//todo: change serverPath
string path = RetroFE.GetAbsolutePath() + "/Collections/" + cvm.Name + "/Settings.conf";
s.Save(path);
}
private bool RemoveCollection()
{
//todo: change location
string path = RetroFE.GetAbsolutePath() + "/Launchers/" + SelectedCollection.Name + ".conf";
if (File.Exists(path))
{
File.Delete(path);
}
CollectionList.Remove(SelectedCollection);
return true;
}
}
}

View File

@@ -0,0 +1,188 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Forms;
using Configuration;
namespace Configuration.ViewModel
{
public class CollectionVM : INotifyPropertyChanged
{
String _Name;
public String Name
{
get { return _Name; }
set { _Name = value; NotifyPropertyChanged("Name"); }
}
String _ListPath;
public String ListPath
{
get { return _ListPath; }
set { _ListPath = value; NotifyPropertyChanged("ListPath"); }
}
String _FileExtensions = null;
public String FileExtensions
{
get { return _FileExtensions; }
set { _FileExtensions = value; NotifyPropertyChanged("FileExtensions"); }
}
LauncherVM _Launcher = null;
public LauncherVM Launcher
{
get { return _Launcher; }
set { _Launcher = value; NotifyPropertyChanged("Launcher"); }
}
String _Layout = null;
public String Layout
{
get { return _Layout; }
set { _Layout = value; NotifyPropertyChanged("Layout"); }
}
bool _IsDefaultLayout;
public bool IsDefaultLayout
{
get { return _IsDefaultLayout; }
set { _IsDefaultLayout = value; NotifyPropertyChanged("IsDefaultLayout"); }
}
String _MediaPathVideo;
public String MediaPathVideo
{
get { return _MediaPathVideo; }
set { _MediaPathVideo = value; NotifyPropertyChanged("MediaPathVideo"); }
}
String _MediaPathTitle;
public String MediaPathTitle
{
get { return _MediaPathTitle; }
set { _MediaPathTitle = value; NotifyPropertyChanged("MediaPathTitle"); }
}
String _MediaPathLogo;
public String MediaPathLogo
{
get { return _MediaPathLogo; }
set { _MediaPathLogo = value; NotifyPropertyChanged("MediaPathLogo"); }
}
String _MediaPathBox;
public String MediaPathBox
{
get { return _MediaPathBox; }
set { _MediaPathBox = value; NotifyPropertyChanged("MediaPathBox"); }
}
String _MediaPathCart;
public String MediaPathCart
{
get { return _MediaPathCart; }
set { _MediaPathCart = value; NotifyPropertyChanged("MediaPathCart"); }
}
String _MediaPathSnap;
public String MediaPathSnap
{
get { return _MediaPathSnap; }
set { _MediaPathSnap = value; NotifyPropertyChanged("MediaPathSnap"); }
}
ObservableCollection<string> _Submenus;
public ObservableCollection<string> Submenus
{
get { return _Submenus; }
set { _Submenus = value; NotifyPropertyChanged("Submenus"); }
}
ICommand _DeleteSubmenuCommand;
public ICommand DeleteSubmenuCommand
{
get
{
if (_DeleteSubmenuCommand == null)
{
_DeleteSubmenuCommand = new RelayCommand(param => this.DeleteSubmenu((string)param), param => true);
}
return _DeleteSubmenuCommand;
}
}
ICommand _BrowseFolderCommand;
public ICommand BrowseFolderCommand
{
get
{
if (_BrowseFolderCommand == null)
{
_BrowseFolderCommand = new RelayCommand(param => this.BrowseFolder((string)param), param => true);
}
return _BrowseFolderCommand;
}
}
public void DeleteSubmenu(string reserved)
{
}
public void BrowseFolder(string type)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
if(dialog.ShowDialog() == DialogResult.OK)
{
string selectedPath = dialog.SelectedPath;
if (type == "Video")
{
MediaPathVideo = selectedPath;
}
else if (type == "Title")
{
MediaPathTitle = selectedPath;
}
else if (type == "Snap")
{
MediaPathSnap = selectedPath;
}
else if (type == "Logo")
{
MediaPathLogo = selectedPath;
}
else if (type == "Cart")
{
MediaPathCart = selectedPath;
}
else if (type == "Box")
{
MediaPathBox = selectedPath;
}
else if (type == "Item")
{
ListPath = selectedPath;
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Forms;
using Configuration;
namespace Configuration.ViewModel
{
public class ControllerVM : INotifyPropertyChanged
{
String _ScrollPrevious;
public String ScrollPrevious
{
get { return _ScrollPrevious; }
set { _ScrollPrevious = value; NotifyPropertyChanged("ScrollPrevious"); }
}
String _ScrollNext;
public String ScrollNext
{
get { return _ScrollNext; }
set { _ScrollNext = value; NotifyPropertyChanged("ScrollNext"); }
}
String _PageUp;
public String PageUp
{
get { return _PageUp; }
set { _PageUp = value; NotifyPropertyChanged("PageUp"); }
}
String _PageDown;
public String PageDown
{
get { return _PageDown; }
set { _PageDown = value; NotifyPropertyChanged("PageDown"); }
}
String _SelectItem;
public String SelectItem
{
get { return _SelectItem; }
set { _SelectItem = value; NotifyPropertyChanged("SelectItem"); }
}
String _Back;
public String Back
{
get { return _Back; }
set { _Back = value; NotifyPropertyChanged("Back"); }
}
String _Quit;
public String Quit
{
get { return _Quit; }
set { _Quit = value; NotifyPropertyChanged("Quit"); }
}
public void Save()
{
ConfFileSaver s = new ConfFileSaver();
s.AddOption("previousItem", ScrollPrevious);
s.AddOption("nextItem", ScrollNext);
s.AddOption("pageUp", PageUp);
s.AddOption("pageDown", PageDown);
s.AddOption("select", SelectItem);
s.AddOption("back", Back);
s.AddOption("quit", Quit);
//todo: change location
string path = RetroFE.GetAbsolutePath() + "/Controls.conf";
s.Save(path);
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View File

@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.IO;
using Configuration;
namespace Configuration.ViewModel
{
class LauncherListVM : INotifyPropertyChanged
{
ObservableCollection<LauncherVM> _LauncherCollection = new ObservableCollection<LauncherVM>();
public ObservableCollection<LauncherVM> LauncherCollection
{
get { return _LauncherCollection; }
set { _LauncherCollection = value; NotifyPropertyChanged("LauncherCollection"); }
}
LauncherVM _SelectedLauncher = null;
public LauncherVM SelectedLauncher
{
get { return _SelectedLauncher; }
set
{
if (_SelectedLauncher != null)
{
Save(_SelectedLauncher);
}
_SelectedLauncher = value;
NotifyPropertyChanged("SelectedLauncher");
}
}
ICommand _AddListItemCommand;
public ICommand AddListItemCommand
{
get
{
if (_AddListItemCommand == null)
{
_AddListItemCommand = new RelayCommand(param => this.AddLauncher(param), param => this.CanAdd());
}
return _AddListItemCommand;
}
}
ICommand _RemoveListItemCommand;
public ICommand RemoveListItemCommand
{
get
{
if (_RemoveListItemCommand == null)
{
_RemoveListItemCommand = new RelayCommand(param => this.RemoveLauncher(), param => this.CanDelete());
}
return _RemoveListItemCommand;
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private bool CanAdd()
{
return true;
}
private bool CanDelete()
{
return (SelectedLauncher != null);
}
private void AddLauncher(object param)
{
LauncherVM l = new LauncherVM();
l.Name = param as String;
NotifyPropertyChanged("LauncherCollection");
ConfFileSaver saver = new ConfFileSaver();
//todo change path
if (!File.Exists(RetroFE.GetAbsolutePath() + "/Launchers/" + l.Name + ".conf"))
{
LauncherCollection.Add(l);
saver.Save(RetroFE.GetAbsolutePath() + "/Launchers/" + l.Name + ".conf");
}
}
public void Save(LauncherVM launcher)
{
if (launcher == null) return;
ConfFileSaver s = new ConfFileSaver();
s.AddOption("executable", launcher.ExecutablePath);
s.AddOption("arguments", launcher.Arguments);
//todo: change location
string path = RetroFE.GetAbsolutePath() + "/Launchers/" + SelectedLauncher.Name + ".conf";
s.Save(path);
}
private bool RemoveLauncher()
{
//todo: change location
string path = RetroFE.GetAbsolutePath() + "/Launchers/" + SelectedLauncher.Name + ".conf";
if (File.Exists(path))
{
File.Delete(path);
}
LauncherCollection.Remove(SelectedLauncher);
return true;
}
}
}

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Forms;
using Configuration;
namespace Configuration.ViewModel
{
public class LauncherVM : INotifyPropertyChanged
{
String _Name;
public String Name
{
get { return _Name; }
set { _Name = value; NotifyPropertyChanged("Name"); }
}
String _ExecutablePath;
public String ExecutablePath
{
get { return _ExecutablePath; }
set { _ExecutablePath = value; NotifyPropertyChanged("ExecutablePath"); }
}
String _Arguments;
public String Arguments
{
get { return _Arguments; }
set { _Arguments = value; NotifyPropertyChanged("Arguments"); }
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
ICommand _BrowseFileCommand;
public ICommand BrowseFileCommand
{
get
{
if (_BrowseFileCommand == null)
{
_BrowseFileCommand = new RelayCommand(param => this.BrowseFile(), param => true);
}
return _BrowseFileCommand;
}
}
public void BrowseFile()
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = false;
if (dialog.ShowDialog() == DialogResult.OK)
{
ExecutablePath = dialog.FileName;
}
}
}
}

View File

@@ -0,0 +1,186 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Configuration;
namespace Configuration.ViewModel
{
public class MainVM : INotifyPropertyChanged
{
bool _IsFullscreen;
public bool IsFullscreen
{
get { return _IsFullscreen; }
set { _IsFullscreen = value; NotifyPropertyChanged("IsFullscreen"); }
}
int _HorizontalResolution;
public int HorizontalResolution
{
get { return _HorizontalResolution; }
set { _HorizontalResolution = value; NotifyPropertyChanged("HorizontalResolution"); }
}
bool _IsHorizontalStretch;
public bool IsHorizontalStretch
{
get { return _IsHorizontalStretch; }
set { _IsHorizontalStretch = value; NotifyPropertyChanged("IsHorizontalStretch"); }
}
bool _IsVerticalStretch;
public bool IsVerticalStretch
{
get { return _IsVerticalStretch; }
set { _IsVerticalStretch = value; NotifyPropertyChanged("IsVerticalStretch"); }
}
int _VerticalResolution;
public int VerticalResolution
{
get { return _VerticalResolution; }
set { _VerticalResolution = value; NotifyPropertyChanged("VerticalResolution"); }
}
String _Layout;
public String Layout
{
get { return _Layout; }
set { _Layout = value; NotifyPropertyChanged("Layout"); }
}
ObservableCollection<string> _Layouts;
public ObservableCollection<string> Layouts
{
get { return _Layouts; }
set { _Layouts = value; NotifyPropertyChanged("Layouts"); }
}
bool _IsMouseHidden;
public bool IsMouseHidden
{
get { return _IsMouseHidden; }
set { _IsMouseHidden = value; NotifyPropertyChanged("IsMouseHidden"); }
}
bool _IsParenthesisVisible;
public bool IsParenthesisVisible
{
get { return _IsParenthesisVisible; }
set { _IsParenthesisVisible = value; NotifyPropertyChanged("IsParenthesisVisible"); }
}
bool _IsBracesVisible;
public bool IsBracesVisible
{
get { return _IsBracesVisible; }
set { _IsBracesVisible = value; NotifyPropertyChanged("IsBracesVisible"); }
}
CollectionVM _FirstCollection;
public CollectionVM FirstCollection
{
get { return _FirstCollection; }
set { _FirstCollection = value; NotifyPropertyChanged("FirstCollection"); }
}
bool _IsVideoEnabled;
public bool IsVideoEnabled
{
get { return _IsVideoEnabled; }
set { _IsVideoEnabled = value; NotifyPropertyChanged("IsVideoEnabled"); }
}
int _VideoLoop;
public int VideoLoop
{
get { return _VideoLoop; }
set { _VideoLoop = value; NotifyPropertyChanged("VideoLoop"); }
}
bool _IsInfiniteLoop;
public bool IsInfiniteLoop
{
get { return _IsInfiniteLoop; }
set { _IsInfiniteLoop = value; NotifyPropertyChanged("IsInfiniteLoop"); }
}
bool _IsExitOnFirstBack;
public bool IsExitOnFirstBack
{
get { return _IsExitOnFirstBack; }
set { _IsExitOnFirstBack = value; NotifyPropertyChanged("IsExitOnFirstBack"); }
}
int _AttractModeTime;
public int AttractModeTime
{
get { return _AttractModeTime; }
set { _AttractModeTime = value; NotifyPropertyChanged("AttractModeTime"); }
}
bool _IsAttractModeEnabled;
public bool IsAttractModeEnabled
{
get { return _IsAttractModeEnabled; }
set { _IsAttractModeEnabled = value; NotifyPropertyChanged("IsAttractModeEnabled"); }
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public void Save()
{
ConfFileSaver s = new ConfFileSaver();
if(IsVerticalStretch)
{
s.AddOption("vertical", "stretch");
}
else
{
s.AddOption("vertical", VerticalResolution);
}
if(IsHorizontalStretch)
{
s.AddOption("horizontal", "stretch");
}
else
{
s.AddOption("horizontal", HorizontalResolution);
}
s.AddOption("fullscreen", IsFullscreen);
s.AddOption("layout", (Layout == null) ? "Default" : Layout);
s.AddOption("hideMouse", IsMouseHidden);
s.AddOption("showParenthesis", IsParenthesisVisible);
s.AddOption("showSquareBrackets", IsBracesVisible);
s.AddOption("firstCollection", (FirstCollection == null) ? "Main" : FirstCollection.Name);
s.AddOption("videoEnable", IsVideoEnabled);
s.AddOption("videoLoop", VideoLoop);
s.AddOption("exitOnFirstPageBack", IsExitOnFirstBack);
s.AddOption("attractModeTime", (IsAttractModeEnabled) ? AttractModeTime : 0);
//todo: change location
string path = RetroFE.GetAbsolutePath() + "/Settings.conf";
s.Save(path);
}
}
}