Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<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>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, 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" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
@@ -41,7 +41,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ControlzEx" publicKeyToken="f08b075e934b7045" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.1.2.3" newVersion="2.1.2.3" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.2.0.4" newVersion="2.2.0.4" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
|
||||
<converters:AvailableThemeComponentsConverter x:Key="AvailableThemeComponentsConverter" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary>
|
||||
<RoutedCommand x:Key="OpenScriptRoutedCommand" />
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -36,34 +36,18 @@ namespace Filtration
|
||||
.Single();
|
||||
|
||||
_container.Kernel.ComponentModelBuilder.RemoveContributor(propInjector);
|
||||
|
||||
|
||||
_container.AddFacility<TypedFactoryFacility>();
|
||||
_container.Install(FromAssembly.InThisApplication());
|
||||
_container.Install(FromAssembly.Named("Filtration.Parser")); // Not directly referenced so manually call its installers
|
||||
|
||||
|
||||
Mapper.Configuration.ConstructServicesUsing(_container.Resolve);
|
||||
|
||||
Mapper.CreateMap<ItemFilterBlockGroup, ItemFilterBlockGroupViewModel>()
|
||||
.ForMember(destination => destination.ChildGroups, options => options.ResolveUsing(
|
||||
delegate(ResolutionResult resolutionResult)
|
||||
{
|
||||
var context = resolutionResult.Context;
|
||||
var showAdvanced = (bool) context.Options.Items["showAdvanced"];
|
||||
var group = (ItemFilterBlockGroup) context.SourceValue;
|
||||
if (showAdvanced)
|
||||
return group.ChildGroups;
|
||||
else
|
||||
return group.ChildGroups.Where(c => c.Advanced == false);
|
||||
}))
|
||||
.ForMember(dest => dest.SourceBlockGroup,
|
||||
opts => opts.MapFrom(from => from))
|
||||
.ForMember(dest => dest.IsExpanded,
|
||||
opts => opts.UseValue(false));
|
||||
|
||||
Mapper.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
|
||||
Mapper.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
|
||||
Mapper.CreateMap<IThemeEditorViewModel, Theme>();
|
||||
Mapper.Initialize(cfg =>
|
||||
{
|
||||
cfg.ConstructServicesUsing(_container.Resolve);
|
||||
cfg.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
|
||||
cfg.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
|
||||
cfg.CreateMap<IThemeEditorViewModel, Theme>();
|
||||
});
|
||||
|
||||
Mapper.AssertConfigurationIsValid();
|
||||
|
||||
@@ -73,7 +57,7 @@ namespace Filtration
|
||||
var updateCheckService = _container.Resolve<IUpdateCheckService>();
|
||||
updateCheckService.CheckForUpdates();
|
||||
}
|
||||
|
||||
|
||||
private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
Logger.Fatal(e.Exception);
|
||||
|
||||
@@ -57,20 +57,18 @@
|
||||
<ApplicationIcon>Resources\filtration.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMapper, Version=4.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AutoMapper.4.2.1\lib\net45\AutoMapper.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="AutoMapper, Version=6.0.2.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AutoMapper.6.0.2\lib\net45\AutoMapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Windsor">
|
||||
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
|
||||
<Reference Include="Castle.Windsor, Version=3.4.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Castle.Windsor.3.4.0\lib\net45\Castle.Windsor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ControlzEx, Version=2.1.2.3, Culture=neutral, PublicKeyToken=f08b075e934b7045, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ControlzEx.2.1.2.3\lib\net45\ControlzEx.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Reference Include="ControlzEx, Version=2.2.0.4, Culture=neutral, PublicKeyToken=f08b075e934b7045, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ControlzEx.2.2.0.4\lib\net45\ControlzEx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Fluent, Version=4.0.3.394, Culture=neutral, PublicKeyToken=3e436e32a8c5546f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Fluent.Ribbon.4.0.3.394\lib\net45\Fluent.dll</HintPath>
|
||||
@@ -94,8 +92,7 @@
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.3.7\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\NLog.4.4.9\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
@@ -109,8 +106,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ControlzEx.2.1.2.3\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\ControlzEx.2.2.0.4\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -200,19 +196,23 @@
|
||||
<Compile Include="UserControls\ThemeComponentSelectionControl.xaml.cs">
|
||||
<DependentUpon>ThemeComponentSelectionControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\AutoMapperHelpers.cs" />
|
||||
<Compile Include="Utilities\BlockGroupMapper.cs" />
|
||||
<Compile Include="Utility\RoutedCommandHandler.cs" />
|
||||
<Compile Include="Utility\RoutedCommandHandlers.cs" />
|
||||
<Compile Include="ViewModels\AvalonDockWorkspaceViewModel.cs" />
|
||||
<Compile Include="ViewModels\Factories\IItemFilterCommentBlockViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\Factories\ItemFilterBlockBaseViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterBlockViewModelBase.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterCommentBlockViewModel.cs" />
|
||||
<Compile Include="ViewModels\SettingsPageViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\BlockGroupBrowserViewModel.cs" />
|
||||
<Compile Include="ViewModels\IItemFilterScriptViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\IItemFilterBlockViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\Factories\IItemFilterScriptViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\Factories\IItemFilterBlockViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterBlockGroupViewModel.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterBlockViewModel.cs" />
|
||||
<Compile Include="ViewModels\ItemFilterScriptViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\BlockOutputPreviewViewModel.cs" />
|
||||
<Compile Include="ViewModels\ReplaceColorsViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\SectionBrowserViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\CommentBlockBrowserViewModel.cs" />
|
||||
<Compile Include="ViewModels\StartPageViewModel.cs" />
|
||||
<Compile Include="ViewModels\ToolPanes\ToolViewModel.cs" />
|
||||
<Compile Include="ViewModels\UpdateAvailableViewModel.cs" />
|
||||
@@ -241,7 +241,6 @@
|
||||
<Compile Include="Views\ToolPanes\BlockGroupBrowserView.xaml.cs">
|
||||
<DependentUpon>BlockGroupBrowserView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\BlockTemplateSelector.cs" />
|
||||
<Compile Include="Views\ItemFilterScriptView.xaml.cs">
|
||||
<DependentUpon>ItemFilterScriptView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -251,8 +250,8 @@
|
||||
<Compile Include="UserControls\NumericFilterPredicateControl.xaml.cs">
|
||||
<DependentUpon>NumericFilterPredicateControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ItemFilterSectionView.xaml.cs">
|
||||
<DependentUpon>ItemFilterSectionView.xaml</DependentUpon>
|
||||
<Compile Include="Views\ItemFilterCommentBlockView.xaml.cs">
|
||||
<DependentUpon>ItemFilterCommentBlockView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\AboutWindow.xaml.cs">
|
||||
<DependentUpon>AboutWindow.xaml</DependentUpon>
|
||||
@@ -266,9 +265,6 @@
|
||||
<Compile Include="Views\ToolPanes\BlockOutputPreviewView.xaml.cs">
|
||||
<DependentUpon>BlockOutputPreviewView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\ToolPanes\SectionBrowserView.xaml.cs">
|
||||
<DependentUpon>SectionBrowserView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\StartPageView.xaml.cs">
|
||||
<DependentUpon>StartPageView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -331,7 +327,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ToolPanes\SectionBrowserView.xaml">
|
||||
<Page Include="Views\ToolPanes\CommentBlockBrowserView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@@ -343,7 +339,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\ItemFilterSectionView.xaml">
|
||||
<Page Include="Views\ItemFilterCommentBlockView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.Factories;
|
||||
using Filtration.Services;
|
||||
using Filtration.ViewModels;
|
||||
using Filtration.ViewModels.Factories;
|
||||
|
||||
namespace Filtration.Repositories
|
||||
{
|
||||
@@ -16,12 +18,15 @@ namespace Filtration.Repositories
|
||||
internal class ItemFilterScriptRepository : IItemFilterScriptRepository
|
||||
{
|
||||
private readonly IItemFilterPersistenceService _itemFilterPersistenceService;
|
||||
private readonly IItemFilterScriptFactory _itemFilterScriptFactory;
|
||||
private readonly IItemFilterScriptViewModelFactory _itemFilterScriptViewModelFactory;
|
||||
|
||||
public ItemFilterScriptRepository(IItemFilterPersistenceService itemFilterPersistenceService,
|
||||
IItemFilterScriptFactory itemFilterScriptFactory,
|
||||
IItemFilterScriptViewModelFactory itemFilterScriptViewModelFactory)
|
||||
{
|
||||
_itemFilterPersistenceService = itemFilterPersistenceService;
|
||||
_itemFilterScriptFactory = itemFilterScriptFactory;
|
||||
_itemFilterScriptViewModelFactory = itemFilterScriptViewModelFactory;
|
||||
}
|
||||
|
||||
@@ -37,7 +42,7 @@ namespace Filtration.Repositories
|
||||
|
||||
public IItemFilterScriptViewModel NewScript()
|
||||
{
|
||||
var newScript = new ItemFilterScript();
|
||||
var newScript = _itemFilterScriptFactory.Create();
|
||||
var newViewModel = _itemFilterScriptViewModelFactory.Create();
|
||||
newViewModel.Initialise(newScript, true);
|
||||
|
||||
|
||||
BIN
Filtration/Resources/Icons/redo_icon.png
Normal file
BIN
Filtration/Resources/Icons/redo_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 579 B |
BIN
Filtration/Resources/Icons/undo_icon.png
Normal file
BIN
Filtration/Resources/Icons/undo_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 339 B |
@@ -11,8 +11,8 @@ namespace Filtration.Services
|
||||
{
|
||||
void SetItemFilterScriptDirectory(string path);
|
||||
string ItemFilterScriptDirectory { get; }
|
||||
Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath);
|
||||
Task SaveItemFilterScriptAsync(ItemFilterScript script);
|
||||
Task<IItemFilterScript> LoadItemFilterScriptAsync(string filePath);
|
||||
Task SaveItemFilterScriptAsync(IItemFilterScript script);
|
||||
string DefaultPathOfExileDirectory();
|
||||
}
|
||||
|
||||
@@ -59,9 +59,9 @@ namespace Filtration.Services
|
||||
Settings.Default.DefaultFilterDirectory = path;
|
||||
}
|
||||
|
||||
public async Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath)
|
||||
public async Task<IItemFilterScript> LoadItemFilterScriptAsync(string filePath)
|
||||
{
|
||||
ItemFilterScript loadedScript = null;
|
||||
IItemFilterScript loadedScript = null;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
loadedScript = _itemFilterScriptTranslator.TranslateStringToItemFilterScript(
|
||||
@@ -76,7 +76,7 @@ namespace Filtration.Services
|
||||
return loadedScript;
|
||||
}
|
||||
|
||||
public async Task SaveItemFilterScriptAsync(ItemFilterScript script)
|
||||
public async Task SaveItemFilterScriptAsync(IItemFilterScript script)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Common.Utilities;
|
||||
using Filtration.Utilities;
|
||||
|
||||
namespace Filtration.Services
|
||||
{
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
using System.Linq;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
namespace Filtration.Utilities
|
||||
{
|
||||
internal class AutoMapperHelpers
|
||||
{
|
||||
public static void ItemFilterBlockGroupViewModelPostMap(ItemFilterBlockGroupViewModel viewModel)
|
||||
{
|
||||
foreach (var childViewModel in viewModel.ChildGroups)
|
||||
{
|
||||
ItemFilterBlockGroupViewModelPostMap(childViewModel);
|
||||
}
|
||||
|
||||
if (viewModel.ChildGroups.Count > 0)
|
||||
{
|
||||
if (viewModel.ChildGroups.All(g => g.IsChecked == true))
|
||||
{
|
||||
viewModel.IsChecked = true;
|
||||
}
|
||||
else if (viewModel.ChildGroups.Any(g => g.IsChecked == true || g.IsChecked == null))
|
||||
{
|
||||
viewModel.IsChecked = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewModel.IsChecked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
namespace Filtration.Utilities
|
||||
{
|
||||
internal interface IBlockGroupMapper
|
||||
{
|
||||
ObservableCollection<ItemFilterBlockGroupViewModel> MapBlockGroupsToViewModels(
|
||||
ObservableCollection<ItemFilterBlockGroup> blockGroups, bool showAdvanced);
|
||||
}
|
||||
|
||||
internal class BlockGroupMapper : IBlockGroupMapper
|
||||
{
|
||||
public ObservableCollection<ItemFilterBlockGroupViewModel> MapBlockGroupsToViewModels(
|
||||
ObservableCollection<ItemFilterBlockGroup> blockGroups, bool showAdvanced)
|
||||
{
|
||||
|
||||
var mappedViewModels = Mapper.Map<ObservableCollection<ItemFilterBlockGroupViewModel>>(blockGroups, opts => opts.Items["showAdvanced"] = showAdvanced);
|
||||
AutoMapperHelpers.ItemFilterBlockGroupViewModelPostMap(mappedViewModels.First());
|
||||
return mappedViewModels.First().ChildGroups;
|
||||
}
|
||||
}
|
||||
}
|
||||
73
Filtration/Utility/RoutedCommandHandler.cs
Normal file
73
Filtration/Utility/RoutedCommandHandler.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Filtration.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows associated a routed command with a non-routed command. Used by
|
||||
/// <see cref="RoutedCommandHandlers"/>.
|
||||
/// </summary>
|
||||
public class RoutedCommandHandler : Freezable
|
||||
{
|
||||
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
|
||||
"Command",
|
||||
typeof(ICommand),
|
||||
typeof(RoutedCommandHandler),
|
||||
new PropertyMetadata(default(ICommand)));
|
||||
|
||||
/// <summary> The command that should be executed when the RoutedCommand fires. </summary>
|
||||
public ICommand Command
|
||||
{
|
||||
get => (ICommand)GetValue(CommandProperty);
|
||||
set => SetValue(CommandProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
|
||||
"IsActive", typeof(bool), typeof(RoutedCommandHandler), new PropertyMetadata(default(bool)));
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get { return (bool) GetValue(IsActiveProperty); }
|
||||
set { SetValue(IsActiveProperty, value); }
|
||||
}
|
||||
|
||||
/// <summary> The command that triggers <see cref="ICommand"/>. </summary>
|
||||
public ICommand RoutedCommand { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return new RoutedCommandHandler();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register this handler to respond to the registered RoutedCommand for the
|
||||
/// given element.
|
||||
/// </summary>
|
||||
/// <param name="owner"> The element for which we should register the command
|
||||
/// binding for the current routed command. </param>
|
||||
internal void Register(FrameworkElement owner)
|
||||
{
|
||||
var binding = new CommandBinding(RoutedCommand, HandleExecuted, HandleCanExecute);
|
||||
owner.CommandBindings.Add(binding);
|
||||
}
|
||||
|
||||
/// <summary> Proxy to the current Command.CanExecute(object). </summary>
|
||||
private void HandleCanExecute(object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
if (!IsActive) return;
|
||||
|
||||
e.CanExecute = Command?.CanExecute(e.Parameter) != null;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary> Proxy to the current Command.Execute(object). </summary>
|
||||
private void HandleExecuted(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
if (!IsActive) return;
|
||||
|
||||
Command?.Execute(e.Parameter);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
79
Filtration/Utility/RoutedCommandHandlers.cs
Normal file
79
Filtration/Utility/RoutedCommandHandlers.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows;
|
||||
|
||||
namespace Filtration.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds a collection of <see cref="RoutedCommandHandler"/> that should be
|
||||
/// turned into CommandBindings.
|
||||
/// </summary>
|
||||
public class RoutedCommandHandlers : FreezableCollection<RoutedCommandHandler>
|
||||
{
|
||||
/// <summary>
|
||||
/// Hide this from WPF so that it's forced to go through
|
||||
/// <see cref="GetCommands"/> and we can auto-create the collection
|
||||
/// if it doesn't already exist. This isn't strictly necessary but it makes
|
||||
/// the XAML much nicer.
|
||||
/// </summary>
|
||||
private static readonly DependencyProperty CommandsProperty = DependencyProperty.RegisterAttached(
|
||||
"CommandsPrivate",
|
||||
typeof(RoutedCommandHandlers),
|
||||
typeof(RoutedCommandHandlers),
|
||||
new PropertyMetadata(default(RoutedCommandHandlers)));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of RoutedCommandHandler for a given element, creating
|
||||
/// it if it doesn't already exist.
|
||||
/// </summary>
|
||||
public static RoutedCommandHandlers GetCommands(FrameworkElement element)
|
||||
{
|
||||
RoutedCommandHandlers handlers = (RoutedCommandHandlers)element.GetValue(CommandsProperty);
|
||||
if (handlers == null)
|
||||
{
|
||||
handlers = new RoutedCommandHandlers(element);
|
||||
element.SetValue(CommandsProperty, handlers);
|
||||
}
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private readonly FrameworkElement _owner;
|
||||
|
||||
/// <summary> Each collection is tied to a specific element. </summary>
|
||||
/// <param name="owner"> The element for which this collection is created. </param>
|
||||
public RoutedCommandHandlers(FrameworkElement owner)
|
||||
{
|
||||
_owner = owner;
|
||||
|
||||
// because we auto-create the collection, we don't know when items will be
|
||||
// added. So, we observe ourself for changes manually.
|
||||
var self = (INotifyCollectionChanged)this;
|
||||
self.CollectionChanged += (sender, args) =>
|
||||
{
|
||||
// note this does not handle deletions, that's left as an exercise for the
|
||||
// reader, but most of the time, that's not needed!
|
||||
((RoutedCommandHandlers)sender).HandleAdditions(args.NewItems);
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary> Invoked when new items are added to the collection. </summary>
|
||||
/// <param name="newItems"> The new items that were added. </param>
|
||||
private void HandleAdditions(IList newItems)
|
||||
{
|
||||
if (newItems == null)
|
||||
return;
|
||||
|
||||
foreach (RoutedCommandHandler routedHandler in newItems)
|
||||
{
|
||||
routedHandler.Register(_owner);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return new RoutedCommandHandlers(_owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ThemeEditor.ViewModels;
|
||||
@@ -18,7 +19,7 @@ namespace Filtration.ViewModels
|
||||
ReadOnlyObservableCollection<IDocument> OpenDocuments { get; }
|
||||
IItemFilterScriptViewModel ActiveScriptViewModel { get; }
|
||||
IThemeEditorViewModel ActiveThemeViewModel { get; }
|
||||
ISectionBrowserViewModel SectionBrowserViewModel { get; }
|
||||
ICommentBlockBrowserViewModel CommentBlockBrowserViewModel { get; }
|
||||
IBlockGroupBrowserViewModel BlockGroupBrowserViewModel { get; }
|
||||
IBlockOutputPreviewViewModel BlockOutputPreviewViewModel { get; }
|
||||
void AddDocument(IDocument document);
|
||||
@@ -29,7 +30,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
internal class AvalonDockWorkspaceViewModel : ViewModelBase, IAvalonDockWorkspaceViewModel
|
||||
{
|
||||
private readonly ISectionBrowserViewModel _sectionBrowserViewModel;
|
||||
private readonly ICommentBlockBrowserViewModel _commentBlockBrowserViewModel;
|
||||
private readonly IBlockGroupBrowserViewModel _blockGroupBrowserViewModel;
|
||||
private readonly IBlockOutputPreviewViewModel _blockOutputPreviewViewModel;
|
||||
|
||||
@@ -38,16 +39,16 @@ namespace Filtration.ViewModels
|
||||
private IThemeEditorViewModel _activeThemeViewModel;
|
||||
private readonly ObservableCollection<IDocument> _openDocuments;
|
||||
|
||||
public AvalonDockWorkspaceViewModel(ISectionBrowserViewModel sectionBrowserViewModel,
|
||||
public AvalonDockWorkspaceViewModel(ICommentBlockBrowserViewModel commentBlockBrowserViewModel,
|
||||
IBlockGroupBrowserViewModel blockGroupBrowserViewModel,
|
||||
IStartPageViewModel startPageViewModel,
|
||||
IBlockOutputPreviewViewModel blockOutputPreviewViewModel)
|
||||
{
|
||||
_sectionBrowserViewModel = sectionBrowserViewModel;
|
||||
_commentBlockBrowserViewModel = commentBlockBrowserViewModel;
|
||||
_blockGroupBrowserViewModel = blockGroupBrowserViewModel;
|
||||
_blockOutputPreviewViewModel = blockOutputPreviewViewModel;
|
||||
|
||||
_sectionBrowserViewModel.Initialise(this);
|
||||
_commentBlockBrowserViewModel.Initialise(this);
|
||||
_blockGroupBrowserViewModel.Initialise(this);
|
||||
_blockOutputPreviewViewModel.Initialise(this);
|
||||
|
||||
@@ -94,13 +95,13 @@ namespace Filtration.ViewModels
|
||||
public IThemeEditorViewModel ActiveThemeViewModel => _activeThemeViewModel;
|
||||
public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel => _blockGroupBrowserViewModel;
|
||||
public IBlockOutputPreviewViewModel BlockOutputPreviewViewModel => _blockOutputPreviewViewModel;
|
||||
public ISectionBrowserViewModel SectionBrowserViewModel => _sectionBrowserViewModel;
|
||||
public ICommentBlockBrowserViewModel CommentBlockBrowserViewModel => _commentBlockBrowserViewModel;
|
||||
|
||||
private List<IToolViewModel> _tools;
|
||||
|
||||
public IEnumerable<IToolViewModel> Tools => _tools ?? (_tools = new List<IToolViewModel>
|
||||
{
|
||||
_sectionBrowserViewModel,
|
||||
_commentBlockBrowserViewModel,
|
||||
_blockGroupBrowserViewModel,
|
||||
_blockOutputPreviewViewModel
|
||||
});
|
||||
@@ -116,7 +117,7 @@ namespace Filtration.ViewModels
|
||||
_activeThemeViewModel = (IThemeEditorViewModel) document;
|
||||
}
|
||||
|
||||
_openDocuments.Add(document);
|
||||
Application.Current.Dispatcher.Invoke(() => _openDocuments.Add(document));
|
||||
ActiveDocument = document;
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
if (document.IsScript && ActiveDocument == document)
|
||||
{
|
||||
_sectionBrowserViewModel.ClearDown();
|
||||
_commentBlockBrowserViewModel.ClearDown();
|
||||
_blockGroupBrowserViewModel.ClearDown();
|
||||
_blockOutputPreviewViewModel.ClearDown();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Filtration.ViewModels
|
||||
namespace Filtration.ViewModels.Factories
|
||||
{
|
||||
internal interface IItemFilterBlockViewModelFactory
|
||||
{
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Filtration.ViewModels.Factories
|
||||
{
|
||||
internal interface IItemFilterCommentBlockViewModelFactory
|
||||
{
|
||||
IItemFilterCommentBlockViewModel Create();
|
||||
void Release(IItemFilterCommentBlockViewModel itemFilterCommentBlockViewModel);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Filtration.ViewModels
|
||||
namespace Filtration.ViewModels.Factories
|
||||
{
|
||||
internal interface IItemFilterScriptViewModelFactory
|
||||
{
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Filtration.ObjectModel;
|
||||
|
||||
namespace Filtration.ViewModels.Factories
|
||||
{
|
||||
internal interface IItemFilterBlockBaseViewModelFactory
|
||||
{
|
||||
IItemFilterBlockViewModelBase Create(IItemFilterBlockBase itemFilterBlockBase);
|
||||
}
|
||||
|
||||
internal class ItemFilterBlockBaseViewModelFactory : IItemFilterBlockBaseViewModelFactory
|
||||
{
|
||||
private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory;
|
||||
private readonly IItemFilterCommentBlockViewModelFactory _itemFilterCommentBlockViewModelFactory;
|
||||
|
||||
public ItemFilterBlockBaseViewModelFactory(IItemFilterBlockViewModelFactory itemFilterBlockViewModelFactory,
|
||||
IItemFilterCommentBlockViewModelFactory itemFilterCommentBlockViewModelFactory)
|
||||
{
|
||||
_itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
|
||||
_itemFilterCommentBlockViewModelFactory = itemFilterCommentBlockViewModelFactory;
|
||||
}
|
||||
|
||||
public IItemFilterBlockViewModelBase Create(IItemFilterBlockBase itemFilterBlockBase)
|
||||
{
|
||||
if (itemFilterBlockBase is IItemFilterBlock)
|
||||
{
|
||||
return _itemFilterBlockViewModelFactory.Create();
|
||||
}
|
||||
if (itemFilterBlockBase is IItemFilterCommentBlock)
|
||||
{
|
||||
return _itemFilterCommentBlockViewModelFactory.Create();
|
||||
}
|
||||
|
||||
throw new InvalidOperationException("Unknown IItemFilterBlockBase type");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,42 @@ namespace Filtration.ViewModels
|
||||
ChildGroups = new ObservableCollection<ItemFilterBlockGroupViewModel>();
|
||||
}
|
||||
|
||||
public ItemFilterBlockGroupViewModel(ItemFilterBlockGroup itemFilterBlockGroup, bool showAdvanced, ItemFilterBlockGroupViewModel parent)
|
||||
{
|
||||
GroupName = itemFilterBlockGroup.GroupName;
|
||||
ParentGroup = parent;
|
||||
Advanced = itemFilterBlockGroup.Advanced;
|
||||
SourceBlockGroup = itemFilterBlockGroup;
|
||||
IsChecked = itemFilterBlockGroup.IsChecked;
|
||||
|
||||
ChildGroups = new ObservableCollection<ItemFilterBlockGroupViewModel>();
|
||||
foreach (var childGroup in itemFilterBlockGroup.ChildGroups.Where(c => showAdvanced || !c.Advanced))
|
||||
{
|
||||
ChildGroups.Add(new ItemFilterBlockGroupViewModel(childGroup, showAdvanced, this));
|
||||
}
|
||||
|
||||
if (ChildGroups.Any())
|
||||
{
|
||||
SetIsCheckedBasedOnChildGroups();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetIsCheckedBasedOnChildGroups()
|
||||
{
|
||||
if (ChildGroups.All(g => g.IsChecked == true))
|
||||
{
|
||||
IsChecked = true;
|
||||
}
|
||||
else if (ChildGroups.Any(g => g.IsChecked == true || g.IsChecked == null))
|
||||
{
|
||||
IsChecked = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
public string GroupName { get; internal set; }
|
||||
public ItemFilterBlockGroupViewModel ParentGroup { get; internal set; }
|
||||
public ObservableCollection<ItemFilterBlockGroupViewModel> ChildGroups { get; internal set; }
|
||||
|
||||
@@ -4,23 +4,18 @@ using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.Services;
|
||||
using Filtration.Views;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using Xceed.Wpf.Toolkit;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
internal interface IItemFilterBlockViewModel
|
||||
internal interface IItemFilterBlockViewModel : IItemFilterBlockViewModelBase
|
||||
{
|
||||
event EventHandler BlockBecameDirty;
|
||||
void Initialise(IItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel);
|
||||
bool IsDirty { get; set; }
|
||||
bool IsExpanded { get; set; }
|
||||
IItemFilterBlock Block { get; }
|
||||
bool BlockEnabled { get; set; }
|
||||
@@ -28,17 +23,16 @@ namespace Filtration.ViewModels
|
||||
void RefreshBlockPreview();
|
||||
}
|
||||
|
||||
internal class ItemFilterBlockViewModel : ViewModelBase, IItemFilterBlockViewModel
|
||||
internal class ItemFilterBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterBlockViewModel
|
||||
{
|
||||
private readonly IStaticDataService _staticDataService;
|
||||
private readonly IReplaceColorsViewModel _replaceColorsViewModel;
|
||||
private readonly MediaPlayer _mediaPlayer = new MediaPlayer();
|
||||
private ItemFilterScriptViewModel _parentScriptViewModel;
|
||||
private IItemFilterScriptViewModel _parentScriptViewModel;
|
||||
|
||||
private bool _displaySettingsPopupOpen;
|
||||
private bool _isExpanded;
|
||||
private bool _audioVisualBlockItemsGridVisible;
|
||||
private bool _isDirty;
|
||||
|
||||
public ItemFilterBlockViewModel(IStaticDataService staticDataService, IReplaceColorsViewModel replaceColorsViewModel)
|
||||
{
|
||||
@@ -65,10 +59,9 @@ namespace Filtration.ViewModels
|
||||
PlayPositionalSoundCommand = new RelayCommand(OnPlayPositionalSoundCommand, () => HasPositionalSound);
|
||||
}
|
||||
|
||||
public event EventHandler BlockBecameDirty;
|
||||
|
||||
public void Initialise(IItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel)
|
||||
public override void Initialise(IItemFilterBlockBase itemFilterBlockBase, IItemFilterScriptViewModel parentScriptViewModel)
|
||||
{
|
||||
var itemFilterBlock = itemFilterBlockBase as IItemFilterBlock;
|
||||
if (itemFilterBlock == null || parentScriptViewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(itemFilterBlock));
|
||||
@@ -77,52 +70,43 @@ namespace Filtration.ViewModels
|
||||
_parentScriptViewModel = parentScriptViewModel;
|
||||
|
||||
Block = itemFilterBlock;
|
||||
|
||||
itemFilterBlock.BlockItems.CollectionChanged += OnBlockItemsCollectionChanged;
|
||||
|
||||
foreach (var blockItem in itemFilterBlock.BlockItems)
|
||||
{
|
||||
blockItem.PropertyChanged += OnBlockItemChanged;
|
||||
}
|
||||
|
||||
|
||||
base.Initialise(itemFilterBlock, parentScriptViewModel);
|
||||
}
|
||||
|
||||
public RelayCommand CopyBlockCommand { get; private set; }
|
||||
public RelayCommand PasteBlockCommand { get; private set; }
|
||||
public RelayCommand CopyBlockStyleCommand { get; private set; }
|
||||
public RelayCommand PasteBlockStyleCommand { get; private set; }
|
||||
public RelayCommand AddBlockCommand { get; private set; }
|
||||
public RelayCommand AddSectionCommand { get; private set; }
|
||||
public RelayCommand DeleteBlockCommand { get; private set; }
|
||||
public RelayCommand MoveBlockUpCommand { get; private set; }
|
||||
public RelayCommand MoveBlockDownCommand { get; private set; }
|
||||
public RelayCommand MoveBlockToTopCommand { get; private set; }
|
||||
public RelayCommand MoveBlockToBottomCommand { get; private set; }
|
||||
public RelayCommand ToggleBlockActionCommand { get; private set; }
|
||||
public RelayCommand ReplaceColorsCommand { get; private set; }
|
||||
public RelayCommand<Type> AddFilterBlockItemCommand { get; private set; }
|
||||
public RelayCommand<IItemFilterBlockItem> RemoveFilterBlockItemCommand { get; private set; }
|
||||
public RelayCommand PlaySoundCommand { get; private set; }
|
||||
public RelayCommand PlayPositionalSoundCommand { get; private set; }
|
||||
public RelayCommand SwitchBlockItemsViewCommand { get; private set; }
|
||||
public RelayCommand CopyBlockCommand { get; }
|
||||
public RelayCommand PasteBlockCommand { get; }
|
||||
public RelayCommand CopyBlockStyleCommand { get; }
|
||||
public RelayCommand PasteBlockStyleCommand { get; }
|
||||
public RelayCommand AddBlockCommand { get; }
|
||||
public RelayCommand AddSectionCommand { get; }
|
||||
public RelayCommand DeleteBlockCommand { get; }
|
||||
public RelayCommand MoveBlockUpCommand { get; }
|
||||
public RelayCommand MoveBlockDownCommand { get; }
|
||||
public RelayCommand MoveBlockToTopCommand { get; }
|
||||
public RelayCommand MoveBlockToBottomCommand { get; }
|
||||
public RelayCommand ToggleBlockActionCommand { get; }
|
||||
public RelayCommand ReplaceColorsCommand { get; }
|
||||
public RelayCommand<Type> AddFilterBlockItemCommand { get; }
|
||||
public RelayCommand<IItemFilterBlockItem> RemoveFilterBlockItemCommand { get; }
|
||||
public RelayCommand PlaySoundCommand { get; }
|
||||
public RelayCommand PlayPositionalSoundCommand { get; }
|
||||
public RelayCommand SwitchBlockItemsViewCommand { get; }
|
||||
|
||||
public IItemFilterBlock Block { get; private set; }
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get { return _isDirty; }
|
||||
set
|
||||
{
|
||||
if (value != _isDirty)
|
||||
{
|
||||
_isDirty = value;
|
||||
RaisePropertyChanged();
|
||||
BlockBecameDirty?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get { return _isExpanded; }
|
||||
get => _isExpanded;
|
||||
set
|
||||
{
|
||||
_isExpanded = value;
|
||||
@@ -312,7 +296,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
private void OnAddSectionCommand()
|
||||
{
|
||||
_parentScriptViewModel.AddSection(this);
|
||||
_parentScriptViewModel.AddCommentBlock(this);
|
||||
}
|
||||
|
||||
private void OnDeleteBlockCommand()
|
||||
|
||||
42
Filtration/ViewModels/ItemFilterBlockViewModelBase.cs
Normal file
42
Filtration/ViewModels/ItemFilterBlockViewModelBase.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Filtration.ObjectModel;
|
||||
using GalaSoft.MvvmLight;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
internal interface IItemFilterBlockViewModelBase
|
||||
{
|
||||
void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel);
|
||||
IItemFilterBlockBase BaseBlock { get; }
|
||||
bool IsDirty { get; set; }
|
||||
event EventHandler BlockBecameDirty;
|
||||
}
|
||||
|
||||
internal abstract class ItemFilterBlockViewModelBase : ViewModelBase, IItemFilterBlockViewModelBase
|
||||
{
|
||||
private bool _isDirty;
|
||||
|
||||
public virtual void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
|
||||
{
|
||||
BaseBlock = itemfilterBlock;
|
||||
}
|
||||
|
||||
public event EventHandler BlockBecameDirty;
|
||||
|
||||
public IItemFilterBlockBase BaseBlock { get; protected set; }
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get => _isDirty;
|
||||
set
|
||||
{
|
||||
if (value != _isDirty)
|
||||
{
|
||||
_isDirty = value;
|
||||
RaisePropertyChanged();
|
||||
BlockBecameDirty?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Filtration/ViewModels/ItemFilterCommentBlockViewModel.cs
Normal file
29
Filtration/ViewModels/ItemFilterCommentBlockViewModel.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Filtration.ObjectModel;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
internal interface IItemFilterCommentBlockViewModel : IItemFilterBlockViewModelBase
|
||||
{
|
||||
IItemFilterCommentBlock ItemFilterCommentBlock { get; }
|
||||
string Comment { get; }
|
||||
}
|
||||
|
||||
internal class ItemFilterCommentBlockViewModel : ItemFilterBlockViewModelBase, IItemFilterCommentBlockViewModel
|
||||
{
|
||||
public ItemFilterCommentBlockViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Initialise(IItemFilterBlockBase itemfilterBlock, IItemFilterScriptViewModel itemFilterScriptViewModel)
|
||||
{
|
||||
ItemFilterCommentBlock = itemfilterBlock as IItemFilterCommentBlock;
|
||||
BaseBlock = ItemFilterCommentBlock;
|
||||
|
||||
base.Initialise(itemfilterBlock, itemFilterScriptViewModel);
|
||||
}
|
||||
|
||||
public IItemFilterCommentBlock ItemFilterCommentBlock { get; private set; }
|
||||
|
||||
public string Comment => ItemFilterCommentBlock.Comment;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -14,8 +16,11 @@ using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Commands;
|
||||
using Filtration.ObjectModel.Commands.ItemFilterScript;
|
||||
using Filtration.Parser.Interface.Services;
|
||||
using Filtration.Services;
|
||||
using Filtration.ViewModels.Factories;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using NLog;
|
||||
@@ -24,17 +29,17 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
internal interface IItemFilterScriptViewModel : IEditableDocument
|
||||
{
|
||||
ItemFilterScript Script { get; }
|
||||
IItemFilterBlockViewModel SelectedBlockViewModel { get; set; }
|
||||
IItemFilterBlockViewModel SectionBrowserSelectedBlockViewModel { get; set; }
|
||||
IEnumerable<IItemFilterBlockViewModel> ItemFilterSectionViewModels { get; }
|
||||
IItemFilterScript Script { get; }
|
||||
IItemFilterBlockViewModelBase SelectedBlockViewModel { get; set; }
|
||||
IItemFilterCommentBlockViewModel CommentBlockBrowserBrowserSelectedBlockViewModel { get; set; }
|
||||
IEnumerable<IItemFilterCommentBlockViewModel> ItemFilterCommentBlockViewModels { get; }
|
||||
Predicate<IItemFilterBlockViewModel> BlockFilterPredicate { get; set; }
|
||||
|
||||
bool ShowAdvanced { get; }
|
||||
string Description { get; set; }
|
||||
string DisplayName { get; }
|
||||
|
||||
void Initialise(ItemFilterScript itemFilterScript, bool newScript);
|
||||
void Initialise(IItemFilterScript itemFilterScript, bool newScript);
|
||||
void RemoveDirtyFlag();
|
||||
void SetDirtyFlag();
|
||||
bool HasSelectedEnabledBlock();
|
||||
@@ -58,19 +63,24 @@ namespace Filtration.ViewModels
|
||||
RelayCommand<bool> ToggleShowAdvancedCommand { get; }
|
||||
RelayCommand ClearFilterCommand { get; }
|
||||
|
||||
void AddSection(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void AddBlock(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void AddCommentBlock(IItemFilterBlockViewModelBase targetBlockViewModel);
|
||||
void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModel);
|
||||
void CopyBlock(IItemFilterBlockViewModelBase targetBlockViewModel);
|
||||
void CopyBlockStyle(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void PasteBlock(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void PasteBlock(IItemFilterBlockViewModelBase targetBlockViewModel);
|
||||
void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel);
|
||||
void DeleteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
void MoveBlockToTop(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
void MoveBlockUp(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
void MoveBlockDown(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
void MoveBlockToBottom(IItemFilterBlockViewModelBase targetBlockViewModelBase);
|
||||
}
|
||||
|
||||
internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory;
|
||||
private readonly IItemFilterBlockBaseViewModelFactory _itemFilterBlockBaseViewModelFactory;
|
||||
private readonly IItemFilterBlockTranslator _blockTranslator;
|
||||
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
||||
private readonly IItemFilterPersistenceService _persistenceService;
|
||||
@@ -79,13 +89,14 @@ namespace Filtration.ViewModels
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
|
||||
private bool _isDirty;
|
||||
private IItemFilterBlockViewModel _selectedBlockViewModel;
|
||||
private IItemFilterBlockViewModel _sectionBrowserSelectedBlockViewModel;
|
||||
private readonly ObservableCollection<IItemFilterBlockViewModel> _itemFilterBlockViewModels;
|
||||
private IItemFilterBlockViewModelBase _selectedBlockViewModel;
|
||||
private IItemFilterCommentBlockViewModel _sectionBrowserSelectedBlockViewModel;
|
||||
private readonly ObservableCollection<IItemFilterBlockViewModelBase> _itemFilterBlockViewModels;
|
||||
private ICollectionView _itemFilterBlockViewModelsCollectionView;
|
||||
private Predicate<IItemFilterBlockViewModel> _blockFilterPredicate;
|
||||
private ICommandManager _scriptCommandManager;
|
||||
|
||||
public ItemFilterScriptViewModel(IItemFilterBlockViewModelFactory itemFilterBlockViewModelFactory,
|
||||
public ItemFilterScriptViewModel(IItemFilterBlockBaseViewModelFactory itemFilterBlockBaseViewModelFactory,
|
||||
IItemFilterBlockTranslator blockTranslator,
|
||||
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
|
||||
IItemFilterPersistenceService persistenceService,
|
||||
@@ -93,7 +104,7 @@ namespace Filtration.ViewModels
|
||||
IClipboardService clipboardService,
|
||||
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||
{
|
||||
_itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
|
||||
_itemFilterBlockBaseViewModelFactory = itemFilterBlockBaseViewModelFactory;
|
||||
_blockTranslator = blockTranslator;
|
||||
_avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
|
||||
_avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
|
||||
@@ -101,18 +112,23 @@ namespace Filtration.ViewModels
|
||||
_messageBoxService = messageBoxService;
|
||||
_clipboardService = clipboardService;
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
|
||||
|
||||
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModelBase>();
|
||||
|
||||
_avalonDockWorkspaceViewModel.ActiveDocumentChanged += (s, e) =>
|
||||
{
|
||||
RaisePropertyChanged(nameof(IsActiveDocument));
|
||||
};
|
||||
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
|
||||
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
|
||||
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) > 0);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) > 0);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) < ItemFilterBlockViewModels.Count);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null && ItemFilterBlockViewModels.IndexOf(SelectedBlockViewModel) < ItemFilterBlockViewModels.Count);
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
|
||||
AddSectionCommand = new RelayCommand(OnAddCommentBlockCommand, () => SelectedBlockViewModel != null);
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
|
||||
@@ -129,6 +145,94 @@ namespace Filtration.ViewModels
|
||||
IconSource = icon;
|
||||
}
|
||||
|
||||
public void Initialise(IItemFilterScript itemFilterScript, bool newScript)
|
||||
{
|
||||
ItemFilterBlockViewModels.Clear();
|
||||
|
||||
Script = itemFilterScript;
|
||||
_scriptCommandManager = Script.CommandManager;
|
||||
AddItemFilterBlockViewModels(Script.ItemFilterBlocks, -1);
|
||||
|
||||
Script.ItemFilterBlocks.CollectionChanged += ItemFilterBlocksOnCollectionChanged;
|
||||
|
||||
_filenameIsFake = newScript;
|
||||
|
||||
if (newScript)
|
||||
{
|
||||
Script.FilePath = "Untitled.filter";
|
||||
}
|
||||
|
||||
Title = Filename;
|
||||
ContentId = "ScriptContentId";
|
||||
}
|
||||
|
||||
private void ItemFilterBlocksOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs)
|
||||
{
|
||||
switch (notifyCollectionChangedEventArgs.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
{
|
||||
AddItemFilterBlockViewModels(notifyCollectionChangedEventArgs.NewItems.Cast<IItemFilterBlockBase>(), notifyCollectionChangedEventArgs.NewStartingIndex);
|
||||
break;
|
||||
}
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
{
|
||||
RemoveItemFilterBlockviewModels(notifyCollectionChangedEventArgs.OldItems.Cast<IItemFilterBlockBase>());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Debugger.Break(); // Unhandled NotifyCollectionChangedAction
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddItemFilterBlockViewModels(IEnumerable<IItemFilterBlockBase> itemFilterBlocks, int addAtIndex)
|
||||
{
|
||||
var firstNewViewModel = true;
|
||||
|
||||
foreach (var itemFilterBlock in itemFilterBlocks)
|
||||
{
|
||||
var vm = _itemFilterBlockBaseViewModelFactory.Create(itemFilterBlock);
|
||||
vm.Initialise(itemFilterBlock, this);
|
||||
vm.BlockBecameDirty += OnBlockBecameDirty;
|
||||
|
||||
if (addAtIndex == -1)
|
||||
{
|
||||
ItemFilterBlockViewModels.Add(vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemFilterBlockViewModels.Insert(addAtIndex, vm);
|
||||
}
|
||||
|
||||
if (firstNewViewModel)
|
||||
{
|
||||
SelectedBlockViewModel = vm;
|
||||
firstNewViewModel = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveItemFilterBlockviewModels(IEnumerable<IItemFilterBlockBase> itemFilterBlocks)
|
||||
{
|
||||
foreach (var itemFilterBlock in itemFilterBlocks)
|
||||
{
|
||||
var itemFilterBlockViewModel = ItemFilterBlockViewModels.FirstOrDefault(f => f.BaseBlock == itemFilterBlock);
|
||||
if (itemFilterBlockViewModel == null)
|
||||
{
|
||||
throw new InvalidOperationException("Item Filter Block removed from model but does not exist in view model!");
|
||||
}
|
||||
|
||||
ItemFilterBlockViewModels.Remove(itemFilterBlockViewModel);
|
||||
if (SelectedBlockViewModel == itemFilterBlockViewModel)
|
||||
{
|
||||
SelectedBlockViewModel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand<bool> ToggleShowAdvancedCommand { get; }
|
||||
public RelayCommand ClearFilterCommand { get; }
|
||||
public RelayCommand CloseCommand { get; }
|
||||
@@ -148,7 +252,19 @@ namespace Filtration.ViewModels
|
||||
public RelayCommand ExpandAllBlocksCommand { get; }
|
||||
public RelayCommand CollapseAllBlocksCommand { get; }
|
||||
|
||||
public ObservableCollection<IItemFilterBlockViewModel> ItemFilterBlockViewModels
|
||||
public bool IsActiveDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
var isActiveDocument = _avalonDockWorkspaceViewModel.ActiveScriptViewModel == this;
|
||||
Debug.WriteLine($"IsActiveDocument: {isActiveDocument}");
|
||||
|
||||
return isActiveDocument;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<IItemFilterBlockViewModelBase> ItemFilterBlockViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -162,6 +278,8 @@ namespace Filtration.ViewModels
|
||||
|
||||
private bool BlockFilter(object item)
|
||||
{
|
||||
if (!(item is IItemFilterBlockViewModelBase)) return false;
|
||||
if (item is IItemFilterCommentBlockViewModel) return true;
|
||||
var blockViewModel = item as IItemFilterBlockViewModel;
|
||||
|
||||
if (BlockFilterPredicate != null)
|
||||
@@ -190,62 +308,60 @@ namespace Filtration.ViewModels
|
||||
|
||||
public Predicate<IItemFilterBlockViewModel> BlockFilterPredicate
|
||||
{
|
||||
get { return _blockFilterPredicate; }
|
||||
get => _blockFilterPredicate;
|
||||
set
|
||||
{
|
||||
_blockFilterPredicate = value;
|
||||
RaisePropertyChanged("ItemFilterBlockViewModels");
|
||||
RaisePropertyChanged(nameof(ItemFilterBlockViewModels));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IItemFilterBlockViewModel> ItemFilterSectionViewModels
|
||||
{
|
||||
get { return ItemFilterBlockViewModels.Where(b => b.Block.GetType() == typeof (ItemFilterSection)); }
|
||||
}
|
||||
public IEnumerable<IItemFilterCommentBlockViewModel> ItemFilterCommentBlockViewModels => ItemFilterBlockViewModels.OfType<IItemFilterCommentBlockViewModel>();
|
||||
|
||||
public bool IsScript => true;
|
||||
public bool IsTheme => false;
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return Script.Description; }
|
||||
set
|
||||
{
|
||||
Script.Description = value;
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
get => Script.Description;
|
||||
set => _scriptCommandManager.ExecuteCommand(new SetScriptDescriptionCommand(Script, value));
|
||||
}
|
||||
|
||||
public bool ShowAdvanced
|
||||
{
|
||||
get { return _showAdvanced; }
|
||||
get => _showAdvanced;
|
||||
private set
|
||||
{
|
||||
_showAdvanced = value;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged("ItemFilterBlockViewModels");
|
||||
RaisePropertyChanged(nameof(ItemFilterBlockViewModels));
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasSelectedBlock()
|
||||
{
|
||||
return SelectedBlockViewModel != null;
|
||||
}
|
||||
|
||||
public bool HasSelectedEnabledBlock()
|
||||
{
|
||||
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && SelectedBlockViewModel.BlockEnabled;
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterBlockViewModel;
|
||||
if (selectedBlockViewModel == null) return false;
|
||||
|
||||
return HasSelectedBlock() && selectedBlockViewModel.BlockEnabled;
|
||||
}
|
||||
|
||||
public bool HasSelectedDisabledBlock()
|
||||
{
|
||||
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && !SelectedBlockViewModel.BlockEnabled;
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterBlockViewModel;
|
||||
if (selectedBlockViewModel == null) return false;
|
||||
|
||||
return HasSelectedBlock() && !selectedBlockViewModel.BlockEnabled;
|
||||
}
|
||||
|
||||
public IItemFilterBlockViewModel SelectedBlockViewModel
|
||||
private bool HasSelectedBlock()
|
||||
{
|
||||
get { return _selectedBlockViewModel; }
|
||||
return SelectedBlockViewModel != null;
|
||||
}
|
||||
|
||||
public IItemFilterBlockViewModelBase SelectedBlockViewModel
|
||||
{
|
||||
get => _selectedBlockViewModel;
|
||||
set
|
||||
{
|
||||
if (value != _selectedBlockViewModel)
|
||||
@@ -257,9 +373,9 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public IItemFilterBlockViewModel SectionBrowserSelectedBlockViewModel
|
||||
public IItemFilterCommentBlockViewModel CommentBlockBrowserBrowserSelectedBlockViewModel
|
||||
{
|
||||
get { return _sectionBrowserSelectedBlockViewModel; }
|
||||
get => _sectionBrowserSelectedBlockViewModel;
|
||||
set
|
||||
{
|
||||
_sectionBrowserSelectedBlockViewModel = value;
|
||||
@@ -268,11 +384,11 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public ItemFilterScript Script { get; private set; }
|
||||
public IItemFilterScript Script { get; private set; }
|
||||
|
||||
public bool IsDirty
|
||||
{
|
||||
get { return _isDirty || HasDirtyChildren; }
|
||||
get => _isDirty || HasDirtyChildren;
|
||||
set
|
||||
{
|
||||
if (_isDirty != value)
|
||||
@@ -295,15 +411,15 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
CleanChildren();
|
||||
IsDirty = false;
|
||||
RaisePropertyChanged("Filename");
|
||||
RaisePropertyChanged("DisplayName");
|
||||
RaisePropertyChanged(nameof(Filename));
|
||||
RaisePropertyChanged(nameof(DisplayName));
|
||||
}
|
||||
|
||||
public void SetDirtyFlag()
|
||||
{
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged("Filename");
|
||||
RaisePropertyChanged("DisplayName");
|
||||
RaisePropertyChanged(nameof(Filename));
|
||||
RaisePropertyChanged(nameof(DisplayName));
|
||||
}
|
||||
|
||||
public string DisplayName => !string.IsNullOrEmpty(Filename) ? Filename : Description;
|
||||
@@ -314,36 +430,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
private bool _filenameIsFake;
|
||||
private bool _showAdvanced;
|
||||
|
||||
public void Initialise(ItemFilterScript itemFilterScript, bool newScript)
|
||||
{
|
||||
ItemFilterBlockViewModels.Clear();
|
||||
|
||||
Script = itemFilterScript;
|
||||
foreach (var block in Script.ItemFilterBlocks)
|
||||
{
|
||||
var vm = _itemFilterBlockViewModelFactory.Create();
|
||||
vm.Initialise(block, this);
|
||||
vm.BlockBecameDirty += OnBlockBecameDirty;
|
||||
ItemFilterBlockViewModels.Add(vm);
|
||||
}
|
||||
|
||||
_filenameIsFake = newScript;
|
||||
|
||||
if (newScript)
|
||||
{
|
||||
Script.FilePath = "Untitled.filter";
|
||||
}
|
||||
|
||||
if (ItemFilterBlockViewModels.Count > 0)
|
||||
{
|
||||
SelectedBlockViewModel = ItemFilterBlockViewModels.First();
|
||||
}
|
||||
|
||||
Title = Filename;
|
||||
ContentId = "ScriptContentId";
|
||||
}
|
||||
|
||||
|
||||
public async Task SaveAsync()
|
||||
{
|
||||
if (!ValidateScript()) return;
|
||||
@@ -426,7 +513,7 @@ namespace Filtration.ViewModels
|
||||
var unusedThemeComponents =
|
||||
Script.ThemeComponents.Where(
|
||||
t =>
|
||||
Script.ItemFilterBlocks.Count(
|
||||
Script.ItemFilterBlocks.OfType<ItemFilterBlock>().Count(
|
||||
b => b.BlockItems.OfType<ColorBlockItem>().Count(i => i.ThemeComponent == t) > 0) == 0).ToList();
|
||||
|
||||
if (unusedThemeComponents.Count <= 0) return true;
|
||||
@@ -550,23 +637,25 @@ namespace Filtration.ViewModels
|
||||
CopyBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
public void CopyBlock(IItemFilterBlockViewModelBase targetBlockViewModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
_clipboardService.SetClipboardText(
|
||||
_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block));
|
||||
_clipboardService.SetClipboardText(_blockTranslator.TranslateItemFilterBlockBaseToString(SelectedBlockViewModel.BaseBlock));
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCopyBlockStyleCommand()
|
||||
{
|
||||
CopyBlockStyle(SelectedBlockViewModel);
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterBlockViewModel;
|
||||
if (selectedBlockViewModel != null)
|
||||
{
|
||||
CopyBlockStyle(selectedBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyBlockStyle(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
@@ -594,7 +683,11 @@ namespace Filtration.ViewModels
|
||||
|
||||
private void OnPasteBlockStyleCommand()
|
||||
{
|
||||
PasteBlockStyle(SelectedBlockViewModel);
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterBlockViewModel;
|
||||
if (selectedBlockViewModel != null)
|
||||
{
|
||||
PasteBlockStyle(selectedBlockViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
@@ -614,45 +707,24 @@ namespace Filtration.ViewModels
|
||||
PasteBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void PasteBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
public void PasteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
try
|
||||
{
|
||||
var clipboardText = _clipboardService.GetClipboardText();
|
||||
if (string.IsNullOrEmpty(clipboardText)) return;
|
||||
_blockGroupHierarchyBuilder.Initialise(Script.ItemFilterBlockGroups.First());
|
||||
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
|
||||
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script, true); // TODO: Doesn't handle pasting comment blocks?
|
||||
if (translatedBlock == null) return;
|
||||
|
||||
var vm = _itemFilterBlockViewModelFactory.Create();
|
||||
vm.Initialise(translatedBlock, this);
|
||||
|
||||
if (ItemFilterBlockViewModels.Count > 0)
|
||||
{
|
||||
Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1,
|
||||
translatedBlock);
|
||||
ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
Script.ItemFilterBlocks.Add(translatedBlock);
|
||||
ItemFilterBlockViewModels.Add(vm);
|
||||
}
|
||||
|
||||
vm.BlockBecameDirty += OnBlockBecameDirty;
|
||||
|
||||
SelectedBlockViewModel = vm;
|
||||
IsDirty = true;
|
||||
_scriptCommandManager.ExecuteCommand(new PasteBlockCommand(Script, translatedBlock, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e);
|
||||
var innerException = e.InnerException?.Message ?? string.Empty;
|
||||
|
||||
_messageBoxService.Show("Paste Error",
|
||||
e.Message + Environment.NewLine + innerException, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
_messageBoxService.Show("Paste Error", e.Message + Environment.NewLine + innerException, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,40 +733,14 @@ namespace Filtration.ViewModels
|
||||
MoveBlockToTop(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void MoveBlockToTop(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
var currentIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModel);
|
||||
|
||||
if (currentIndex > 0)
|
||||
{
|
||||
var block = targetBlockViewModel.Block;
|
||||
Script.ItemFilterBlocks.Remove(block);
|
||||
Script.ItemFilterBlocks.Insert(0, block);
|
||||
ItemFilterBlockViewModels.Move(currentIndex, 0);
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMoveBlockUpCommand()
|
||||
{
|
||||
MoveBlockUp(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void MoveBlockUp(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
public void MoveBlockUp(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
var currentIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModel);
|
||||
|
||||
if (currentIndex > 0)
|
||||
{
|
||||
var block = targetBlockViewModel.Block;
|
||||
var blockPos = Script.ItemFilterBlocks.IndexOf(block);
|
||||
Script.ItemFilterBlocks.RemoveAt(blockPos);
|
||||
Script.ItemFilterBlocks.Insert(blockPos - 1, block);
|
||||
ItemFilterBlockViewModels.Move(currentIndex, currentIndex - 1);
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||
}
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockUpCommand(Script, targetBlockViewModelBase?.BaseBlock));
|
||||
}
|
||||
|
||||
private void OnMoveBlockDownCommand()
|
||||
@@ -702,20 +748,9 @@ namespace Filtration.ViewModels
|
||||
MoveBlockDown(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void MoveBlockDown(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
public void MoveBlockDown(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
var currentIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModel);
|
||||
|
||||
if (currentIndex < ItemFilterBlockViewModels.Count - 1)
|
||||
{
|
||||
var block = targetBlockViewModel.Block;
|
||||
var blockPos = Script.ItemFilterBlocks.IndexOf(block);
|
||||
Script.ItemFilterBlocks.RemoveAt(blockPos);
|
||||
Script.ItemFilterBlocks.Insert(blockPos + 1, block);
|
||||
ItemFilterBlockViewModels.Move(currentIndex, currentIndex + 1);
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||
}
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockDownCommand(Script, targetBlockViewModelBase?.BaseBlock));
|
||||
}
|
||||
|
||||
private void OnMoveBlockToBottomCommand()
|
||||
@@ -723,47 +758,35 @@ namespace Filtration.ViewModels
|
||||
MoveBlockToBottom(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void MoveBlockToBottom(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
var currentIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModel);
|
||||
|
||||
if (currentIndex < ItemFilterBlockViewModels.Count - 1)
|
||||
{
|
||||
var block = targetBlockViewModel.Block;
|
||||
Script.ItemFilterBlocks.Remove(block);
|
||||
Script.ItemFilterBlocks.Add(block);
|
||||
ItemFilterBlockViewModels.Move(currentIndex, ItemFilterBlockViewModels.Count - 1);
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAddBlockCommand()
|
||||
{
|
||||
AddBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void AddBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
public void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
var vm = _itemFilterBlockViewModelFactory.Create();
|
||||
var newBlock = new ItemFilterBlock();
|
||||
vm.Initialise(newBlock, this);
|
||||
_scriptCommandManager.ExecuteCommand(new AddBlockCommand(Script, targetBlockViewModelBase?.BaseBlock));
|
||||
// TODO: Expand new viewmodel
|
||||
}
|
||||
|
||||
if (targetBlockViewModel != null)
|
||||
{
|
||||
Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, newBlock);
|
||||
ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm);
|
||||
}
|
||||
else
|
||||
{
|
||||
Script.ItemFilterBlocks.Add(newBlock);
|
||||
ItemFilterBlockViewModels.Add(vm);
|
||||
}
|
||||
public void AddCommentBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new AddCommentBlockCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
|
||||
vm.BlockBecameDirty += OnBlockBecameDirty;
|
||||
SelectedBlockViewModel = vm;
|
||||
vm.IsExpanded = true;
|
||||
IsDirty = true;
|
||||
public void DeleteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new RemoveBlockCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
|
||||
public void MoveBlockToBottom(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockToBottomCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
|
||||
public void MoveBlockToTop(IItemFilterBlockViewModelBase targetBlockViewModelBase)
|
||||
{
|
||||
_scriptCommandManager.ExecuteCommand(new MoveBlockToTopCommand(Script, targetBlockViewModelBase.BaseBlock));
|
||||
}
|
||||
|
||||
private void OnBlockBecameDirty(object sender, EventArgs e)
|
||||
@@ -771,28 +794,14 @@ namespace Filtration.ViewModels
|
||||
SetDirtyFlag();
|
||||
}
|
||||
|
||||
private void OnAddSectionCommand()
|
||||
private void OnAddCommentBlockCommand()
|
||||
{
|
||||
AddSection(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void AddSection(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
var vm = _itemFilterBlockViewModelFactory.Create();
|
||||
var newSection = new ItemFilterSection { Description = "New Section" };
|
||||
vm.Initialise(newSection, this);
|
||||
|
||||
Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block), newSection);
|
||||
ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel), vm);
|
||||
IsDirty = true;
|
||||
SelectedBlockViewModel = vm;
|
||||
RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
|
||||
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
||||
AddCommentBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
private void OnExpandAllBlocksCommand()
|
||||
{
|
||||
foreach (var blockViewModel in ItemFilterBlockViewModels)
|
||||
foreach (var blockViewModel in ItemFilterBlockViewModels.OfType<IItemFilterBlockViewModel>())
|
||||
{
|
||||
blockViewModel.IsExpanded = true;
|
||||
}
|
||||
@@ -800,7 +809,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
private void OnCollapseAllBlocksCommand()
|
||||
{
|
||||
foreach (var blockViewModel in ItemFilterBlockViewModels)
|
||||
foreach (var blockViewModel in ItemFilterBlockViewModels.OfType<IItemFilterBlockViewModel>())
|
||||
{
|
||||
blockViewModel.IsExpanded = false;
|
||||
}
|
||||
@@ -811,49 +820,22 @@ namespace Filtration.ViewModels
|
||||
DeleteBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
public void DeleteBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
var result = _messageBoxService.Show("Delete Confirmation", "Are you sure you wish to delete this block?",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
var isSection = targetBlockViewModel.Block is ItemFilterSection;
|
||||
|
||||
Script.ItemFilterBlocks.Remove(targetBlockViewModel.Block);
|
||||
ItemFilterBlockViewModels.Remove(targetBlockViewModel);
|
||||
IsDirty = true;
|
||||
|
||||
targetBlockViewModel.BlockBecameDirty -= OnBlockBecameDirty;
|
||||
|
||||
if (isSection)
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
||||
}
|
||||
|
||||
}
|
||||
SelectedBlockViewModel = null;
|
||||
}
|
||||
|
||||
private void OnDisableBlockCommand()
|
||||
{
|
||||
DisableBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
private void DisableBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
targetBlockViewModel.BlockEnabled = false;
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterBlockViewModel;
|
||||
if (selectedBlockViewModel != null)
|
||||
{
|
||||
selectedBlockViewModel.BlockEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnableBlockCommand()
|
||||
{
|
||||
EnableBlock(SelectedBlockViewModel);
|
||||
}
|
||||
|
||||
private void EnableBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
targetBlockViewModel.BlockEnabled = true;
|
||||
var selectedBlockViewModel = SelectedBlockViewModel as IItemFilterBlockViewModel;
|
||||
if (selectedBlockViewModel != null)
|
||||
{
|
||||
selectedBlockViewModel.BlockEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,11 @@ namespace Filtration.ViewModels
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
// TODO: Only enabled if undo/redo available
|
||||
UndoCommand = new RelayCommand(OnUndoCommand, () => ActiveDocumentIsScript);
|
||||
RedoCommand = new RelayCommand(OnRedoCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
@@ -191,6 +196,9 @@ namespace Filtration.ViewModels
|
||||
public RelayCommand OpenAboutWindowCommand { get; }
|
||||
public RelayCommand ReplaceColorsCommand { get; }
|
||||
|
||||
public RelayCommand UndoCommand { get;}
|
||||
public RelayCommand RedoCommand { get; }
|
||||
|
||||
public RelayCommand EditMasterThemeCommand { get; }
|
||||
public RelayCommand CreateThemeCommand { get; }
|
||||
public RelayCommand ApplyThemeToScriptCommand { get; }
|
||||
@@ -216,7 +224,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public RelayCommand<bool> ToggleShowAdvancedCommand { get; }
|
||||
public RelayCommand ClearFiltersCommand { get; }
|
||||
|
||||
|
||||
public ImageSource Icon { get; private set; }
|
||||
|
||||
public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel => _avalonDockWorkspaceViewModel;
|
||||
@@ -334,7 +342,7 @@ namespace Filtration.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
await LoadScriptAsync(filePath);
|
||||
await LoadScriptAsync(filePath); // TODO: fix crash
|
||||
}
|
||||
|
||||
private async Task LoadScriptAsync(string scriptFilename)
|
||||
@@ -346,20 +354,19 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
|
||||
}
|
||||
catch (IOException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
if (Logger.IsErrorEnabled)
|
||||
{
|
||||
Logger.Error(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"));
|
||||
}
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
|
||||
}
|
||||
|
||||
@@ -382,12 +389,9 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
loadedViewModel = await _themeProvider.LoadThemeFromFile(themeFilename);
|
||||
}
|
||||
catch (IOException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
if (Logger.IsErrorEnabled)
|
||||
{
|
||||
Logger.Error(e);
|
||||
}
|
||||
Logger.Error(e);
|
||||
_messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message,
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
@@ -525,6 +529,16 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.PasteBlockStyleCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void OnUndoCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script.CommandManager.Undo();
|
||||
}
|
||||
|
||||
private void OnRedoCommand()
|
||||
{
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script.CommandManager.Redo();
|
||||
}
|
||||
|
||||
private void OnNewScriptCommand()
|
||||
{
|
||||
var newViewModel = _itemFilterScriptRepository.NewScript();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.Views;
|
||||
@@ -13,13 +12,13 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
internal interface IReplaceColorsViewModel
|
||||
{
|
||||
void Initialise(ItemFilterScript itemFilterScript, IItemFilterBlock initialiseFromBlock);
|
||||
void Initialise(ItemFilterScript itemFilterScript);
|
||||
void Initialise(IItemFilterScript itemFilterScript, IItemFilterBlock initialiseFromBlock);
|
||||
void Initialise(IItemFilterScript itemFilterScript);
|
||||
}
|
||||
|
||||
internal class ReplaceColorsViewModel : ViewModelBase, IReplaceColorsViewModel
|
||||
{
|
||||
private ItemFilterScript _itemFilterScript;
|
||||
private IItemFilterScript _itemFilterScript;
|
||||
private ReplaceColorsParameterSet _replaceColorsParameterSet;
|
||||
|
||||
public ReplaceColorsViewModel()
|
||||
@@ -29,7 +28,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public RelayCommand ReplaceColorsCommand { get; private set; }
|
||||
|
||||
public void Initialise(ItemFilterScript itemFilterScript, IItemFilterBlock initialiseFromBlock)
|
||||
public void Initialise(IItemFilterScript itemFilterScript, IItemFilterBlock initialiseFromBlock)
|
||||
{
|
||||
_replaceColorsParameterSet = new ReplaceColorsParameterSet();
|
||||
|
||||
@@ -67,7 +66,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public Color NewTextColor
|
||||
{
|
||||
get { return _replaceColorsParameterSet.NewTextColor; }
|
||||
get => _replaceColorsParameterSet.NewTextColor;
|
||||
set
|
||||
{
|
||||
_replaceColorsParameterSet.NewTextColor = value;
|
||||
@@ -82,7 +81,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public bool ReplaceTextColor
|
||||
{
|
||||
get { return _replaceColorsParameterSet.ReplaceTextColor; }
|
||||
get => _replaceColorsParameterSet.ReplaceTextColor;
|
||||
set
|
||||
{
|
||||
_replaceColorsParameterSet.ReplaceTextColor = value;
|
||||
@@ -92,7 +91,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public Color NewBackgroundColor
|
||||
{
|
||||
get { return _replaceColorsParameterSet.NewBackgroundColor; }
|
||||
get => _replaceColorsParameterSet.NewBackgroundColor;
|
||||
set
|
||||
{
|
||||
_replaceColorsParameterSet.NewBackgroundColor = value;
|
||||
@@ -107,7 +106,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public bool ReplaceBackgroundColor
|
||||
{
|
||||
get { return _replaceColorsParameterSet.ReplaceBackgroundColor; }
|
||||
get => _replaceColorsParameterSet.ReplaceBackgroundColor;
|
||||
set
|
||||
{
|
||||
_replaceColorsParameterSet.ReplaceBackgroundColor = value;
|
||||
@@ -117,7 +116,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public Color NewBorderColor
|
||||
{
|
||||
get { return _replaceColorsParameterSet.NewBorderColor; }
|
||||
get => _replaceColorsParameterSet.NewBorderColor;
|
||||
set
|
||||
{
|
||||
_replaceColorsParameterSet.NewBorderColor = value;
|
||||
@@ -132,7 +131,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public bool ReplaceBorderColor
|
||||
{
|
||||
get { return _replaceColorsParameterSet.ReplaceBorderColor; }
|
||||
get => _replaceColorsParameterSet.ReplaceBorderColor;
|
||||
set
|
||||
{
|
||||
_replaceColorsParameterSet.ReplaceBorderColor = value;
|
||||
@@ -142,7 +141,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public ReplaceColorsParameterSet ReplaceColorsParameterSet => _replaceColorsParameterSet;
|
||||
|
||||
public void Initialise(ItemFilterScript itemFilterScript)
|
||||
public void Initialise(IItemFilterScript itemFilterScript)
|
||||
{
|
||||
_replaceColorsParameterSet = new ReplaceColorsParameterSet();
|
||||
_itemFilterScript = itemFilterScript;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Filtration.Utilities;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
@@ -15,13 +15,11 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
|
||||
internal class BlockGroupBrowserViewModel : ToolViewModel, IBlockGroupBrowserViewModel
|
||||
{
|
||||
private readonly IBlockGroupMapper _blockGroupMapper;
|
||||
private ObservableCollection<ItemFilterBlockGroupViewModel> _blockGroupViewModelViewModels;
|
||||
private ItemFilterBlockGroupViewModel _selectedBlockGroupViewModel;
|
||||
|
||||
public BlockGroupBrowserViewModel(IBlockGroupMapper blockGroupMapper) : base("Block Group Browser")
|
||||
public BlockGroupBrowserViewModel() : base("Block Group Browser")
|
||||
{
|
||||
_blockGroupMapper = blockGroupMapper;
|
||||
FilterToSelectedBlockGroupCommand = new RelayCommand(OnFilterToSelectedBlockGroupCommand, () => SelectedBlockGroupViewModel != null);
|
||||
|
||||
ContentId = ToolContentId;
|
||||
@@ -60,7 +58,7 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
|
||||
public ItemFilterBlockGroupViewModel SelectedBlockGroupViewModel
|
||||
{
|
||||
get { return _selectedBlockGroupViewModel; }
|
||||
get => _selectedBlockGroupViewModel;
|
||||
set
|
||||
{
|
||||
_selectedBlockGroupViewModel = value;
|
||||
@@ -73,7 +71,7 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
|
||||
public ObservableCollection<ItemFilterBlockGroupViewModel> BlockGroupViewModels
|
||||
{
|
||||
get { return _blockGroupViewModelViewModels; }
|
||||
get => _blockGroupViewModelViewModels;
|
||||
private set
|
||||
{
|
||||
_blockGroupViewModelViewModels = value;
|
||||
@@ -94,9 +92,11 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
|
||||
private ObservableCollection<ItemFilterBlockGroupViewModel> RebuildBlockGroupViewModels(bool showAdvanced)
|
||||
{
|
||||
return
|
||||
_blockGroupMapper.MapBlockGroupsToViewModels(
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script.ItemFilterBlockGroups, showAdvanced);
|
||||
// This assumes that there will only ever be a single root node.
|
||||
return new ObservableCollection<ItemFilterBlockGroupViewModel>
|
||||
(
|
||||
new ItemFilterBlockGroupViewModel(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script.ItemFilterBlockGroups.First(), showAdvanced, null).ChildGroups
|
||||
);
|
||||
}
|
||||
|
||||
private void OnFilterToSelectedBlockGroupCommand()
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
}
|
||||
|
||||
PreviewText =
|
||||
_itemFilterBlockTranslator.TranslateItemFilterBlockToString(
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel.Block);
|
||||
_itemFilterBlockTranslator.TranslateItemFilterBlockBaseToString(
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel.BaseBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,18 @@ using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
namespace Filtration.ViewModels.ToolPanes
|
||||
{
|
||||
internal interface ISectionBrowserViewModel : IToolViewModel
|
||||
internal interface ICommentBlockBrowserViewModel : IToolViewModel
|
||||
{
|
||||
void ClearDown();
|
||||
bool IsVisible { get; set; }
|
||||
}
|
||||
|
||||
internal class SectionBrowserViewModel : ToolViewModel, ISectionBrowserViewModel
|
||||
internal class CommentBlockBrowserViewModel : ToolViewModel, ICommentBlockBrowserViewModel
|
||||
{
|
||||
private IEnumerable<IItemFilterBlockViewModel> _sectionBlockViewModels;
|
||||
private IItemFilterBlockViewModel _selectedSectionBlockViewModel;
|
||||
private IEnumerable<IItemFilterCommentBlockViewModel> _itemFilterCommentBlockViewModels;
|
||||
private IItemFilterCommentBlockViewModel _selectedItemFilterCommentBlockViewModel;
|
||||
|
||||
public SectionBrowserViewModel() : base("Section Browser")
|
||||
public CommentBlockBrowserViewModel() : base("Section Browser")
|
||||
{
|
||||
ContentId = ToolContentId;
|
||||
var icon = new BitmapImage();
|
||||
@@ -40,25 +40,25 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
|
||||
public const string ToolContentId = "SectionBrowserTool";
|
||||
|
||||
public IEnumerable<IItemFilterBlockViewModel> SectionBlockViewModels
|
||||
public IEnumerable<IItemFilterCommentBlockViewModel> ItemFilterCommentBlockViewModels
|
||||
{
|
||||
get { return _sectionBlockViewModels; }
|
||||
get => _itemFilterCommentBlockViewModels;
|
||||
private set
|
||||
{
|
||||
_sectionBlockViewModels = value;
|
||||
_itemFilterCommentBlockViewModels = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public IItemFilterBlockViewModel SelectedSectionBlockViewModel
|
||||
public IItemFilterCommentBlockViewModel SelectedItemFilterCommentBlockViewModel
|
||||
{
|
||||
get { return _selectedSectionBlockViewModel; }
|
||||
get => _selectedItemFilterCommentBlockViewModel;
|
||||
set
|
||||
{
|
||||
_selectedSectionBlockViewModel = value;
|
||||
_selectedItemFilterCommentBlockViewModel = value;
|
||||
if (AvalonDockWorkspaceViewModel.ActiveDocument.IsScript)
|
||||
{
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SectionBrowserSelectedBlockViewModel = value;
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.CommentBlockBrowserBrowserSelectedBlockViewModel = value;
|
||||
}
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
{
|
||||
if (AvalonDockWorkspaceViewModel.ActiveScriptViewModel != null && AvalonDockWorkspaceViewModel.ActiveDocument.IsScript)
|
||||
{
|
||||
SectionBlockViewModels = AvalonDockWorkspaceViewModel.ActiveScriptViewModel.ItemFilterSectionViewModels;
|
||||
ItemFilterCommentBlockViewModels = AvalonDockWorkspaceViewModel.ActiveScriptViewModel.ItemFilterCommentBlockViewModels;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -78,8 +78,8 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
|
||||
public void ClearDown()
|
||||
{
|
||||
SectionBlockViewModels = null;
|
||||
SelectedSectionBlockViewModel = null;
|
||||
ItemFilterCommentBlockViewModels = null;
|
||||
SelectedItemFilterCommentBlockViewModel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@
|
||||
</viewsAvalonDock:PanesTemplateSelector.BlockGroupBrowserTemplate>
|
||||
<viewsAvalonDock:PanesTemplateSelector.SectionBrowserTemplate>
|
||||
<DataTemplate>
|
||||
<toolPanes:SectionBrowserView DataContext="{Binding}" />
|
||||
<toolPanes:CommentBlockBrowserView DataContext="{Binding}" />
|
||||
</DataTemplate>
|
||||
</viewsAvalonDock:PanesTemplateSelector.SectionBrowserTemplate>
|
||||
<viewsAvalonDock:PanesTemplateSelector.BlockOutputPreviewTemplate>
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Filtration.Views.AvalonDock
|
||||
if (destinationContainer?.FindParent<LayoutFloatingWindow>() != null)
|
||||
return false;
|
||||
|
||||
if (anchorableToShow.Content is SectionBrowserViewModel)
|
||||
if (anchorableToShow.Content is CommentBlockBrowserViewModel)
|
||||
{
|
||||
var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "SectionBrowserPane");
|
||||
if (toolsPane != null)
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Filtration.Views.AvalonDock
|
||||
return ThemeTemplate;
|
||||
}
|
||||
|
||||
if (item is SectionBrowserViewModel)
|
||||
if (item is CommentBlockBrowserViewModel)
|
||||
{
|
||||
return SectionBrowserTemplate;
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
namespace Filtration.Views
|
||||
{
|
||||
public class BlockTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
var viewModel = item as ItemFilterBlockViewModel;
|
||||
var element = container as FrameworkElement;
|
||||
|
||||
if (viewModel == null || element == null)
|
||||
return null;
|
||||
|
||||
if (viewModel.Block is ItemFilterSection)
|
||||
{
|
||||
return element.FindResource("ItemFilterSectionTemplate") as DataTemplate;
|
||||
}
|
||||
|
||||
return element.FindResource("ItemFilterBlockTemplate") as DataTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@
|
||||
<Image Source="/Filtration;component/Resources/Icons/PasteStyle.ico" x:Key="PasteStyleIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/filtration_icon.png" x:Key="FiltrationIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/Add.ico" x:Key="AddIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/undo_icon.png" x:Key="UndoIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/redo_icon.png" x:Key="RedoIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/ThemeComponentDelete.ico" x:Key="ThemeComponentDeleteIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/standby_enabled_icon.png" x:Key="StandbyEnabledIcon" x:Shared="False" />
|
||||
<Image Source="/Filtration;component/Resources/Icons/standby_disabled_icon.png" x:Key="StandbyDisabledIcon" x:Shared="False" />
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<UserControl x:Class="Filtration.Views.ItemFilterSectionView"
|
||||
<UserControl x:Class="Filtration.Views.ItemFilterCommentBlockView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterBlockViewModel}"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterCommentBlockViewModel}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="50" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
@@ -45,7 +45,7 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column ="0" Text="{Binding BlockDescription, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
|
||||
<TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace Filtration.Views
|
||||
{
|
||||
public partial class ItemFilterSectionView
|
||||
public partial class ItemFilterCommentBlockView
|
||||
{
|
||||
public ItemFilterSectionView()
|
||||
public ItemFilterCommentBlockView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
xmlns:attachedProperties="clr-namespace:Filtration.Views.AttachedProperties"
|
||||
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
||||
xmlns:userControls="clr-namespace:Filtration.UserControls"
|
||||
xmlns:utility="clr-namespace:Filtration.Utility"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterScriptViewModel}"
|
||||
d:DesignHeight="300" d:DesignWidth="600">
|
||||
@@ -16,19 +17,19 @@
|
||||
<KeyBinding Command="{Binding CopyBlockStyleCommand}" Modifiers="Shift+Control" Key="C" />
|
||||
<KeyBinding Command="{Binding PasteBlockStyleCommand}" Modifiers="Shift+Control" Key="V" />
|
||||
</UserControl.InputBindings>
|
||||
<!--<utility:RoutedCommandHandlers.Commands>
|
||||
<utility:RoutedCommandHandler RoutedCommand="{StaticResource MoveBlockUpRoutedCommand}" Command="{Binding MoveBlockUpCommand}" IsActive="{Binding IsActiveDocument}" />
|
||||
</utility:RoutedCommandHandlers.Commands>-->
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||
<DataTemplate x:Key="ItemFilterBlockTemplate">
|
||||
<DataTemplate DataType="{x:Type viewModels:ItemFilterBlockViewModel}">
|
||||
<views:ItemFilterBlockView Margin="1" />
|
||||
</DataTemplate>
|
||||
<!-- ReSharper disable once Xaml.RedundantResource -->
|
||||
<DataTemplate x:Key="ItemFilterSectionTemplate">
|
||||
<views:ItemFilterSectionView Margin="1" />
|
||||
<DataTemplate DataType="{x:Type viewModels:ItemFilterCommentBlockViewModel}">
|
||||
<views:ItemFilterCommentBlockView Margin="1" />
|
||||
</DataTemplate>
|
||||
<views:BlockTemplateSelector x:Key="BlockTemplateSelector" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary Source="ExpanderStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
@@ -36,14 +37,14 @@
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0" BorderThickness="1" BorderBrush="DarkGray" Margin="5,5,5,0">
|
||||
<StackPanel Margin="2,2,2,2">
|
||||
<Expander Style="{StaticResource ExpanderRightAlignStyle}">
|
||||
<Expander.Header>
|
||||
<TextBlock Text="Script Description" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Script Description" VerticalAlignment="Center" />
|
||||
</Expander.Header>
|
||||
<Grid>
|
||||
<TextBox Text="{Binding Description, UpdateSourceTrigger=PropertyChanged}" Margin="5" MaxLines="20" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" />
|
||||
@@ -59,9 +60,9 @@
|
||||
BorderThickness="0"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
VirtualizingStackPanel.VirtualizationMode="Recycling"
|
||||
ItemTemplateSelector="{StaticResource BlockTemplateSelector}"
|
||||
attachedProperties:SelectingItemAttachedProperty.SelectingItem="{Binding SectionBrowserSelectedBlockViewModel}"
|
||||
SelectedItem="{Binding SelectedBlockViewModel}" x:Name="BlocksListBox">
|
||||
attachedProperties:SelectingItemAttachedProperty.SelectingItem="{Binding CommentBlockBrowserBrowserSelectedBlockViewModel}"
|
||||
SelectedItem="{Binding SelectedBlockViewModel}">
|
||||
<!--ItemTemplateSelector="{StaticResource BlockTemplateSelector}"-->
|
||||
<ListBox.InputBindings>
|
||||
<KeyBinding Key="Delete" Command="{Binding DeleteBlockCommand}" />
|
||||
</ListBox.InputBindings>
|
||||
|
||||
@@ -9,15 +9,24 @@
|
||||
xmlns:viewsAvalonDock="clr-namespace:Filtration.Views.AvalonDock"
|
||||
xmlns:views="clr-namespace:Filtration.Views"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
xmlns:utility="clr-namespace:Filtration.Utility"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"
|
||||
Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True"
|
||||
Closing="MainWindow_OnClosing" Drop="MainWindow_OnDrop" AllowDrop="True">
|
||||
|
||||
<fluent:RibbonWindow.InputBindings>
|
||||
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
|
||||
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
|
||||
<KeyBinding Command="{Binding NewScriptCommand}" Modifiers="Control" Key="N" />
|
||||
|
||||
<!-- Undo/Redo support incomplete -->
|
||||
<!--<KeyBinding Command="{Binding UndoCommand}" Modifiers="Control" Key="Z" />
|
||||
<KeyBinding Command="{Binding RedoCommand}" Modifiers="Control" Key="Y" />-->
|
||||
</fluent:RibbonWindow.InputBindings>
|
||||
<utility:RoutedCommandHandlers.Commands>
|
||||
<utility:RoutedCommandHandler RoutedCommand="{StaticResource OpenScriptRoutedCommand}" Command="{Binding OpenScriptCommand}" />
|
||||
</utility:RoutedCommandHandlers.Commands>
|
||||
<DockPanel x:Name="RootDockPanel">
|
||||
<fluent:Ribbon DockPanel.Dock="Top" x:Name="RibbonRoot" IsEnabled="{Binding ShowLoadingBanner, Converter={StaticResource BoolInverterConverter}}">
|
||||
<fluent:Ribbon.Menu>
|
||||
@@ -27,7 +36,7 @@
|
||||
<fluent:BackstageTabItem.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="20">Recent Documents will go here in a future release.</TextBlock>
|
||||
<TextBlock Margin="20">Recent Documents will go here in a future release.</TextBlock>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</fluent:BackstageTabItem.ContentTemplate>
|
||||
@@ -67,7 +76,7 @@
|
||||
</fluent:Ribbon.ContextualGroups>
|
||||
<fluent:RibbonTabItem Header="View">
|
||||
<fluent:RibbonGroupBox Header="Tools">
|
||||
<fluent:ToggleButton Header="Section Browser" Width="150" Size="Middle" Icon="{StaticResource AddSectionIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.SectionBrowserViewModel.IsVisible}"/>
|
||||
<fluent:ToggleButton Header="Section Browser" Width="150" Size="Middle" Icon="{StaticResource AddSectionIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.CommentBlockBrowserViewModel.IsVisible}"/>
|
||||
<fluent:ToggleButton Header="Block Group Browser" SizeDefinition="Middle" Icon="{StaticResource BlockGroupBrowserIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockGroupBrowserViewModel.IsVisible}" />
|
||||
<fluent:ToggleButton Header="Block Output Preview" SizeDefinition="Middle" Icon="{StaticResource BlockOutputPreviewIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockOutputPreviewViewModel.IsVisible}" />
|
||||
</fluent:RibbonGroupBox>
|
||||
@@ -80,6 +89,12 @@
|
||||
<fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" ToolTip="Paste Style (Ctrl+Shift+V)" />
|
||||
<fluent:Button Header="Copy Script" Command="{Binding CopyScriptCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
|
||||
</fluent:RibbonGroupBox>
|
||||
|
||||
<!-- Undo/Redo support incomplete -->
|
||||
<!--<fluent:RibbonGroupBox Header="Undo">
|
||||
<fluent:Button Header="Undo" Command="{Binding UndoCommand}" ToolTip="Undo" SizeDefinition="Middle" Icon="{StaticResource UndoIcon}" />
|
||||
<fluent:Button Header="Redo" Command="{Binding RedoCommand}" ToolTip="Redo" SizeDefinition="Middle" Icon="{StaticResource RedoIcon}" />
|
||||
</fluent:RibbonGroupBox>-->
|
||||
<fluent:RibbonGroupBox Header="Blocks">
|
||||
<fluent:Button Header="Add Block" Command="{Binding AddBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource AddBlockIcon}" />
|
||||
<fluent:Button Header="Add Section" Command="{Binding AddSectionCommand}" SizeDefinition="Middle" Icon="{StaticResource AddSectionIcon}" />
|
||||
@@ -146,4 +161,5 @@
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</fluent:RibbonWindow>
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<UserControl x:Class="Filtration.Views.ToolPanes.SectionBrowserView"
|
||||
<UserControl x:Class="Filtration.Views.ToolPanes.CommentBlockBrowserView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||
xmlns:toolPanes="clr-namespace:Filtration.ViewModels.ToolPanes"
|
||||
d:DataContext="{d:DesignInstance Type=toolPanes:SectionBrowserViewModel}"
|
||||
d:DataContext="{d:DesignInstance Type=toolPanes:CommentBlockBrowserViewModel}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<UserControl.Resources>
|
||||
<converters:HashSignRemovalConverter x:Key="HashSignRemovalConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<ListBox ItemsSource="{Binding SectionBlockViewModels}"
|
||||
SelectedItem="{Binding SelectedSectionBlockViewModel}"
|
||||
<ListBox ItemsSource="{Binding ItemFilterCommentBlockViewModels}"
|
||||
SelectedItem="{Binding SelectedItemFilterCommentBlockViewModel}"
|
||||
x:Name="SectionBrowserListBox"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Hidden"><!--SelectionChanged="SectionBrowserListBox_OnSelectionChanged"-->
|
||||
<ListBox.Resources>
|
||||
@@ -21,7 +21,7 @@
|
||||
</ListBox.Resources>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding BlockDescription, Converter={StaticResource HashSignRemovalConverter}}" ToolTip="{Binding BlockDescription}" />
|
||||
<TextBlock Text="{Binding Comment, Converter={StaticResource HashSignRemovalConverter}}" ToolTip="{Binding Comment}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace Filtration.Views.ToolPanes
|
||||
{
|
||||
public partial class SectionBrowserView
|
||||
public partial class CommentBlockBrowserView
|
||||
{
|
||||
public SectionBrowserView()
|
||||
public CommentBlockBrowserView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
using Castle.MicroKernel.SubSystems.Configuration;
|
||||
using Castle.Windsor;
|
||||
using Filtration.Services;
|
||||
using Filtration.Utilities;
|
||||
|
||||
namespace Filtration.WindsorInstallers
|
||||
{
|
||||
@@ -20,11 +19,6 @@ namespace Filtration.WindsorInstallers
|
||||
.ImplementedBy<StaticDataService>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<IBlockGroupMapper>()
|
||||
.ImplementedBy<BlockGroupMapper>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<IHTTPService>()
|
||||
.ImplementedBy<HTTPService>()
|
||||
|
||||
@@ -3,6 +3,7 @@ using Castle.MicroKernel.Registration;
|
||||
using Castle.MicroKernel.SubSystems.Configuration;
|
||||
using Castle.Windsor;
|
||||
using Filtration.ViewModels;
|
||||
using Filtration.ViewModels.Factories;
|
||||
using Filtration.ViewModels.ToolPanes;
|
||||
|
||||
namespace Filtration.WindsorInstallers
|
||||
@@ -26,6 +27,11 @@ namespace Filtration.WindsorInstallers
|
||||
.ImplementedBy<ItemFilterBlockViewModel>()
|
||||
.LifeStyle.Transient);
|
||||
|
||||
container.Register(
|
||||
Component.For<IItemFilterCommentBlockViewModel>()
|
||||
.ImplementedBy<ItemFilterCommentBlockViewModel>()
|
||||
.LifeStyle.Transient);
|
||||
|
||||
container.Register(
|
||||
Component.For<IItemFilterScriptViewModel>()
|
||||
.ImplementedBy<ItemFilterScriptViewModel>()
|
||||
@@ -42,8 +48,8 @@ namespace Filtration.WindsorInstallers
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<ISectionBrowserViewModel>()
|
||||
.ImplementedBy<SectionBrowserViewModel>()
|
||||
Component.For<ICommentBlockBrowserViewModel>()
|
||||
.ImplementedBy<CommentBlockBrowserViewModel>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
@@ -69,8 +75,16 @@ namespace Filtration.WindsorInstallers
|
||||
container.Register(
|
||||
Component.For<IItemFilterBlockViewModelFactory>().AsFactory());
|
||||
|
||||
container.Register(
|
||||
Component.For<IItemFilterCommentBlockViewModelFactory>().AsFactory());
|
||||
|
||||
container.Register(
|
||||
Component.For<IItemFilterScriptViewModelFactory>().AsFactory());
|
||||
|
||||
container.Register(
|
||||
Component.For<IItemFilterBlockBaseViewModelFactory>()
|
||||
.ImplementedBy<ItemFilterBlockBaseViewModelFactory>()
|
||||
.LifeStyle.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="AutoMapper" version="4.2.1" targetFramework="net461" />
|
||||
<package id="AutoMapper" version="6.0.2" targetFramework="net461" />
|
||||
<package id="Castle.Core" version="3.3.3" targetFramework="net451" />
|
||||
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
|
||||
<package id="Castle.Windsor" version="3.4.0" targetFramework="net461" />
|
||||
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
|
||||
<package id="ControlzEx" version="2.1.2.3" targetFramework="net461" />
|
||||
<package id="ControlzEx" version="2.2.0.4" targetFramework="net461" />
|
||||
<package id="Extended.Wpf.Toolkit" version="2.9" targetFramework="net461" />
|
||||
<package id="Fluent.Ribbon" version="4.0.3.394" targetFramework="net461" />
|
||||
<package id="MahApps.Metro" version="1.2.4.0" targetFramework="net461" />
|
||||
<package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.3.7" targetFramework="net461" />
|
||||
<package id="NLog" version="4.4.9" targetFramework="net461" />
|
||||
<package id="NLog.Config" version="4.3.7" targetFramework="net461" />
|
||||
<package id="NLog.Schema" version="4.3.7" targetFramework="net461" />
|
||||
<package id="NLog.Schema" version="4.4.9" targetFramework="net461" />
|
||||
<package id="WpfAnimatedGif" version="1.4.14" targetFramework="net461" />
|
||||
<package id="WPFToolkit" version="3.5.50211.1" targetFramework="net451" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user