Added Default Path of Exile directory to saved settings

This commit is contained in:
Ben 2015-06-24 21:24:38 +01:00
parent c6f5dcda39
commit 1ba3b3f850
18 changed files with 218 additions and 28 deletions

View File

@ -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")]

View File

@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Filtration.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<userSettings>
<Filtration.Properties.Settings>
<setting name="DefaultFilterDirectory" serializeAs="String">
<value />
</setting>
</Filtration.Properties.Settings>
</userSettings>
</configuration>

View File

@ -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);
}
}

View File

@ -121,6 +121,7 @@
<Compile Include="Services\FileSystemService.cs" />
<Compile Include="Services\ItemFilterPersistenceService.cs" />
<Compile Include="Services\StaticDataService.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
@ -346,6 +347,8 @@
<Resource Include="Resources\Icons\filter_icon.png" />
<Resource Include="Resources\Icons\show_advanced_icon.png" />
<Resource Include="Resources\Icons\block_output_preview_icon.png" />
<Resource Include="Resources\Icons\collapse_icon.png" />
<Resource Include="Resources\Icons\expand_icon.png" />
<Content Include="Resources\ItemBaseTypes.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -1,30 +1,38 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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.
// </auto-generated>
//------------------------------------------------------------------------------
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;
}
}
}
}

View File

@ -1,7 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Filtration.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="DefaultFilterDirectory" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

View File

@ -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)

28
Filtration/Settings.cs Normal file
View File

@ -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.
}
}
}

View File

@ -40,6 +40,7 @@ namespace Filtration.ViewModels
_sectionBrowserViewModel.Initialise(this);
_blockGroupBrowserViewModel.Initialise(this);
_blockOutputPreviewViewModel.Initialise(this);
_openDocuments = new ObservableCollection<IDocument> {startPageViewModel};
ActiveDocument = startPageViewModel;
@ -135,6 +136,7 @@ namespace Filtration.ViewModels
{
_sectionBrowserViewModel.ClearDown();
_blockGroupBrowserViewModel.ClearDown();
_blockOutputPreviewViewModel.ClearDown();
}
OpenDocuments.Remove(document);

View File

@ -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:

View File

@ -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();
}
}
}

View File

@ -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<NotificationMessage>(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);
}
}
}

View File

@ -22,4 +22,6 @@
<Image Source="/Filtration;component/Resources/Icons/show_advanced_icon.png" x:Key="ShowAdvancedIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/block_group_browser_icon.png" x:Key="BlockGroupBrowserIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/block_output_preview_icon.png" x:Key="BlockOutputPreviewIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/expand_icon.png" x:Key="ExpandIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/collapse_icon.png" x:Key="CollapseIcon" x:Shared="False" />
</ResourceDictionary>

View File

@ -21,17 +21,27 @@
</Grid.RowDefinitions>
<ToolBar Grid.Row="0">
<Button Height="20" Command="{Binding FilterToSelectedBlockGroupCommand}" Content="{StaticResource FilterIcon}" ToolTip="Filter to Selected Block Group" />
<Button Height="20" Content="{StaticResource ExpandIcon}" ToolTip="Expand All (Not Implemented)" Name="ExpandAllButton" />
<Button Height="20" Content="{StaticResource CollapseIcon}" ToolTip="Collapse All (Not Implemented)" Name="CollapseAllButton" />
</ToolBar>
<TreeView Grid.Row="1" ItemsSource="{Binding BlockGroupViewModels}" Name="TreeView">
<TreeView.Style>
<Style TargetType="{x:Type TreeView}"></Style>
</TreeView.Style>
<i:Interaction.Behaviors>
<behaviors:BindableSelectedItemBehavior SelectedItem="{Binding SelectedBlockGroupViewModel, Mode=OneWayToSource}" />
</i:Interaction.Behaviors>
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type viewModels:ItemFilterBlockGroupViewModel}" ItemsSource="{Binding ChildGroups}">
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
<WrapPanel>
<CheckBox IsThreeState="True" IsChecked="{Binding IsChecked}" Click="BlockGroupCheckBox_Clicked" />
<TextBlock Text="{Binding GroupName}" Foreground="{Binding Advanced, Converter={StaticResource BlockGroupAdvancedColorConverter}}" />
<CheckBox IsThreeState="True" IsChecked="{Binding IsChecked}" Click="BlockGroupCheckBox_Clicked" />
<TextBlock Text="{Binding GroupName}" Foreground="{Binding Advanced, Converter={StaticResource BlockGroupAdvancedColorConverter}}" />
</WrapPanel>
</HierarchicalDataTemplate>
</TreeView.Resources>

View File

@ -3,9 +3,11 @@
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:toolPanes="clr-namespace:Filtration.ViewModels.ToolPanes"
d:DataContext="{d:DesignInstance Type=toolPanes:BlockOutputPreviewViewModel}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<TextBlock>This is the Block Text Preview Pane</TextBlock>
<TextBlock Text="{Binding PreviewText}" ToolTip="{Binding PreviewText}" Margin="10" />
</Grid>
</UserControl>

View File

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