48 Commits
0.6 ... 0.11

Author SHA1 Message Date
Ben
94146467a3 Removed async from a test that didn't need it 2015-07-31 21:43:33 +01:00
Ben
da9fad05a6 Changed maximum PlayAlertSound volume from 100 to 300 as per latest patch.
Updated version to 0.11
2015-07-31 19:52:19 +01:00
Ben
eb73767560 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-31 19:45:57 +01:00
Ben
2954cfe259 Fixed async tests 2015-07-31 19:45:51 +01:00
Ben Wallis
3694e6fa0c Updated release to 0.10 2015-07-26 17:19:53 +01:00
Ben
37258e563a Added Divination Cards to base types 2015-07-26 17:12:51 +01:00
Ben
71e1f2bf78 Revert "Removed Stackable Currency from ItemClasses"
This reverts commit f3ed386845.
2015-07-26 17:03:12 +01:00
Ben
b2b412a73c Revert "Removed Thrusting One Hand Swords from Base Types"
This reverts commit e80295cb69.
2015-07-26 17:03:06 +01:00
Ben
ae948c83a5 Updated version number to 0.10 2015-07-26 17:02:54 +01:00
Ben
3727166a44 Added drag and drop to open script/theme functionality 2015-07-26 11:48:54 +01:00
Ben
32b0a0199f Implemented async saving and loading 2015-07-25 19:02:42 +01:00
Ben
e54730d693 Added Tooltips for keyboard shortcuts and added Ctrl+N shortcut 2015-07-25 15:46:38 +01:00
Ben
d11eefaeab Fixed crash when pasting blocks with block groups assigned 2015-07-24 18:41:13 +01:00
Ben
da5b2c73a0 Moved clipboard operations to ClipboardService 2015-07-24 16:52:31 +01:00
Ben
2ff1373c6b Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-24 14:47:52 +01:00
Ben
1882687601 Fixed BlockGroupBrowser indeterminate checkbox state bug 2015-07-24 14:47:47 +01:00
Ben Wallis
3ba25b8f07 Updated release to 0.9 2015-07-15 19:55:52 +01:00
Ben
e80295cb69 Removed Thrusting One Hand Swords from Base Types 2015-07-15 19:48:51 +01:00
Ben
f3ed386845 Removed Stackable Currency from ItemClasses 2015-07-15 19:48:33 +01:00
Ben
89e0c717e8 Bumped version to 0.9 2015-07-15 19:45:49 +01:00
Ben
8924637b98 Added hint text when no audio visual block items are added. 2015-07-15 19:41:31 +01:00
Ben
b0b912c676 Added save check on close 2015-07-15 19:36:42 +01:00
Ben
92ebc51e7b Switched file save encoding to UTF-8 2015-07-15 19:17:19 +01:00
Ben
95e7581a5b Fixed Delete Theme Component button being enabled for non-master themes 2015-07-15 19:12:19 +01:00
Ben
9cb854b584 Fixed Usages: 0 being visible when editing a non-master theme 2015-07-15 19:10:51 +01:00
Ben
61c2902f0c Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-15 19:02:34 +01:00
Ben
dc157713f3 Fixed Issue #8 - Crash when Filtration cannot perform the update check on startup 2015-07-15 19:02:29 +01:00
Ben Wallis
16fe837544 updated to 0.8 2015-07-13 15:17:53 +01:00
Ben
58de6f06b9 Added Jewel to ItemClasses.txt 2015-07-10 18:13:12 +01:00
Ben
af2dace29a Fixed crash when opening a script after Filtration is invoked via file association (Issue #7) 2015-07-10 18:11:03 +01:00
Ben
59cf604430 Revert "Increased the size of the Item Preview control to cater for FontSize 45"
This reverts commit 93a51e7829.
2015-07-10 17:54:42 +01:00
Ben
93a51e7829 Increased the size of the Item Preview control to cater for FontSize 45 2015-07-10 17:52:10 +01:00
Ben
9d928a374a Fixed crash when clicking Close menu option with no script/theme open
Fixed memory leak when documents are closed.
2015-07-10 17:48:34 +01:00
Ben
b5788504cb Fixed Disabled Block Block Group Bug (Issue #6) 2015-07-10 17:29:37 +01:00
Ben
6e71005e93 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-09 18:58:27 +01:00
Ben
56e163e3e0 Fix for line description being lost when reading disabled blocks 2015-07-09 18:58:22 +01:00
Ben Wallis
c856bbcee7 updated screenshots 2015-07-06 19:14:28 +01:00
Ben Wallis
490496f2f7 Updated release to 0.7 2015-07-06 18:41:14 +01:00
Ben
9fcb609a51 Implemented disabled block support 2015-07-06 18:19:05 +01:00
Ben
1b63f68eee Fixed theme serialization/deserialization and added them toolbar icons 2015-07-06 15:33:25 +01:00
Ben
a496ab9b42 Resharper Code Issues Cleanup 2015-07-06 13:45:19 +01:00
Ben
cbbc7c25fa More theme changes 2015-07-06 13:41:46 +01:00
Ben
d6bd1678b4 Fixed contextual tabs 2015-07-06 12:01:48 +01:00
Ben
bfa2341ab8 Implemented editable themes / master themes 2015-07-05 22:43:17 +01:00
Ben
511f503e88 Refactored ThemeComponentBuilder into ThemeComponentCollection 2015-07-05 16:54:09 +01:00
Ben
3ea0530c01 Added Divination Cards to Classes and Base Types lookup lists 2015-07-05 16:19:45 +01:00
Ben
aad34b1407 Changed UpdateDataUrl back to correct url 2015-07-05 11:14:44 +01:00
Ben
544b931477 Added theme component tag selection control 2015-07-05 11:09:59 +01:00
88 changed files with 2522 additions and 831 deletions

View File

@@ -2,7 +2,7 @@
using System.Globalization; using System.Globalization;
using System.Windows.Data; using System.Windows.Data;
namespace Filtration.Converters namespace Filtration.Common.Converters
{ {
internal class BoolInverterConverter : IValueConverter internal class BoolInverterConverter : IValueConverter
{ {

View File

@@ -3,9 +3,9 @@ using System.Globalization;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
namespace Filtration.Converters namespace Filtration.Common.Converters
{ {
internal class BooleanVisibilityConverterCopy : IValueConverter public class BooleanVisibilityConverter : IValueConverter
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {

View File

@@ -2,7 +2,7 @@
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Media; using System.Windows.Media;
namespace Filtration.Converters namespace Filtration.Common.Converters
{ {
public class ColorToSolidColorBrushConverter : IValueConverter public class ColorToSolidColorBrushConverter : IValueConverter
{ {

View File

@@ -3,9 +3,9 @@ using System.Globalization;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
namespace Filtration.Converters namespace Filtration.Common.Converters
{ {
internal class BooleanVisibilityConverter : IValueConverter internal class InverseBooleanVisibilityConverter : IValueConverter
{ {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
@@ -14,25 +14,24 @@ namespace Filtration.Converters
var val = (bool) value; var val = (bool) value;
if (val) if (val)
{ {
return Visibility.Visible; return Visibility.Collapsed;
} }
if (parameter is Visibility) if (parameter is Visibility)
{ {
return parameter; return parameter;
} }
return Visibility.Collapsed; return Visibility.Visible;
} }
if (value != null) if (value != null)
{ {
return Visibility.Visible; return Visibility.Collapsed;
} }
if (parameter is Visibility) if (parameter is Visibility)
{ {
return parameter; return parameter;
} }
return Visibility.Collapsed; return Visibility.Visible;
} }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View File

@@ -3,7 +3,7 @@ using System.Globalization;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
namespace Filtration.Converters namespace Filtration.Common.Converters
{ {
internal class StringToVisibilityConverter : IValueConverter internal class StringToVisibilityConverter : IValueConverter
{ {

View File

@@ -64,6 +64,12 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Converters\BooleanInverterConverter.cs" />
<Compile Include="Converters\BooleanVisibilityConverter.cs" />
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
<Compile Include="Converters\InverseBooleanVisibilityConverter.cs" />
<Compile Include="Converters\StringToVisibilityConverter.cs" />
<Compile Include="Messages\ThemeClosedMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\FileSystemService.cs" /> <Compile Include="Services\FileSystemService.cs" />
<Compile Include="Services\MessageBoxService.cs" /> <Compile Include="Services\MessageBoxService.cs" />
@@ -80,6 +86,12 @@
<Name>Filtration.ObjectModel</Name> <Name>Filtration.ObjectModel</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Page Include="Styles\SharedResourcesDictionary.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Filtration.Common.Messages
{
class ThemeClosedMessage
{
}
}

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Text;
namespace Filtration.Common.Services namespace Filtration.Common.Services
{ {
@@ -20,7 +21,7 @@ namespace Filtration.Common.Services
public void WriteFileFromString(string filePath, string inputString) public void WriteFileFromString(string filePath, string inputString)
{ {
File.WriteAllText(filePath, inputString); File.WriteAllText(filePath, inputString, Encoding.UTF8);
} }
public bool DirectoryExists(string directoryPath) public bool DirectoryExists(string directoryPath)

View File

@@ -1,8 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Filtration.Converters"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converters="clr-namespace:Filtration.Common.Converters"
mc:Ignorable="d" > mc:Ignorable="d" >
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary> <ResourceDictionary>
@@ -31,17 +31,19 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" /> <Style TargetType="{x:Type Border}" x:Key="BlockItemBorder">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Margin" Value="0,0,5,5" />
</Style>
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" /> <converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
<converters:BoolInverterConverter x:Key="BoolInverterConverter" /> <converters:BoolInverterConverter x:Key="BoolInverterConverter" />
<converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" /> <converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
<converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" /> <converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
<converters:InverseBooleanVisibilityConverter x:Key="InverseBooleanVisibilityConverter" /> <converters:InverseBooleanVisibilityConverter x:Key="InverseBooleanVisibilityConverter" />
<converters:BlockItemToRemoveEnabledVisibilityConverter x:Key="BlockItemToRemoveEnabledVisibilityConverter" />
</ResourceDictionary> </ResourceDictionary>
<ResourceDictionary Source="ExpanderStyle.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -1,9 +1,11 @@
namespace Filtration.Interface using System.Threading.Tasks;
namespace Filtration.Interface
{ {
public interface IDocument public interface IDocument
{ {
bool IsScript { get; } bool IsScript { get; }
bool IsTheme { get; } bool IsTheme { get; }
void Close(); Task Close();
} }
} }

View File

@@ -1,9 +1,11 @@
namespace Filtration.Interface using System.Threading.Tasks;
namespace Filtration.Interface
{ {
public interface IEditableDocument : IDocument public interface IEditableDocument : IDocument
{ {
bool IsDirty { get; } bool IsDirty { get; }
void Save(); Task SaveAsync();
void SaveAs(); Task SaveAsAsync();
} }
} }

View File

@@ -50,6 +50,7 @@
<Compile Include="TestItemFilterBlock.cs" /> <Compile Include="TestItemFilterBlock.cs" />
<Compile Include="TestItemFilterBlockGroup.cs" /> <Compile Include="TestItemFilterBlockGroup.cs" />
<Compile Include="TestItemFilterScript.cs" /> <Compile Include="TestItemFilterScript.cs" />
<Compile Include="ThemeEditor\TestThemeComponentCollection.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj"> <ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
@@ -60,6 +61,7 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -0,0 +1,30 @@
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using NUnit.Framework;
namespace Filtration.ObjectModel.Tests.ThemeEditor
{
[TestFixture]
public class TestThemeComponentCollection
{
[Test]
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
{
// Arrange
var testInputTargetType = ThemeComponentType.TextColor;
var testInputComponentName = "testComponent";
var testInputColor = new Color();
var componentCollection = new ThemeComponentCollection();
// Act
var firstResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
var secondResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
// Assert
Assert.AreSame(firstResult, secondResult);
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Windows.Media; using System;
using System.Windows.Media;
using Filtration.ObjectModel.ThemeEditor; using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ObjectModel.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
@@ -6,6 +7,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem
{ {
private Color _color; private Color _color;
private ThemeComponent _themeComponent;
protected ColorBlockItem() protected ColorBlockItem()
{ {
@@ -31,7 +33,28 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
get { return string.Empty; } get { return string.Empty; }
} }
public ThemeComponent ThemeComponent { get; set; } public ThemeComponent ThemeComponent
{
get { return _themeComponent; }
set
{
if (_themeComponent == value){ return;}
if (_themeComponent != null)
{
_themeComponent.ThemeComponentUpdated -= OnThemeComponentUpdated;
_themeComponent.ThemeComponentDeleted -= OnThemeComponentDeleted;
}
if (value != null)
{
value.ThemeComponentUpdated += OnThemeComponentUpdated;
value.ThemeComponentDeleted += OnThemeComponentDeleted;
}
_themeComponent = value;
OnPropertyChanged();
}
}
public override Color SummaryBackgroundColor { get { return Colors.Transparent; } } public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public override Color SummaryTextColor { get { return Colors.Transparent; } } public override Color SummaryTextColor { get { return Colors.Transparent; } }
@@ -45,5 +68,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
OnPropertyChanged(); OnPropertyChanged();
} }
} }
private void OnThemeComponentUpdated(object sender, EventArgs e)
{
Color = ((ThemeComponent) sender).Color;
}
private void OnThemeComponentDeleted(object sender, EventArgs e)
{
ThemeComponent = null;
}
} }
} }

View File

@@ -83,6 +83,7 @@
<Compile Include="ReplaceColorsParameterSet.cs" /> <Compile Include="ReplaceColorsParameterSet.cs" />
<Compile Include="ThemeEditor\Theme.cs" /> <Compile Include="ThemeEditor\Theme.cs" />
<Compile Include="ThemeEditor\ThemeComponent.cs" /> <Compile Include="ThemeEditor\ThemeComponent.cs" />
<Compile Include="ThemeEditor\ThemeComponentCollection.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -13,8 +13,10 @@ namespace Filtration.ObjectModel
public ItemFilterBlock() public ItemFilterBlock()
{ {
BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)}; BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)};
Enabled = true;
} }
public bool Enabled { get; set; }
public string Description { get; set; } public string Description { get; set; }
public ItemFilterBlockGroup BlockGroup public ItemFilterBlockGroup BlockGroup

View File

@@ -16,13 +16,13 @@ namespace Filtration.ObjectModel
{ {
new ItemFilterBlockGroup("Root", null) new ItemFilterBlockGroup("Root", null)
}; };
ThemeComponents = new List<ThemeComponent>(); ThemeComponents = new ThemeComponentCollection { IsMasterCollection = true};
} }
public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; } public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; }
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; } public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; }
public List<ThemeComponent> ThemeComponents { get; set; } public ThemeComponentCollection ThemeComponents { get; set; }
public string FilePath { get; set; } public string FilePath { get; set; }
public string Description { get; set; } public string Description { get; set; }

View File

@@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor namespace Filtration.ObjectModel.ThemeEditor
@@ -8,24 +10,28 @@ namespace Filtration.ObjectModel.ThemeEditor
[Serializable] [Serializable]
public class Theme public class Theme
{ {
private readonly List<ThemeComponent> _components; private readonly ThemeComponentCollection _components;
public Theme() public Theme()
{ {
_components = new List<ThemeComponent>(); _components = new ThemeComponentCollection { IsMasterCollection = false};
} }
public string Name { get; set; } public string Name { get; set; }
[XmlIgnore]
public string FilePath { get; set; } public string FilePath { get; set; }
public List<ThemeComponent> Components public ThemeComponentCollection Components
{ {
get { return _components; } get { return _components; }
} }
public bool ComponentExists(ThemeComponentType componentType, string componentName) public bool ComponentExists(ThemeComponentType componentType, string componentName)
{ {
return _components.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType); var componentCount =
_components.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
return componentCount > 0;
} }
public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor) public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)

View File

@@ -1,12 +1,20 @@
using System; using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media; using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Annotations;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor namespace Filtration.ObjectModel.ThemeEditor
{ {
[Serializable] [Serializable]
public class ThemeComponent public class ThemeComponent : INotifyPropertyChanged
{ {
private Color _color;
private EventHandler _themeComponentUpdatedEventHandler;
private readonly object _eventLock = new object();
public ThemeComponent() public ThemeComponent()
{ {
@@ -24,8 +32,75 @@ namespace Filtration.ObjectModel.ThemeEditor
ComponentName = componentName; ComponentName = componentName;
} }
// By implementing a custom event accessor here we can keep the UsageCount up to date.
public event EventHandler ThemeComponentUpdated
{
add
{
lock (_eventLock)
{
_themeComponentUpdatedEventHandler += value;
OnPropertyChanged("UsageCount");
}
}
remove
{
lock (_eventLock)
{
// ReSharper disable once DelegateSubtraction
_themeComponentUpdatedEventHandler -= value;
OnPropertyChanged("UsageCount");
}
}
}
public event EventHandler ThemeComponentDeleted;
public string ComponentName { get; set; } public string ComponentName { get; set; }
public ThemeComponentType ComponentType{ get; set; } public ThemeComponentType ComponentType{ get; set; }
public Color Color { get; set; }
public Color Color
{
get { return _color; }
set
{
_color = value;
OnPropertyChanged();
if (_themeComponentUpdatedEventHandler != null)
{
_themeComponentUpdatedEventHandler.Invoke(this, EventArgs.Empty);
}
}
}
public int UsageCount
{
get
{
if (_themeComponentUpdatedEventHandler == null)
{
return 0;
}
return _themeComponentUpdatedEventHandler.GetInvocationList().Length;
}
}
public void TerminateComponent()
{
if (ThemeComponentDeleted != null)
{
ThemeComponentDeleted.Invoke(this, EventArgs.Empty);
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
} }
} }

View File

@@ -0,0 +1,32 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
{
public class ThemeComponentCollection : ObservableCollection<ThemeComponent>
{
public bool IsMasterCollection { get; set; }
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
if (ComponentExists(componentType, componentName))
{
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
}
var component = new ThemeComponent(componentType, componentName, componentColor);
Items.Add(component);
return component;
}
private bool ComponentExists(ThemeComponentType componentType, string componentName)
{
var componentCount =
Items.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
return componentCount > 0;
}
}
}

View File

@@ -55,7 +55,6 @@
<Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" /> <Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" />
<Compile Include="Translators\TestItemFilterBlockTranslator.cs" /> <Compile Include="Translators\TestItemFilterBlockTranslator.cs" />
<Compile Include="Translators\TestItemFilterScriptTranslator.cs" /> <Compile Include="Translators\TestItemFilterScriptTranslator.cs" />
<Compile Include="Translators\TestThemeComponentListBuilder.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" /> <None Include="app.config" />

View File

@@ -1,4 +1,6 @@
using System.IO; using System.IO;
using System.Threading.Tasks;
using Filtration.ObjectModel;
using Filtration.Repositories; using Filtration.Repositories;
using Filtration.Services; using Filtration.Services;
using Filtration.ViewModels; using Filtration.ViewModels;
@@ -11,14 +13,14 @@ namespace Filtration.Tests.Repositories
public class TestItemFilterScriptRepository public class TestItemFilterScriptRepository
{ {
[Test] [Test]
public void LoadScriptFromFile_CallsPersistenceServiceUsingPathAndReturnsViewModel() public async Task LoadScriptFromFile_CallsPersistenceServiceUsingPathAndReturnsViewModel()
{ {
// Arrange // Arrange
var testInputPath = "C:\\TestPath.filter"; var testInputPath = "C:\\TestPath.filter";
var mockPersistenceService = new Mock<IItemFilterPersistenceService>(); var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
mockPersistenceService.Setup(p => p.LoadItemFilterScript(testInputPath)).Verifiable(); mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).ReturnsAsync(new ItemFilterScript()).Verifiable();
var mockItemFilterScriptViewModel = new Mock<IItemFilterScriptViewModel>(); var mockItemFilterScriptViewModel = new Mock<IItemFilterScriptViewModel>();
@@ -28,7 +30,7 @@ namespace Filtration.Tests.Repositories
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object); var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
// Act // Act
var result = repository.LoadScriptFromFile(testInputPath); var result = await repository.LoadScriptFromFileAsync(testInputPath);
// Assert // Assert
mockPersistenceService.Verify(); mockPersistenceService.Verify();
@@ -42,7 +44,7 @@ namespace Filtration.Tests.Repositories
var testInputPath = "C:\\TestPath.filter"; var testInputPath = "C:\\TestPath.filter";
var mockPersistenceService = new Mock<IItemFilterPersistenceService>(); var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
mockPersistenceService.Setup(p => p.LoadItemFilterScript(testInputPath)).Throws<IOException>(); mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).Throws<IOException>();
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>(); var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
@@ -51,7 +53,7 @@ namespace Filtration.Tests.Repositories
// Act // Act
// Assert // Assert
Assert.Throws<IOException>(() => repository.LoadScriptFromFile(testInputPath)); Assert.Throws<IOException>(async () => await repository.LoadScriptFromFileAsync(testInputPath));
} }
[Test] [Test]

View File

@@ -1,4 +1,5 @@
using System.IO; using System.IO;
using System.Threading.Tasks;
using Filtration.Common.Services; using Filtration.Common.Services;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.Services; using Filtration.Services;
@@ -12,7 +13,7 @@ namespace Filtration.Tests.Services
public class TestItemFilterPersistenceService public class TestItemFilterPersistenceService
{ {
[Test] [Test]
public void LoadItemFilterScript_CallsTranslatorAndFileSystemService() public async Task LoadItemFilterScript_CallsTranslatorAndFileSystemService()
{ {
// Arrange // Arrange
const string TestInputPath = "C:\\Test Path\\Script.Filter"; const string TestInputPath = "C:\\Test Path\\Script.Filter";
@@ -28,7 +29,7 @@ namespace Filtration.Tests.Services
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
// Act // Act
var script = service.LoadItemFilterScript(TestInputPath); var script = await service.LoadItemFilterScriptAsync(TestInputPath);
// Assert // Assert
mockFileSystemService.Verify(); mockFileSystemService.Verify();
@@ -37,7 +38,7 @@ namespace Filtration.Tests.Services
} }
[Test] [Test]
public void SaveItemFilterScript_CallsTranslatorAndFileSystemService() public async Task SaveItemFilterScript_CallsTranslatorAndFileSystemService()
{ {
// Arrange // Arrange
var testFilePath = "C:\\Test\\File.txt"; var testFilePath = "C:\\Test\\File.txt";
@@ -53,7 +54,7 @@ namespace Filtration.Tests.Services
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
// Act // Act
service.SaveItemFilterScript(testScript); await service.SaveItemFilterScriptAsync(testScript);
// Assert // Assert
mockFileSystemService.Verify(); mockFileSystemService.Verify();

View File

@@ -25,6 +25,36 @@ namespace Filtration.Tests.Translators
_testUtility = new ItemFilterBlockTranslatorTestUtility(); _testUtility = new ItemFilterBlockTranslatorTestUtility();
} }
[Test]
public void TranslateStringToItemFilterBlock_NotDisabled_SetsBlockEnabledTrue()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(true, result.Enabled);
}
[Test]
public void TranslateStringToItemFilterBlock_DisabledBlock_SetsBlockEnabledFalse()
{
// Arrange
var inputString = "HideDisabled" + Environment.NewLine +
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(2, result.BlockItems.Count);
Assert.AreEqual(BlockAction.Hide, result.Action);
Assert.AreEqual(false, result.Enabled);
}
[Test] [Test]
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
{ {
@@ -33,7 +63,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem));
@@ -51,7 +81,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(); _testUtility.MockBlockGroupHierarchyBuilder.Verify();
@@ -66,7 +96,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(true, inputBlockGroup.IsChecked); Assert.AreEqual(true, inputBlockGroup.IsChecked);
@@ -81,7 +111,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(false, inputBlockGroup.IsChecked); Assert.AreEqual(false, inputBlockGroup.IsChecked);
@@ -95,7 +125,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never); _testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
@@ -109,7 +139,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never); _testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
@@ -124,7 +154,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable();
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(testBlockGroup, result.BlockGroup); Assert.AreEqual(testBlockGroup, result.BlockGroup);
@@ -138,7 +168,7 @@ namespace Filtration.Tests.Translators
var inputString = "Hide" + Environment.NewLine; var inputString = "Hide" + Environment.NewLine;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem));
@@ -154,7 +184,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual("This is a test Block", result.Description); Assert.AreEqual("This is a test Block", result.Description);
@@ -174,7 +204,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual("Second Line", result.Description); Assert.AreEqual("Second Line", result.Description);
@@ -192,7 +222,7 @@ namespace Filtration.Tests.Translators
" DropLevel = 40"; " DropLevel = 40";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -210,7 +240,7 @@ namespace Filtration.Tests.Translators
" Quality < 18"; " Quality < 18";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -228,7 +258,7 @@ namespace Filtration.Tests.Translators
" Rarity > Normal"; " Rarity > Normal";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -246,7 +276,7 @@ namespace Filtration.Tests.Translators
" Rarity Normal"; " Rarity Normal";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem));
@@ -263,7 +293,7 @@ namespace Filtration.Tests.Translators
@" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2"""; @" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2""";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem));
@@ -282,7 +312,7 @@ namespace Filtration.Tests.Translators
@" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2"""; @" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2""";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem));
@@ -301,7 +331,7 @@ namespace Filtration.Tests.Translators
" Sockets > 2"; " Sockets > 2";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -319,7 +349,7 @@ namespace Filtration.Tests.Translators
" LinkedSockets != 1"; " LinkedSockets != 1";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -337,7 +367,7 @@ namespace Filtration.Tests.Translators
" Width != 1"; " Width != 1";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -355,7 +385,7 @@ namespace Filtration.Tests.Translators
" Height <= 3"; " Height <= 3";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -373,7 +403,7 @@ namespace Filtration.Tests.Translators
" Height <=3"; " Height <=3";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem));
@@ -390,7 +420,7 @@ namespace Filtration.Tests.Translators
" SocketGroup RRGB"; " SocketGroup RRGB";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem));
@@ -408,7 +438,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 255 20 100"; " SetTextColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -426,7 +456,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 65 0 255 12"; " SetTextColor 65 0 255 12";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -445,7 +475,7 @@ namespace Filtration.Tests.Translators
" SetBackgroundColor 255 20 100"; " SetBackgroundColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
@@ -464,7 +494,7 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 20 100"; " SetBorderColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -483,8 +513,8 @@ namespace Filtration.Tests.Translators
// Act // Act
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString)); Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null));
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -500,21 +530,17 @@ namespace Filtration.Tests.Translators
// Arrange // Arrange
var inputString = "Show" + Environment.NewLine + var inputString = "Show" + Environment.NewLine +
" SetTextColor 255 20 100 # Rare Item Text"; " SetTextColor 255 20 100 # Rare Item Text";
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "testComponent", new Color()); var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
_testUtility.MockThemeComponentListBuilder.Setup(
t =>
t.AddComponent(ThemeComponentType.TextColor, "Rare Item Text",
new Color {A = 255, R = 255, G = 20, B = 100})).Returns(testComponent).Verifiable();
_testUtility.MockThemeComponentListBuilder.SetupGet(t => t.IsInitialised).Returns(true);
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, testInputThemeComponentCollection);
// Assert // Assert
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First(); var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
Assert.AreSame(testComponent, blockItem.ThemeComponent); Assert.AreSame(testComponent, blockItem.ThemeComponent);
_testUtility.MockThemeComponentListBuilder.Verify(); var firstComponent = testInputThemeComponentCollection.First();
Assert.AreEqual("Rare Item Text", firstComponent.ComponentName);
} }
[Test] [Test]
@@ -526,7 +552,7 @@ namespace Filtration.Tests.Translators
" SetFontSize 15"; " SetFontSize 15";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
@@ -543,7 +569,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 4"; " PlayAlertSound 4";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -561,7 +587,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 2 95"; " PlayAlertSound 2 95";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -578,7 +604,7 @@ namespace Filtration.Tests.Translators
var inputString = "# Section: " + TestInputSectionDescription; var inputString = "# Section: " + TestInputSectionDescription;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.IsInstanceOf<ItemFilterSection>(result); Assert.IsInstanceOf<ItemFilterSection>(result);
@@ -611,7 +637,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 3"; " PlayAlertSound 3";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual("Test filter with everything", result.Description); Assert.AreEqual("Test filter with everything", result.Description);
@@ -693,7 +719,7 @@ namespace Filtration.Tests.Translators
" Quality < 17"; " Quality < 17";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem)); Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem));
@@ -722,7 +748,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 255 20 100"; " SetTextColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -743,7 +769,7 @@ namespace Filtration.Tests.Translators
" SetFontSize 27" + Environment.NewLine; " SetFontSize 27" + Environment.NewLine;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
@@ -762,7 +788,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 2" + Environment.NewLine; " PlayAlertSound 2" + Environment.NewLine;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -780,7 +806,7 @@ namespace Filtration.Tests.Translators
" SetBackgroundColor 255 20 100"; " SetBackgroundColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
@@ -799,7 +825,7 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 20 100"; " SetBorderColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -1268,6 +1294,26 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
} }
[Test]
public void TranslateItemFilterBlockToString_DisabledBlock_ReturnsCorrectString()
{
// Arrange
var expectedResult = "#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# Width = 4" + Environment.NewLine +
"#Disabled Block End";
_testUtility.TestBlock.Enabled = false;
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4));
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
// Assert
Assert.AreEqual(expectedResult, result);
}
[Test] [Test]
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString() public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
{ {
@@ -1347,6 +1393,26 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color); Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color);
} }
[Test]
public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlockBugTest()
{
// Arrange
var testInputString = "SetBackgroundColor 70 0 0 255";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new BackgroundColorBlockItem(new Color { R = 70, G = 0, B = 1, A = 255});
testInputBlockItems.Add(testInputBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
Assert.IsNotNull(backgroundColorBlockItem);
Assert.AreNotSame(testInputBlockItem, backgroundColorBlockItem);
Assert.AreEqual(new Color { R = 70, G = 0, B = 0, A = 255 }, backgroundColorBlockItem.Color);
}
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")] [Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
[Test] [Test]
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing() public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
@@ -1461,6 +1527,7 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem)); Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
} }
[Ignore("ThemeComponentBuilder deprecated")]
[Test] [Test]
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent() public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
{ {
@@ -1470,13 +1537,12 @@ namespace Filtration.Tests.Translators
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>(); var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new TextColorBlockItem(Colors.Red); var testInputBlockItem = new TextColorBlockItem(Colors.Red);
testInputBlockItems.Add(testInputBlockItem); testInputBlockItems.Add(testInputBlockItem);
_testUtility.MockThemeComponentListBuilder.Setup(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>())).Verifiable();
// Act // Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString); _testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert // Assert
_testUtility.MockThemeComponentListBuilder.Verify(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>()), Times.Never);
} }
private class ItemFilterBlockTranslatorTestUtility private class ItemFilterBlockTranslatorTestUtility
{ {
@@ -1487,16 +1553,13 @@ namespace Filtration.Tests.Translators
// Mock setups // Mock setups
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>(); MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
// Class under test instantiation // Class under test instantiation
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object, Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object);
MockThemeComponentListBuilder.Object);
} }
public ItemFilterBlock TestBlock { get; set; } public ItemFilterBlock TestBlock { get; set; }
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; } public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
public ItemFilterBlockTranslator Translator { get; private set; } public ItemFilterBlockTranslator Translator { get; private set; }
} }
} }

View File

@@ -32,7 +32,7 @@ namespace Filtration.Tests.Translators
// Arrange // Arrange
var testInput = File.ReadAllText(@"Resources/testscript.txt"); var testInput = File.ReadAllText(@"Resources/testscript.txt");
_testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable(); _testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
// Act // Act
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput); var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
@@ -54,7 +54,7 @@ namespace Filtration.Tests.Translators
"End Script Description"; "End Script Description";
var mockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>(); var mockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable(); mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
// Act // Act
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput); var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
@@ -63,37 +63,6 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(expectedDescription, script.Description); Assert.AreEqual(expectedDescription, script.Description);
} }
[Test]
public void TranslateStringToItemFilterScript_CallsThemeComponentListBuilderInitialise()
{
// Arrange
var testInput = File.ReadAllText(@"Resources/testscript.txt");
_testUtility.MockThemeComponentListBuilder.Setup(t => t.Initialise()).Verifiable();
// Act
_testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
// Assert
_testUtility.MockThemeComponentListBuilder.Verify();
}
[Test]
public void TranslateStringToItemFilterScript_SetsScriptThemeComponentsToComponentListBuilderResult()
{
// Arrange
var testInput = File.ReadAllText(@"Resources/testscript.txt");
List<ThemeComponent> testThemeComponents = new List<ThemeComponent>();
_testUtility.MockThemeComponentListBuilder.Setup(t => t.GetComponents()).Returns(testThemeComponents).Verifiable();
// Act
var result = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
// Assert
_testUtility.MockThemeComponentListBuilder.Verify();
Assert.AreSame(testThemeComponents, result.ThemeComponents);
}
[Ignore("Integration Test")] [Ignore("Integration Test")]
[Test] [Test]
public void TranslateStringToItemFilterScript_ThioleItemFilterTest() public void TranslateStringToItemFilterScript_ThioleItemFilterTest()
@@ -101,10 +70,9 @@ namespace Filtration.Tests.Translators
// Arrange // Arrange
var testInput = File.ReadAllText(@"Resources/ThioleItemFilter.txt"); var testInput = File.ReadAllText(@"Resources/ThioleItemFilter.txt");
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object, var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
_testUtility.MockThemeComponentListBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator, var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object); _testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act // Act
translator.TranslateStringToItemFilterScript(testInput); translator.TranslateStringToItemFilterScript(testInput);
@@ -161,10 +129,9 @@ namespace Filtration.Tests.Translators
" Width = 3" + Environment.NewLine + " Width = 3" + Environment.NewLine +
" SetFontSize 7" + Environment.NewLine; " SetFontSize 7" + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object, var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
_testUtility.MockThemeComponentListBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator, var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object); _testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act // Act
var result = translator.TranslateItemFilterScriptToString(script); var result = translator.TranslateItemFilterScriptToString(script);
@@ -207,10 +174,9 @@ namespace Filtration.Tests.Translators
" Width = 3" + Environment.NewLine + " Width = 3" + Environment.NewLine +
" SetFontSize 7" + Environment.NewLine + Environment.NewLine; " SetFontSize 7" + Environment.NewLine + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object, var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
_testUtility.MockThemeComponentListBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator, var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object); _testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act // Act
var result = translator.TranslateItemFilterScriptToString(script); var result = translator.TranslateItemFilterScriptToString(script);
@@ -251,10 +217,9 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 0 255" + Environment.NewLine + " SetBorderColor 255 0 255" + Environment.NewLine +
" SetFontSize 25"; " SetFontSize 25";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object, var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
_testUtility.MockThemeComponentListBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator, var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object); _testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act // Act
var result = translator.TranslateStringToItemFilterScript(testInputScript); var result = translator.TranslateStringToItemFilterScript(testInputScript);
@@ -275,10 +240,9 @@ namespace Filtration.Tests.Translators
Environment.NewLine + Environment.NewLine +
"Show" + Environment.NewLine + "Show" + Environment.NewLine +
"BaseType \"Maelström Staff\"" + Environment.NewLine + Environment.NewLine; "BaseType \"Maelström Staff\"" + Environment.NewLine + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object, var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
_testUtility.MockThemeComponentListBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator, var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object); _testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act // Act
var result = translator.TranslateStringToItemFilterScript(testInputScript); var result = translator.TranslateStringToItemFilterScript(testInputScript);
@@ -289,6 +253,139 @@ namespace Filtration.Tests.Translators
Assert.IsNullOrEmpty(firstBlock.Description); Assert.IsNullOrEmpty(firstBlock.Description);
} }
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlockCount()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine +
" SetTextColor 255 255 0";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlocks()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine +
" SetTextColor 255 255 0";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
var firstBlock = result.ItemFilterBlocks.First();
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
var thirdBlock = result.ItemFilterBlocks.Skip(2).First();
Assert.AreEqual(3, firstBlock.BlockItems.Count);
Assert.AreEqual(5, secondBlock.BlockItems.Count);
Assert.AreEqual(3, thirdBlock.BlockItems.Count);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_BlockDescriptionNotLost()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"# This is a disabled block" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"#Disabled Block End";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
Assert.AreEqual("This is a disabled block", secondBlock.Description);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlockWithBlockGroup_ReturnsCorrectBlock()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"# This is a disabled block" + Environment.NewLine +
"#Show#My Block Group" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"#Disabled Block End";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
_testUtility.MockBlockGroupHierarchyBuilder.Setup(
b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()))
.Returns(new ItemFilterBlockGroup("My Block Group", null));
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
Assert.AreEqual("This is a disabled block", secondBlock.Description);
Assert.AreEqual("My Block Group", secondBlock.BlockGroup.GroupName);
}
private class ItemFilterScriptTranslatorTestUtility private class ItemFilterScriptTranslatorTestUtility
{ {
public ItemFilterScriptTranslatorTestUtility() public ItemFilterScriptTranslatorTestUtility()
@@ -296,16 +393,14 @@ namespace Filtration.Tests.Translators
// Mock setups // Mock setups
MockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>(); MockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>(); MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
// Class under test instantiation // Class under test instantiation
ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object, MockThemeComponentListBuilder.Object); ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object);
} }
public ItemFilterScriptTranslator ScriptTranslator { get; private set; } public ItemFilterScriptTranslator ScriptTranslator { get; private set; }
public Mock<IItemFilterBlockTranslator> MockItemFilterBlockTranslator { get; private set; } public Mock<IItemFilterBlockTranslator> MockItemFilterBlockTranslator { get; private set; }
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; } public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
} }
} }
} }

View File

@@ -1,60 +0,0 @@
using System.Net.Mime;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.Translators;
using NUnit.Framework;
namespace Filtration.Tests.Translators
{
[TestFixture]
public class TestThemeComponentListBuilder
{
[Test]
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
{
// Arrange
var testInputTargetType = ThemeComponentType.TextColor;
var testInputComponentName = "testComponent";
var testInputColor = new Color();
var builder = new ThemeComponentListBuilder();
builder.Initialise();
// Act
var firstResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
var secondResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
// Assert
Assert.AreSame(firstResult, secondResult);
}
[Test]
public void IsInitialised_NotInitialised_ReturnsFalse()
{
// Arrange
var builder = new ThemeComponentListBuilder();
// Act
var result = builder.IsInitialised;
// Assert
Assert.IsFalse(result);
}
[Test]
public void IsInitialised_Initialised_ReturnsTrue()
{
// Arrange
var builder = new ThemeComponentListBuilder();
builder.Initialise();
// Act
var result = builder.IsInitialised;
// Assert
Assert.IsTrue(result);
}
}
}

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Windows.Data; using System.Windows.Data;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions; using Filtration.ObjectModel.Extensions;
@@ -18,6 +17,22 @@ namespace Filtration.ThemeEditor.Converters
} }
var type = (ThemeComponentType) value; var type = (ThemeComponentType) value;
switch (type.GetAttributeDescription())
{
case "Text":
{
return "Text Color Theme Components";
}
case "Border":
{
return "Border Color Theme Components";
}
case "Background":
{
return "Background Color Theme Components";
}
}
return type.GetAttributeDescription(); return type.GetAttributeDescription();
} }

View File

@@ -95,18 +95,19 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" /> <Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" />
<Compile Include="Messages\ThemeClosedMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\ThemeProvider.cs" /> <Compile Include="Providers\ThemeProvider.cs" />
<Compile Include="Services\ThemePersistenceService.cs" /> <Compile Include="Services\ThemePersistenceService.cs" />
<Compile Include="Services\ThemeService.cs" /> <Compile Include="Services\ThemeService.cs" />
<Compile Include="ViewModels\IThemeViewModelFactory.cs" /> <Compile Include="ViewModels\IThemeViewModelFactory.cs" />
<Compile Include="ViewModels\ThemeComponentViewModel.cs" /> <Compile Include="ViewModels\ThemeComponentViewModel.cs" />
<Compile Include="ViewModels\ThemeViewModel.cs" /> <Compile Include="ViewModels\ThemeEditorViewModel.cs" />
<Compile Include="Views\ThemeComponentControl.xaml.cs"> <Compile Include="Views\ThemeComponentControl.xaml.cs">
<DependentUpon>ThemeComponentControl.xaml</DependentUpon> <DependentUpon>ThemeComponentControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\ThemeControl.xaml.cs"> <Compile Include="Views\ThemeEditorView.xaml.cs">
<DependentUpon>ThemeControl.xaml</DependentUpon> <DependentUpon>ThemeEditorView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="WindsorInstallers\ProvidersInstaller.cs" /> <Compile Include="WindsorInstallers\ProvidersInstaller.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" /> <Compile Include="WindsorInstallers\ServicesInstaller.cs" />
@@ -132,7 +133,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\ThemeControl.xaml"> <Page Include="Views\ThemeEditorView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>

View File

@@ -0,0 +1,9 @@
using Filtration.ThemeEditor.ViewModels;
namespace Filtration.ThemeEditor.Messages
{
public class ThemeClosedMessage
{
public IThemeEditorViewModel ClosedViewModel { get; set; }
}
}

View File

@@ -1,4 +1,7 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper; using AutoMapper;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.ThemeEditor; using Filtration.ObjectModel.ThemeEditor;
@@ -9,10 +12,11 @@ namespace Filtration.ThemeEditor.Providers
{ {
public interface IThemeProvider public interface IThemeProvider
{ {
IThemeViewModel NewThemeForScript(ItemFilterScript script); IThemeEditorViewModel NewThemeForScript(ItemFilterScript script);
IThemeViewModel LoadThemeFromFile(string filePath); IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script);
Theme LoadThemeModelFromFile(string filePath); Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath);
void SaveTheme(IThemeViewModel themeViewModel, string filePath); Task<Theme> LoadThemeModelFromFile(string filePath);
Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath);
} }
internal class ThemeProvider : IThemeProvider internal class ThemeProvider : IThemeProvider
@@ -26,33 +30,51 @@ namespace Filtration.ThemeEditor.Providers
_themePersistenceService = themePersistenceService; _themePersistenceService = themePersistenceService;
} }
public IThemeViewModel NewThemeForScript(ItemFilterScript script) public IThemeEditorViewModel NewThemeForScript(ItemFilterScript script)
{ {
var themeComponentViewModels = Mapper.Map<ObservableCollection<ThemeComponentViewModel>>(script.ThemeComponents); var themeComponentCollection = script.ThemeComponents.Aggregate(new ThemeComponentCollection(),
(c, component) =>
{
c.Add(new ThemeComponent(component.ComponentType, component.ComponentName, component.Color));
return c;
});
var themeViewModel = _themeViewModelFactory.Create(); var themeViewModel = _themeViewModelFactory.Create();
themeViewModel.Initialise(themeComponentViewModels, true); themeViewModel.InitialiseForNewTheme(themeComponentCollection);
themeViewModel.FilePath = "Untitled.filtertheme"; themeViewModel.FilePath = "Untitled.filtertheme";
return themeViewModel; return themeViewModel;
} }
public IThemeViewModel LoadThemeFromFile(string filePath) public IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script)
{ {
var model = _themePersistenceService.LoadTheme(filePath); var themeViewModel = _themeViewModelFactory.Create();
var viewModel = Mapper.Map<IThemeViewModel>(model); themeViewModel.InitialiseForMasterTheme(script);
themeViewModel.FilePath = "<Master Theme> " + Path.GetFileName(script.FilePath);
return themeViewModel;
}
public async Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath)
{
var model = await _themePersistenceService.LoadThemeAsync(filePath);
var viewModel = Mapper.Map<IThemeEditorViewModel>(model);
viewModel.FilePath = filePath; viewModel.FilePath = filePath;
return viewModel; return viewModel;
} }
public Theme LoadThemeModelFromFile(string filePath) public async Task<Theme> LoadThemeModelFromFile(string filePath)
{ {
return _themePersistenceService.LoadTheme(filePath); return await _themePersistenceService.LoadThemeAsync(filePath);
} }
public void SaveTheme(IThemeViewModel themeViewModel, string filePath) public async Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath)
{ {
var theme = Mapper.Map<Theme>(themeViewModel); await Task.Run(() =>
_themePersistenceService.SaveTheme(theme, filePath); {
var theme = Mapper.Map<Theme>(themeEditorViewModel);
_themePersistenceService.SaveThemeAsync(theme, filePath);
});
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using System.IO; using System.IO;
using System.Threading.Tasks;
using System.Xml.Serialization; using System.Xml.Serialization;
using Filtration.ObjectModel.ThemeEditor; using Filtration.ObjectModel.ThemeEditor;
@@ -6,35 +7,42 @@ namespace Filtration.ThemeEditor.Services
{ {
internal interface IThemePersistenceService internal interface IThemePersistenceService
{ {
Theme LoadTheme(string filePath); Task<Theme> LoadThemeAsync(string filePath);
void SaveTheme(Theme theme, string filePath); Task SaveThemeAsync(Theme theme, string filePath);
} }
internal class ThemePersistenceService : IThemePersistenceService internal class ThemePersistenceService : IThemePersistenceService
{ {
public Theme LoadTheme(string filePath) public async Task<Theme> LoadThemeAsync(string filePath)
{ {
var xmlSerializer = new XmlSerializer(typeof(Theme)); Theme loadedTheme = null;
Theme loadedTheme; await Task.Run(() =>
using (Stream reader = new FileStream(filePath, FileMode.Open))
{ {
loadedTheme = (Theme)xmlSerializer.Deserialize(reader); var xmlSerializer = new XmlSerializer(typeof (Theme));
}
using (Stream reader = new FileStream(filePath, FileMode.Open))
{
loadedTheme = (Theme) xmlSerializer.Deserialize(reader);
}
loadedTheme.FilePath = filePath;
});
loadedTheme.FilePath = filePath;
return loadedTheme; return loadedTheme;
} }
public void SaveTheme(Theme theme, string filePath) public async Task SaveThemeAsync(Theme theme, string filePath)
{ {
var xmlSerializer = new XmlSerializer(typeof(Theme)); await Task.Run(() =>
using (Stream writer = new FileStream(filePath, FileMode.Create))
{ {
xmlSerializer.Serialize(writer, theme); var xmlSerializer = new XmlSerializer(typeof (Theme));
}
using (Stream writer = new FileStream(filePath, FileMode.Create))
{
xmlSerializer.Serialize(writer, theme);
}
});
} }
} }
} }

View File

@@ -2,7 +2,7 @@
{ {
public interface IThemeViewModelFactory public interface IThemeViewModelFactory
{ {
IThemeViewModel Create(); IThemeEditorViewModel Create();
void Release(IThemeViewModel themeViewModel); void Release(IThemeEditorViewModel themeEditorViewModel);
} }
} }

View File

@@ -0,0 +1,215 @@
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Interface;
using Filtration.ObjectModel;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.ThemeEditor.Messages;
using Filtration.ThemeEditor.Providers;
using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging;
using NLog;
namespace Filtration.ThemeEditor.ViewModels
{
public interface IThemeEditorViewModel : IEditableDocument
{
RelayCommand<ThemeComponentType> AddThemeComponentCommand { get; }
RelayCommand<ThemeComponent> DeleteThemeComponentCommand { get; }
RelayCommand CloseCommand { get; }
void InitialiseForNewTheme(ThemeComponentCollection themeComponentCollection);
void InitialiseForMasterTheme(ItemFilterScript script);
bool IsMasterTheme { get; }
ItemFilterScript IsMasterThemeForScript { get; }
string Title { get; }
string FilePath { get; set; }
string Filename { get; }
string Name { get; set; }
ThemeComponentCollection Components { get; set; }
ThemeComponent SelectedThemeComponent { get; }
}
public class ThemeEditorViewModel : PaneViewModel, IThemeEditorViewModel
{
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly IThemeProvider _themeProvider;
private readonly IMessageBoxService _messageBoxService;
private bool _filenameIsFake;
private string _filePath;
private ThemeComponent _selectedThemeComponent;
public ThemeEditorViewModel(IThemeProvider themeProvider,
IMessageBoxService messageBoxService)
{
_themeProvider = themeProvider;
_messageBoxService = messageBoxService;
AddThemeComponentCommand = new RelayCommand<ThemeComponentType>(OnAddThemeComponentCommand, t => IsMasterTheme);
DeleteThemeComponentCommand = new RelayCommand<ThemeComponent>(OnDeleteThemeComponentCommand,
t => IsMasterTheme && SelectedThemeComponent != null);
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
var icon = new BitmapImage();
icon.BeginInit();
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/Theme.ico");
icon.EndInit();
IconSource = icon;
}
public RelayCommand<ThemeComponentType> AddThemeComponentCommand { get; private set; }
public RelayCommand<ThemeComponent> DeleteThemeComponentCommand { get; private set; }
public RelayCommand CloseCommand { get; private set; }
public bool IsMasterTheme
{
get { return Components.IsMasterCollection; }
}
public ItemFilterScript IsMasterThemeForScript { get; private set; }
public void InitialiseForNewTheme(ThemeComponentCollection themeComponentCollection)
{
Components = themeComponentCollection;
_filenameIsFake = true;
}
public void InitialiseForMasterTheme(ItemFilterScript script)
{
Components = script.ThemeComponents;
IsMasterThemeForScript = script;
_filenameIsFake = true;
}
public bool IsScript { get { return false; } }
public bool IsTheme { get { return true; } }
public bool IsDirty { get; private set; }
public string FilePath
{
get { return _filePath; }
set
{
_filePath = value;
Title = Filename;
}
}
public string Filename
{
get { return _filenameIsFake ? FilePath : Path.GetFileName(FilePath); }
}
public string Name { get; set; }
public ThemeComponentCollection Components { get; set; }
public ThemeComponent SelectedThemeComponent
{
get { return _selectedThemeComponent; }
set
{
_selectedThemeComponent = value;
RaisePropertyChanged();
}
}
public async Task SaveAsync()
{
if (IsMasterTheme) return;
if (_filenameIsFake)
{
await SaveAsAsync();
return;
}
try
{
await _themeProvider.SaveThemeAsync(this, FilePath);
//RemoveDirtyFlag();
}
catch (Exception e)
{
if (_logger.IsErrorEnabled)
{
_logger.Error(e);
}
_messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public async Task SaveAsAsync()
{
if (IsMasterTheme) return;
var saveDialog = new SaveFileDialog
{
DefaultExt = ".filter",
Filter = @"Filter Theme Files (*.filtertheme)|*.filtertheme|All Files (*.*)|*.*"
};
var result = saveDialog.ShowDialog();
if (result != DialogResult.OK) return;
var previousFilePath = FilePath;
try
{
FilePath = saveDialog.FileName;
await _themeProvider.SaveThemeAsync(this, FilePath);
_filenameIsFake = false;
Title = Filename;
//RemoveDirtyFlag();
}
catch (Exception e)
{
if (_logger.IsErrorEnabled)
{
_logger.Error(e);
}
_messageBoxService.Show("Save Error", "Error saving theme file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error);
FilePath = previousFilePath;
}
}
public async Task OnCloseCommand()
{
await Close();
}
#pragma warning disable 1998
public async Task Close()
#pragma warning restore 1998
{
Messenger.Default.Send(new ThemeClosedMessage {ClosedViewModel = this});
}
private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType)
{
Components.Add(new ThemeComponent(themeComponentType, "Untitled Component",
new Color {A = 255, R = 255, G = 255, B = 255}));
}
private void OnDeleteThemeComponentCommand(ThemeComponent themeComponent)
{
if (themeComponent == null) return;
themeComponent.TerminateComponent();
Components.Remove(themeComponent);
}
}
}

View File

@@ -1,142 +0,0 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using Filtration.Common.Services;
using Filtration.Common.ViewModels;
using Filtration.Interface;
using Filtration.ThemeEditor.Providers;
using NLog;
using MessageBox = System.Windows.MessageBox;
namespace Filtration.ThemeEditor.ViewModels
{
public interface IThemeViewModel : IEditableDocument
{
void Initialise(ObservableCollection<ThemeComponentViewModel> themeComponentViewModels, bool newTheme);
string Title { get; }
string FilePath { get; set; }
string Filename { get; }
string Name { get; set; }
ObservableCollection<ThemeComponentViewModel> Components { get; set; }
}
public class ThemeViewModel : PaneViewModel, IThemeViewModel
{
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly IThemeProvider _themeProvider;
private readonly IMessageBoxService _messageBoxService;
private bool _filenameIsFake;
private string _filePath;
public ThemeViewModel(IThemeProvider themeProvider,
IMessageBoxService messageBoxService)
{
_themeProvider = themeProvider;
_messageBoxService = messageBoxService;
Components = new ObservableCollection<ThemeComponentViewModel>();
var icon = new BitmapImage();
icon.BeginInit();
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/Theme.ico");
icon.EndInit();
IconSource = icon;
}
public void Initialise(ObservableCollection<ThemeComponentViewModel> themeComponentViewModels, bool newTheme)
{
Components = themeComponentViewModels;
_filenameIsFake = newTheme;
}
public bool IsScript { get { return false; } }
public bool IsTheme { get { return true; } }
public bool IsDirty { get; private set; }
public string FilePath
{
get { return _filePath; }
set
{
_filePath = value;
Title = Filename;
}
}
public string Filename
{
get { return Path.GetFileName(FilePath); }
}
public string Name { get; set; }
public ObservableCollection<ThemeComponentViewModel> Components { get; set; }
public void Save()
{
if (_filenameIsFake)
{
SaveAs();
return;
}
try
{
_themeProvider.SaveTheme(this, FilePath);
//RemoveDirtyFlag();
}
catch (Exception e)
{
if (_logger.IsErrorEnabled)
{
_logger.Error(e);
}
_messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
}
}
public void SaveAs()
{
var saveDialog = new SaveFileDialog
{
DefaultExt = ".filter",
Filter = @"Filter Theme Files (*.filtertheme)|*.filtertheme|All Files (*.*)|*.*"
};
var result = saveDialog.ShowDialog();
if (result != DialogResult.OK) return;
var previousFilePath = FilePath;
try
{
FilePath = saveDialog.FileName;
_themeProvider.SaveTheme(this, FilePath);
_filenameIsFake = false;
//RemoveDirtyFlag();
}
catch (Exception e)
{
if (_logger.IsErrorEnabled)
{
_logger.Error(e);
}
_messageBoxService.Show("Save Error", "Error saving theme file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error);
FilePath = previousFilePath;
}
}
public void Close()
{
throw new NotImplementedException();
}
}
}

View File

@@ -3,14 +3,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters" xmlns:commonConverters="clr-namespace:Filtration.Common.Converters;assembly=Filtration.Common"
xmlns:themeEditor="clr-namespace:Filtration.ObjectModel.ThemeEditor;assembly=Filtration.ObjectModel"
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeComponentViewModel}" d:DataContext="{d:DesignInstance Type=themeEditor:ThemeComponent}"
d:DesignHeight="40" d:DesignWidth="200"> d:DesignHeight="100" d:DesignWidth="200">
<UserControl.Resources> <UserControl.Resources>
<converters:ThemeComponentTypeToStringConverter x:Key="ThemeComponentTypeToStringConverter" /> <commonConverters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
</UserControl.Resources> </UserControl.Resources>
<Grid Width="200"> <Grid Width="200">
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -18,8 +19,45 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="25" /> <RowDefinition Height="25" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding ComponentType, Converter={StaticResource ThemeComponentTypeToStringConverter}}" Foreground="Red" FontSize="10" /> <Grid.Resources>
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" /> <DataTemplate x:Key="EditableComponentNameTemplate">
<xctk:ColorPicker Grid.Row="2" Grid.Column="0" SelectedColor="{Binding Color}" /> <StackPanel>
<TextBlock Text="{Binding UsageCount, StringFormat='Usages: {0}'}"
FontSize="10"
HorizontalAlignment="Right"
Visibility="{Binding Path=DataContext.EditEnabled, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}, Converter={StaticResource BooleanVisibilityConverter}}">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding UsageCount}" Value="0">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Foreground" Value="SteelBlue" />
</Style>
</TextBlock.Style>
</TextBlock>
<TextBox Text="{Binding ComponentName}" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ViewOnlyComponentNameTemplate">
<TextBlock Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
</DataTemplate>
</Grid.Resources>
<ContentControl Grid.Row="1" Content="{Binding}">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=DataContext.IsMasterTheme, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="true">
<Setter Property="ContentTemplate" Value="{StaticResource EditableComponentNameTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=DataContext.IsMasterTheme, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}}" Value="false">
<Setter Property="ContentTemplate" Value="{StaticResource ViewOnlyComponentNameTemplate}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
<xctk:ColorPicker Grid.Row="2" SelectedColor="{Binding Color}" />
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -1,47 +0,0 @@
<UserControl x:Class="Filtration.ThemeEditor.Views.ThemeControl"
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.ThemeEditor.ViewModels"
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<CollectionViewSource Source="{Binding Components}" x:Key="ComponentsViewSource">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ComponentType" />
</CollectionViewSource.GroupDescriptions>
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="ComponentType" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</UserControl.Resources>
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding Source={StaticResource ComponentsViewSource}}" Margin="10">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock FontWeight="Bold" FontSize="15" Text="{Binding Path=Name}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ItemsControl.GroupStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<views:ThemeComponentControl DataContext="{Binding}" Margin="10,5,10,5" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>

View File

@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Filtration.ThemeEditor.Views
{
/// <summary>
/// Interaction logic for ThemeControl.xaml
/// </summary>
public partial class ThemeControl : UserControl
{
public ThemeControl()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,78 @@
<UserControl x:Class="Filtration.ThemeEditor.Views.ThemeEditorView"
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.ThemeEditor.ViewModels"
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeEditorViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<CollectionViewSource Source="{Binding Components}" x:Key="ComponentsViewSource">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="ComponentType" />
</CollectionViewSource.GroupDescriptions>
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="ComponentType" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
<converters:ThemeComponentTypeToStringConverter x:Key="ThemeComponentTypeToStringConverter" />
</ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Margin="10">
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<ListView ItemsSource="{Binding Source={StaticResource ComponentsViewSource}}"
SelectedItem="{Binding SelectedThemeComponent}"
Margin="5"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.Resources>
<Style TargetType="ListViewItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Border Name="Border" BorderBrush="Black" Background="White" BorderThickness="1" CornerRadius="3" Margin="2" SnapsToDevicePixels="true">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border" Property="Background" Value="#A9BDD8"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.Resources>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Margin="7,5,0,0" FontWeight="Bold" FontSize="15" Text="{Binding Path=Name, Converter={StaticResource ThemeComponentTypeToStringConverter}}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemTemplate>
<DataTemplate>
<views:ThemeComponentControl DataContext="{Binding}" Margin="10,5,10,5" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollViewer>
</Grid>
</UserControl>

View File

@@ -0,0 +1,10 @@
namespace Filtration.ThemeEditor.Views
{
public partial class ThemeEditorView
{
public ThemeEditorView()
{
InitializeComponent();
}
}
}

View File

@@ -11,8 +11,8 @@ namespace Filtration.ThemeEditor.WindsorInstallers
public void Install(IWindsorContainer container, IConfigurationStore store) public void Install(IWindsorContainer container, IConfigurationStore store)
{ {
container.Register( container.Register(
Component.For<IThemeViewModel>() Component.For<IThemeEditorViewModel>()
.ImplementedBy<ThemeViewModel>() .ImplementedBy<ThemeEditorViewModel>()
.LifeStyle.Transient); .LifeStyle.Transient);
container.Register( container.Register(

View File

@@ -1,10 +1,13 @@
<Application x:Class="Filtration.App" <Application x:Class="Filtration.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Filtration.Converters"
Startup="Application_Startup"> Startup="Application_Startup">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Generic.xaml" /> <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Generic.xaml" />
<ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/windows8/silver.xaml" /> <ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/windows8/silver.xaml" />
<ResourceDictionary Source="Views/Styles/Colours.xaml" /> <ResourceDictionary Source="Views/Styles/Colours.xaml" />
@@ -20,9 +23,11 @@
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.RadioButton.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.RadioButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Scrollbars.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Scrollbars.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ListView.xaml" />
<ResourceDictionary Source="Views/CrossButton.xaml" /> <ResourceDictionary Source="Views/CrossButton.xaml" />
<ResourceDictionary Source="Views/IconsDictionary.xaml" /> <ResourceDictionary Source="Views/IconsDictionary.xaml" />
<ResourceDictionary Source="Views/ExpanderStyle.xaml" />
<ResourceDictionary> <ResourceDictionary>
<Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" /> <Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" />
@@ -30,6 +35,14 @@
<Style TargetType="ScrollBar" BasedOn="{StaticResource MetroScrollBar}" /> <Style TargetType="ScrollBar" BasedOn="{StaticResource MetroScrollBar}" />
<Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}" /> <Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}" />
</ResourceDictionary> </ResourceDictionary>
<ResourceDictionary>
<converters:BlockItemToRemoveEnabledVisibilityConverter x:Key="BlockItemToRemoveEnabledVisibilityConverter" />
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" />
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
<converters:AvailableThemeComponentsConverter x:Key="AvailableThemeComponentsConverter" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
@@ -58,9 +57,9 @@ namespace Filtration
.ForMember(dest => dest.IsExpanded, .ForMember(dest => dest.IsExpanded,
opts => opts.UseValue(false)); opts => opts.UseValue(false));
Mapper.CreateMap<Theme, IThemeViewModel>().ConstructUsingServiceLocator(); Mapper.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
Mapper.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap(); Mapper.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
Mapper.CreateMap<IThemeViewModel, Theme>(); Mapper.CreateMap<IThemeEditorViewModel, Theme>();
Mapper.AssertConfigurationIsValid(); Mapper.AssertConfigurationIsValid();

View File

@@ -0,0 +1,49 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.Converters
{
public class AvailableThemeComponentsConverter :IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var themeComponentsList = values[0] as ThemeComponentCollection;
if (themeComponentsList == null || themeComponentsList.Count == 0) return null;
var blockItem = values[1] as ColorBlockItem;
if (blockItem == null) return null;
ThemeComponentType themeComponentType;
if (blockItem.GetType() == typeof(BackgroundColorBlockItem))
{
themeComponentType = ThemeComponentType.BackgroundColor;
}
else if (blockItem.GetType() == typeof(TextColorBlockItem))
{
themeComponentType = ThemeComponentType.TextColor;
}
else if (blockItem.GetType() == typeof(BorderColorBlockItem))
{
themeComponentType = ThemeComponentType.BorderColor;
}
else
{
return null;
}
return themeComponentsList.Where(t => t.ComponentType == themeComponentType).ToList();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -94,6 +94,10 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="WpfAnimatedGif, Version=1.4.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WpfAnimatedGif.1.4.13\lib\net\WpfAnimatedGif.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\WPFToolkit.3.5.50211.1\lib\WPFToolkit.dll</HintPath> <HintPath>..\packages\WPFToolkit.3.5.50211.1\lib\WPFToolkit.dll</HintPath>
@@ -129,27 +133,23 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Converters\ActiveDocumentConverter.cs" /> <Compile Include="Converters\ActiveDocumentConverter.cs" />
<Compile Include="Converters\AvailableThemeComponentsConverter.cs" />
<Compile Include="Converters\BlockGroupAdvancedFillConverter.cs" /> <Compile Include="Converters\BlockGroupAdvancedFillConverter.cs" />
<Compile Include="Converters\BlockGroupAdvancedColorConverter.cs" /> <Compile Include="Converters\BlockGroupAdvancedColorConverter.cs" />
<Compile Include="Converters\BlockGroupVisibilityConverter.cs" /> <Compile Include="Converters\BlockGroupVisibilityConverter.cs" />
<Compile Include="Converters\BlockItemTypeToStringConverter.cs" /> <Compile Include="Converters\BlockItemTypeToStringConverter.cs" />
<Compile Include="Converters\BooleanInverterConverter.cs" />
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" /> <Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
<Compile Include="Converters\BooleanToBlockActionConverter.cs" /> <Compile Include="Converters\BooleanToBlockActionConverter.cs" />
<Compile Include="Converters\BooleanVisibilityConverter.cs" />
<Compile Include="Converters\BooleanVisibilityConverterCopy.cs" />
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" /> <Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
<Compile Include="Converters\HashSignRemovalConverter.cs" /> <Compile Include="Converters\HashSignRemovalConverter.cs" />
<Compile Include="Converters\ItemRarityConverter.cs" /> <Compile Include="Converters\ItemRarityConverter.cs" />
<Compile Include="Converters\InverseBooleanVisibilityConverter.cs" />
<Compile Include="Converters\StringToVisibilityConverter.cs" />
<Compile Include="Converters\TreeViewMarginConverter.cs" /> <Compile Include="Converters\TreeViewMarginConverter.cs" />
<Compile Include="Extensions\EnumerationExtension.cs" /> <Compile Include="Extensions\EnumerationExtension.cs" />
<Compile Include="Extensions\HyperlinkExtensions.cs" /> <Compile Include="Extensions\HyperlinkExtensions.cs" />
<Compile Include="Models\UpdateData.cs" /> <Compile Include="Models\UpdateData.cs" />
<Compile Include="Properties\Annotations.cs" /> <Compile Include="Properties\Annotations.cs" />
<Compile Include="Repositories\ItemFilterScriptRepository.cs" /> <Compile Include="Repositories\ItemFilterScriptRepository.cs" />
<Compile Include="Services\ClipboardService.cs" />
<Compile Include="Services\HTTPService.cs" /> <Compile Include="Services\HTTPService.cs" />
<Compile Include="Services\ItemFilterPersistenceService.cs" /> <Compile Include="Services\ItemFilterPersistenceService.cs" />
<Compile Include="Services\StaticDataService.cs" /> <Compile Include="Services\StaticDataService.cs" />
@@ -158,7 +158,6 @@
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" /> <Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
<Compile Include="Translators\ItemFilterBlockTranslator.cs" /> <Compile Include="Translators\ItemFilterBlockTranslator.cs" />
<Compile Include="Translators\ItemFilterScriptTranslator.cs" /> <Compile Include="Translators\ItemFilterScriptTranslator.cs" />
<Compile Include="Translators\ThemeComponentListBuilder.cs" />
<Compile Include="UserControls\AutoScrollingListBox.cs" /> <Compile Include="UserControls\AutoScrollingListBox.cs" />
<Compile Include="UserControls\BlockItemControl.xaml.cs"> <Compile Include="UserControls\BlockItemControl.xaml.cs">
<DependentUpon>BlockItemControl.xaml</DependentUpon> <DependentUpon>BlockItemControl.xaml</DependentUpon>
@@ -170,6 +169,9 @@
<Compile Include="UserControls\ItemPreviewControl.xaml.cs"> <Compile Include="UserControls\ItemPreviewControl.xaml.cs">
<DependentUpon>ItemPreviewControl.xaml</DependentUpon> <DependentUpon>ItemPreviewControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UserControls\ThemeComponentSelectionControl.xaml.cs">
<DependentUpon>ThemeComponentSelectionControl.xaml</DependentUpon>
</Compile>
<Compile Include="Utilities\AutoMapperHelpers.cs" /> <Compile Include="Utilities\AutoMapperHelpers.cs" />
<Compile Include="Utilities\BlockGroupMapper.cs" /> <Compile Include="Utilities\BlockGroupMapper.cs" />
<Compile Include="Utilities\LineReader.cs" /> <Compile Include="Utilities\LineReader.cs" />
@@ -201,6 +203,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UserControls\ThemeComponentSelectionControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Styles\ListBoxItem.xaml"> <Page Include="Views\Styles\ListBoxItem.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
@@ -242,7 +248,6 @@
<Compile Include="Views\UpdateAvailableView.xaml.cs"> <Compile Include="Views\UpdateAvailableView.xaml.cs">
<DependentUpon>UpdateAvailableView.xaml</DependentUpon> <DependentUpon>UpdateAvailableView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="WindsorInstallers\ModelsInstaller.cs" />
<Compile Include="WindsorInstallers\RepositoriesInstaller.cs" /> <Compile Include="WindsorInstallers\RepositoriesInstaller.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" /> <Compile Include="WindsorInstallers\ServicesInstaller.cs" />
<Compile Include="WindsorInstallers\TranslatorsInstaller.cs" /> <Compile Include="WindsorInstallers\TranslatorsInstaller.cs" />
@@ -304,10 +309,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\SharedResourcesDictionary.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ItemFilterScriptView.xaml"> <Page Include="Views\ItemFilterScriptView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -368,10 +369,14 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Resource Include="Resources\loading_spinner.gif" />
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<Content Include="LICENSE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="NLog.config"> <Content Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
@@ -427,6 +432,10 @@
<Resource Include="Resources\Icons\ReplaceColors.ico" /> <Resource Include="Resources\Icons\ReplaceColors.ico" />
<Resource Include="Resources\Icons\Theme.ico" /> <Resource Include="Resources\Icons\Theme.ico" />
<Resource Include="Resources\Icons\filtration_icon.png" /> <Resource Include="Resources\Icons\filtration_icon.png" />
<Resource Include="Resources\Icons\Add.ico" />
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
<Resource Include="Resources\Icons\standby_disabled_icon.png" />
<Resource Include="Resources\Icons\standby_enabled_icon.png" />
<Content Include="Resources\ItemBaseTypes.txt"> <Content Include="Resources\ItemBaseTypes.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>

339
Filtration/LICENSE.txt Normal file
View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -7,7 +7,7 @@ using System.Windows;
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Filtration")] [assembly: AssemblyTitle("Filtration")]
[assembly: AssemblyDescription("An item filter script manager for Path of Exile")] [assembly: AssemblyDescription("An item filter script editor for Path of Exile")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("XVar Industries Inc.")] [assembly: AssemblyCompany("XVar Industries Inc.")]
[assembly: AssemblyProduct("Filtration")] [assembly: AssemblyProduct("Filtration")]
@@ -50,7 +50,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.*")] [assembly: AssemblyVersion("0.11.*")]
[assembly: InternalsVisibleTo("Filtration.Tests")] [assembly: InternalsVisibleTo("Filtration.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]

View File

@@ -1,5 +1,4 @@
using System; using System.Threading.Tasks;
using System.IO;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.Services; using Filtration.Services;
using Filtration.ViewModels; using Filtration.ViewModels;
@@ -8,7 +7,7 @@ namespace Filtration.Repositories
{ {
internal interface IItemFilterScriptRepository internal interface IItemFilterScriptRepository
{ {
IItemFilterScriptViewModel LoadScriptFromFile(string path); Task<IItemFilterScriptViewModel> LoadScriptFromFileAsync(string path);
IItemFilterScriptViewModel NewScript(); IItemFilterScriptViewModel NewScript();
string GetItemFilterScriptDirectory(); string GetItemFilterScriptDirectory();
void SetItemFilterScriptDirectory(string path); void SetItemFilterScriptDirectory(string path);
@@ -26,9 +25,9 @@ namespace Filtration.Repositories
_itemFilterScriptViewModelFactory = itemFilterScriptViewModelFactory; _itemFilterScriptViewModelFactory = itemFilterScriptViewModelFactory;
} }
public IItemFilterScriptViewModel LoadScriptFromFile(string path) public async Task<IItemFilterScriptViewModel> LoadScriptFromFileAsync(string path)
{ {
var loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path); var loadedScript = await _itemFilterPersistenceService.LoadItemFilterScriptAsync(path);
var newViewModel = _itemFilterScriptViewModelFactory.Create(); var newViewModel = _itemFilterScriptViewModelFactory.Create();
newViewModel.Initialise(loadedScript, false); newViewModel.Initialise(loadedScript, false);

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -1069,3 +1069,54 @@ Sage Wand
Serpent Wand Serpent Wand
Spiraled Wand Spiraled Wand
Tornado Wand Tornado Wand
Abandoned Wealth
The Avenger
The Battle Born
Birth of the Three
The Brittle Emperor
The Carrion Crow
The Cataclysm
The Celestial Justicar
The Chains that Bind
Chaotic Disposition
Coveted Possession
The Dark Mage
The Doctor
The Drunken Aristocrat
Emperor's Luck
The Explorer
The Feast
The Fiend
The Gambler
The Gemcutter
Gemcutter's Promise
The Gladiator
The Hermit
The Hoarder
Hope
The Hunger
Humility
The Incantation
The Inventor
Jack in the Box
The King's Heart
Lantador's Lost Love
The Lover
Lucky Connections
The Metalsmith's Gift
The Pact
The Poet
The Queen
Rain of Chaos
The Road to Power
The Scarred Meadow
The Scholar
The Summoner
The Sun
Three Faces in the Dark
Time-Lost Relic
The Union
Vinia's Token
The Warden
The Watcher
The Wind

View File

@@ -34,3 +34,5 @@ Fishing Rods
Map Fragments Map Fragments
Hideout Doodads Hideout Doodads
Microtransactions Microtransactions
Divination Card
Jewel

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -0,0 +1,43 @@
using System;
using System.Threading;
using System.Windows;
using NLog;
namespace Filtration.Services
{
internal interface IClipboardService
{
void SetClipboardText(string inputText);
string GetClipboardText();
}
internal class ClipboardService : IClipboardService
{
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
public void SetClipboardText(string inputText)
{
for (var i = 0; i < 10; i++)
{
try
{
Clipboard.SetText(inputText);
return;
}
catch (Exception e)
{
_logger.Error(e);
}
Thread.Sleep(10);
}
throw new Exception("Failed to copy to clipboard");
}
public string GetClipboardText()
{
return Clipboard.GetText();
}
}
}

View File

@@ -1,4 +1,5 @@
using System.IO; using System.IO;
using System.Threading.Tasks;
using Filtration.Common.Services; using Filtration.Common.Services;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.Properties; using Filtration.Properties;
@@ -10,8 +11,8 @@ namespace Filtration.Services
{ {
void SetItemFilterScriptDirectory(string path); void SetItemFilterScriptDirectory(string path);
string ItemFilterScriptDirectory { get; } string ItemFilterScriptDirectory { get; }
ItemFilterScript LoadItemFilterScript(string filePath); Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath);
void SaveItemFilterScript(ItemFilterScript script); Task SaveItemFilterScriptAsync(ItemFilterScript script);
string DefaultPathOfExileDirectory(); string DefaultPathOfExileDirectory();
} }
@@ -58,20 +59,30 @@ namespace Filtration.Services
Settings.Default.DefaultFilterDirectory = path; Settings.Default.DefaultFilterDirectory = path;
} }
public ItemFilterScript LoadItemFilterScript(string filePath) public async Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath)
{ {
var script = ItemFilterScript loadedScript = null;
_itemFilterScriptTranslator.TranslateStringToItemFilterScript( await Task.Run(() =>
{
loadedScript = _itemFilterScriptTranslator.TranslateStringToItemFilterScript(
_fileSystemService.ReadFileAsString(filePath)); _fileSystemService.ReadFileAsString(filePath));
});
script.FilePath = filePath; if (loadedScript != null)
return script; {
loadedScript.FilePath = filePath;
}
return loadedScript;
} }
public void SaveItemFilterScript(ItemFilterScript script) public async Task SaveItemFilterScriptAsync(ItemFilterScript script)
{ {
_fileSystemService.WriteFileFromString(script.FilePath, await Task.Run(() =>
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(script)); {
_fileSystemService.WriteFileFromString(script.FilePath,
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(script));
});
} }
} }
} }

View File

@@ -1,6 +1,8 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows;
using Filtration.Common.Services; using Filtration.Common.Services;
using Filtration.Utilities; using Filtration.Utilities;
@@ -28,10 +30,10 @@ namespace Filtration.Services
private void PopulateStaticData() private void PopulateStaticData()
{ {
var itemBaseTypes = _fileSystemService.ReadFileAsString("Resources\\ItemBaseTypes.txt"); var itemBaseTypes = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemBaseTypes.txt");
ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList(); ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList();
var itemClasses = _fileSystemService.ReadFileAsString("Resources\\ItemClasses.txt"); var itemClasses = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemClasses.txt");
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList(); ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
} }
} }

View File

@@ -7,21 +7,20 @@ namespace Filtration.Services
{ {
internal interface IUpdateCheckService internal interface IUpdateCheckService
{ {
Task<UpdateData> GetUpdateData(); Task<UpdateData> GetUpdateDataAsync();
} }
internal class UpdateCheckService : IUpdateCheckService internal class UpdateCheckService : IUpdateCheckService
{ {
private readonly IHTTPService _httpService; private readonly IHTTPService _httpService;
//private const string UpdateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml"; private const string UpdateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml";
private const string UpdateDataUrl = "http://xvar.net/filtration_version.xml";
public UpdateCheckService(IHTTPService httpService) public UpdateCheckService(IHTTPService httpService)
{ {
_httpService = httpService; _httpService = httpService;
} }
public async Task<UpdateData> GetUpdateData() public async Task<UpdateData> GetUpdateDataAsync()
{ {
var updateXml = await _httpService.GetContentAsync(UpdateDataUrl); var updateXml = await _httpService.GetContentAsync(UpdateDataUrl);
return (DeserializeUpdateData(updateXml)); return (DeserializeUpdateData(updateXml));

View File

@@ -10,14 +10,15 @@ using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions; using Filtration.ObjectModel.Extensions;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.Utilities; using Filtration.Utilities;
namespace Filtration.Translators namespace Filtration.Translators
{ {
internal interface IItemFilterBlockTranslator internal interface IItemFilterBlockTranslator
{ {
void InitialiseForExistingScript(ItemFilterScript script); ItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString); ThemeComponentCollection masterComponentCollection);
string TranslateItemFilterBlockToString(ItemFilterBlock block); string TranslateItemFilterBlockToString(ItemFilterBlock block);
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString); void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
} }
@@ -25,28 +26,24 @@ namespace Filtration.Translators
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
{ {
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder; private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
private const string Indent = " "; private const string Indent = " ";
private readonly string _newLine = Environment.NewLine + Indent; private readonly string _newLine = Environment.NewLine + Indent;
private readonly string _disabledNewLine = Environment.NewLine + "#" + Indent;
private ThemeComponentCollection _masterComponentCollection;
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder, IThemeComponentListBuilder themeComponentListBuilder) public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
{ {
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder; _blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
_themeComponentListBuilder = themeComponentListBuilder;
}
public void InitialiseForExistingScript(ItemFilterScript script)
{
_themeComponentListBuilder.Initialise(script.ThemeComponents);
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
} }
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks // This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
// and reading ItemFilterScripts from a file. // and reading ItemFilterScripts from a file.
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString) public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString, ThemeComponentCollection masterComponentCollection)
{ {
_masterComponentCollection = masterComponentCollection;
var block = new ItemFilterBlock(); var block = new ItemFilterBlock();
var showHideFound = false; var showHideFound = false;
foreach (var line in new LineReader(() => new StringReader(inputString))) foreach (var line in new LineReader(() => new StringReader(inputString)))
{ {
@@ -67,6 +64,7 @@ namespace Filtration.Translators
var adjustedLine = line.Replace("#", " # "); var adjustedLine = line.Replace("#", " # ");
var trimmedLine = adjustedLine.TrimStart(' '); var trimmedLine = adjustedLine.TrimStart(' ');
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length; var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos); var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
@@ -75,11 +73,25 @@ namespace Filtration.Translators
case "Show": case "Show":
showHideFound = true; showHideFound = true;
block.Action = BlockAction.Show; block.Action = BlockAction.Show;
block.Enabled = true;
AddBlockGroupToBlock(block, trimmedLine); AddBlockGroupToBlock(block, trimmedLine);
break; break;
case "Hide": case "Hide":
showHideFound = true; showHideFound = true;
block.Action = BlockAction.Hide; block.Action = BlockAction.Hide;
block.Enabled = true;
AddBlockGroupToBlock(block, trimmedLine);
break;
case "ShowDisabled":
showHideFound = true;
block.Action = BlockAction.Show;
block.Enabled = false;
AddBlockGroupToBlock(block, trimmedLine);
break;
case "HideDisabled":
showHideFound = true;
block.Action = BlockAction.Hide;
block.Enabled = false;
AddBlockGroupToBlock(block, trimmedLine); AddBlockGroupToBlock(block, trimmedLine);
break; break;
case "ItemLevel": case "ItemLevel":
@@ -300,9 +312,9 @@ namespace Filtration.Translators
{ {
throw new Exception("Parsing error - unknown theme component type"); throw new Exception("Parsing error - unknown theme component type");
} }
if (_themeComponentListBuilder.IsInitialised) if (_masterComponentCollection != null)
{ {
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName, blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
blockItem.Color); blockItem.Color);
} }
} }
@@ -404,12 +416,17 @@ namespace Filtration.Translators
var outputString = string.Empty; var outputString = string.Empty;
if (!block.Enabled)
{
outputString += "#Disabled Block Start" + Environment.NewLine;
}
if (!string.IsNullOrEmpty(block.Description)) if (!string.IsNullOrEmpty(block.Description))
{ {
outputString += "# " + block.Description + Environment.NewLine; outputString += "# " + block.Description + Environment.NewLine;
} }
outputString += block.Action.GetAttributeDescription(); outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription();
if (block.BlockGroup != null) if (block.BlockGroup != null)
{ {
@@ -421,10 +438,15 @@ namespace Filtration.Translators
{ {
if (blockItem.OutputText != string.Empty) if (blockItem.OutputText != string.Empty)
{ {
outputString += _newLine + blockItem.OutputText; outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText;
} }
} }
if (!block.Enabled)
{
outputString += Environment.NewLine + "#Disabled Block End";
}
return outputString; return outputString;
} }
} }

View File

@@ -20,15 +20,72 @@ namespace Filtration.Translators
{ {
private readonly IItemFilterBlockTranslator _blockTranslator; private readonly IItemFilterBlockTranslator _blockTranslator;
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder; private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
public ItemFilterScriptTranslator(IItemFilterBlockTranslator blockTranslator, public ItemFilterScriptTranslator(IItemFilterBlockTranslator blockTranslator,
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder, IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
IThemeComponentListBuilder themeComponentListBuilder)
{ {
_blockTranslator = blockTranslator; _blockTranslator = blockTranslator;
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder; _blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
_themeComponentListBuilder = themeComponentListBuilder; }
public string PreprocessDisabledBlocks(string inputString)
{
bool inDisabledBlock = false;
var showHideFound = false;
var lines = Regex.Split(inputString, "\r\n|\r|\n").ToList();
var linesToRemove = new List<int>();
for (var i = 0; i < lines.Count; i++)
{
if (lines[i].StartsWith("#Disabled Block Start"))
{
inDisabledBlock = true;
linesToRemove.Add(i);
continue;
}
if (inDisabledBlock)
{
if (lines[i].StartsWith("#Disabled Block End"))
{
inDisabledBlock = false;
showHideFound = false;
linesToRemove.Add(i);
continue;
}
lines[i] = lines[i].TrimStart('#');
lines[i] = lines[i].Replace("#", " # ");
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
// If we haven't found a Show or Hide line yet, then this is probably the block comment.
// Put its # back on and skip to the next line.
if (lineOption != "Show" && lineOption != "Hide" && showHideFound == false)
{
lines[i] = "#" + lines[i];
continue;
}
if (lineOption == "Show")
{
lines[i] = lines[i].Replace("Show", "ShowDisabled");
showHideFound = true;
}
else if (lineOption == "Hide")
{
lines[i] = lines[i].Replace("Hide", "HideDisabled");
showHideFound = true;
}
}
}
for (var i = linesToRemove.Count - 1; i >= 0; i--)
{
lines.RemoveAt(linesToRemove[i]);
}
return lines.Aggregate((c, n) => c + Environment.NewLine + n);
} }
public ItemFilterScript TranslateStringToItemFilterScript(string inputString) public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
@@ -37,6 +94,11 @@ namespace Filtration.Translators
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First()); _blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
inputString = inputString.Replace("\t", ""); inputString = inputString.Replace("\t", "");
if (inputString.Contains("#Disabled Block Start"))
{
inputString = PreprocessDisabledBlocks(inputString);
}
var conditionBoundaries = IdentifyBlockBoundaries(inputString); var conditionBoundaries = IdentifyBlockBoundaries(inputString);
var lines = Regex.Split(inputString, "\r\n|\r|\n"); var lines = Regex.Split(inputString, "\r\n|\r|\n");
@@ -55,8 +117,6 @@ namespace Filtration.Translators
script.Description = script.Description.TrimEnd('\n').TrimEnd('\r'); script.Description = script.Description.TrimEnd('\n').TrimEnd('\r');
} }
_themeComponentListBuilder.Initialise();
// Extract each block from between boundaries and translate it into a ItemFilterBlock object // Extract each block from between boundaries and translate it into a ItemFilterBlock object
// and add that object to the ItemFilterBlocks list // and add that object to the ItemFilterBlocks list
for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next) for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next)
@@ -66,12 +126,10 @@ namespace Filtration.Translators
var block = new string[end - begin]; var block = new string[end - begin];
Array.Copy(lines, begin, block, 0, end - begin); Array.Copy(lines, begin, block, 0, end - begin);
var blockString = string.Join("\r\n", block); var blockString = string.Join("\r\n", block);
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString)); script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString, script.ThemeComponents));
} }
script.ThemeComponents = _themeComponentListBuilder.GetComponents();
_blockGroupHierarchyBuilder.Cleanup(); _blockGroupHierarchyBuilder.Cleanup();
_themeComponentListBuilder.Cleanup();
return script; return script;
} }
@@ -92,7 +150,10 @@ namespace Filtration.Translators
// as it represents the block description. // as it represents the block description.
// currentLine > 2 caters for an edge case where the script description is a single line and the first // currentLine > 2 caters for an edge case where the script description is a single line and the first
// block has no description. This prevents the script description from being assigned to the first block's description. // block has no description. This prevents the script description from being assigned to the first block's description.
blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") && currentLine > 2 ? currentLine - 2 : currentLine - 1); blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") &&
currentLine > 2
? currentLine - 2
: currentLine - 1);
} }
previousLine = line; previousLine = line;
} }

View File

@@ -1,74 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.Translators
{
internal interface IThemeComponentListBuilder
{
void Initialise();
void Initialise(List<ThemeComponent> themeComponents);
bool IsInitialised { get; }
ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor);
List<ThemeComponent> GetComponents();
void Cleanup();
}
internal class ThemeComponentListBuilder : IThemeComponentListBuilder
{
private List<ThemeComponent> _themeComponents;
public ThemeComponentListBuilder()
{
}
public bool IsInitialised
{
get
{
return _themeComponents != null;
}
}
public void Initialise()
{
_themeComponents = new List<ThemeComponent>();
}
public void Initialise(List<ThemeComponent> themeComponents)
{
_themeComponents = themeComponents;
}
public void Cleanup()
{
_themeComponents = null;
}
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
if (ComponentExists(componentType, componentName))
{
return _themeComponents.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
}
var component = new ThemeComponent(componentType, componentName, componentColor);
_themeComponents.Add(component);
return component;
}
public List<ThemeComponent> GetComponents()
{
return _themeComponents;
}
private bool ComponentExists(ThemeComponentType componentType, string componentName)
{
return _themeComponents.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType);
}
}
}

View File

@@ -13,21 +13,6 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=userControls:BlockItemControl}" d:DataContext="{d:DesignInstance Type=userControls:BlockItemControl}"
d:DesignHeight="200" d:DesignWidth="150"> d:DesignHeight="200" d:DesignWidth="150">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<Style TargetType="{x:Type Border}" x:Key="BlockItemBorder">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Margin" Value="0,0,5,5" />
</Style>
</ResourceDictionary>
<ResourceDictionary Source="../Views/SharedResourcesDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border Style="{StaticResource BlockItemBorder}" Width="142"> <Border Style="{StaticResource BlockItemBorder}" Width="142">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -86,7 +71,19 @@
<!-- Color Template --> <!-- Color Template -->
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}"> <DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}">
<xctk:ColorPicker SelectedColor="{Binding Color}" AvailableColors="{Binding ElementName=BlockItemContentControl, Path=DataContext.AvailableColors }" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/> <StackPanel>
<xctk:ColorPicker SelectedColor="{Binding Color}" AvailableColors="{Binding ElementName=BlockItemContentControl, Path=DataContext.AvailableColors }" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}"
Margin="0,2,0,2">
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." />
</MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl>
</StackPanel>
</DataTemplate> </DataTemplate>
<!-- Font Size Template --> <!-- Font Size Template -->
@@ -103,7 +100,7 @@
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button> </Button>
<ComboBox ItemsSource="{Binding ElementName=BlockItemContentControl, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}" /> <ComboBox ItemsSource="{Binding ElementName=BlockItemContentControl, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}" />
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="100" HorizontalAlignment="Right" ToolTip="Volume"/> <xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="300" HorizontalAlignment="Right" ToolTip="Volume"/>
</WrapPanel> </WrapPanel>
</DataTemplate> </DataTemplate>
</ContentControl.Resources> </ContentControl.Resources>

View File

@@ -19,8 +19,12 @@ namespace Filtration.UserControls
InitializeComponent(); InitializeComponent();
// ReSharper disable once PossibleNullReferenceException // ReSharper disable once PossibleNullReferenceException
(Content as FrameworkElement).DataContext = this; (Content as FrameworkElement).DataContext = this;
SetBlockColorCommand = new RelayCommand(OnSetBlockColorCommmand);
} }
public RelayCommand SetBlockColorCommand { get; private set; }
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register( public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
"BlockItem", "BlockItem",
typeof(IItemFilterBlockItem), typeof(IItemFilterBlockItem),
@@ -94,6 +98,14 @@ namespace Filtration.UserControls
} }
} }
private void OnSetBlockColorCommmand()
{
var blockItem = BlockItem as ColorBlockItem;
if (blockItem == null || blockItem.ThemeComponent == null) return;
blockItem.Color = blockItem.ThemeComponent.Color;
}
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator] [NotifyPropertyChangedInvocator]

View File

@@ -7,9 +7,6 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=userControls:ItemPreviewControl}" d:DataContext="{d:DesignInstance Type=userControls:ItemPreviewControl}"
d:DesignHeight="35" d:DesignWidth="170"> d:DesignHeight="35" d:DesignWidth="170">
<UserControl.Resources>
<ResourceDictionary Source="../Views/SharedResourcesDictionary.xaml" />
</UserControl.Resources>
<Border BorderBrush="Black" BorderThickness="1"> <Border BorderBrush="Black" BorderThickness="1">
<Grid Width="166" Height="39"> <Grid Width="166" Height="39">
<Image Source="pack://application:,,,/resources/groundtile.png" Stretch="Fill" /> <Image Source="pack://application:,,,/resources/groundtile.png" Stretch="Fill" />

View File

@@ -1,5 +1,4 @@
using System; using System.Windows;
using System.Windows;
using System.Windows.Media; using System.Windows.Media;
namespace Filtration.UserControls namespace Filtration.UserControls

View File

@@ -0,0 +1,79 @@
<UserControl x:Class="Filtration.UserControls.ThemeComponentSelectionControl"
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:userControls="clr-namespace:Filtration.UserControls"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=userControls:ThemeComponentSelectionControl}"
d:DesignHeight="50" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Height="20">
<Grid.Resources>
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource MetroComboBox}">
<Setter Property="MinHeight" Value="0" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0"
ItemsSource="{Binding AvailableThemeComponents}"
SelectedValue="{Binding ThemeComponent}"
Grid.IsSharedSizeScope="True"
Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SetBlockColorCommand, RelativeSource={RelativeSource AncestorType=userControls:BlockItemControl}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ComboBox.ItemTemplate>
<DataTemplate >
<ContentControl Content="{Binding}">
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="ComponentNameColumn" Width="Auto" />
<ColumnDefinition SharedSizeGroup="ComponentColorColumn" Width="20" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding ComponentName}" Margin="0,0,2,0" />
<Border Grid.Column="1" Background="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ComboBoxItem}}" Value="{x:Null}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding ComponentName}" />
</DataTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<userControls:CrossButton Grid.Column="1" Height="12" Command="{Binding RemoveThemeComponentCommand}" VerticalAlignment="Top" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource InverseBooleanVisibilityConverter}}" VerticalAlignment="Center">
<Hyperlink Command="{Binding AddThemeComponentCommand}">Add Theme Tag</Hyperlink>
</TextBlock>
</Grid>
</UserControl>

View File

@@ -0,0 +1,99 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using Filtration.Annotations;
using Filtration.ObjectModel.ThemeEditor;
using GalaSoft.MvvmLight.CommandWpf;
namespace Filtration.UserControls
{
public partial class ThemeComponentSelectionControl : INotifyPropertyChanged
{
public ThemeComponentSelectionControl()
{
InitializeComponent();
(Content as FrameworkElement).DataContext = this;
AddThemeComponentCommand = new RelayCommand(OnAddThemeComponentCommand);
RemoveThemeComponentCommand = new RelayCommand(OnRemoveThemeComponentCommand);
}
public static readonly DependencyProperty ThemeComponentProperty = DependencyProperty.Register(
"ThemeComponent",
typeof(ThemeComponent),
typeof(ThemeComponentSelectionControl),
new FrameworkPropertyMetadata() { BindsTwoWayByDefault = true });
public static readonly DependencyProperty AvailableThemeComponentsProperty = DependencyProperty.Register(
"AvailableThemeComponents",
typeof(List<ThemeComponent>),
typeof(ThemeComponentSelectionControl),
new FrameworkPropertyMetadata());
private bool _showThemeComponentComboBox;
public RelayCommand AddThemeComponentCommand { get; private set; }
public RelayCommand RemoveThemeComponentCommand { get; private set; }
public ThemeComponent ThemeComponent
{
get
{
return (ThemeComponent)GetValue(ThemeComponentProperty);
}
set
{
SetValue(ThemeComponentProperty, value);
}
}
public List<ThemeComponent> AvailableThemeComponents
{
get
{
return (List<ThemeComponent>)GetValue(AvailableThemeComponentsProperty);
}
set
{
SetValue(AvailableThemeComponentsProperty, value);
OnPropertyChanged();
}
}
public bool ShowThemeComponentComboBox
{
get { return _showThemeComponentComboBox || HasThemeComponent; }
set
{
_showThemeComponentComboBox = value;
OnPropertyChanged();
OnPropertyChanged("HasThemeComponent");
}
}
public bool HasThemeComponent
{
get { return ThemeComponent != null; }
}
private void OnAddThemeComponentCommand()
{
ShowThemeComponentComboBox = true;
}
private void OnRemoveThemeComponentCommand()
{
ThemeComponent = null;
ShowThemeComponentComboBox = false;
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -17,7 +17,8 @@ namespace Filtration.Utilities
if (viewModel.ChildGroups.All(g => g.IsChecked == true)) if (viewModel.ChildGroups.All(g => g.IsChecked == true))
{ {
viewModel.IsChecked = true; viewModel.IsChecked = true;
} else if (viewModel.ChildGroups.Any(g => g.IsChecked == true)) }
else if (viewModel.ChildGroups.Any(g => g.IsChecked == true || g.IsChecked == null))
{ {
viewModel.IsChecked = null; viewModel.IsChecked = null;
} }

View File

@@ -1,6 +1,5 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Net.Mime;
using AutoMapper; using AutoMapper;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ViewModels; using Filtration.ViewModels;

View File

@@ -1,8 +1,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
using Filtration.Common.ViewModels; using Filtration.Common.ViewModels;
using Filtration.Interface; using Filtration.Interface;
using Filtration.ThemeEditor.ViewModels;
using Filtration.ViewModels.ToolPanes; using Filtration.ViewModels.ToolPanes;
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
@@ -14,12 +16,14 @@ namespace Filtration.ViewModels
IDocument ActiveDocument { get; set; } IDocument ActiveDocument { get; set; }
ReadOnlyObservableCollection<IDocument> OpenDocuments { get; } ReadOnlyObservableCollection<IDocument> OpenDocuments { get; }
IItemFilterScriptViewModel ActiveScriptViewModel { get; } IItemFilterScriptViewModel ActiveScriptViewModel { get; }
IThemeEditorViewModel ActiveThemeViewModel { get; }
ISectionBrowserViewModel SectionBrowserViewModel { get; } ISectionBrowserViewModel SectionBrowserViewModel { get; }
IBlockGroupBrowserViewModel BlockGroupBrowserViewModel { get; } IBlockGroupBrowserViewModel BlockGroupBrowserViewModel { get; }
IBlockOutputPreviewViewModel BlockOutputPreviewViewModel { get; } IBlockOutputPreviewViewModel BlockOutputPreviewViewModel { get; }
void AddDocument(IDocument document); void AddDocument(IDocument document);
void CloseDocument(IDocument document); void CloseDocument(IDocument document);
void SwitchActiveDocument(IDocument document); void SwitchActiveDocument(IDocument document);
IThemeEditorViewModel OpenMasterThemeForScript(IItemFilterScriptViewModel scriptViewModel);
} }
internal class AvalonDockWorkspaceViewModel : FiltrationViewModelBase, IAvalonDockWorkspaceViewModel internal class AvalonDockWorkspaceViewModel : FiltrationViewModelBase, IAvalonDockWorkspaceViewModel
@@ -30,13 +34,14 @@ namespace Filtration.ViewModels
private IDocument _activeDocument; private IDocument _activeDocument;
private IItemFilterScriptViewModel _activeScriptViewModel; private IItemFilterScriptViewModel _activeScriptViewModel;
private IThemeEditorViewModel _activeThemeViewModel;
private readonly ObservableCollection<IDocument> _openDocuments; private readonly ObservableCollection<IDocument> _openDocuments;
private readonly ReadOnlyObservableCollection<IDocument> _readOnlyOpenDocuments; private readonly ReadOnlyObservableCollection<IDocument> _readOnlyOpenDocuments;
public AvalonDockWorkspaceViewModel(ISectionBrowserViewModel sectionBrowserViewModel, public AvalonDockWorkspaceViewModel(ISectionBrowserViewModel sectionBrowserViewModel,
IBlockGroupBrowserViewModel blockGroupBrowserViewModel, IBlockGroupBrowserViewModel blockGroupBrowserViewModel,
IStartPageViewModel startPageViewModel, IStartPageViewModel startPageViewModel,
IBlockOutputPreviewViewModel blockOutputPreviewViewModel) IBlockOutputPreviewViewModel blockOutputPreviewViewModel)
{ {
_sectionBrowserViewModel = sectionBrowserViewModel; _sectionBrowserViewModel = sectionBrowserViewModel;
_blockGroupBrowserViewModel = blockGroupBrowserViewModel; _blockGroupBrowserViewModel = blockGroupBrowserViewModel;
@@ -72,9 +77,14 @@ namespace Filtration.ViewModels
{ {
_activeScriptViewModel = (IItemFilterScriptViewModel) value; _activeScriptViewModel = (IItemFilterScriptViewModel) value;
} }
else if (value.IsTheme)
{
_activeThemeViewModel = (IThemeEditorViewModel) value;
}
else else
{ {
_activeScriptViewModel = null; _activeScriptViewModel = null;
_activeThemeViewModel = null;
} }
if (ActiveDocumentChanged != null) if (ActiveDocumentChanged != null)
@@ -91,6 +101,11 @@ namespace Filtration.ViewModels
get { return _activeScriptViewModel; } get { return _activeScriptViewModel; }
} }
public IThemeEditorViewModel ActiveThemeViewModel
{
get { return _activeThemeViewModel; }
}
public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel
{ {
get { return _blockGroupBrowserViewModel; } get { return _blockGroupBrowserViewModel; }
@@ -127,6 +142,10 @@ namespace Filtration.ViewModels
{ {
_activeScriptViewModel = (IItemFilterScriptViewModel) document; _activeScriptViewModel = (IItemFilterScriptViewModel) document;
} }
else if (document.IsTheme)
{
_activeThemeViewModel = (IThemeEditorViewModel) document;
}
_openDocuments.Add(document); _openDocuments.Add(document);
ActiveDocument = document; ActiveDocument = document;
@@ -151,6 +170,19 @@ namespace Filtration.ViewModels
{ {
_activeDocument = null; _activeDocument = null;
} }
// TODO: Replace _activeScriptViewModel and _activeThemeViewModel with a better solution.
if (document.IsScript && _activeScriptViewModel == (IItemFilterScriptViewModel) document)
{
_activeScriptViewModel = null;
}
if (document.IsTheme && _activeThemeViewModel == (IThemeEditorViewModel)document)
{
_activeThemeViewModel = null;
}
} }
public void SwitchActiveDocument(IDocument document) public void SwitchActiveDocument(IDocument document)
@@ -162,5 +194,19 @@ namespace Filtration.ViewModels
ActiveDocument = document; ActiveDocument = document;
} }
public IThemeEditorViewModel OpenMasterThemeForScript(IItemFilterScriptViewModel scriptViewModel)
{
var existingMasterThemeViewModelCount =
OpenDocuments.OfType<IThemeEditorViewModel>()
.Count(c => c.IsMasterThemeForScript == scriptViewModel.Script);
if (existingMasterThemeViewModelCount > 0)
{
return OpenDocuments.OfType<IThemeEditorViewModel>()
.First(c => c.IsMasterThemeForScript == scriptViewModel.Script);
}
return null;
}
} }
} }

View File

@@ -21,6 +21,7 @@ namespace Filtration.ViewModels
bool IsDirty { get; set; } bool IsDirty { get; set; }
bool IsExpanded { get; set; } bool IsExpanded { get; set; }
ItemFilterBlock Block { get; } ItemFilterBlock Block { get; }
bool BlockEnabled { get; set; }
void RefreshBlockPreview(); void RefreshBlockPreview();
} }
@@ -209,6 +210,20 @@ namespace Filtration.ViewModels
} }
} }
public bool BlockEnabled
{
get { return Block.Enabled; }
set
{
if (Block.Enabled != value)
{
Block.Enabled = value;
IsDirty = true;
RaisePropertyChanged();
}
}
}
public string BlockDescription public string BlockDescription
{ {
get get
@@ -302,6 +317,12 @@ namespace Filtration.ViewModels
get { return Block.HasBlockItemOfType<SoundBlockItem>(); } get { return Block.HasBlockItemOfType<SoundBlockItem>(); }
} }
public bool HasAudioVisualBlockItems
{
get { return AudioVisualBlockItems.Any(); }
}
private void OnSwitchBlockItemsViewCommand() private void OnSwitchBlockItemsViewCommand()
{ {
AudioVisualBlockItemsGridVisible = !AudioVisualBlockItemsGridVisible; AudioVisualBlockItemsGridVisible = !AudioVisualBlockItemsGridVisible;
@@ -444,6 +465,7 @@ namespace Filtration.ViewModels
RaisePropertyChanged("RegularBlockItems"); RaisePropertyChanged("RegularBlockItems");
RaisePropertyChanged("SummaryBlockItems"); RaisePropertyChanged("SummaryBlockItems");
RaisePropertyChanged("AudioVisualBlockItems"); RaisePropertyChanged("AudioVisualBlockItems");
RaisePropertyChanged("HasAudioVisualBlockItems");
} }
} }
} }

View File

@@ -4,21 +4,21 @@ using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Castle.Core.Internal;
using Filtration.Common.Services; using Filtration.Common.Services;
using Filtration.Common.ViewModels; using Filtration.Common.ViewModels;
using Filtration.Interface; using Filtration.Interface;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Services; using Filtration.Services;
using Filtration.Translators; using Filtration.Translators;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
using NLog; using NLog;
using Clipboard = System.Windows.Clipboard;
namespace Filtration.ViewModels namespace Filtration.ViewModels
{ {
@@ -37,9 +37,13 @@ namespace Filtration.ViewModels
void Initialise(ItemFilterScript itemFilterScript, bool newScript); void Initialise(ItemFilterScript itemFilterScript, bool newScript);
void RemoveDirtyFlag(); void RemoveDirtyFlag();
void SetDirtyFlag(); void SetDirtyFlag();
bool HasSelectedEnabledBlock();
bool HasSelectedDisabledBlock();
RelayCommand AddBlockCommand { get; } RelayCommand AddBlockCommand { get; }
RelayCommand AddSectionCommand { get; } RelayCommand AddSectionCommand { get; }
RelayCommand DisableBlockCommand { get; }
RelayCommand EnableBlockCommand { get; }
RelayCommand DeleteBlockCommand { get; } RelayCommand DeleteBlockCommand { get; }
RelayCommand MoveBlockUpCommand { get; } RelayCommand MoveBlockUpCommand { get; }
RelayCommand MoveBlockDownCommand { get; } RelayCommand MoveBlockDownCommand { get; }
@@ -71,6 +75,8 @@ namespace Filtration.ViewModels
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel; private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
private readonly IItemFilterPersistenceService _persistenceService; private readonly IItemFilterPersistenceService _persistenceService;
private readonly IMessageBoxService _messageBoxService; private readonly IMessageBoxService _messageBoxService;
private readonly IClipboardService _clipboardService;
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
private bool _isDirty; private bool _isDirty;
private IItemFilterBlockViewModel _selectedBlockViewModel; private IItemFilterBlockViewModel _selectedBlockViewModel;
@@ -83,7 +89,9 @@ namespace Filtration.ViewModels
IItemFilterBlockTranslator blockTranslator, IItemFilterBlockTranslator blockTranslator,
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel, IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
IItemFilterPersistenceService persistenceService, IItemFilterPersistenceService persistenceService,
IMessageBoxService messageBoxService) IMessageBoxService messageBoxService,
IClipboardService clipboardService,
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
{ {
_itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory; _itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
_blockTranslator = blockTranslator; _blockTranslator = blockTranslator;
@@ -91,11 +99,13 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged; _avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
_persistenceService = persistenceService; _persistenceService = persistenceService;
_messageBoxService = messageBoxService; _messageBoxService = messageBoxService;
_clipboardService = clipboardService;
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>(); _itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand); ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null); ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
CloseCommand = new RelayCommand(OnCloseCommand); CloseCommand = new RelayCommand(async () => await OnCloseCommand());
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null); DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null); MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null);
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null); MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null);
@@ -103,6 +113,8 @@ namespace Filtration.ViewModels
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null); MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null);
AddBlockCommand = new RelayCommand(OnAddBlockCommand); AddBlockCommand = new RelayCommand(OnAddBlockCommand);
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null); AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null); CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null); CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null); PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
@@ -127,6 +139,8 @@ namespace Filtration.ViewModels
public RelayCommand MoveBlockToBottomCommand { get; private set; } public RelayCommand MoveBlockToBottomCommand { get; private set; }
public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddBlockCommand { get; private set; }
public RelayCommand AddSectionCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; }
public RelayCommand EnableBlockCommand { get; private set; }
public RelayCommand DisableBlockCommand { get; private set; }
public RelayCommand CopyBlockCommand { get; private set; } public RelayCommand CopyBlockCommand { get; private set; }
public RelayCommand CopyBlockStyleCommand { get; private set; } public RelayCommand CopyBlockStyleCommand { get; private set; }
public RelayCommand PasteBlockCommand { get; private set; } public RelayCommand PasteBlockCommand { get; private set; }
@@ -214,6 +228,21 @@ namespace Filtration.ViewModels
} }
} }
public bool HasSelectedBlock()
{
return SelectedBlockViewModel != null;
}
public bool HasSelectedEnabledBlock()
{
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && SelectedBlockViewModel.BlockEnabled;
}
public bool HasSelectedDisabledBlock()
{
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && !SelectedBlockViewModel.BlockEnabled;
}
public IItemFilterBlockViewModel SelectedBlockViewModel public IItemFilterBlockViewModel SelectedBlockViewModel
{ {
get { return _selectedBlockViewModel; } get { return _selectedBlockViewModel; }
@@ -323,19 +352,21 @@ namespace Filtration.ViewModels
ContentId = "ScriptContentId"; ContentId = "ScriptContentId";
} }
public void Save() public async Task SaveAsync()
{ {
if (!ValidateScript()) return; if (!ValidateScript()) return;
if (!CheckForUnusedThemeComponents()) return;
if (_filenameIsFake) if (_filenameIsFake)
{ {
SaveAs(); await SaveAsAsync();
return; return;
} }
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
try try
{ {
_persistenceService.SaveItemFilterScript(Script); await _persistenceService.SaveItemFilterScriptAsync(Script);
RemoveDirtyFlag(); RemoveDirtyFlag();
} }
catch (Exception e) catch (Exception e)
@@ -348,11 +379,18 @@ namespace Filtration.ViewModels
_messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK, _messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error); MessageBoxImage.Error);
} }
finally
{
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
}
return;
} }
public void SaveAs() public async Task SaveAsAsync()
{ {
if (!ValidateScript()) return; if (!ValidateScript()) return;
if (!CheckForUnusedThemeComponents()) return;
var saveDialog = new SaveFileDialog var saveDialog = new SaveFileDialog
{ {
@@ -365,11 +403,13 @@ namespace Filtration.ViewModels
if (result != DialogResult.OK) return; if (result != DialogResult.OK) return;
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
var previousFilePath = Script.FilePath; var previousFilePath = Script.FilePath;
try try
{ {
Script.FilePath = saveDialog.FileName; Script.FilePath = saveDialog.FileName;
_persistenceService.SaveItemFilterScript(Script); await _persistenceService.SaveItemFilterScriptAsync(Script);
_filenameIsFake = false; _filenameIsFake = false;
Title = Filename; Title = Filename;
RemoveDirtyFlag(); RemoveDirtyFlag();
@@ -385,6 +425,31 @@ namespace Filtration.ViewModels
MessageBoxImage.Error); MessageBoxImage.Error);
Script.FilePath = previousFilePath; Script.FilePath = previousFilePath;
} }
finally
{
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
}
}
private bool CheckForUnusedThemeComponents()
{
var unusedThemeComponents =
Script.ThemeComponents.Where(
t =>
Script.ItemFilterBlocks.Count(
b => b.BlockItems.OfType<ColorBlockItem>().Count(i => i.ThemeComponent == t) > 0) == 0).ToList();
if (unusedThemeComponents.Count <= 0) return true;
var themeComponents = unusedThemeComponents.Aggregate(string.Empty,
(current, themeComponent) => current + (themeComponent.ComponentName + Environment.NewLine));
var ignoreUnusedThemeComponents = _messageBoxService.Show("Unused Theme Components",
"The following theme components are unused, they will be lost when this script is reopened. Save anyway?" +
Environment.NewLine + Environment.NewLine + themeComponents, MessageBoxButton.YesNo,
MessageBoxImage.Exclamation);
return ignoreUnusedThemeComponents != MessageBoxResult.No;
} }
private void OnActiveDocumentChanged(object sender, EventArgs e) private void OnActiveDocumentChanged(object sender, EventArgs e)
@@ -429,12 +494,12 @@ namespace Filtration.ViewModels
return false; return false;
} }
private void OnCloseCommand() private async Task OnCloseCommand()
{ {
Close(); await Close();
} }
public void Close() public async Task Close()
{ {
if (!IsDirty) if (!IsDirty)
{ {
@@ -443,31 +508,38 @@ namespace Filtration.ViewModels
else else
{ {
var result = _messageBoxService.Show("Filtration", var result = _messageBoxService.Show("Filtration",
"Want to save your changes to this script?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); "Save script \"" + Filename + "\"?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
switch (result) switch (result)
{ {
case MessageBoxResult.Yes: case MessageBoxResult.Yes:
{ {
Save(); await SaveAsync();
CloseScript(); CloseScript();
break; break;
} }
case MessageBoxResult.No: case MessageBoxResult.No:
{ {
CloseScript(); CloseScript();
break; break;
} }
case MessageBoxResult.Cancel: case MessageBoxResult.Cancel:
{ {
return; return;
} }
} }
} }
} }
private void CloseScript() private void CloseScript()
{ {
var openMasterThemForScript =
_avalonDockWorkspaceViewModel.OpenMasterThemeForScript(this);
if (openMasterThemForScript != null)
{
_avalonDockWorkspaceViewModel.CloseDocument(openMasterThemForScript);
}
_avalonDockWorkspaceViewModel.ActiveDocumentChanged -= OnActiveDocumentChanged; _avalonDockWorkspaceViewModel.ActiveDocumentChanged -= OnActiveDocumentChanged;
_avalonDockWorkspaceViewModel.CloseDocument(this); _avalonDockWorkspaceViewModel.CloseDocument(this);
} }
@@ -490,7 +562,16 @@ namespace Filtration.ViewModels
public void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel) public void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel)
{ {
Clipboard.SetText(_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block)); try
{
_clipboardService.SetClipboardText(
_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block));
}
catch
{
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
private void OnCopyBlockStyleCommand() private void OnCopyBlockStyleCommand()
@@ -510,8 +591,15 @@ namespace Filtration.ViewModels
} }
outputText += blockItem.OutputText; outputText += blockItem.OutputText;
} }
try
Clipboard.SetText(outputText); {
_clipboardService.SetClipboardText(outputText);
}
catch
{
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
private void OnPasteBlockStyleCommand() private void OnPasteBlockStyleCommand()
@@ -521,7 +609,7 @@ namespace Filtration.ViewModels
public void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel) public void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel)
{ {
var clipboardText = Clipboard.GetText(); var clipboardText = _clipboardService.GetClipboardText();
if (string.IsNullOrEmpty(clipboardText)) if (string.IsNullOrEmpty(clipboardText))
{ {
return; return;
@@ -540,11 +628,11 @@ namespace Filtration.ViewModels
{ {
try try
{ {
var clipboardText = Clipboard.GetText(); var clipboardText = _clipboardService.GetClipboardText();
if (clipboardText.IsNullOrEmpty()) return; if (string.IsNullOrEmpty(clipboardText)) return;
_blockGroupHierarchyBuilder.Initialise(Script.ItemFilterBlockGroups.First());
_blockTranslator.InitialiseForExistingScript(Script); var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText);
if (translatedBlock == null) return; if (translatedBlock == null) return;
var vm = _itemFilterBlockViewModelFactory.Create(); var vm = _itemFilterBlockViewModelFactory.Create();
@@ -568,9 +656,12 @@ namespace Filtration.ViewModels
catch (Exception e) catch (Exception e)
{ {
_logger.Error(e); _logger.Error(e);
var innerException = e.InnerException != null
? e.InnerException.Message
: string.Empty;
_messageBoxService.Show("Paste Error", _messageBoxService.Show("Paste Error",
e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine + e.Message + Environment.NewLine + innerException, MessageBoxButton.OK,
e.InnerException.Message + Environment.NewLine + e.InnerException.StackTrace, MessageBoxButton.OK,
MessageBoxImage.Error); MessageBoxImage.Error);
} }
} }
@@ -700,6 +791,7 @@ namespace Filtration.ViewModels
IsDirty = true; IsDirty = true;
SelectedBlockViewModel = vm; SelectedBlockViewModel = vm;
RaisePropertyChanged("ItemFilterSectionViewModels"); RaisePropertyChanged("ItemFilterSectionViewModels");
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
} }
private void OnExpandAllBlocksCommand() private void OnExpandAllBlocksCommand()
@@ -731,11 +823,39 @@ namespace Filtration.ViewModels
if (result == MessageBoxResult.Yes) if (result == MessageBoxResult.Yes)
{ {
var isSection = targetBlockViewModel.Block is ItemFilterSection;
Script.ItemFilterBlocks.Remove(targetBlockViewModel.Block); Script.ItemFilterBlocks.Remove(targetBlockViewModel.Block);
ItemFilterBlockViewModels.Remove(targetBlockViewModel); ItemFilterBlockViewModels.Remove(targetBlockViewModel);
IsDirty = true; IsDirty = true;
if (isSection)
{
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
}
} }
SelectedBlockViewModel = null; SelectedBlockViewModel = null;
} }
private void OnDisableBlockCommand()
{
DisableBlock(SelectedBlockViewModel);
}
private void DisableBlock(IItemFilterBlockViewModel targetBlockViewModel)
{
targetBlockViewModel.BlockEnabled = false;
}
private void OnEnableBlockCommand()
{
EnableBlock(SelectedBlockViewModel);
}
private void EnableBlock(IItemFilterBlockViewModel targetBlockViewModel)
{
targetBlockViewModel.BlockEnabled = true;
}
} }
} }

View File

@@ -1,19 +1,25 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Filtration.Common.Services; using Filtration.Common.Services;
using Filtration.Common.ViewModels; using Filtration.Common.ViewModels;
using Filtration.Interface; using Filtration.Interface;
using Filtration.Models; using Filtration.Models;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor; using Filtration.ObjectModel.ThemeEditor;
using Filtration.Properties; using Filtration.Properties;
using Filtration.Repositories; using Filtration.Repositories;
using Filtration.Services; using Filtration.Services;
using Filtration.ThemeEditor.Messages;
using Filtration.ThemeEditor.Providers; using Filtration.ThemeEditor.Providers;
using Filtration.ThemeEditor.Services; using Filtration.ThemeEditor.Services;
using Filtration.ThemeEditor.ViewModels; using Filtration.ThemeEditor.ViewModels;
@@ -22,7 +28,6 @@ using Filtration.Views;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
using NLog; using NLog;
using Clipboard = System.Windows.Clipboard;
using OpenFileDialog = Microsoft.Win32.OpenFileDialog; using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
namespace Filtration.ViewModels namespace Filtration.ViewModels
@@ -31,6 +36,8 @@ namespace Filtration.ViewModels
{ {
RelayCommand OpenScriptCommand { get; } RelayCommand OpenScriptCommand { get; }
RelayCommand NewScriptCommand { get; } RelayCommand NewScriptCommand { get; }
Task<bool> CloseAllDocumentsAsync();
Task OpenDroppedFilesAsync(List<string> filenames);
} }
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
@@ -47,6 +54,8 @@ namespace Filtration.ViewModels
private readonly IUpdateCheckService _updateCheckService; private readonly IUpdateCheckService _updateCheckService;
private readonly IUpdateAvailableViewModel _updateAvailableViewModel; private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
private readonly IMessageBoxService _messageBoxService; private readonly IMessageBoxService _messageBoxService;
private readonly IClipboardService _clipboardService;
private bool _showLoadingBanner;
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository, public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
IItemFilterScriptTranslator itemFilterScriptTranslator, IItemFilterScriptTranslator itemFilterScriptTranslator,
@@ -57,7 +66,8 @@ namespace Filtration.ViewModels
IThemeService themeService, IThemeService themeService,
IUpdateCheckService updateCheckService, IUpdateCheckService updateCheckService,
IUpdateAvailableViewModel updateAvailableViewModel, IUpdateAvailableViewModel updateAvailableViewModel,
IMessageBoxService messageBoxService) IMessageBoxService messageBoxService,
IClipboardService clipboardService)
{ {
_itemFilterScriptRepository = itemFilterScriptRepository; _itemFilterScriptRepository = itemFilterScriptRepository;
_itemFilterScriptTranslator = itemFilterScriptTranslator; _itemFilterScriptTranslator = itemFilterScriptTranslator;
@@ -69,15 +79,16 @@ namespace Filtration.ViewModels
_updateCheckService = updateCheckService; _updateCheckService = updateCheckService;
_updateAvailableViewModel = updateAvailableViewModel; _updateAvailableViewModel = updateAvailableViewModel;
_messageBoxService = messageBoxService; _messageBoxService = messageBoxService;
_clipboardService = clipboardService;
NewScriptCommand = new RelayCommand(OnNewScriptCommand); NewScriptCommand = new RelayCommand(OnNewScriptCommand);
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript); CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand); OpenScriptCommand = new RelayCommand(async () => await OnOpenScriptCommand());
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand); OpenThemeCommand = new RelayCommand(async () => await OnOpenThemeCommandAsync());
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable); SaveCommand = new RelayCommand(async () => await OnSaveDocumentCommandAsync(), ActiveDocumentIsEditable);
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable); SaveAsCommand = new RelayCommand(async () => await OnSaveAsCommandAsync(), ActiveDocumentIsEditable);
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null); CloseCommand = new RelayCommand(OnCloseDocumentCommand, ActiveDocumentIsEditable);
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
@@ -91,12 +102,25 @@ namespace Filtration.ViewModels
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript); AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript); AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock); DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
() => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
() => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand); OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript); ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript); CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript);
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript); ApplyThemeToScriptCommand = new RelayCommand(async () => await OnApplyThemeToScriptCommandAsync(), () => ActiveDocumentIsScript);
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
() =>
ActiveDocumentIsTheme && ActiveThemeIsEditable &&
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript); ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript); CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
@@ -115,6 +139,12 @@ namespace Filtration.ViewModels
icon.EndInit(); icon.EndInit();
Icon = icon; Icon = icon;
Messenger.Default.Register<ThemeClosedMessage>(this, message =>
{
if (message.ClosedViewModel == null) return;
AvalonDockWorkspaceViewModel.CloseDocument(message.ClosedViewModel);
});
Messenger.Default.Register<NotificationMessage>(this, message => Messenger.Default.Register<NotificationMessage>(this, message =>
{ {
switch (message.Notification) switch (message.Notification)
@@ -129,7 +159,10 @@ namespace Filtration.ViewModels
PasteCommand.RaiseCanExecuteChanged(); PasteCommand.RaiseCanExecuteChanged();
ReplaceColorsCommand.RaiseCanExecuteChanged(); ReplaceColorsCommand.RaiseCanExecuteChanged();
ApplyThemeToScriptCommand.RaiseCanExecuteChanged(); ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
EditMasterThemeCommand.RaiseCanExecuteChanged();
CreateThemeCommand.RaiseCanExecuteChanged(); CreateThemeCommand.RaiseCanExecuteChanged();
RaisePropertyChanged("ActiveDocumentIsScript");
RaisePropertyChanged("ActiveDocumentIsTheme");
RaisePropertyChanged("ShowAdvancedStatus"); RaisePropertyChanged("ShowAdvancedStatus");
break; break;
} }
@@ -140,12 +173,28 @@ namespace Filtration.ViewModels
} }
case "OpenScript": case "OpenScript":
{ {
#pragma warning disable 4014
OnOpenScriptCommand(); OnOpenScriptCommand();
#pragma warning restore 4014
break;
}
case "ShowLoadingBanner":
{
ShowLoadingBanner = true;
break;
}
case "HideLoadingBanner":
{
ShowLoadingBanner = false;
break; break;
} }
} }
}); });
CheckForUpdates();
Task.Run(async () =>
{
await CheckForUpdatesAsync();
}).Wait();
} }
public RelayCommand OpenScriptCommand { get; private set; } public RelayCommand OpenScriptCommand { get; private set; }
@@ -161,12 +210,21 @@ namespace Filtration.ViewModels
public RelayCommand CloseCommand { get; private set; } public RelayCommand CloseCommand { get; private set; }
public RelayCommand OpenAboutWindowCommand { get; private set; } public RelayCommand OpenAboutWindowCommand { get; private set; }
public RelayCommand ReplaceColorsCommand { get; private set; } public RelayCommand ReplaceColorsCommand { get; private set; }
public RelayCommand EditMasterThemeCommand { get; private set; }
public RelayCommand CreateThemeCommand { get; private set; } public RelayCommand CreateThemeCommand { get; private set; }
public RelayCommand ApplyThemeToScriptCommand { get; private set; } public RelayCommand ApplyThemeToScriptCommand { get; private set; }
public RelayCommand AddTextColorThemeComponentCommand { get; private set; }
public RelayCommand AddBackgroundColorThemeComponentCommand { get; private set; }
public RelayCommand AddBorderColorThemeComponentCommand { get; private set; }
public RelayCommand DeleteThemeComponentCommand { get; private set; }
public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddBlockCommand { get; private set; }
public RelayCommand AddSectionCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; }
public RelayCommand DeleteBlockCommand { get; private set; } public RelayCommand DeleteBlockCommand { get; private set; }
public RelayCommand DisableBlockCommand { get; private set; }
public RelayCommand EnableBlockCommand { get; private set; }
public RelayCommand MoveBlockUpCommand { get; private set; } public RelayCommand MoveBlockUpCommand { get; private set; }
public RelayCommand MoveBlockDownCommand { get; private set; } public RelayCommand MoveBlockDownCommand { get; private set; }
@@ -180,14 +238,14 @@ namespace Filtration.ViewModels
public RelayCommand ClearFiltersCommand { get; private set; } public RelayCommand ClearFiltersCommand { get; private set; }
public async void CheckForUpdates() public async Task CheckForUpdatesAsync()
{ {
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
var result = await _updateCheckService.GetUpdateData();
try try
{ {
var result = await _updateCheckService.GetUpdateDataAsync();
if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart && if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart &&
result.LatestVersionMinorPart > assemblyVersion.FileMinorPart) result.LatestVersionMinorPart > assemblyVersion.FileMinorPart)
{ {
@@ -244,15 +302,24 @@ namespace Filtration.ViewModels
} }
} }
public bool ShowLoadingBanner
{
get { return _showLoadingBanner; }
private set
{
_showLoadingBanner = value;
RaisePropertyChanged();
}
}
public bool ActiveDocumentIsScript public bool ActiveDocumentIsScript
{ {
get get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; }
{ }
{
var isScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel; public bool ActiveDocumentIsTheme
return isScript; {
} get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; }
}
} }
public bool ActiveScriptHasSelectedBlock public bool ActiveScriptHasSelectedBlock
@@ -260,9 +327,19 @@ namespace Filtration.ViewModels
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; } get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; }
} }
public bool ActiveDocumentIsTheme public bool ActiveScriptHasSelectedEnabledBlock
{ {
get { { return AvalonDockWorkspaceViewModel.ActiveDocument is ThemeViewModel; } } get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedEnabledBlock(); }
}
public bool ActiveScriptHasSelectedDisabledBlock
{
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedDisabledBlock(); }
}
public bool ActiveThemeIsEditable
{
get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; }
} }
private bool ActiveDocumentIsEditable() private bool ActiveDocumentIsEditable()
@@ -278,21 +355,61 @@ namespace Filtration.ViewModels
} }
} }
public async Task OpenDroppedFilesAsync(List<string> filenames)
{
foreach (var filename in filenames)
{
var extension = Path.GetExtension(filename);
if (extension == null) continue;
switch (extension.ToUpperInvariant())
{
case ".FILTER":
{
await LoadScriptAsync(filename);
break;
}
case ".FILTERTHEME":
{
await LoadThemeAsync(filename);
break;
}
}
}
}
private void OnCreateThemeCommand() private void OnCreateThemeCommand()
{ {
var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script); var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
OpenTheme(themeViewModel); OpenTheme(themeViewModel);
} }
private void OpenTheme(IThemeViewModel themeViewModel) private void OnEditMasterThemeCommand()
{ {
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeViewModel)) var openMasterThemForScript =
AvalonDockWorkspaceViewModel.OpenMasterThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel);
if (openMasterThemForScript != null)
{ {
AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeViewModel); AvalonDockWorkspaceViewModel.SwitchActiveDocument(openMasterThemForScript);
} }
else else
{ {
AvalonDockWorkspaceViewModel.AddDocument(themeViewModel); var themeViewModel =
_themeProvider.MasterThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
OpenTheme(themeViewModel);
}
}
private void OpenTheme(IThemeEditorViewModel themeEditorViewModel)
{
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeEditorViewModel))
{
AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeEditorViewModel);
}
else
{
AvalonDockWorkspaceViewModel.AddDocument(themeEditorViewModel);
} }
} }
@@ -301,24 +418,31 @@ namespace Filtration.ViewModels
var aboutWindow = new AboutWindow(); var aboutWindow = new AboutWindow();
aboutWindow.ShowDialog(); aboutWindow.ShowDialog();
} }
private void OnOpenScriptCommand()
private async Task OnOpenScriptCommand()
{ {
var openFileDialog = new OpenFileDialog var filePath = ShowOpenScriptDialog();
if (string.IsNullOrEmpty(filePath))
{ {
Filter = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*", return;
InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory() }
};
if (openFileDialog.ShowDialog() != true) return; await LoadScriptAsync(filePath);
}
private async Task LoadScriptAsync(string scriptFilename)
{
IItemFilterScriptViewModel loadedViewModel; IItemFilterScriptViewModel loadedViewModel;
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
try try
{ {
loadedViewModel = _itemFilterScriptRepository.LoadScriptFromFile(openFileDialog.FileName); loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
} }
catch(IOException e) catch (IOException e)
{ {
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
if (_logger.IsErrorEnabled) if (_logger.IsErrorEnabled)
{ {
_logger.Error(e); _logger.Error(e);
@@ -329,23 +453,28 @@ namespace Filtration.ViewModels
return; return;
} }
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel); _avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
} }
private void OnOpenThemeCommand() private async Task OnOpenThemeCommandAsync()
{ {
var filePath = ShowOpenThemeDialog(); var filePath = ShowOpenThemeDialog();
if (string.IsNullOrEmpty(filePath)) if (string.IsNullOrEmpty(filePath))
{ {
return; return;
} }
IThemeViewModel loadedViewModel; await LoadThemeAsync(filePath);
}
private async Task LoadThemeAsync(string themeFilename)
{
IThemeEditorViewModel loadedViewModel;
try try
{ {
loadedViewModel = _themeProvider.LoadThemeFromFile(filePath); loadedViewModel = await _themeProvider.LoadThemeFromFile(themeFilename);
} }
catch (IOException e) catch (IOException e)
{ {
@@ -362,7 +491,7 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel); _avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
} }
private void OnApplyThemeToScriptCommand() private async Task OnApplyThemeToScriptCommandAsync()
{ {
var filePath = ShowOpenThemeDialog(); var filePath = ShowOpenThemeDialog();
if (string.IsNullOrEmpty(filePath)) if (string.IsNullOrEmpty(filePath))
@@ -374,7 +503,7 @@ namespace Filtration.ViewModels
try try
{ {
loadedTheme = _themeProvider.LoadThemeModelFromFile(filePath); loadedTheme = await _themeProvider.LoadThemeModelFromFile(filePath);
} }
catch (IOException e) catch (IOException e)
{ {
@@ -400,6 +529,16 @@ namespace Filtration.ViewModels
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SetDirtyFlag(); AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SetDirtyFlag();
} }
private string ShowOpenScriptDialog()
{
var openFileDialog = new OpenFileDialog
{
Filter = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*",
InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
};
return openFileDialog.ShowDialog() != true ? string.Empty : openFileDialog.FileName;
}
private string ShowOpenThemeDialog() private string ShowOpenThemeDialog()
{ {
@@ -412,8 +551,6 @@ namespace Filtration.ViewModels
return openFileDialog.ShowDialog() != true ? string.Empty : openFileDialog.FileName; return openFileDialog.ShowDialog() != true ? string.Empty : openFileDialog.FileName;
} }
private void SetItemFilterScriptDirectory() private void SetItemFilterScriptDirectory()
{ {
var dlg = new FolderBrowserDialog var dlg = new FolderBrowserDialog
@@ -429,14 +566,14 @@ namespace Filtration.ViewModels
} }
} }
private void OnSaveDocumentCommand() private async Task OnSaveDocumentCommandAsync()
{ {
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).Save(); await ((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAsync();
} }
private void OnSaveAsCommand() private async Task OnSaveAsCommandAsync()
{ {
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAs(); await ((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAsAsync();
} }
private void OnReplaceColorsCommand() private void OnReplaceColorsCommand()
@@ -448,7 +585,18 @@ namespace Filtration.ViewModels
private void OnCopyScriptCommand() private void OnCopyScriptCommand()
{ {
Clipboard.SetText(_itemFilterScriptTranslator.TranslateItemFilterScriptToString(_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script)); try
{
_clipboardService.SetClipboardText(
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script));
}
catch
{
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
MessageBoxButton.OK, MessageBoxImage.Error);
}
} }
private void OnCopyBlockCommand() private void OnCopyBlockCommand()
@@ -517,6 +665,16 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null); _avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null);
} }
private void OnDisableBlockCommand()
{
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DisableBlockCommand.Execute(null);
}
private void OnEnableBlockCommand()
{
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableBlockCommand.Execute(null);
}
private void OnExpandAllBlocksCommand() private void OnExpandAllBlocksCommand()
{ {
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null); _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);
@@ -536,5 +694,43 @@ namespace Filtration.ViewModels
{ {
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ClearFilterCommand.Execute(null); _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ClearFilterCommand.Execute(null);
} }
private void OnAddTextColorThemeComponentCommand()
{
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.TextColor);
}
private void OnAddBackgroundColorThemeComponentCommand()
{
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BackgroundColor);
}
private void OnAddBorderColorThemeComponentCommand()
{
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BorderColor);
}
private void OnDeleteThemeComponentCommand()
{
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute(
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent);
}
public async Task<bool> CloseAllDocumentsAsync()
{
var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().ToList();
foreach (var document in openDocuments)
{
var docCount = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count();
await document.Close();
if (_avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count() == docCount)
{
return false;
}
}
return true;
}
} }
} }

View File

@@ -1,4 +1,5 @@
using Filtration.Common.ViewModels; using System.Threading.Tasks;
using Filtration.Common.ViewModels;
using Filtration.Interface; using Filtration.Interface;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
@@ -25,7 +26,7 @@ namespace Filtration.ViewModels
public bool IsScript { get { return false; } } public bool IsScript { get { return false; } }
public bool IsTheme { get { return false; } } public bool IsTheme { get { return false; } }
public void Close() public Task Close()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using GalaSoft.MvvmLight.Messaging;
namespace Filtration.ViewModels.ToolPanes namespace Filtration.ViewModels.ToolPanes
{ {
@@ -23,6 +24,18 @@ namespace Filtration.ViewModels.ToolPanes
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/add_section_icon.png"); icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/add_section_icon.png");
icon.EndInit(); icon.EndInit();
IconSource = icon; IconSource = icon;
Messenger.Default.Register<NotificationMessage>(this, message =>
{
switch (message.Notification)
{
case "SectionsChanged":
{
OnActiveDocumentChanged(this, EventArgs.Empty);
break;
}
}
});
} }
public const string ToolContentId = "SectionBrowserTool"; public const string ToolContentId = "SectionBrowserTool";

View File

@@ -10,9 +10,10 @@
xmlns:converters="clr-namespace:Filtration.Converters" xmlns:converters="clr-namespace:Filtration.Converters"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock" xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:themeEditorViews="clr-namespace:Filtration.ThemeEditor.Views;assembly=Filtration.ThemeEditor" xmlns:themeEditorViews="clr-namespace:Filtration.ThemeEditor.Views;assembly=Filtration.ThemeEditor"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance d:Type=viewModels:AvalonDockWorkspaceViewModel}" d:DataContext="{d:DesignInstance d:Type=viewModels:AvalonDockWorkspaceViewModel}"
d:DesignHeight="300" d:DesignWidth="300"> d:DesignHeight="300" d:DesignWidth="700">
<UserControl.Resources> <UserControl.Resources>
<xcad:BoolToVisibilityConverter x:Key="AvalonBoolToVisibilityConverter" /> <xcad:BoolToVisibilityConverter x:Key="AvalonBoolToVisibilityConverter" />
<converters:ActiveDocumentConverter x:Key="ActiveDocumentConverter" /> <converters:ActiveDocumentConverter x:Key="ActiveDocumentConverter" />
@@ -56,7 +57,7 @@
</viewsAvalonDock:PanesTemplateSelector.StartPageTemplate> </viewsAvalonDock:PanesTemplateSelector.StartPageTemplate>
<viewsAvalonDock:PanesTemplateSelector.ThemeTemplate> <viewsAvalonDock:PanesTemplateSelector.ThemeTemplate>
<DataTemplate> <DataTemplate>
<themeEditorViews:ThemeControl DataContext="{Binding}" /> <themeEditorViews:ThemeEditorView DataContext="{Binding}" />
</DataTemplate> </DataTemplate>
</viewsAvalonDock:PanesTemplateSelector.ThemeTemplate> </viewsAvalonDock:PanesTemplateSelector.ThemeTemplate>
</viewsAvalonDock:PanesTemplateSelector> </viewsAvalonDock:PanesTemplateSelector>

View File

@@ -25,7 +25,7 @@ namespace Filtration.Views.AvalonDock
return ItemFilterScriptTemplate; return ItemFilterScriptTemplate;
} }
if (item is IThemeViewModel) if (item is IThemeEditorViewModel)
{ {
return ThemeTemplate; return ThemeTemplate;
} }

View File

@@ -29,4 +29,8 @@
<Image Source="/Filtration;component/Resources/Icons/Paste.ico" x:Key="PasteIcon" x:Shared="False" /> <Image Source="/Filtration;component/Resources/Icons/Paste.ico" x:Key="PasteIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/PasteStyle.ico" x:Key="PasteStyleIcon" x:Shared="False" /> <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/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/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" />
</ResourceDictionary> </ResourceDictionary>

View File

@@ -15,7 +15,6 @@
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
<ResourceDictionary> <ResourceDictionary>
<views:BindingProxy x:Key="proxy" Data="{Binding}" /> <views:BindingProxy x:Key="proxy" Data="{Binding}" />
<converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" /> <converters:BlockGroupAdvancedFillColorConverter x:Key="BlockGroupAdvancedFillColorConverter" />
@@ -42,6 +41,11 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid x:Name="TopLevelGrid"> <Grid x:Name="TopLevelGrid">
<Grid x:Name="DisabledBlockOverlay" IsHitTestVisible="False" Panel.ZIndex="1000" Visibility="{Binding BlockEnabled, Converter={StaticResource InverseBooleanVisibilityConverter}}">
<Grid.Background>
<SolidColorBrush Color="Gray" Opacity=".5" />
</Grid.Background>
</Grid>
<Border BorderThickness="1" BorderBrush="SlateGray" CornerRadius="2" Background="White"> <Border BorderThickness="1" BorderBrush="SlateGray" CornerRadius="2" Background="White">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -63,8 +67,8 @@
<Expander.ContextMenu> <Expander.ContextMenu>
<ContextMenu> <ContextMenu>
<ContextMenu.Items> <ContextMenu.Items>
<MenuItem Header="Copy" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" /> <MenuItem Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" />
<MenuItem Header="Paste" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" /> <MenuItem Header="Paste Block" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" />
<Separator /> <Separator />
<MenuItem Header="Block Style"> <MenuItem Header="Block Style">
<MenuItem Header="Copy Block Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" /> <MenuItem Header="Copy Block Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" />
@@ -90,6 +94,7 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- BlockItems Summary Panel --> <!-- BlockItems Summary Panel -->
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"> <StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">
@@ -124,7 +129,7 @@
</StackPanel> </StackPanel>
<!-- Item Preview Box --> <!-- Item Preview Box -->
<WrapPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"> <WrapPanel Grid.Row="0" Grid.Column="2" VerticalAlignment="Center">
<Button Command="{Binding PlaySoundCommand}" <Button Command="{Binding PlaySoundCommand}"
Width="25" Width="25"
Height="25" Height="25"
@@ -161,6 +166,10 @@
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"> <TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<Hyperlink Command="{Binding SwitchBlockItemsViewCommand}"> <Hyperlink Command="{Binding SwitchBlockItemsViewCommand}">
Switch to Appearance Block Items Switch to Appearance Block Items
@@ -168,7 +177,7 @@
</TextBlock> </TextBlock>
<!-- Add Block Item Links --> <!-- Add Block Item Links -->
<ItemsControl ItemsSource="{Binding BlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,10"> <ItemsControl Grid.Column="0" ItemsSource="{Binding BlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,10">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<WrapPanel></WrapPanel> <WrapPanel></WrapPanel>
@@ -185,8 +194,34 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
<!-- Enable/Disable Block Button -->
<ToggleButton Grid.Row="0"
Grid.Column="1"
Style="{StaticResource ChromelessToggleButton}"
IsChecked="{Binding BlockEnabled}"
Margin="0,0,5,0"
ToolTip="Enable/Disable Block"
Cursor="Hand"
Width="25"
Height="25">
<Image RenderOptions.BitmapScalingMode="HighQuality">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding BlockEnabled}" Value="true">
<Setter Property="Source" Value="/Filtration;component/Resources/Icons/standby_enabled_icon.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding BlockEnabled}" Value="false">
<Setter Property="Source" Value="/Filtration;component/Resources/Icons/standby_disabled_icon.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</ToggleButton>
<!-- Block Items --> <!-- Block Items -->
<WrapPanel Grid.Row="1" MaxHeight="200"> <WrapPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" MaxHeight="200">
<WrapPanel.Resources> <WrapPanel.Resources>
<CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource"> <CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource">
<CollectionViewSource.SortDescriptions> <CollectionViewSource.SortDescriptions>
@@ -237,6 +272,8 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
<TextBlock Grid.Row="1" FontStyle="Italic" Visibility="{Binding HasAudioVisualBlockItems, Converter={StaticResource InverseBooleanVisibilityConverter}}">To change the appearance of this block, add a Text, Background or Border Block Item above.</TextBlock>
<!-- Block Items --> <!-- Block Items -->
<WrapPanel Grid.Row="1" MaxHeight="200"> <WrapPanel Grid.Row="1" MaxHeight="200">
<WrapPanel.Resources> <WrapPanel.Resources>

View File

@@ -7,20 +7,19 @@
xmlns:fluent="clr-namespace:Fluent;assembly=Fluent" xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
xmlns:viewModels="clr-namespace:Filtration.ViewModels" xmlns:viewModels="clr-namespace:Filtration.ViewModels"
xmlns:viewsAvalonDock="clr-namespace:Filtration.Views.AvalonDock" xmlns:viewsAvalonDock="clr-namespace:Filtration.Views.AvalonDock"
xmlns:converters="clr-namespace:Filtration.Converters"
xmlns:views="clr-namespace:Filtration.Views" xmlns:views="clr-namespace:Filtration.Views"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}" d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"
Title="{Binding WindowTitle}" Height="768" Width="1100" BorderThickness="1" BorderBrush="Black" IsIconVisible="True" > Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True"
Closing="MainWindow_OnClosing" Drop="MainWindow_OnDrop" AllowDrop="True">
<fluent:RibbonWindow.InputBindings> <fluent:RibbonWindow.InputBindings>
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" /> <KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" /> <KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
<KeyBinding Command="{Binding NewScriptCommand}" Modifiers="Control" Key="N" />
</fluent:RibbonWindow.InputBindings> </fluent:RibbonWindow.InputBindings>
<fluent:RibbonWindow.Resources>
<converters:BooleanVisibilityConverterCopy x:Key="BooleanVisibilityConverterCopy" />
</fluent:RibbonWindow.Resources>
<DockPanel x:Name="RootDockPanel"> <DockPanel x:Name="RootDockPanel">
<fluent:Ribbon DockPanel.Dock="Top"> <fluent:Ribbon DockPanel.Dock="Top" x:Name="RibbonRoot" IsEnabled="{Binding ShowLoadingBanner, Converter={StaticResource BoolInverterConverter}}">
<fluent:Ribbon.Menu> <fluent:Ribbon.Menu>
<fluent:Backstage> <fluent:Backstage>
<fluent:BackstageTabControl> <fluent:BackstageTabControl>
@@ -33,10 +32,10 @@
</DataTemplate> </DataTemplate>
</fluent:BackstageTabItem.ContentTemplate> </fluent:BackstageTabItem.ContentTemplate>
</fluent:BackstageTabItem> </fluent:BackstageTabItem>
<fluent:Button Header="New Script" Command="{Binding NewScriptCommand}" Icon="{StaticResource NewIcon}" /> <fluent:Button Header="New Script" Command="{Binding NewScriptCommand}" Icon="{StaticResource NewIcon}" ToolTip="New Script (Ctrl+N)" />
<fluent:Button Header="Open Script" Command="{Binding OpenScriptCommand}" Icon="{StaticResource OpenIcon}" /> <fluent:Button Header="Open Script" Command="{Binding OpenScriptCommand}" Icon="{StaticResource OpenIcon}" ToolTip="Open Script (Ctrl+O)" />
<fluent:Button Header="Open Theme" Command="{Binding OpenThemeCommand}" Icon="{StaticResource OpenIcon}" /> <fluent:Button Header="Open Theme" Command="{Binding OpenThemeCommand}" Icon="{StaticResource OpenIcon}" />
<fluent:Button Header="Save" Command="{Binding SaveCommand}" Icon="{StaticResource SaveIcon}" /> <fluent:Button Header="Save" Command="{Binding SaveCommand}" Icon="{StaticResource SaveIcon}" ToolTip="Save (Ctrl+S)" />
<fluent:Button Header="Save As" Command="{Binding SaveAsCommand}" Icon="{StaticResource SaveIcon}" /> <fluent:Button Header="Save As" Command="{Binding SaveAsCommand}" Icon="{StaticResource SaveIcon}" />
<fluent:Button Header="Close" Command="{Binding CloseCommand}" /> <fluent:Button Header="Close" Command="{Binding CloseCommand}" />
<fluent:SeparatorTabItem /> <fluent:SeparatorTabItem />
@@ -53,19 +52,32 @@
</fluent:Backstage> </fluent:Backstage>
</fluent:Ribbon.Menu> </fluent:Ribbon.Menu>
<fluent:Ribbon.ContextualGroups> <fluent:Ribbon.ContextualGroups>
<fluent:RibbonContextualTabGroup Header="Script Tools" <fluent:RibbonContextualTabGroup Header="Script"
Background="ForestGreen" Background="ForestGreen"
BorderBrush="ForestGreen" BorderBrush="ForestGreen"
x:Name="ScriptToolsGroup" x:Name="ScriptToolsGroup"
Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverterCopy}, Mode=OneWay}" /> IsVisibleChanged="ScriptToolsGroup_OnIsVisibleChanged"
Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" />
<fluent:RibbonContextualTabGroup Header="Theme"
Background="DodgerBlue"
BorderBrush="DodgerBlue"
x:Name="ThemeToolsGroup"
IsVisibleChanged="ThemeToolsGroup_OnIsVisibleChanged"
Visibility="{Binding ActiveDocumentIsTheme, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" />
</fluent:Ribbon.ContextualGroups> </fluent:Ribbon.ContextualGroups>
<fluent:RibbonTabItem Header="Script Tools" Group="{Binding ElementName=ScriptToolsGroup}"> <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="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>
</fluent:RibbonTabItem>
<fluent:RibbonTabItem x:Name="ScriptToolsTabItem" Header="Script Tools" Group="{Binding ElementName=ScriptToolsGroup}" Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" >
<fluent:RibbonGroupBox Header="Clipboard"> <fluent:RibbonGroupBox Header="Clipboard">
<fluent:Button Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}"> <fluent:Button Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" ToolTip="Copy Block (Ctrl+C)"/>
</fluent:Button> <fluent:Button Header="Paste Block" Command="{Binding PasteCommand}" Icon="{StaticResource PasteIcon}" LargeIcon="{StaticResource PasteIcon}" ToolTip="Paste Block (Ctrl+V)"/>
<fluent:Button Header="Paste Block" Command="{Binding PasteCommand}" Icon="{StaticResource PasteIcon}" LargeIcon="{StaticResource PasteIcon}" /> <fluent:Button Header="Copy Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" SizeDefinition="Middle" ToolTip="Copy Style (Ctrl+Shift+C)" />
<fluent:Button Header="Copy Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" SizeDefinition="Middle" /> <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="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
<fluent:Button Header="Copy Script" Command="{Binding CopyScriptCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" /> <fluent:Button Header="Copy Script" Command="{Binding CopyScriptCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
</fluent:RibbonGroupBox> </fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Blocks"> <fluent:RibbonGroupBox Header="Blocks">
@@ -76,6 +88,8 @@
<fluent:Button Header="Move Up" Command="{Binding MoveBlockUpCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveUpIcon}" /> <fluent:Button Header="Move Up" Command="{Binding MoveBlockUpCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveUpIcon}" />
<fluent:Button Header="Move Down" Command="{Binding MoveBlockDownCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveDownIcon}" /> <fluent:Button Header="Move Down" Command="{Binding MoveBlockDownCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveDownIcon}" />
<fluent:Button Header="Move To Bottom" Command="{Binding MoveBlockToBottomCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveToBottomIcon}" /> <fluent:Button Header="Move To Bottom" Command="{Binding MoveBlockToBottomCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveToBottomIcon}" />
<fluent:Button Header="Enable Block" Command="{Binding EnableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyEnabledIcon}" />
<fluent:Button Header="Disable Block" Command="{Binding DisableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyDisabledIcon}" />
</fluent:RibbonGroupBox> </fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Expand / Collapse"> <fluent:RibbonGroupBox Header="Expand / Collapse">
<fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" /> <fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />
@@ -86,21 +100,50 @@
<fluent:Button Header="Clear All Filters" Command="{Binding ClearFiltersCommand}" SizeDefinition="Middle" Icon="{StaticResource ClearFilterIcon}" /> <fluent:Button Header="Clear All Filters" Command="{Binding ClearFiltersCommand}" SizeDefinition="Middle" Icon="{StaticResource ClearFilterIcon}" />
</fluent:RibbonGroupBox> </fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Themes"> <fluent:RibbonGroupBox Header="Themes">
<fluent:Button Header="Edit Master Theme" Command="{Binding EditMasterThemeCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />
<fluent:Button Header="Apply Theme" Command="{Binding ApplyThemeToScriptCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" /> <fluent:Button Header="Apply Theme" Command="{Binding ApplyThemeToScriptCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />
<fluent:Button Header="Create Theme" Command="{Binding CreateThemeCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" /> <fluent:Button Header="Create Theme" Command="{Binding CreateThemeCommand}" Icon="{StaticResource ThemeIcon}" LargeIcon="{StaticResource ThemeIcon}" />
<fluent:Button Header="Replace Colours" Command="{Binding ReplaceColorsCommand}" Icon="{StaticResource ReplaceColorsIcon}" LargeIcon="{StaticResource ReplaceColorsIcon}" /> <fluent:Button Header="Replace Colours" Command="{Binding ReplaceColorsCommand}" Icon="{StaticResource ReplaceColorsIcon}" LargeIcon="{StaticResource ReplaceColorsIcon}" />
</fluent:RibbonGroupBox> </fluent:RibbonGroupBox>
</fluent:RibbonTabItem> </fluent:RibbonTabItem>
<fluent:RibbonTabItem Header="View"> <fluent:RibbonTabItem x:Name="ThemeToolsTabItem" Header="Theme Tools" Group="{Binding ElementName=ThemeToolsGroup}" Visibility="{Binding ActiveDocumentIsTheme, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}">
<fluent:RibbonGroupBox Header="Tools"> <fluent:RibbonGroupBox Header="Add Components">
<fluent:ToggleButton Header="Section Browser" Width="150" SizeDefinition="Middle" Icon="{StaticResource AddSectionIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.SectionBrowserViewModel.IsVisible}" /> <fluent:Button SizeDefinition="Middle" Header="Add Text Color" Icon="{StaticResource AddIcon}" Command="{Binding AddTextColorThemeComponentCommand}" />
<fluent:ToggleButton Header="Block Group Browser" Width="150" SizeDefinition="Middle" Icon="{StaticResource BlockGroupBrowserIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockGroupBrowserViewModel.IsVisible}" /> <fluent:Button SizeDefinition="Middle" Header="Add Background Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBackgroundColorThemeComponentCommand}" />
<fluent:ToggleButton Header="Block Output Preview" Width="150" SizeDefinition="Middle" Icon="{StaticResource BlockOutputPreviewIcon}" IsChecked="{Binding AvalonDockWorkspaceViewModel.BlockOutputPreviewViewModel.IsVisible}" /> <fluent:Button SizeDefinition="Middle" Header="Add Border Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBorderColorThemeComponentCommand}" />
</fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Delete">
<fluent:Button Header="Delete Theme Component" Icon="{StaticResource ThemeComponentDeleteIcon}" LargeIcon="{StaticResource ThemeComponentDeleteIcon}" Command="{Binding DeleteThemeComponentCommand}" />
</fluent:RibbonGroupBox> </fluent:RibbonGroupBox>
</fluent:RibbonTabItem> </fluent:RibbonTabItem>
</fluent:Ribbon> </fluent:Ribbon>
<Grid> <Grid>
<viewsAvalonDock:AvalonDockWorkspaceView DataContext="{Binding AvalonDockWorkspaceViewModel}" /> <viewsAvalonDock:AvalonDockWorkspaceView DataContext="{Binding AvalonDockWorkspaceViewModel}" />
<Grid ZIndex="9999" Visibility="{Binding ShowLoadingBanner, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}">
<Grid.Background>
<SolidColorBrush Color="Black" Opacity="0.5" />
</Grid.Background>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="Black" BorderThickness="1" Background="White" Padding="20">
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" FontWeight="DemiBold">Working...</TextBlock>
<Image gif:ImageBehavior.AnimatedSource="/Filtration;component/Resources/loading_spinner.gif" Height="32" Margin="10,0,0,0"/>
</StackPanel>
</Border>
</Grid>
</Grid>
</Grid> </Grid>
</DockPanel> </DockPanel>
</fluent:RibbonWindow> </fluent:RibbonWindow>

View File

@@ -1,4 +1,9 @@
using Filtration.ViewModels; using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using Filtration.ViewModels;
namespace Filtration.Views namespace Filtration.Views
{ {
@@ -9,10 +14,62 @@ namespace Filtration.Views
internal partial class MainWindow : IMainWindow internal partial class MainWindow : IMainWindow
{ {
private readonly IMainWindowViewModel _mainWindowViewModel;
public MainWindow(IMainWindowViewModel mainWindowViewModel) public MainWindow(IMainWindowViewModel mainWindowViewModel)
{ {
_mainWindowViewModel = mainWindowViewModel;
InitializeComponent(); InitializeComponent();
DataContext = mainWindowViewModel; DataContext = mainWindowViewModel;
} }
private void ScriptToolsGroup_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (ScriptToolsGroup.IsVisible)
{
RibbonRoot.SelectedTabItem = ScriptToolsTabItem;
}
}
private void ThemeToolsGroup_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (ThemeToolsGroup.IsVisible)
{
RibbonRoot.SelectedTabItem = ThemeToolsTabItem;
}
}
private void MainWindow_OnClosing(object sender, CancelEventArgs e)
{
var allDocumentsClosed = _mainWindowViewModel.CloseAllDocumentsAsync().Result;
if (!allDocumentsClosed)
{
e.Cancel = true;
}
}
private async void MainWindow_OnDrop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return;
var filenames = (string[])e.Data.GetData(DataFormats.FileDrop);
var droppedFilterFiles = new List<string>();
foreach (var filename in filenames)
{
var extension = Path.GetExtension(filename);
if (extension != null &&
(extension.ToUpperInvariant() == ".FILTER" || extension.ToUpperInvariant() == ".FILTERTHEME"))
{
droppedFilterFiles.Add(filename);
}
}
if (droppedFilterFiles.Count > 0)
{
await _mainWindowViewModel.OpenDroppedFilesAsync(droppedFilterFiles);
}
}
} }
} }

View File

@@ -11,14 +11,6 @@
Title="Replace Script Colors" Height="280" Width="540" Title="Replace Script Colors" Height="280" Width="540"
BorderThickness="1" BorderBrush="Black" BorderThickness="1" BorderBrush="Black"
Loaded="ReplaceColorsWindow_OnLoaded" ResizeMode="CanMinimize"> Loaded="ReplaceColorsWindow_OnLoaded" ResizeMode="CanMinimize">
<!--ShowMaxRestoreButton="False"-->
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition>

View File

@@ -1,23 +1,6 @@
using System; namespace Filtration.Views
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Filtration.Views
{ {
/// <summary> public partial class UpdateAvailableView
/// Interaction logic for UpdateAvailableView.xaml
/// </summary>
public partial class UpdateAvailableView : Window
{ {
public UpdateAvailableView() public UpdateAvailableView()
{ {

View File

@@ -1,14 +0,0 @@
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
namespace Filtration.WindsorInstallers
{
public class ModelsInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
}
}
}

View File

@@ -34,6 +34,11 @@ namespace Filtration.WindsorInstallers
Component.For<IUpdateCheckService>() Component.For<IUpdateCheckService>()
.ImplementedBy<UpdateCheckService>() .ImplementedBy<UpdateCheckService>()
.LifeStyle.Singleton); .LifeStyle.Singleton);
container.Register(
Component.For<IClipboardService>()
.ImplementedBy<ClipboardService>()
.LifeStyle.Singleton);
} }
} }
} }

View File

@@ -23,11 +23,6 @@ namespace Filtration.WindsorInstallers
Component.For<IBlockGroupHierarchyBuilder>() Component.For<IBlockGroupHierarchyBuilder>()
.ImplementedBy<BlockGroupHierarchyBuilder>() .ImplementedBy<BlockGroupHierarchyBuilder>()
.LifeStyle.Singleton); .LifeStyle.Singleton);
container.Register(
Component.For<IThemeComponentListBuilder>()
.ImplementedBy<ThemeComponentListBuilder>()
.LifeStyle.Singleton);
} }
} }
} }

View File

@@ -11,5 +11,6 @@
<package id="NLog" version="4.0.1" targetFramework="net451" /> <package id="NLog" version="4.0.1" targetFramework="net451" />
<package id="NLog.Config" version="4.0.1" targetFramework="net451" /> <package id="NLog.Config" version="4.0.1" targetFramework="net451" />
<package id="NLog.Schema" version="4.0.1" targetFramework="net451" /> <package id="NLog.Schema" version="4.0.1" targetFramework="net451" />
<package id="WpfAnimatedGif" version="1.4.13" targetFramework="net451" />
<package id="WPFToolkit" version="3.5.50211.1" targetFramework="net451" /> <package id="WPFToolkit" version="3.5.50211.1" targetFramework="net451" />
</packages> </packages>

View File

@@ -2,10 +2,10 @@
Filtration is an editor for Path of Exile item filter scripts. Filtration is an editor for Path of Exile item filter scripts.
## Current Release ## Current Release (Released 2015-07-26)
<b>Installer (6.01mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.5/filtration_0.5_setup.exe">filtration_0.5_setup.exe</a> <b>Installer (6.37mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.10/filtration_0.10_setup.exe">filtration_0.10_setup.exe</a>
<b>Zip File (7.54mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.5/filtration_0.5.zip">filtration_0.5.zip</a> <b>Zip File (7.97mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.10/filtration_0.10.zip">filtration_0.10.zip</a>
## System Requirements ## System Requirements
Filtration requires .NET Framework 4.5.1 installed. Filtration requires .NET Framework 4.5.1 installed.
@@ -26,19 +26,10 @@ If you'd like to make your script fully compatible with Filtration, please take
## Screenshots ## Screenshots
##### Main Window ##### Main Window
<img src="http://i.imgur.com/s2lNHCm.png" /> <img src="http://i.imgur.com/eAsMoSo.png" />
##### Block Editor
<img src="http://i.imgur.com/BqWGxs7.png" />
##### Theme Editor ##### Theme Editor
<img src="http://i.imgur.com/R2w7Hf2.png" /> <img src="http://i.imgur.com/FJWJknO.png" />
##### Block Color Editor
<img src="http://i.imgur.com/nlBGiG4.png" />
##### Replace Colors Tool
<img src="http://i.imgur.com/oY1q6hq.png" />
## Contact ## Contact