diff --git a/.hgignore b/.hgignore index 4539299..2e155dd 100644 --- a/.hgignore +++ b/.hgignore @@ -1,2 +1,11 @@ syntax: glob -Build/ \ No newline at end of file +*.orig +*.suo +.git +Build/ +Documentation/Documentation/* +Documentation/Artifacts/* +Documentation/Manual/_build/* +Configuration/Configuration/bin/** +Configuration/Configuration/obj/** + diff --git a/Assets/Environment/Common/Layouts/Default 16x9/Layout.xml b/Assets/Environment/Common/Layouts/Default 16x9/Layout.xml deleted file mode 100644 index 4a1a58c..0000000 --- a/Assets/Environment/Common/Layouts/Default 16x9/Layout.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Assets/Environment/Common/Layouts/Default 4x3/Age.otf b/Assets/Environment/Common/Layouts/Default 4x3/Age.otf deleted file mode 100644 index 5d76781..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/Age.otf and /dev/null differ diff --git a/Assets/Environment/Common/Layouts/Default 4x3/Layout.xml b/Assets/Environment/Common/Layouts/Default 4x3/Layout.xml deleted file mode 100644 index 471c965..0000000 --- a/Assets/Environment/Common/Layouts/Default 4x3/Layout.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Assets/Environment/Common/Layouts/Default 4x3/background.png b/Assets/Environment/Common/Layouts/Default 4x3/background.png deleted file mode 100644 index ce0e1a0..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/background.png and /dev/null differ diff --git a/Assets/Environment/Common/Layouts/Default 4x3/highlight.wav b/Assets/Environment/Common/Layouts/Default 4x3/highlight.wav deleted file mode 100644 index 589d167..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/highlight.wav and /dev/null differ diff --git a/Assets/Environment/Common/Layouts/Default 4x3/load.wav b/Assets/Environment/Common/Layouts/Default 4x3/load.wav deleted file mode 100644 index 077480e..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/load.wav and /dev/null differ diff --git a/Assets/Environment/Common/Layouts/Default 4x3/logo.png b/Assets/Environment/Common/Layouts/Default 4x3/logo.png deleted file mode 100644 index 54bd5ac..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/logo.png and /dev/null differ diff --git a/Assets/Environment/Common/Layouts/Default 4x3/select.wav b/Assets/Environment/Common/Layouts/Default 4x3/select.wav deleted file mode 100644 index 6678b93..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/select.wav and /dev/null differ diff --git a/Assets/Environment/Common/Layouts/Default 4x3/square.png b/Assets/Environment/Common/Layouts/Default 4x3/square.png deleted file mode 100644 index de7cb82..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/square.png and /dev/null differ diff --git a/Assets/Environment/Common/Layouts/Default 4x3/unload.wav b/Assets/Environment/Common/Layouts/Default 4x3/unload.wav deleted file mode 100644 index 65f069a..0000000 Binary files a/Assets/Environment/Common/Layouts/Default 4x3/unload.wav and /dev/null differ diff --git a/Configuration/Configuration.sln b/Configuration/Configuration.sln new file mode 100644 index 0000000..8011aba --- /dev/null +++ b/Configuration/Configuration.sln @@ -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 diff --git a/Configuration/Configuration/App.config b/Configuration/Configuration/App.config new file mode 100644 index 0000000..fad249e --- /dev/null +++ b/Configuration/Configuration/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Configuration/Configuration/App.xaml b/Configuration/Configuration/App.xaml new file mode 100644 index 0000000..a07c142 --- /dev/null +++ b/Configuration/Configuration/App.xaml @@ -0,0 +1,42 @@ + + + + + + + + + diff --git a/Configuration/Configuration/App.xaml.cs b/Configuration/Configuration/App.xaml.cs new file mode 100644 index 0000000..ce657d8 --- /dev/null +++ b/Configuration/Configuration/App.xaml.cs @@ -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 +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + + } +} diff --git a/Configuration/Configuration/Assets/Icons/Add.png b/Configuration/Configuration/Assets/Icons/Add.png new file mode 100644 index 0000000..cf2e43e Binary files /dev/null and b/Configuration/Configuration/Assets/Icons/Add.png differ diff --git a/Configuration/Configuration/Assets/Icons/Delete.png b/Configuration/Configuration/Assets/Icons/Delete.png new file mode 100644 index 0000000..27a3623 Binary files /dev/null and b/Configuration/Configuration/Assets/Icons/Delete.png differ diff --git a/Configuration/Configuration/Builder.cs b/Configuration/Configuration/Builder.cs new file mode 100644 index 0000000..0684668 --- /dev/null +++ b/Configuration/Configuration/Builder.cs @@ -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, ObservableCollectionlayouts, ObservableCollection 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 LoadLaunchers() + { + //todo :make paths relative + ObservableCollection launchers = new ObservableCollection(); + + 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 LoadCollections(ObservableCollection launchers) + { + //todo :make paths relative + ObservableCollection collections = new ObservableCollection(); + + 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 LoadLayouts() + { + //todo :make paths relative + ObservableCollection layouts = new ObservableCollection(); + + 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"); + } + } +} diff --git a/Configuration/Configuration/ConfFileParser.cs b/Configuration/Configuration/ConfFileParser.cs new file mode 100644 index 0000000..2f7e90d --- /dev/null +++ b/Configuration/Configuration/ConfFileParser.cs @@ -0,0 +1,146 @@ +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; + +public class ConfFileParser +{ + private Dictionary keyPairs = new Dictionary(); + private String FilePath; + + /// + /// Opens the INI file at the given path and enumerates the values in the IniParser. + /// + /// Full path to INI file. + 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); + + } + + /// + /// Returns the value for the given section, key pair. + /// + /// Section name. + /// Key name. + public String GetSetting(String settingName) + { + if(keyPairs.ContainsKey(settingName)) + return (String)keyPairs[settingName]; + + return ""; + } + + /// + /// Adds or replaces a setting to the table to be saved. + /// + /// Section to add under. + /// Key name to add. + /// Value of key. + public void AddSetting(String settingName, String settingValue) + { + keyPairs[settingName] = settingValue; + } + + /// + /// Remove a setting. + /// + /// Section to add under. + /// Key name to add. + public void DeleteSetting(String settingName) + { + if (keyPairs.ContainsKey(settingName)) + keyPairs.Remove(settingName); + } + + /// + /// Save settings to new file. + /// + /// New file path. + 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; + } + } + + /// + /// Save settings back to ini file. + /// + public void SaveSettings() + { + SaveSettings(FilePath); + } +} \ No newline at end of file diff --git a/Configuration/Configuration/ConfFileSaver.cs b/Configuration/Configuration/ConfFileSaver.cs new file mode 100644 index 0000000..bf9fbbd --- /dev/null +++ b/Configuration/Configuration/ConfFileSaver.cs @@ -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 option in Options) + { + iniFile.Write(option.Key + " = " + option.Value + Environment.NewLine); + } + + } + catch (Exception ex) + { + throw ex; + } + finally + { + if (iniFile != null) + iniFile.Close(); + } + } + + private Dictionary Options = new Dictionary(); + } +} diff --git a/Configuration/Configuration/Configuration.csproj b/Configuration/Configuration/Configuration.csproj new file mode 100644 index 0000000..537d00a --- /dev/null +++ b/Configuration/Configuration/Configuration.csproj @@ -0,0 +1,182 @@ + + + + + Debug + AnyCPU + {90F163C8-2147-46C9-8BF5-C51116856F62} + WinExe + Properties + Configuration + Configuration + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + ManagedMinimumRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + ManagedMinimumRules.ruleset + true + + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + + AddRemoveList.xaml + + + Collection.xaml + + + ControlInput.xaml + + + Launcher.xaml + + + MainSettings.xaml + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Configuration/Configuration/Converter/CollectionExistsConverter.cs b/Configuration/Configuration/Converter/CollectionExistsConverter.cs new file mode 100644 index 0000000..a24f94f --- /dev/null +++ b/Configuration/Configuration/Converter/CollectionExistsConverter.cs @@ -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(); + } + } +} diff --git a/Configuration/Configuration/Converter/InverseBooleanConverter.cs b/Configuration/Configuration/Converter/InverseBooleanConverter.cs new file mode 100644 index 0000000..67f6c23 --- /dev/null +++ b/Configuration/Configuration/Converter/InverseBooleanConverter.cs @@ -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(); + } + } +} diff --git a/Configuration/Configuration/Converter/InverseBooleanToVisibilityConverter.cs b/Configuration/Configuration/Converter/InverseBooleanToVisibilityConverter.cs new file mode 100644 index 0000000..595cd59 --- /dev/null +++ b/Configuration/Configuration/Converter/InverseBooleanToVisibilityConverter.cs @@ -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(); + } + + } +} diff --git a/Configuration/Configuration/Converter/NullToVisibilityConverter.cs b/Configuration/Configuration/Converter/NullToVisibilityConverter.cs new file mode 100644 index 0000000..d255838 --- /dev/null +++ b/Configuration/Configuration/Converter/NullToVisibilityConverter.cs @@ -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(); + } + + } +} diff --git a/Configuration/Configuration/MainWindow.xaml b/Configuration/Configuration/MainWindow.xaml new file mode 100644 index 0000000..8c04d08 --- /dev/null +++ b/Configuration/Configuration/MainWindow.xaml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Configuration/Configuration/MainWindow.xaml.cs b/Configuration/Configuration/MainWindow.xaml.cs new file mode 100644 index 0000000..4ed668c --- /dev/null +++ b/Configuration/Configuration/MainWindow.xaml.cs @@ -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 +{ + /// + /// Interaction logic for MainWindow.xaml + /// + /// + + 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 layouts = new ObservableCollection(); + 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); + } + } + + } +} diff --git a/Configuration/Configuration/MenuParser.cs b/Configuration/Configuration/MenuParser.cs new file mode 100644 index 0000000..140608e --- /dev/null +++ b/Configuration/Configuration/MenuParser.cs @@ -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 ReadCollections(string filePath) + { + + ObservableCollection list = new ObservableCollection(); + 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; + } + + /// + /// Save settings back to ini file. + /// + public void Save(ObservableCollection 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); + } +} \ No newline at end of file diff --git a/Configuration/Configuration/Properties/AssemblyInfo.cs b/Configuration/Configuration/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c893c5f --- /dev/null +++ b/Configuration/Configuration/Properties/AssemblyInfo.cs @@ -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 +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the 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")] diff --git a/Configuration/Configuration/Properties/Resources.Designer.cs b/Configuration/Configuration/Properties/Resources.Designer.cs new file mode 100644 index 0000000..744b8ff --- /dev/null +++ b/Configuration/Configuration/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace Configuration.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Configuration/Configuration/Properties/Resources.resx b/Configuration/Configuration/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/Configuration/Configuration/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Configuration/Configuration/Properties/Settings.Designer.cs b/Configuration/Configuration/Properties/Settings.Designer.cs new file mode 100644 index 0000000..c17d0c2 --- /dev/null +++ b/Configuration/Configuration/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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; + } + } + } +} diff --git a/Configuration/Configuration/Properties/Settings.settings b/Configuration/Configuration/Properties/Settings.settings new file mode 100644 index 0000000..8f2fd95 --- /dev/null +++ b/Configuration/Configuration/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Configuration/Configuration/RelayCommand.cs b/Configuration/Configuration/RelayCommand.cs new file mode 100644 index 0000000..b85758b --- /dev/null +++ b/Configuration/Configuration/RelayCommand.cs @@ -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 _execute; + readonly Predicate _canExecute; + + #endregion // Fields + + #region Constructors + + /// + /// Creates a new command that can always execute. + /// + /// The execution logic. + public RelayCommand(Action execute) + : this(execute, null) + { + } + + /// + /// Creates a new command. + /// + /// The execution logic. + /// The execution status logic. + public RelayCommand(Action execute, Predicate 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 + } +} diff --git a/Configuration/Configuration/RetroFE.cs b/Configuration/Configuration/RetroFE.cs new file mode 100644 index 0000000..c84b041 --- /dev/null +++ b/Configuration/Configuration/RetroFE.cs @@ -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; + } + } +} diff --git a/Configuration/Configuration/View/AddRemoveList.xaml b/Configuration/Configuration/View/AddRemoveList.xaml new file mode 100644 index 0000000..0dd0f88 --- /dev/null +++ b/Configuration/Configuration/View/AddRemoveList.xaml @@ -0,0 +1,75 @@ + + + /Assets/Icons/Add.png + /Assets/Icons/Delete.png + + + + + + + + + + + + + + + + + + + + + Name + + + + + + + + +