6 Commits

Author SHA1 Message Date
Ben Wallis
ba6d50cf45 * Added auto-expand sections on open setting
* Changed all sections to be expanded unless the new setting is disabled
* Tidied up some casting in ItemFilterScriptViewModel by using pattern matching
2018-11-28 22:28:21 +00:00
Ben Wallis
6838cb12a8 Fixed a crash when loading filters with custom sounds 2018-11-28 22:03:27 +00:00
Ben Wallis
fd2023598b #83 - Fixed theme serialization 2018-11-28 21:50:42 +00:00
Ben Wallis
e3b1a5dba7 Updated nuspec release notes 2018-11-27 21:56:20 +00:00
Ben Wallis
25c25c2a1d * Removed incorrect use of async method in MainWindowViewModel constructor
* Moved script/theme loading code to new ScriptLoadingService class
2018-11-27 21:48:36 +00:00
Ben Wallis
e5386132c3 Updated Squirrel from 1.8.0 to 1.9.0 2018-11-27 21:34:58 +00:00
24 changed files with 366 additions and 276 deletions

View File

@@ -9,6 +9,10 @@ namespace Filtration.ObjectModel.ThemeEditor
{
private Color _color;
private ColorThemeComponent()
{
}
public ColorThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
if (componentName == null || componentColor == null)
@@ -23,7 +27,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public Color Color
{
get { return _color; }
get => _color;
set
{
_color = value;

View File

@@ -9,22 +9,21 @@ namespace Filtration.ObjectModel.ThemeEditor
private EffectColor _effectColor;
private bool _temporary;
public EffectColorThemeComponent(ThemeComponentType componentType, string componentName, EffectColor componentEffectColor, bool componentTemporary)
private EffectColorThemeComponent()
{
if (componentName == null)
{
throw new ArgumentException("Null parameters not allowed in EffectColorThemeComponent constructor");
}
public EffectColorThemeComponent(ThemeComponentType componentType, string componentName, EffectColor componentEffectColor, bool componentTemporary)
{
ComponentType = componentType;
ComponentName = componentName;
ComponentName = componentName ?? throw new ArgumentException("Null parameters not allowed in EffectColorThemeComponent constructor");
EffectColor = componentEffectColor;
Temporary = componentTemporary;
}
public EffectColor EffectColor
{
get { return _effectColor; }
get => _effectColor;
set
{
_effectColor = value;
@@ -35,7 +34,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public bool Temporary
{
get { return _temporary; }
get => _temporary;
set
{
_temporary = value;

View File

@@ -10,6 +10,10 @@ namespace Filtration.ObjectModel.ThemeEditor
private IconColor _iconColor;
private IconShape _iconShape;
private IconThemeComponent()
{
}
public IconThemeComponent(ThemeComponentType componentType, string componentName, IconSize componentIconSize, IconColor componentIconColor, IconShape componentIconShape)
{
if (componentName == null)
@@ -26,7 +30,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public IconSize IconSize
{
get { return _iconSize; }
get => _iconSize;
set
{
_iconSize = value;
@@ -37,7 +41,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public IconColor IconColor
{
get { return _iconColor; }
get => _iconColor;
set
{
_iconColor = value;
@@ -48,7 +52,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public IconShape IconShape
{
get { return _iconShape; }
get => _iconShape;
set
{
_iconShape = value;

View File

@@ -9,6 +9,10 @@ namespace Filtration.ObjectModel.ThemeEditor
{
private int _value;
private IntegerThemeComponent()
{
}
public IntegerThemeComponent(ThemeComponentType componentType, string componentName, int componentValue)
{
if (componentName == null)
@@ -23,7 +27,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public int Value
{
get { return _value; }
get => _value;
set
{
_value = value;

View File

@@ -9,6 +9,10 @@ namespace Filtration.ObjectModel.ThemeEditor
private string _value;
private int _secondValue;
private StrIntThemeComponent()
{
}
public StrIntThemeComponent(ThemeComponentType componentType, string componentName, string componentValue, int componentSecondValue)
{
if (componentName == null || componentValue == null)
@@ -24,7 +28,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public string Value
{
get { return _value; }
get => _value;
set
{
_value = value;
@@ -35,7 +39,7 @@ namespace Filtration.ObjectModel.ThemeEditor
public int SecondValue
{
get { return _secondValue; }
get => _secondValue;
set
{
_secondValue = value;

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Xml.Serialization;
using Filtration.ObjectModel.Enums;
using GalaSoft.MvvmLight.Command;
using Microsoft.Win32;
@@ -13,6 +14,10 @@ namespace Filtration.ObjectModel.ThemeEditor
private string _value;
public static ObservableCollection<string> _customSoundsAvailable;
private StringThemeComponent()
{
}
public StringThemeComponent(ThemeComponentType componentType, string componentName, string componentValue)
{
if (componentName == null || componentValue == null)
@@ -61,13 +66,14 @@ namespace Filtration.ObjectModel.ThemeEditor
CustomSoundFileDialogCommand = new RelayCommand(OnCustomSoundFileDialog);
}
[XmlIgnore]
public RelayCommand CustomSoundFileDialogCommand { get; set; }
public ObservableCollection<string> CustomSoundsAvailable => _customSoundsAvailable;
public string Value
{
get { return _value; }
get => _value;
set
{
_value = value;
@@ -78,12 +84,11 @@ namespace Filtration.ObjectModel.ThemeEditor
private void OnCustomSoundFileDialog()
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.DefaultExt = ".mp3";
var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\";
OpenFileDialog fileDialog = new OpenFileDialog {DefaultExt = ".mp3"};
var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\My Games\Path of Exile\";
fileDialog.InitialDirectory = poePath;
Nullable<bool> result = fileDialog.ShowDialog();
bool? result = fileDialog.ShowDialog();
if (result == true)
{
var fileName = fileDialog.FileName;

View File

@@ -7,13 +7,17 @@ using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
{
[Serializable]
[XmlInclude(typeof(ColorThemeComponent))]
[XmlInclude(typeof(EffectColorThemeComponent))]
[XmlInclude(typeof(IconThemeComponent))]
[XmlInclude(typeof(IntegerThemeComponent))]
[XmlInclude(typeof(StringThemeComponent))]
[XmlInclude(typeof(StrIntThemeComponent))]
public class Theme
{
private readonly ThemeComponentCollection _components;
public Theme()
{
_components = new ThemeComponentCollection { IsMasterCollection = false};
Components = new ThemeComponentCollection { IsMasterCollection = false};
}
public string Name { get; set; }
@@ -21,28 +25,28 @@ namespace Filtration.ObjectModel.ThemeEditor
[XmlIgnore]
public string FilePath { get; set; }
public ThemeComponentCollection Components => _components;
public ThemeComponentCollection Components { get; set; }
public bool ComponentExists(ThemeComponentType componentType, string componentName)
{
var componentCount =
_components.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
Components.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
return componentCount > 0;
}
public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
_components.Add(new ColorThemeComponent(componentType, componentName, componentColor));
Components.Add(new ColorThemeComponent(componentType, componentName, componentColor));
}
public void AddComponent(ThemeComponentType componentType, string componentName, int componentValue)
{
_components.Add(new IntegerThemeComponent(componentType, componentName, componentValue));
Components.Add(new IntegerThemeComponent(componentType, componentName, componentValue));
}
public void AddComponent(ThemeComponentType componentType, string componentName, string componentValue, int componentSecondValue)
{
_components.Add(new StrIntThemeComponent(componentType, componentName, componentValue, componentSecondValue));
Components.Add(new StrIntThemeComponent(componentType, componentName, componentValue, componentSecondValue));
}
}
}

View File

@@ -55,9 +55,12 @@
<setting name="WindowHeight" serializeAs="String">
<value>800</value>
</setting>
<setting name="LastActiveDocument" serializeAs="String">
<setting name="LastOpenScripts" serializeAs="String">
<value />
</setting>
<setting name="BlocksExpandedOnOpen" serializeAs="String">
<value>True</value>
</setting>
</Filtration.Properties.Settings>
</userSettings>
<runtime>

View File

@@ -43,7 +43,7 @@ namespace Filtration
cfg.CreateMap<StringThemeComponent, StringThemeComponentViewModel>().ReverseMap();
cfg.CreateMap<IconThemeComponent, IconThemeComponentViewModel>().ReverseMap();
cfg.CreateMap<EffectColorThemeComponent, EffectColorThemeComponentViewModel>().ReverseMap();
cfg.CreateMap<IThemeEditorViewModel, Theme>();
cfg.CreateMap<ThemeEditorViewModel, Theme>();
});
Mapper.AssertConfigurationIsValid();

View File

@@ -114,7 +114,7 @@
<HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.8.0\lib\Net45\NuGet.Squirrel.dll</HintPath>
<HintPath>..\packages\squirrel.windows.1.9.0\lib\Net45\NuGet.Squirrel.dll</HintPath>
</Reference>
<Reference Include="SharpCompress, Version=0.17.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.17.1\lib\net45\SharpCompress.dll</HintPath>
@@ -122,8 +122,8 @@
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
</Reference>
<Reference Include="Squirrel, Version=1.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.8.0\lib\Net45\Squirrel.dll</HintPath>
<Reference Include="Squirrel, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.9.0\lib\Net45\Squirrel.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
@@ -217,6 +217,7 @@
<Compile Include="Services\HTTPService.cs" />
<Compile Include="Services\ItemFilterPersistenceService.cs" />
<Compile Include="Services\ItemFilterScriptDirectoryService.cs" />
<Compile Include="Services\ScriptLoadingService.cs" />
<Compile Include="Services\SettingsService.cs" />
<Compile Include="Services\StaticDataService.cs" />
<Compile Include="Services\UpdateService.cs" />

View File

@@ -9,7 +9,14 @@
<description>A Path of Exile loot filter script editor</description>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright 2018</copyright>
<releaseNotes>* Fixed crash on exit</releaseNotes>
<releaseNotes>* All open filter scripts are now remembered on exit and reopened when the application is started rather than just the last opened one (#95)
* Filter sections are once again now expanded by default when scripts are opened, unless the new "Auto-expand all sections when opening scripts" setting is disabled
* A new Clear Styles button has been added which removes all styles from the selected block (#96)
* Fixed theme saving (blank theme files were being saved) (#83)
* Fixed checkboxes in Block Group Browser (#97)
* Fixed the Select Path of Exile data directory dialog appearing after every upgrade (#94)
* Fixed an issue where custom sounds were only populated from the default Path of Exile data directory rather than the configured directory
* Clean installs no longer prompt to select the Path of Exile data directory if the default directory exists</releaseNotes>
<dependencies />
</metadata>
<files>

View File

@@ -12,7 +12,7 @@ namespace Filtration.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -229,5 +229,17 @@ namespace Filtration.Properties {
this["LastOpenScripts"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool BlocksExpandedOnOpen {
get {
return ((bool)(this["BlocksExpandedOnOpen"]));
}
set {
this["BlocksExpandedOnOpen"] = value;
}
}
}
}

View File

@@ -53,8 +53,11 @@
<Setting Name="WindowHeight" Type="System.Int32" Scope="User">
<Value Profile="(Default)">800</Value>
</Setting>
<Setting Name="LastActiveDocument" Type="System.String" Scope="User">
<Setting Name="LastOpenScripts" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="BlocksExpandedOnOpen" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using System.Windows;
using Filtration.Properties;
using Filtration.Views;
using NLog;
@@ -17,16 +18,19 @@ namespace Filtration.Services
private readonly IItemFilterScriptDirectoryService _itemFilterScriptDirectoryService;
private readonly IMainWindow _mainWindow;
private readonly IScriptLoadingService _scriptLoadingService;
private readonly ISettingsService _settingsService;
private readonly IUpdateService _updateService;
public Bootstrapper(IItemFilterScriptDirectoryService itemFilterScriptDirectoryService,
IMainWindow mainWindow,
IScriptLoadingService scriptLoadingService,
ISettingsService settingsService,
IUpdateService updateService)
{
_itemFilterScriptDirectoryService = itemFilterScriptDirectoryService;
_mainWindow = mainWindow;
_scriptLoadingService = scriptLoadingService;
_settingsService = settingsService;
_updateService = updateService;
}
@@ -44,6 +48,12 @@ namespace Filtration.Services
_mainWindow.Show();
// If there were scripts open the last time the application was closed, reopen them
if (!string.IsNullOrWhiteSpace(Settings.Default.LastOpenScripts))
{
await _scriptLoadingService.LoadScriptsAsync(Settings.Default.LastOpenScripts.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
}
await _updateService.CheckForUpdatesAsync();
}

View File

@@ -0,0 +1,98 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using Filtration.Common.Services;
using Filtration.Repositories;
using Filtration.ThemeEditor.Providers;
using Filtration.ThemeEditor.ViewModels;
using Filtration.ViewModels;
using GalaSoft.MvvmLight.Messaging;
using NLog;
namespace Filtration.Services
{
internal interface IScriptLoadingService
{
Task LoadScriptAsync(string scriptFilename);
Task LoadScriptsAsync(string[] files);
Task LoadThemeAsync(string themeFilename);
}
internal sealed class ScriptLoadingService : IScriptLoadingService
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
private readonly IMessageBoxService _messageBoxService;
private readonly IThemeProvider _themeProvider;
private readonly IItemFilterScriptRepository _itemFilterScriptRepository;
public ScriptLoadingService(IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
IItemFilterScriptRepository itemFilterScriptRepository,
IMessageBoxService messageBoxService,
IThemeProvider themeProvider)
{
_avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
_messageBoxService = messageBoxService;
_themeProvider = themeProvider;
_itemFilterScriptRepository = itemFilterScriptRepository;
}
public async Task LoadScriptsAsync(string[] files)
{
foreach (var file in files)
{
if (File.Exists(file))
{
await LoadScriptAsync(file);
}
}
}
public async Task LoadScriptAsync(string scriptFilename)
{
IItemFilterScriptViewModel loadedViewModel;
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
try
{
loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
}
catch (Exception e)
{
Logger.Error(e);
_messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
finally
{
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
}
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
}
public async Task LoadThemeAsync(string themeFilename)
{
IThemeEditorViewModel loadedViewModel;
try
{
loadedViewModel = await _themeProvider.LoadThemeFromFile(themeFilename);
}
catch (Exception e)
{
Logger.Error(e);
_messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
}
}
}

View File

@@ -12,6 +12,8 @@ namespace Filtration.ViewModels.DesignTime
set { }
}
public bool BlocksExpandedOnOpen { get; set; }
public bool ExtraLineBetweenBlocks
{
get => true;

View File

@@ -7,7 +7,7 @@ namespace Filtration.ViewModels
{
internal interface IItemFilterBlockViewModelBase
{
void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel);
void Initialise(IItemFilterBlockBase itemFilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel);
IItemFilterBlockBase BaseBlock { get; }
bool IsDirty { get; set; }
bool IsVisible { get; set; }
@@ -25,9 +25,9 @@ namespace Filtration.ViewModels
}
public virtual void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
public virtual void Initialise(IItemFilterBlockBase itemFilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
{
BaseBlock = itemfilterBlock;
BaseBlock = itemFilterBlock;
_parentScriptViewModel = itemFilterScriptViewModel;
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand);

View File

@@ -11,6 +11,7 @@ namespace Filtration.ViewModels
string Comment { get; }
bool IsExpanded { get; set; }
bool HasVisibleChild { get; }
int ChildCount { get; set; }
}
internal class ItemFilterCommentBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterCommentBlockViewModel
@@ -28,13 +29,13 @@ namespace Filtration.ViewModels
ToggleSectionCommand = new RelayCommand(OnToggleSectionCommand);
}
public override void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
public override void Initialise(IItemFilterBlockBase itemFilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
{
_parentScriptViewModel = itemFilterScriptViewModel;
ItemFilterCommentBlock = itemfilterBlock as IItemFilterCommentBlock;
ItemFilterCommentBlock = itemFilterBlock as IItemFilterCommentBlock;
BaseBlock = ItemFilterCommentBlock;
base.Initialise(itemfilterBlock, itemFilterScriptViewModel);
base.Initialise(itemFilterBlock, itemFilterScriptViewModel);
}
public RelayCommand ToggleSectionCommand { get; }
@@ -43,10 +44,7 @@ namespace Filtration.ViewModels
public string Comment
{
get
{
return ItemFilterCommentBlock.Comment;
}
get => ItemFilterCommentBlock.Comment;
set
{
if (ItemFilterCommentBlock.Comment != value)

View File

@@ -105,17 +105,13 @@ namespace Filtration.ViewModels
private readonly IItemFilterPersistenceService _persistenceService;
private readonly IMessageBoxService _messageBoxService;
private readonly IClipboardService _clipboardService;
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
private bool _isDirty;
private readonly ObservableCollection<IItemFilterBlockViewModelBase> _selectedBlockViewModels;
private IItemFilterCommentBlockViewModel _sectionBrowserSelectedBlockViewModel;
private readonly ObservableCollection<IItemFilterBlockViewModelBase> _itemFilterBlockViewModels;
private Predicate<IItemFilterBlockViewModel> _blockFilterPredicate;
private ICommandManager _scriptCommandManager;
private ObservableCollection<string> _customSoundsAvailable;
private ListCollectionView _viewItemFilterBlockViewModels;
private readonly List<IItemFilterBlockViewModelBase> _lastAddedBlocks;
public ItemFilterScriptViewModel(IItemFilterBlockBaseViewModelFactory itemFilterBlockBaseViewModelFactory,
@@ -124,8 +120,7 @@ namespace Filtration.ViewModels
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
IItemFilterPersistenceService persistenceService,
IMessageBoxService messageBoxService,
IClipboardService clipboardService,
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
IClipboardService clipboardService)
{
_itemFilterBlockBaseViewModelFactory = itemFilterBlockBaseViewModelFactory;
_blockTranslator = blockTranslator;
@@ -135,10 +130,9 @@ namespace Filtration.ViewModels
_persistenceService = persistenceService;
_messageBoxService = messageBoxService;
_clipboardService = clipboardService;
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
_selectedBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
_selectedBlockViewModels.CollectionChanged += (s, e) =>
ItemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
SelectedBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
SelectedBlockViewModels.CollectionChanged += (s, e) =>
{
RaisePropertyChanged(nameof(SelectedBlockViewModels));
RaisePropertyChanged(nameof(LastSelectedBlockViewModel));
@@ -154,9 +148,9 @@ namespace Filtration.ViewModels
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
ClearStylesCommand = new RelayCommand(OnClearStylesCommand, () => SelectedBlockViewModels.OfType<IItemFilterBlockViewModel>().Count() > 0);
ClearStylesCommand = new RelayCommand(OnClearStylesCommand, () => SelectedBlockViewModels.OfType<IItemFilterBlockViewModel>().Any());
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => CanModifySelectedBlocks());
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, CanModifySelectedBlocks);
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModels.Count > 0 && CanModifySelectedBlocks());
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModels.Count > 0 && CanModifySelectedBlocks());
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModels.Count == 1 && ViewItemFilterBlockViewModels.IndexOf(LastSelectedBlockViewModel) > 0);
@@ -191,6 +185,8 @@ namespace Filtration.ViewModels
Script = itemFilterScript;
_scriptCommandManager = Script.CommandManager;
InitialiseCustomSounds();
AddItemFilterBlockViewModels(Script.ItemFilterBlocks, -1);
UpdateChildCount();
@@ -207,7 +203,28 @@ namespace Filtration.ViewModels
}
}
Script.ItemFilterBlocks.CollectionChanged += ItemFilterBlocksOnCollectionChanged;
_filenameIsFake = newScript;
if (newScript)
{
Script.FilePath = "Untitled.filter";
}
Title = Filename;
ContentId = "ScriptContentId";
if (!Settings.Default.BlocksExpandedOnOpen)
{
CollapseAllSections();
}
}
private void InitialiseCustomSounds()
{
_customSoundsAvailable = new ObservableCollection<string>();
_customSoundsAvailable.CollectionChanged += CustomSoundsAvailableOnCollectionChanged;
var poeFolderFiles = Directory.GetFiles(_persistenceService.ItemFilterScriptDirectory + "\\").Where(
s => s.EndsWith(".mp3")
@@ -223,21 +240,6 @@ namespace Filtration.ViewModels
{
_customSoundsAvailable.Add(file.Replace(_persistenceService.ItemFilterScriptDirectory + "\\", ""));
}
Script.ItemFilterBlocks.CollectionChanged += ItemFilterBlocksOnCollectionChanged;
_customSoundsAvailable.CollectionChanged += CustomSoundsAvailableOnCollectionChanged;
_filenameIsFake = newScript;
if (newScript)
{
Script.FilePath = "Untitled.filter";
}
Title = Filename;
ContentId = "ScriptContentId";
CollapseAllSections();
}
private void ItemFilterBlocksOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
@@ -251,7 +253,7 @@ namespace Filtration.ViewModels
}
case NotifyCollectionChangedAction.Remove:
{
RemoveItemFilterBlockviewModels(notifyCollectionChangedEventArgs.OldItems.Cast<IItemFilterBlockBase>());
RemoveItemFilterBlockViewModels(notifyCollectionChangedEventArgs.OldItems.Cast<IItemFilterBlockBase>());
break;
}
default:
@@ -289,8 +291,7 @@ namespace Filtration.ViewModels
_lastAddedBlocks.Add(vm);
var itemBlock = itemFilterBlock as IItemFilterBlock;
if (itemBlock != null)
if (itemFilterBlock is IItemFilterBlock itemBlock)
{
foreach (var customSoundBlockItem in itemBlock.BlockItems.OfType<CustomSoundBlockItem>())
{
@@ -303,7 +304,7 @@ namespace Filtration.ViewModels
}
}
private void RemoveItemFilterBlockviewModels(IEnumerable<IItemFilterBlockBase> itemFilterBlocks)
private void RemoveItemFilterBlockViewModels(IEnumerable<IItemFilterBlockBase> itemFilterBlocks)
{
foreach (var itemFilterBlock in itemFilterBlocks)
{
@@ -319,7 +320,7 @@ namespace Filtration.ViewModels
private void UpdateFilteredBlockList()
{
ICollectionView filteredBlocks = CollectionViewSource.GetDefaultView(_itemFilterBlockViewModels);
ICollectionView filteredBlocks = CollectionViewSource.GetDefaultView(ItemFilterBlockViewModels);
filteredBlocks.Filter = BlockFilter;
ItemFilterCommentBlockViewModel previousSection = new ItemFilterCommentBlockViewModel();
@@ -329,16 +330,16 @@ namespace Filtration.ViewModels
{
previousSection.VisibleChildCount++;
}
else if (block is ItemFilterCommentBlockViewModel)
else if (block is ItemFilterCommentBlockViewModel model)
{
previousSection = block as ItemFilterCommentBlockViewModel;
previousSection = model;
previousSection.VisibleChildCount = 0;
}
}
_viewItemFilterBlockViewModels = (ListCollectionView)CollectionViewSource.GetDefaultView(
ViewItemFilterBlockViewModels = (ListCollectionView)CollectionViewSource.GetDefaultView(
filteredBlocks.Cast<IItemFilterBlockViewModelBase>().ToList());
_viewItemFilterBlockViewModels.Filter = BlockVisibilityFilter;
ViewItemFilterBlockViewModels.Filter = BlockVisibilityFilter;
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
SelectedBlockViewModels.Clear();
@@ -355,24 +356,24 @@ namespace Filtration.ViewModels
previousSection.ChildCount++;
block.IsVisible = previousSection.IsExpanded;
}
else if (block is ItemFilterCommentBlockViewModel)
else if (block is ItemFilterCommentBlockViewModel model)
{
previousSection = block as ItemFilterCommentBlockViewModel;
previousSection = model;
previousSection.ChildCount = 0;
}
}
}
private List<IItemFilterBlockViewModelBase> getChildren(IItemFilterCommentBlockViewModel targetBlockViewModel)
private List<IItemFilterBlockViewModelBase> GetChildren(IItemFilterCommentBlockViewModel targetBlockViewModel)
{
return ItemFilterBlockViewModels.ToList().GetRange(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1,
(targetBlockViewModel as ItemFilterCommentBlockViewModel).ChildCount);
targetBlockViewModel.ChildCount);
}
private List<int> getChildrenIndexes(IItemFilterCommentBlockViewModel targetBlockViewModel)
private List<int> GetChildrenIndexes(IItemFilterCommentBlockViewModel targetBlockViewModel)
{
return Enumerable.Range(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1,
(targetBlockViewModel as ItemFilterCommentBlockViewModel).ChildCount).ToList();
targetBlockViewModel.ChildCount).ToList();
}
private void ValidateSelectedBlocks()
@@ -427,25 +428,16 @@ namespace Filtration.ViewModels
public ObservableCollection<string> CustomSoundsAvailable
{
get => _customSoundsAvailable;
set
private set
{
_customSoundsAvailable = value;
RaisePropertyChanged();
}
}
public ListCollectionView ViewItemFilterBlockViewModels
{
get => _viewItemFilterBlockViewModels;
}
public ListCollectionView ViewItemFilterBlockViewModels { get; private set; }
public ObservableCollection<IItemFilterBlockViewModelBase> ItemFilterBlockViewModels
{
get
{
return _itemFilterBlockViewModels;
}
}
public ObservableCollection<IItemFilterBlockViewModelBase> ItemFilterBlockViewModels { get; }
private bool BlockFilter(object item)
{
@@ -550,7 +542,7 @@ namespace Filtration.ViewModels
public bool HasSelectedCommentBlock()
{
return SelectedBlockViewModels.OfType<IItemFilterCommentBlockViewModel>().Count() > 0;
return SelectedBlockViewModels.OfType<IItemFilterCommentBlockViewModel>().Any();
}
public bool CanModifySelectedBlocks()
@@ -581,18 +573,9 @@ namespace Filtration.ViewModels
return itemFilterCommentBlock.ChildCount == itemFilterCommentBlock.VisibleChildCount;
}
public ObservableCollection<IItemFilterBlockViewModelBase> SelectedBlockViewModels
{
get => _selectedBlockViewModels;
}
public ObservableCollection<IItemFilterBlockViewModelBase> SelectedBlockViewModels { get; }
public IItemFilterBlockViewModelBase LastSelectedBlockViewModel
{
get
{
return SelectedBlockViewModels.Count > 0 ? SelectedBlockViewModels.Last() : null;
}
}
public IItemFilterBlockViewModelBase LastSelectedBlockViewModel => SelectedBlockViewModels.Count > 0 ? SelectedBlockViewModels.Last() : null;
public IItemFilterCommentBlockViewModel CommentBlockBrowserBrowserSelectedBlockViewModel
{
@@ -877,9 +860,9 @@ namespace Filtration.ViewModels
foreach (var block in SelectedBlockViewModels.OfType<IItemFilterBlockViewModelBase>())
{
blocksToCopy.Add(block);
if (block is IItemFilterCommentBlockViewModel && !(block as IItemFilterCommentBlockViewModel).IsExpanded)
if (block is IItemFilterCommentBlockViewModel model && !model.IsExpanded)
{
blocksToCopy.AddRange(getChildren(block as IItemFilterCommentBlockViewModel));
blocksToCopy.AddRange(GetChildren(model));
}
}
@@ -896,14 +879,14 @@ namespace Filtration.ViewModels
else
{
var blocksToCopy = new List<IItemFilterBlockViewModelBase> { targetBlockViewModelBase };
blocksToCopy.AddRange(getChildren(targetBlockViewModelBase as IItemFilterCommentBlockViewModel));
blocksToCopy.AddRange(GetChildren((IItemFilterCommentBlockViewModel)targetBlockViewModelBase));
CopyBlocks(blocksToCopy);
}
}
public void CopyBlocks(IEnumerable<IItemFilterBlockViewModelBase> targetBlockViewModels)
{
if (targetBlockViewModels.Count() < 1)
if (!targetBlockViewModels.Any())
{
return;
}
@@ -926,8 +909,7 @@ namespace Filtration.ViewModels
private void OnCopyBlockStyleCommand()
{
var selectedBlockViewModel = LastSelectedBlockViewModel as IItemFilterBlockViewModel;
if (selectedBlockViewModel != null)
if (LastSelectedBlockViewModel is IItemFilterBlockViewModel selectedBlockViewModel)
{
CopyBlockStyle(selectedBlockViewModel);
}
@@ -958,8 +940,7 @@ namespace Filtration.ViewModels
private void OnPasteBlockStyleCommand()
{
var selectedBlockViewModel = LastSelectedBlockViewModel as IItemFilterBlockViewModel;
if (selectedBlockViewModel != null)
if (LastSelectedBlockViewModel is IItemFilterBlockViewModel selectedBlockViewModel)
{
PasteBlockStyle(selectedBlockViewModel);
}
@@ -988,7 +969,7 @@ namespace Filtration.ViewModels
if (commentBlock != null && !commentBlock.IsExpanded)
{
targetBlockViewModelBase = ItemFilterBlockViewModels[ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase) +
(commentBlock as ItemFilterCommentBlockViewModel).ChildCount];
commentBlock.ChildCount];
}
try
@@ -1046,12 +1027,12 @@ namespace Filtration.ViewModels
var indexToMove = ItemFilterBlockViewModels.IndexOf(
ViewItemFilterBlockViewModels.GetItemAt(blockIndex - 1) as IItemFilterBlockViewModelBase);
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel &&
!(targetBlockViewModelBase as IItemFilterCommentBlockViewModel).IsExpanded)
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel model &&
!model.IsExpanded)
{
ExecuteCommandAndSelectAdded(new MoveBlocksToIndexCommand(Script,
Enumerable.Range(ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase),
(targetBlockViewModelBase as ItemFilterCommentBlockViewModel).ChildCount + 1).ToList(), indexToMove));
Enumerable.Range(ItemFilterBlockViewModels.IndexOf(model),
model.ChildCount + 1).ToList(), indexToMove));
if (_lastAddedBlocks.Count > 0)
{
ToggleSection(_lastAddedBlocks[0] as IItemFilterCommentBlockViewModel);
@@ -1088,13 +1069,13 @@ namespace Filtration.ViewModels
indexToMove += (belowBlock as ItemFilterCommentBlockViewModel).ChildCount;
}
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel &&
!(targetBlockViewModelBase as IItemFilterCommentBlockViewModel).IsExpanded)
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel model &&
!model.IsExpanded)
{
indexToMove -= (targetBlockViewModelBase as ItemFilterCommentBlockViewModel).ChildCount;
indexToMove -= model.ChildCount;
ExecuteCommandAndSelectAdded(new MoveBlocksToIndexCommand(Script,
Enumerable.Range(ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase),
(targetBlockViewModelBase as ItemFilterCommentBlockViewModel).ChildCount + 1).ToList(), indexToMove));
Enumerable.Range(ItemFilterBlockViewModels.IndexOf(model),
model.ChildCount + 1).ToList(), indexToMove));
if (_lastAddedBlocks.Count > 0)
{
ToggleSection(_lastAddedBlocks[0] as IItemFilterCommentBlockViewModel);
@@ -1119,11 +1100,10 @@ namespace Filtration.ViewModels
public void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel && !(targetBlockViewModelBase as IItemFilterCommentBlockViewModel).IsExpanded)
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel model && !model.IsExpanded)
{
ToggleSection(targetBlockViewModelBase as IItemFilterCommentBlockViewModel);
targetBlockViewModelBase = ItemFilterBlockViewModels[ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase) +
(targetBlockViewModelBase as ItemFilterCommentBlockViewModel).ChildCount];
ToggleSection(model);
targetBlockViewModelBase = ItemFilterBlockViewModels[ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase) + model.ChildCount];
}
ExecuteCommandAndSelectAdded(new AddBlockCommand(Script, targetBlockViewModelBase?.BaseBlock));
@@ -1155,7 +1135,7 @@ namespace Filtration.ViewModels
blocksToDelete.Add(block);
if (block is IItemFilterCommentBlockViewModel && !(block as IItemFilterCommentBlockViewModel).IsExpanded)
{
blocksToDelete.AddRange(getChildren(block as IItemFilterCommentBlockViewModel));
blocksToDelete.AddRange(GetChildren(block as IItemFilterCommentBlockViewModel));
}
}
@@ -1223,7 +1203,7 @@ namespace Filtration.ViewModels
sourceIndexes.Add(ItemFilterBlockViewModels.IndexOf(block));
if (block is IItemFilterCommentBlockViewModel && !(block as IItemFilterCommentBlockViewModel).IsExpanded)
{
sourceIndexes.AddRange(getChildrenIndexes(block as IItemFilterCommentBlockViewModel));
sourceIndexes.AddRange(GetChildrenIndexes(block as IItemFilterCommentBlockViewModel));
}
}
@@ -1246,11 +1226,11 @@ namespace Filtration.ViewModels
public void MoveBlockToTop(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel && !(targetBlockViewModelBase as IItemFilterCommentBlockViewModel).IsExpanded)
if (targetBlockViewModelBase is IItemFilterCommentBlockViewModel model && !model.IsExpanded)
{
ExecuteCommandAndSelectAdded(new MoveBlocksToTopCommand(Script,
Enumerable.Range(ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase),
(targetBlockViewModelBase as ItemFilterCommentBlockViewModel).ChildCount + 1).ToList()));
Enumerable.Range(ItemFilterBlockViewModels.IndexOf(model),
model.ChildCount + 1).ToList()));
if (_lastAddedBlocks.Count > 0)
{
ToggleSection(_lastAddedBlocks[0] as IItemFilterCommentBlockViewModel);
@@ -1270,18 +1250,18 @@ namespace Filtration.ViewModels
foreach (var block in targetCommentBlockViewModels)
{
sourceIndexes.Add(ItemFilterBlockViewModels.IndexOf(block));
if (block is IItemFilterCommentBlockViewModel && !(block as IItemFilterCommentBlockViewModel).IsExpanded)
if (block is IItemFilterCommentBlockViewModel model && !model.IsExpanded)
{
sourceIndexes.AddRange(getChildrenIndexes(block as IItemFilterCommentBlockViewModel));
sourceIndexes.AddRange(GetChildrenIndexes(model));
}
}
ExecuteCommandAndSelectAdded(new MoveBlocksToTopCommand(Script, sourceIndexes));
for (var i = 0; i < sourceIndexes.Count; i++)
{
if (ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel != null)
if (ItemFilterBlockViewModels[i] is IItemFilterCommentBlockViewModel model)
{
ToggleSection(ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel);
ToggleSection(model);
}
}
@@ -1313,11 +1293,11 @@ namespace Filtration.ViewModels
{
foreach (var block in SelectedBlockViewModels)
{
if (block is IItemFilterCommentBlockViewModel)
if (block is IItemFilterCommentBlockViewModel model)
{
if (!(block as IItemFilterCommentBlockViewModel).IsExpanded)
if (!model.IsExpanded)
{
foreach (var child in getChildren(block as IItemFilterCommentBlockViewModel))
foreach (var child in GetChildren(model))
{
((IItemFilterBlockViewModel)child).BlockEnabled = false;
}
@@ -1334,11 +1314,11 @@ namespace Filtration.ViewModels
{
foreach (var block in SelectedBlockViewModels)
{
if (block is IItemFilterCommentBlockViewModel)
if (block is IItemFilterCommentBlockViewModel model)
{
if (!(block as IItemFilterCommentBlockViewModel).IsExpanded)
if (!model.IsExpanded)
{
foreach (var child in getChildren(block as IItemFilterCommentBlockViewModel))
foreach (var child in GetChildren(model))
{
((IItemFilterBlockViewModel)child).BlockEnabled = true;
}
@@ -1355,7 +1335,7 @@ namespace Filtration.ViewModels
{
foreach (var block in SelectedBlockViewModels.OfType<IItemFilterCommentBlockViewModel>())
{
foreach (var child in getChildren(block as IItemFilterCommentBlockViewModel))
foreach (var child in GetChildren(block))
{
((IItemFilterBlockViewModel)child).BlockEnabled = false;
}
@@ -1366,7 +1346,7 @@ namespace Filtration.ViewModels
{
foreach (var block in SelectedBlockViewModels.OfType<IItemFilterCommentBlockViewModel>())
{
foreach (var child in getChildren(block as IItemFilterCommentBlockViewModel))
foreach (var child in GetChildren(block))
{
((IItemFilterBlockViewModel)child).BlockEnabled = true;
}
@@ -1399,7 +1379,7 @@ namespace Filtration.ViewModels
{
var newState = !targetCommentBlockViewModelBase.IsExpanded;
targetCommentBlockViewModelBase.IsExpanded = newState;
foreach (var child in getChildren(targetCommentBlockViewModelBase))
foreach (var child in GetChildren(targetCommentBlockViewModelBase))
{
child.IsVisible = newState;
}
@@ -1414,15 +1394,11 @@ namespace Filtration.ViewModels
private void CollapseAllSections()
{
for (int i = 0; i < ItemFilterBlockViewModels.Count; i++)
foreach (var model in ItemFilterBlockViewModels.OfType<IItemFilterCommentBlockViewModel>())
{
var block = ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel;
if (block != null)
if (model.IsExpanded)
{
if(block.IsExpanded)
{
ToggleSection(block, true);
}
ToggleSection(model, true);
}
}
@@ -1433,12 +1409,11 @@ namespace Filtration.ViewModels
private void ExpandAllSections()
{
for (int i = 0; i < ItemFilterBlockViewModels.Count; i++)
foreach (var model in ItemFilterBlockViewModels.OfType<IItemFilterCommentBlockViewModel>())
{
var block = ItemFilterBlockViewModels[i] as IItemFilterCommentBlockViewModel;
if (block != null && !block.IsExpanded)
if (!model.IsExpanded)
{
ToggleSection(block, true);
ToggleSection(model, true);
}
}

View File

@@ -49,6 +49,7 @@ namespace Filtration.ViewModels
private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator;
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
private readonly IScriptLoadingService _scriptLoadingService;
private readonly IThemeProvider _themeProvider;
private readonly IThemeService _themeService;
private readonly IMessageBoxService _messageBoxService;
@@ -63,6 +64,7 @@ namespace Filtration.ViewModels
IItemFilterScriptTranslator itemFilterScriptTranslator,
IReplaceColorsViewModel replaceColorsViewModel,
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
IScriptLoadingService scriptLoadingService,
ISettingsPageViewModel settingsPageViewModel,
IThemeProvider themeProvider,
IThemeService themeService,
@@ -75,6 +77,7 @@ namespace Filtration.ViewModels
_itemFilterScriptTranslator = itemFilterScriptTranslator;
_replaceColorsViewModel = replaceColorsViewModel;
_avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
_scriptLoadingService = scriptLoadingService;
SettingsPageViewModel = settingsPageViewModel;
_themeProvider = themeProvider;
_themeService = themeService;
@@ -204,10 +207,6 @@ namespace Filtration.ViewModels
}
});
if (!string.IsNullOrWhiteSpace(Settings.Default.LastOpenScripts))
{
LoadScriptsAsync(Settings.Default.LastOpenScripts.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
}
}
public RelayCommand OpenScriptCommand { get; }
@@ -369,12 +368,12 @@ namespace Filtration.ViewModels
{
case ".FILTER":
{
await LoadScriptAsync(filename);
await _scriptLoadingService.LoadScriptAsync(filename);
break;
}
case ".FILTERTHEME":
{
await LoadThemeAsync(filename);
await _scriptLoadingService.LoadThemeAsync(filename);
break;
}
}
@@ -431,43 +430,7 @@ namespace Filtration.ViewModels
return;
}
await LoadScriptAsync(filePath); // TODO: fix crash
}
private async Task LoadScriptsAsync(string[] files)
{
foreach (var file in files)
{
if (File.Exists(file))
{
await LoadScriptAsync(file);
}
}
}
private async Task LoadScriptAsync(string scriptFilename)
{
IItemFilterScriptViewModel loadedViewModel;
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
try
{
loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
}
catch (Exception e)
{
Logger.Error(e);
_messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
finally
{
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
}
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
await _scriptLoadingService.LoadScriptAsync(filePath);
}
private async Task OnOpenThemeCommandAsync()
@@ -478,27 +441,7 @@ namespace Filtration.ViewModels
return;
}
await LoadThemeAsync(filePath);
}
private async Task LoadThemeAsync(string themeFilename)
{
IThemeEditorViewModel loadedViewModel;
try
{
loadedViewModel = await _themeProvider.LoadThemeFromFile(themeFilename);
}
catch (Exception e)
{
Logger.Error(e);
_messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
await _scriptLoadingService.LoadThemeAsync(filePath);
}
private async Task OnApplyThemeToScriptCommandAsync()

View File

@@ -10,8 +10,9 @@ namespace Filtration.ViewModels
RelayCommand SetItemFilterScriptDirectoryCommand { get; }
string DefaultFilterDirectory { get; }
bool ExtraLineBetweenBlocks { get; set; }
bool BlocksExpandedOnOpen { get; set; }
bool DownloadPrereleaseUpdates { get; set; }
bool ExtraLineBetweenBlocks { get; set; }
}
internal class SettingsPageViewModel : ViewModelBase, ISettingsPageViewModel
@@ -28,10 +29,10 @@ namespace Filtration.ViewModels
public string DefaultFilterDirectory => Settings.Default.DefaultFilterDirectory;
public bool ExtraLineBetweenBlocks
public bool BlocksExpandedOnOpen
{
get => Settings.Default.ExtraLineBetweenBlocks;
set => Settings.Default.ExtraLineBetweenBlocks = value;
get => Settings.Default.BlocksExpandedOnOpen;
set => Settings.Default.BlocksExpandedOnOpen = value;
}
public bool DownloadPrereleaseUpdates
@@ -40,6 +41,12 @@ namespace Filtration.ViewModels
set => Settings.Default.DownloadPrereleaseUpdates = value;
}
public bool ExtraLineBetweenBlocks
{
get => Settings.Default.ExtraLineBetweenBlocks;
set => Settings.Default.ExtraLineBetweenBlocks = value;
}
private void OnSetItemFilterScriptDirectoryCommand()
{
_itemFilterScriptDirectoryService.SetItemFilterScriptDirectory();

View File

@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:designTime="clr-namespace:Filtration.ViewModels.DesignTime"
mc:Ignorable="d" d:DesignWidth="1200"
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="400"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeSettingsPageViewModel, IsDesignTimeCreatable=True}">
<Border BorderBrush="Black" BorderThickness="1">
<DockPanel Margin="10" MaxWidth="600" HorizontalAlignment="Left">
@@ -22,8 +22,8 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="5" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition x:Name="BlankLineBetweenBlocks" Height="Auto" />
<RowDefinition x:Name="DownloadPreReleases" Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
@@ -40,8 +40,10 @@
</Grid>
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center">Add blank line between blocks when saving</TextBlock>
<CheckBox Grid.Row="2" Grid.Column="2" IsChecked="{Binding ExtraLineBetweenBlocks}" />
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center">Download pre-release updates (use with caution)</TextBlock>
<CheckBox Grid.Row="4" Grid.Column="2" IsChecked="{Binding DownloadPrereleaseUpdates}" />
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center">Download pre-release updates (use with caution)</TextBlock>
<CheckBox Grid.Row="3" Grid.Column="2" IsChecked="{Binding DownloadPrereleaseUpdates}" />
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center">Auto-expand all sections when opening scripts</TextBlock>
<CheckBox Grid.Row="4" Grid.Column="2" IsChecked="{Binding BlocksExpandedOnOpen}" />
</Grid>
</Grid>
</DockPanel>

View File

@@ -19,6 +19,11 @@ namespace Filtration.WindsorInstallers
.ImplementedBy<ItemFilterScriptDirectoryService>()
.LifeStyle.Singleton);
container.Register(
Component.For<IScriptLoadingService>()
.ImplementedBy<ScriptLoadingService>()
.LifeStyle.Singleton);
container.Register(
Component.For<IStaticDataService>()
.ImplementedBy<StaticDataService>()

View File

@@ -16,7 +16,7 @@
<package id="NuGet.CommandLine" version="4.7.1" targetFramework="net461" developmentDependency="true" />
<package id="SharpCompress" version="0.17.1" targetFramework="net461" />
<package id="Splat" version="1.6.2" targetFramework="net461" />
<package id="squirrel.windows" version="1.8.0" targetFramework="net461" />
<package id="squirrel.windows" version="1.9.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
<package id="WindowsAPICodePack-Core" version="1.1.2" targetFramework="net461" />
<package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net461" />