From 1ba3b3f85015c438cb81f2a3307ba0f27d1e5a88 Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 24 Jun 2015 21:24:38 +0100 Subject: [PATCH] Added Default Path of Exile directory to saved settings --- .../Properties/AssemblyInfo.cs | 35 +++++++++++ Filtration/App.config | 12 ++++ Filtration/App.xaml.cs | 2 + Filtration/Filtration.csproj | 3 + Filtration/Properties/Settings.Designer.cs | 36 ++++++----- Filtration/Properties/Settings.settings | 12 ++-- Filtration/Resources/Icons/collapse_icon.png | Bin 0 -> 224 bytes Filtration/Resources/Icons/expand_icon.png | Bin 0 -> 196 bytes .../Services/ItemFilterPersistenceService.cs | 12 +++- Filtration/Settings.cs | 28 +++++++++ .../AvalonDockWorkspaceViewModel.cs | 2 + .../ItemFilterBlockGroupViewModel.cs | 11 ++++ .../ViewModels/ItemFilterScriptViewModel.cs | 8 ++- .../ToolPanes/BlockOutputPreviewViewModel.cs | 59 +++++++++++++++++- Filtration/Views/IconsDictionary.xaml | 2 + .../ToolPanes/BlockGroupBrowserView.xaml | 14 ++++- .../ToolPanes/BlockOutputPreviewView.xaml | 4 +- Releases/0.1/Filtration.exe.config | 6 ++ 18 files changed, 218 insertions(+), 28 deletions(-) create mode 100644 Filtration.ObjectModel.Tests/Properties/AssemblyInfo.cs create mode 100644 Filtration/Resources/Icons/collapse_icon.png create mode 100644 Filtration/Resources/Icons/expand_icon.png create mode 100644 Filtration/Settings.cs create mode 100644 Releases/0.1/Filtration.exe.config diff --git a/Filtration.ObjectModel.Tests/Properties/AssemblyInfo.cs b/Filtration.ObjectModel.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d98fb3d --- /dev/null +++ b/Filtration.ObjectModel.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// 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("Filtration.ObjectModel.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Filtration.ObjectModel.Tests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[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)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("7ed27cde-6bc5-4d11-b45d-8823de2077ce")] + +// 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/Filtration/App.config b/Filtration/App.config index 9c05822..3a0477b 100644 --- a/Filtration/App.config +++ b/Filtration/App.config @@ -1,6 +1,18 @@  + + +
+ + + + + + + + + \ No newline at end of file diff --git a/Filtration/App.xaml.cs b/Filtration/App.xaml.cs index 0f66f22..8bdcdb2 100644 --- a/Filtration/App.xaml.cs +++ b/Filtration/App.xaml.cs @@ -3,6 +3,7 @@ using System.Windows; using Castle.MicroKernel.ModelBuilder.Inspectors; using Castle.Windsor; using Castle.Windsor.Installer; +using Filtration.Properties; using Filtration.Views; namespace Filtration @@ -31,6 +32,7 @@ namespace Filtration protected override void OnExit(ExitEventArgs e) { _container.Dispose(); + Settings.Default.Save(); base.OnExit(e); } } diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index 0d1e226..7869f32 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -121,6 +121,7 @@ + @@ -346,6 +347,8 @@ + + Always diff --git a/Filtration/Properties/Settings.Designer.cs b/Filtration/Properties/Settings.Designer.cs index 60cbe77..eb7c523 100644 --- a/Filtration/Properties/Settings.Designer.cs +++ b/Filtration/Properties/Settings.Designer.cs @@ -1,30 +1,38 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace Filtration.Properties -{ - - +namespace Filtration.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 - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.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 - { + + public static Settings Default { + get { return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string DefaultFilterDirectory { + get { + return ((string)(this["DefaultFilterDirectory"])); + } + set { + this["DefaultFilterDirectory"] = value; + } + } } } diff --git a/Filtration/Properties/Settings.settings b/Filtration/Properties/Settings.settings index 033d7a5..f44e762 100644 --- a/Filtration/Properties/Settings.settings +++ b/Filtration/Properties/Settings.settings @@ -1,7 +1,9 @@  - - - - - + + + + + + + \ No newline at end of file diff --git a/Filtration/Resources/Icons/collapse_icon.png b/Filtration/Resources/Icons/collapse_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a1a16de004f1beb4de06d1124f3ee98fabed1148 GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5M?jcysy3fAP*5S+ zBgmJ5p-Pp3p`n?9;pcxK{gQ#9)PRBERRRNp)eHs(@%%~gN8NyG(>z@qLn>}1{rUgj zo>{e_wXw1B;qUM7Q)V7IdGh25rpG^i{Ftz$^7J%a4)FsAc5Qv#c}Ye@h9lkBFo1*Y z9)nm3W8;*o6{a;aguRl*7u+`Z!8~zSV#Az69jrb7|NmdEVQd&QYc3-*!&xSoAMJYb RH-I)Wc)I$ztaD0e0st~JzO&hrI7tml7CP>6E8Xn73i0tQc4KbLh*2~7Y|ZAnT1 literal 0 HcmV?d00001 diff --git a/Filtration/Services/ItemFilterPersistenceService.cs b/Filtration/Services/ItemFilterPersistenceService.cs index ae5314b..748d2b7 100644 --- a/Filtration/Services/ItemFilterPersistenceService.cs +++ b/Filtration/Services/ItemFilterPersistenceService.cs @@ -1,5 +1,6 @@ using System.IO; using Filtration.ObjectModel; +using Filtration.Properties; using Filtration.Translators; namespace Filtration.Services @@ -23,7 +24,15 @@ namespace Filtration.Services _fileSystemService = fileSystemService; _itemFilterScriptTranslator = itemFilterScriptTranslator; - ItemFilterScriptDirectory = DefaultPathOfExileDirectory(); + if (string.IsNullOrEmpty(Settings.Default.DefaultFilterDirectory)) + { + ItemFilterScriptDirectory = DefaultPathOfExileDirectory(); + Settings.Default.DefaultFilterDirectory = ItemFilterScriptDirectory; + } + else + { + ItemFilterScriptDirectory = Settings.Default.DefaultFilterDirectory; + } } public string ItemFilterScriptDirectory { get; private set; } @@ -45,6 +54,7 @@ namespace Filtration.Services } ItemFilterScriptDirectory = path; + Settings.Default.DefaultFilterDirectory = path; } public ItemFilterScript LoadItemFilterScript(string filePath) diff --git a/Filtration/Settings.cs b/Filtration/Settings.cs new file mode 100644 index 0000000..eb1469e --- /dev/null +++ b/Filtration/Settings.cs @@ -0,0 +1,28 @@ +namespace Filtration.Properties { + + + // This class allows you to handle specific events on the settings class: + // The SettingChanging event is raised before a setting's value is changed. + // The PropertyChanged event is raised after a setting's value is changed. + // The SettingsLoaded event is raised after the setting values are loaded. + // The SettingsSaving event is raised before the setting values are saved. + internal sealed partial class Settings { + + public Settings() { + // // To add event handlers for saving and changing settings, uncomment the lines below: + // + // this.SettingChanging += this.SettingChangingEventHandler; + // + // this.SettingsSaving += this.SettingsSavingEventHandler; + // + } + + private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { + // Add code to handle the SettingChangingEvent event here. + } + + private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { + // Add code to handle the SettingsSaving event here. + } + } +} diff --git a/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs b/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs index 7a4d21b..415bf78 100644 --- a/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs +++ b/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs @@ -40,6 +40,7 @@ namespace Filtration.ViewModels _sectionBrowserViewModel.Initialise(this); _blockGroupBrowserViewModel.Initialise(this); + _blockOutputPreviewViewModel.Initialise(this); _openDocuments = new ObservableCollection {startPageViewModel}; ActiveDocument = startPageViewModel; @@ -135,6 +136,7 @@ namespace Filtration.ViewModels { _sectionBrowserViewModel.ClearDown(); _blockGroupBrowserViewModel.ClearDown(); + _blockOutputPreviewViewModel.ClearDown(); } OpenDocuments.Remove(document); diff --git a/Filtration/ViewModels/ItemFilterBlockGroupViewModel.cs b/Filtration/ViewModels/ItemFilterBlockGroupViewModel.cs index f38cdc9..c9487ef 100644 --- a/Filtration/ViewModels/ItemFilterBlockGroupViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockGroupViewModel.cs @@ -9,6 +9,7 @@ namespace Filtration.ViewModels private bool? _isChecked; private bool _reentrancyCheck; private bool _postMapComplete; + private bool _isExpanded; public ItemFilterBlockGroupViewModel() { @@ -54,6 +55,16 @@ namespace Filtration.ViewModels } } + public bool IsExpanded + { + get { return _isExpanded; } + set + { + _isExpanded = value; + RaisePropertyChanged(); + } + } + private void UpdateCheckState() { // update all children: diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index 4f80d71..655bfd7 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -165,8 +165,12 @@ namespace Filtration.ViewModels get { return _selectedBlockViewModel; } set { - _selectedBlockViewModel = value; - RaisePropertyChanged(); + if (value != _selectedBlockViewModel) + { + _selectedBlockViewModel = value; + Messenger.Default.Send(new NotificationMessage("SelectedBlockChanged")); + RaisePropertyChanged(); + } } } diff --git a/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs b/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs index 049c883..6b3a722 100644 --- a/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs +++ b/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs @@ -1,17 +1,24 @@ using System; using System.Windows.Media.Imaging; +using Filtration.Translators; +using GalaSoft.MvvmLight.Messaging; namespace Filtration.ViewModels.ToolPanes { internal interface IBlockOutputPreviewViewModel : IToolViewModel { bool IsVisible { get; set; } + void ClearDown(); } internal class BlockOutputPreviewViewModel : ToolViewModel, IBlockOutputPreviewViewModel { - public BlockOutputPreviewViewModel() : base("Block Output Preview") + private readonly IItemFilterBlockTranslator _itemFilterBlockTranslator; + private string _previewText; + + public BlockOutputPreviewViewModel(IItemFilterBlockTranslator itemFilterBlockTranslator) : base("Block Output Preview") { + _itemFilterBlockTranslator = itemFilterBlockTranslator; ContentId = ToolContentId; var icon = new BitmapImage(); icon.BeginInit(); @@ -19,10 +26,56 @@ namespace Filtration.ViewModels.ToolPanes icon.EndInit(); IconSource = icon; - IsVisible = false; + IsVisible = false; + + Messenger.Default.Register(this, message => + { + switch (message.Notification) + { + case "SelectedBlockChanged": + { + OnSelectedBlockChanged(null, null); + break; + } + case "ActiveDocumentChanged": + { + OnSelectedBlockChanged(null, null); + break; + } + } + }); + + } + + public const string ToolContentId = "BlockOutputPreviewTool"; + + public string PreviewText + { + get { return _previewText; } + private set + { + _previewText = value; + RaisePropertyChanged(); + } } + public void ClearDown() + { + PreviewText = string.Empty; + } - public const string ToolContentId = "BlockOutputPreviewTool"; + private void OnSelectedBlockChanged(object sender, EventArgs e) + { + if (AvalonDockWorkspaceViewModel.ActiveScriptViewModel == null || + AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel == null) + { + PreviewText = string.Empty; + return; + } + + PreviewText = + _itemFilterBlockTranslator.TranslateItemFilterBlockToString( + AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel.Block); + } } } diff --git a/Filtration/Views/IconsDictionary.xaml b/Filtration/Views/IconsDictionary.xaml index 9677152..c02c072 100644 --- a/Filtration/Views/IconsDictionary.xaml +++ b/Filtration/Views/IconsDictionary.xaml @@ -22,4 +22,6 @@ + + \ No newline at end of file diff --git a/Filtration/Views/ToolPanes/BlockGroupBrowserView.xaml b/Filtration/Views/ToolPanes/BlockGroupBrowserView.xaml index d2858c8..1b5ccf1 100644 --- a/Filtration/Views/ToolPanes/BlockGroupBrowserView.xaml +++ b/Filtration/Views/ToolPanes/BlockGroupBrowserView.xaml @@ -21,17 +21,27 @@