48 Commits
0.4 ... 0.9

Author SHA1 Message Date
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
Ben
f5dcdf0af9 Removed item block display settings popup 2015-07-04 22:38:13 +01:00
Ben
da3759cd76 Refactored ItemFilterBlockView to use new usercontrol instead of datatemplate spam 2015-07-04 21:12:47 +01:00
Ben
d586492de8 Added theme component tooltip in theme editor 2015-07-04 20:24:00 +01:00
Ben
3337531161 Fixed another copy paste bug, changed speaker icon to button 2015-07-04 17:28:34 +01:00
Ben
0c470b3c97 Fixed copy paste crashes 2015-07-04 16:47:28 +01:00
Ben
3a60a5005b Changed versioning format, added grouping to theme browser, fixed styles 2015-07-04 14:29:07 +01:00
Ben
8b6207e334 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-04 12:24:56 +01:00
Ben
fea6bf6da2 Fixed bug causing clicks between documents and toolpanes not to register. 2015-07-04 12:24:50 +01:00
Ben Wallis
b6d1befd23 Delete Filtration.exe.config 2015-07-03 22:56:26 +01:00
Ben Wallis
2475d90bac Delete LootFilterScriptViewModel - Copy.cs 2015-07-03 22:55:51 +01:00
Ben
aae014b6e0 Added NLog logging 2015-07-03 22:16:17 +01:00
Ben
aadd56c473 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-03 21:19:30 +01:00
Ben
8f533e8fd7 Fixed localised decimal bug and tidied up About Window 2015-07-03 21:19:25 +01:00
Ben Wallis
272b7e8360 Update README.md 2015-07-02 22:48:57 +01:00
Ben
2d448ed850 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-02 22:02:55 +01:00
Ben
bf4781dbde Added application-level unhandled exception handler 2015-07-02 22:02:51 +01:00
Ben Wallis
b889f1ef9a Update README.md 2015-07-02 20:47:00 +01:00
99 changed files with 5340 additions and 1129 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 BooleanVisibilityConverter : 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 BooleanVisibilityConverterCopy : 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

@@ -49,11 +49,13 @@
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> <HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath> <HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@@ -62,8 +64,15 @@
<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="ViewModels\FiltrationViewModelBase.cs" /> <Compile Include="ViewModels\FiltrationViewModelBase.cs" />
<Compile Include="ViewModels\PaneViewModel.cs" /> <Compile Include="ViewModels\PaneViewModel.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" /> <Compile Include="WindsorInstallers\ServicesInstaller.cs" />
@@ -77,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

@@ -0,0 +1,17 @@
using System.Windows;
namespace Filtration.Common.Services
{
public interface IMessageBoxService
{
MessageBoxResult Show(string caption, string message, MessageBoxButton buttons, MessageBoxImage image);
}
public class MessageBoxService : IMessageBoxService
{
public MessageBoxResult Show(string caption, string message, MessageBoxButton buttons, MessageBoxImage image)
{
return MessageBox.Show(message, caption, buttons, image);
}
}
}

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,15 +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" />
</ResourceDictionary> </ResourceDictionary>
<ResourceDictionary Source="ExpanderStyle.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -13,6 +13,11 @@ namespace Filtration.Common.WindsorInstallers
Component.For<IFileSystemService>() Component.For<IFileSystemService>()
.ImplementedBy<FileSystemService>() .ImplementedBy<FileSystemService>()
.LifeStyle.Singleton); .LifeStyle.Singleton);
container.Register(
Component.For<IMessageBoxService>()
.ImplementedBy<MessageBoxService>()
.LifeStyle.Singleton);
} }
} }
} }

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

@@ -1,14 +1,12 @@
using System.Net.Mime; using System.Windows.Media;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
using Filtration.Translators; using Filtration.ObjectModel.ThemeEditor;
using NUnit.Framework; using NUnit.Framework;
namespace Filtration.Tests.Translators namespace Filtration.ObjectModel.Tests.ThemeEditor
{ {
[TestFixture] [TestFixture]
public class TestThemeComponentListBuilder public class TestThemeComponentCollection
{ {
[Test] [Test]
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice() public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
@@ -19,11 +17,11 @@ namespace Filtration.Tests.Translators
var testInputComponentName = "testComponent"; var testInputComponentName = "testComponent";
var testInputColor = new Color(); var testInputColor = new Color();
var builder = new ThemeComponentListBuilder(); var componentCollection = new ThemeComponentCollection();
// Act // Act
var firstResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor); var firstResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
var secondResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor); var secondResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
// Assert // Assert
Assert.AreSame(firstResult, secondResult); 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

@@ -18,7 +18,8 @@ namespace Filtration.Tests.Services
{ {
// Arrange // Arrange
var testInputData = @"<UpdateData> var testInputData = @"<UpdateData>
<CurrentVersion>0.2</CurrentVersion> <LatestVersionMajorPart>1</LatestVersionMajorPart>
<LatestVersionMinorPart>3</LatestVersionMinorPart>
<ReleaseDate>2015-07-01</ReleaseDate> <ReleaseDate>2015-07-01</ReleaseDate>
<DownloadUrl>http://www.google.com</DownloadUrl> <DownloadUrl>http://www.google.com</DownloadUrl>
<ReleaseNotes>* Release notes line 1 <ReleaseNotes>* Release notes line 1
@@ -28,7 +29,8 @@ namespace Filtration.Tests.Services
var expectedResult = new UpdateData var expectedResult = new UpdateData
{ {
CurrentVersion = 0.2m, LatestVersionMajorPart = 1,
LatestVersionMinorPart = 3,
DownloadUrl = "http://www.google.com", DownloadUrl = "http://www.google.com",
ReleaseDate = new DateTime(2015, 7, 1), ReleaseDate = new DateTime(2015, 7, 1),
ReleaseNotes = @"* Release notes line 1 ReleaseNotes = @"* Release notes line 1
@@ -43,7 +45,8 @@ namespace Filtration.Tests.Services
var result = service.DeserializeUpdateData(testInputData); var result = service.DeserializeUpdateData(testInputData);
// Assert // Assert
Assert.AreEqual(expectedResult.CurrentVersion, result.CurrentVersion); Assert.AreEqual(expectedResult.LatestVersionMajorPart, result.LatestVersionMajorPart);
Assert.AreEqual(expectedResult.LatestVersionMinorPart, result.LatestVersionMinorPart);
Assert.AreEqual(expectedResult.DownloadUrl, result.DownloadUrl); Assert.AreEqual(expectedResult.DownloadUrl, result.DownloadUrl);
Assert.AreEqual(expectedResult.ReleaseDate, result.ReleaseDate); Assert.AreEqual(expectedResult.ReleaseDate, result.ReleaseDate);
Assert.AreEqual(expectedResult.ReleaseNotes, result.ReleaseNotes); Assert.AreEqual(expectedResult.ReleaseNotes, result.ReleaseNotes);

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,20 +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();
// 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]
@@ -525,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));
@@ -542,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));
@@ -560,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));
@@ -577,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);
@@ -610,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);
@@ -692,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));
@@ -721,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));
@@ -742,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));
@@ -761,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));
@@ -779,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));
@@ -798,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));
@@ -1267,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()
{ {
@@ -1346,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()
@@ -1460,6 +1527,23 @@ 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]
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
testInputBlockItems.Add(testInputBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
}
private class ItemFilterBlockTranslatorTestUtility private class ItemFilterBlockTranslatorTestUtility
{ {
public ItemFilterBlockTranslatorTestUtility() public ItemFilterBlockTranslatorTestUtility()
@@ -1469,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

@@ -55,6 +55,10 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Filtration.Common\Filtration.Common.csproj">
<Project>{8cb44f28-2956-4c2a-9314-72727262edd4}</Project>
<Name>Filtration.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj"> <ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project> <Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name> <Name>Filtration.ObjectModel</Name>

View File

@@ -1,9 +1,11 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Common.Services;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemTypes; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor; using Filtration.ObjectModel.ThemeEditor;
using Filtration.ThemeEditor.Services; using Filtration.ThemeEditor.Services;
using Moq;
using NUnit.Framework; using NUnit.Framework;
namespace Filtration.ThemeEditor.Tests.Services namespace Filtration.ThemeEditor.Tests.Services
@@ -27,8 +29,9 @@ namespace Filtration.ThemeEditor.Tests.Services
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor); var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
testInputTheme.Components.Add(testInputThemeComponent); testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputThemeComponent; testInputBlockItem.ThemeComponent = testInputThemeComponent;
var mockMessageBoxService = new Mock<IMessageBoxService>();
var service = new ThemeService(); var service = new ThemeService(mockMessageBoxService.Object);
// Act // Act
service.ApplyThemeToScript(testInputTheme, testInputScript); service.ApplyThemeToScript(testInputTheme, testInputScript);
@@ -55,7 +58,9 @@ namespace Filtration.ThemeEditor.Tests.Services
testInputTheme.Components.Add(testInputThemeComponent); testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputBlockItemThemeComponent; testInputBlockItem.ThemeComponent = testInputBlockItemThemeComponent;
var service = new ThemeService(); var mockMessageBoxService = new Mock<IMessageBoxService>();
var service = new ThemeService(mockMessageBoxService.Object);
// Act // Act
service.ApplyThemeToScript(testInputTheme, testInputScript); service.ApplyThemeToScript(testInputTheme, testInputScript);

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

@@ -54,6 +54,9 @@
<Reference Include="Microsoft.Practices.ServiceLocation"> <Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> <HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference> </Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
@@ -92,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" />
@@ -129,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,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using AutoMapper; using AutoMapper;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.ThemeEditor; using Filtration.ObjectModel.ThemeEditor;
@@ -9,10 +11,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);
IThemeEditorViewModel LoadThemeFromFile(string filePath);
Theme LoadThemeModelFromFile(string filePath); Theme LoadThemeModelFromFile(string filePath);
void SaveTheme(IThemeViewModel themeViewModel, string filePath); void SaveTheme(IThemeEditorViewModel themeEditorViewModel, string filePath);
} }
internal class ThemeProvider : IThemeProvider internal class ThemeProvider : IThemeProvider
@@ -26,20 +29,35 @@ 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 themeViewModel = _themeViewModelFactory.Create();
themeViewModel.InitialiseForMasterTheme(script);
themeViewModel.FilePath = "<Master Theme> " + Path.GetFileName(script.FilePath);
return themeViewModel;
}
public IThemeEditorViewModel LoadThemeFromFile(string filePath)
{ {
var model = _themePersistenceService.LoadTheme(filePath); var model = _themePersistenceService.LoadTheme(filePath);
var viewModel = Mapper.Map<IThemeViewModel>(model); var viewModel = Mapper.Map<IThemeEditorViewModel>(model);
viewModel.FilePath = filePath; viewModel.FilePath = filePath;
return viewModel; return viewModel;
} }
@@ -49,9 +67,9 @@ namespace Filtration.ThemeEditor.Providers
return _themePersistenceService.LoadTheme(filePath); return _themePersistenceService.LoadTheme(filePath);
} }
public void SaveTheme(IThemeViewModel themeViewModel, string filePath) public void SaveTheme(IThemeEditorViewModel themeEditorViewModel, string filePath)
{ {
var theme = Mapper.Map<Theme>(themeViewModel); var theme = Mapper.Map<Theme>(themeEditorViewModel);
_themePersistenceService.SaveTheme(theme, filePath); _themePersistenceService.SaveTheme(theme, filePath);
} }
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using Filtration.Common.Services;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes; using Filtration.ObjectModel.BlockItemTypes;
@@ -16,6 +17,13 @@ namespace Filtration.ThemeEditor.Services
public class ThemeService : IThemeService public class ThemeService : IThemeService
{ {
private readonly IMessageBoxService _messageBoxService;
public ThemeService(IMessageBoxService messageBoxService)
{
_messageBoxService = messageBoxService;
}
public void ApplyThemeToScript(Theme theme, ItemFilterScript script) public void ApplyThemeToScript(Theme theme, ItemFilterScript script)
{ {
var mismatchedComponents = false; var mismatchedComponents = false;
@@ -58,9 +66,9 @@ namespace Filtration.ThemeEditor.Services
if (mismatchedComponents) if (mismatchedComponents)
{ {
MessageBox.Show( _messageBoxService.Show("Possible Theme Mismatch",
"Not all theme components had matches - are you sure this theme is designed for this script?", "Not all theme components had matches - are you sure this theme is designed for this script?",
"Possible Theme Mismatch", MessageBoxButton.OK, MessageBoxImage.Exclamation); MessageBoxButton.OK, MessageBoxImage.Exclamation);
} }
} }
} }

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,212 @@
using System;
using System.IO;
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(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 void Save()
{
if (IsMasterTheme) return;
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()
{
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;
_themeProvider.SaveTheme(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 void OnCloseCommand()
{
Close();
}
public void Close()
{
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,126 +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.ViewModels;
using Filtration.Interface;
using Filtration.ThemeEditor.Providers;
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 readonly IThemeProvider _themeProvider;
private bool _filenameIsFake;
private string _filePath;
public ThemeViewModel(IThemeProvider themeProvider)
{
_themeProvider = themeProvider;
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)
{
MessageBox.Show(@"Error saving filter theme - " + e.Message, @"Save Error", 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)
//{
// MessageBox.Show(@"Error saving theme file - " + e.Message, @"Save Error", 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}" /> <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,27 +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"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding Components}" Margin="10">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<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

@@ -6,4 +6,5 @@
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" /> <package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
<package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" /> <package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" />
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" /> <package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
<package id="NLog" version="4.0.1" targetFramework="net451" />
</packages> </packages>

View File

@@ -16,12 +16,15 @@
<setting name="ExtraLineBetweenBlocks" serializeAs="String"> <setting name="ExtraLineBetweenBlocks" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="SuppressUpdatesUpToVersion" serializeAs="String"> <setting name="SuppressUpdatesUpToVersionMajorPart" serializeAs="String">
<value>0</value> <value>0</value>
</setting> </setting>
<setting name="SuppressUpdates" serializeAs="String"> <setting name="SuppressUpdates" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="SuppressUpdatesUpToVersionMinorPart" serializeAs="String">
<value>0</value>
</setting>
</Filtration.Properties.Settings> </Filtration.Properties.Settings>
</userSettings> </userSettings>
<runtime> <runtime>

View File

@@ -1,18 +1,48 @@
<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" />
<ResourceDictionary Source="Views/Styles/CheckBox.xaml" /> <ResourceDictionary Source="Views/Styles/CheckBox.xaml" />
<ResourceDictionary Source="Views/Styles/ListBoxItem.xaml" /> <ResourceDictionary Source="Views/Styles/ListBoxItem.xaml" />
<ResourceDictionary Source="Views/Styles/TreeViewItem.xaml" /> <ResourceDictionary Source="Views/Styles/TreeViewItem.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Sizes.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ComboBox.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.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>
<Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" />
<Style TargetType="ComboBoxItem" BasedOn="{StaticResource MetroComboBoxItem}" />
<Style TargetType="ScrollBar" BasedOn="{StaticResource MetroScrollBar}" />
<Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}" />
</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,6 +1,7 @@
using System.IO.Compression; using System;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Threading;
using AutoMapper; using AutoMapper;
using Castle.Facilities.TypedFactory; using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.ModelBuilder.Inspectors; using Castle.MicroKernel.ModelBuilder.Inspectors;
@@ -12,15 +13,19 @@ using Filtration.Properties;
using Filtration.ThemeEditor.ViewModels; using Filtration.ThemeEditor.ViewModels;
using Filtration.ViewModels; using Filtration.ViewModels;
using Filtration.Views; using Filtration.Views;
using NLog;
namespace Filtration namespace Filtration
{ {
public partial class App public partial class App : Application
{ {
private IWindsorContainer _container; private IWindsorContainer _container;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private void Application_Startup(object sender, StartupEventArgs e) private void Application_Startup(object sender, StartupEventArgs e)
{ {
DispatcherUnhandledException += OnDispatcherUnhandledException;
_container = new WindsorContainer(); _container = new WindsorContainer();
var propInjector = _container.Kernel.ComponentModelBuilder var propInjector = _container.Kernel.ComponentModelBuilder
@@ -52,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();
@@ -62,9 +67,18 @@ namespace Filtration
mainWindow.Show(); mainWindow.Show();
} }
public void TestTest() public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{ {
_logger.Fatal(e.Exception);
var exception = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
var innerException = e.Exception.InnerException != null
? e.Exception.InnerException.Message + Environment.NewLine +
e.Exception.InnerException.StackTrace
: string.Empty;
MessageBox.Show(
exception + Environment.NewLine + innerException,
"Unhandled Exception", MessageBoxButton.OK, MessageBoxImage.Error);
} }
protected override void OnExit(ExitEventArgs e) protected override void OnExit(ExitEventArgs e)

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

@@ -0,0 +1,23 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Converters
{
public class BlockItemToRemoveEnabledVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var actionBlock = value as ActionBlockItem;
return actionBlock != null ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -64,6 +64,12 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath> <HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference> </Reference>
<Reference Include="MahApps.Metro">
<HintPath>..\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.ObjectModel" /> <Reference Include="System.ObjectModel" />
@@ -78,7 +84,7 @@
</Reference> </Reference>
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Fluent.Ribbon.3.4.0\lib\net45\System.Windows.Interactivity.dll</HintPath> <HintPath>..\packages\MahApps.Metro.1.1.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@@ -123,19 +129,16 @@
<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\BooleanVisibilityConverterCopy.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\BooleanVisibilityConverter.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" />
@@ -150,8 +153,10 @@
<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">
<DependentUpon>BlockItemControl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\CrossButton.cs" /> <Compile Include="UserControls\CrossButton.cs" />
<Compile Include="UserControls\EditableListBoxControl.xaml.cs"> <Compile Include="UserControls\EditableListBoxControl.xaml.cs">
<DependentUpon>EditableListBoxControl.xaml</DependentUpon> <DependentUpon>EditableListBoxControl.xaml</DependentUpon>
@@ -159,6 +164,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" />
@@ -186,6 +194,14 @@
<Compile Include="Views\SettingsPageView.xaml.cs"> <Compile Include="Views\SettingsPageView.xaml.cs">
<DependentUpon>SettingsPageView.xaml</DependentUpon> <DependentUpon>SettingsPageView.xaml</DependentUpon>
</Compile> </Compile>
<Page Include="UserControls\BlockItemControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</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>
@@ -194,9 +210,6 @@
<DependentUpon>BlockGroupBrowserView.xaml</DependentUpon> <DependentUpon>BlockGroupBrowserView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\BlockTemplateSelector.cs" /> <Compile Include="Views\BlockTemplateSelector.cs" />
<Compile Include="Views\ItemFilterBlockDisplaySettingsView.xaml.cs">
<DependentUpon>ItemFilterBlockDisplaySettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ItemFilterScriptView.xaml.cs"> <Compile Include="Views\ItemFilterScriptView.xaml.cs">
<DependentUpon>ItemFilterScriptView.xaml</DependentUpon> <DependentUpon>ItemFilterScriptView.xaml</DependentUpon>
</Compile> </Compile>
@@ -256,6 +269,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\Styles\TextBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Styles\TreeViewItem.xaml"> <Page Include="Views\Styles\TreeViewItem.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -280,10 +297,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\ItemFilterBlockDisplaySettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ToolPanes\BlockOutputPreviewView.xaml"> <Page Include="Views\ToolPanes\BlockOutputPreviewView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -292,10 +305,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>
@@ -360,6 +369,15 @@
<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">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@@ -409,6 +427,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

@@ -9,7 +9,8 @@ namespace Filtration.Models
private string _releaseNotes; private string _releaseNotes;
public string DownloadUrl { get; set; } public string DownloadUrl { get; set; }
public decimal CurrentVersion { get; set; } public int LatestVersionMajorPart { get; set; }
public int LatestVersionMinorPart { get; set; }
public DateTime ReleaseDate { get; set; } public DateTime ReleaseDate { get; set; }
public string ReleaseNotes public string ReleaseNotes

22
Filtration/NLog.config Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
<targets>
<target xsi:type="File" name="fErrors" fileName="${basedir}/Filtration_errors_${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
<target xsi:type="File" name="fDebug" fileName="${basedir}/Filtration_debug_${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
</targets>
<rules>
<!-- Uncomment the Debug line to enable Debug logging -->
<!--<logger name="*" minlevel="Debug" writeTo="fDebug" final="true" />-->
<logger name="*" minlevel="Error" writeTo="fErrors" />
</rules>
</nlog>

2479
Filtration/NLog.xsd Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -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.4.*")] [assembly: AssemblyVersion("0.9.*")]
[assembly: InternalsVisibleTo("Filtration.Tests")] [assembly: InternalsVisibleTo("Filtration.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]

View File

@@ -50,12 +50,12 @@ namespace Filtration.Properties {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")] [global::System.Configuration.DefaultSettingValueAttribute("0")]
public decimal SuppressUpdatesUpToVersion { public int SuppressUpdatesUpToVersionMajorPart {
get { get {
return ((decimal)(this["SuppressUpdatesUpToVersion"])); return ((int)(this["SuppressUpdatesUpToVersionMajorPart"]));
} }
set { set {
this["SuppressUpdatesUpToVersion"] = value; this["SuppressUpdatesUpToVersionMajorPart"] = value;
} }
} }
@@ -70,5 +70,17 @@ namespace Filtration.Properties {
this["SuppressUpdates"] = value; this["SuppressUpdates"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int SuppressUpdatesUpToVersionMinorPart {
get {
return ((int)(this["SuppressUpdatesUpToVersionMinorPart"]));
}
set {
this["SuppressUpdatesUpToVersionMinorPart"] = value;
}
}
} }
} }

View File

@@ -8,11 +8,14 @@
<Setting Name="ExtraLineBetweenBlocks" Type="System.Boolean" Scope="User"> <Setting Name="ExtraLineBetweenBlocks" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="SuppressUpdatesUpToVersion" Type="System.Decimal" Scope="User"> <Setting Name="SuppressUpdatesUpToVersionMajorPart" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value> <Value Profile="(Default)">0</Value>
</Setting> </Setting>
<Setting Name="SuppressUpdates" Type="System.Boolean" Scope="User"> <Setting Name="SuppressUpdates" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="SuppressUpdatesUpToVersionMinorPart" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@@ -1,6 +1,4 @@
using System; using Filtration.ObjectModel;
using System.IO;
using Filtration.ObjectModel;
using Filtration.Services; using Filtration.Services;
using Filtration.ViewModels; using Filtration.ViewModels;
@@ -28,15 +26,7 @@ namespace Filtration.Repositories
public IItemFilterScriptViewModel LoadScriptFromFile(string path) public IItemFilterScriptViewModel LoadScriptFromFile(string path)
{ {
ItemFilterScript loadedScript; var loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path);
try
{
loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path);
}
catch (Exception e)
{
throw new IOException("Error loading filter script - " + e.Message);
}
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

@@ -23,6 +23,7 @@ Decoy Totem
Desecrate Desecrate
Determination Determination
Detonate Dead Detonate Dead
Detonate Mines
Devouring Totem Devouring Totem
Discharge Discharge
Discipline Discipline
@@ -1068,3 +1069,31 @@ Sage Wand
Serpent Wand Serpent Wand
Spiraled Wand Spiraled Wand
Tornado Wand Tornado Wand
Emperor's Luck
The Avenger
The Brittle Emperor
Hope
The Battle Born
The Carrion Crow
The Cataclysm
The Dark Mage
The Drunken Aristocrat
The Gladiator
The Hoarder
The Hunger
The Metalsmith's Gift
The Poet
The Road to Power
The Scholar
The Summoner
Vinia's Token
Three Faces in the Dark
The Hermit
Lantador's Lost Love
Birth of the Three
The Lover
Chaotic Disposition
Eternal Sword
The Sun
The Gemcutter
The Warden

View File

@@ -8,7 +8,6 @@ Claws
Daggers Daggers
Wands Wands
One Hand Swords One Hand Swords
Thrusting One Hand Swords
One Hand Axes One Hand Axes
One Hand Maces One Hand Maces
Bows Bows
@@ -25,7 +24,6 @@ Boots
Body Armours Body Armours
Helmets Helmets
Shields Shields
Stackable Currency
Quest Items Quest Items
Sceptres Sceptres
Utility Flasks Utility Flasks
@@ -34,3 +32,5 @@ Fishing Rods
Map Fragments Map Fragments
Hideout Doodads Hideout Doodads
Microtransactions Microtransactions
Divination Card
Jewel

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

@@ -1,5 +1,4 @@
using System.IO; using System.IO;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Serialization; using System.Xml.Serialization;
using Filtration.Models; using Filtration.Models;

View File

@@ -10,13 +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
{ {
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);
} }
@@ -24,22 +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;
} }
// 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)))
{ {
@@ -60,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);
@@ -68,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":
@@ -293,14 +312,17 @@ namespace Filtration.Translators
{ {
throw new Exception("Parsing error - unknown theme component type"); throw new Exception("Parsing error - unknown theme component type");
} }
if (_masterComponentCollection != null)
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName, blockItem.Color); {
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
blockItem.Color);
}
} }
return blockItem; return blockItem;
} }
public void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems , string inputString) public void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
{ {
// Reverse iterate to remove existing IAudioVisualBlockItems // Reverse iterate to remove existing IAudioVisualBlockItems
for (var idx = blockItems.Count - 1; idx >= 0; idx--) for (var idx = blockItems.Count - 1; idx >= 0; idx--)
@@ -343,25 +365,6 @@ namespace Filtration.Translators
} }
} }
private void ReplaceColorBlockItem<T>(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString) where T : ColorBlockItem
{
var newBlockItem = GetColorBlockItemFromString<T>(inputString);
var existingBlockItem = blockItems.OfType<T>().FirstOrDefault();
blockItems.Remove(existingBlockItem);
blockItems.Add(newBlockItem);
}
private void ReplaceFontSizeBlockItem(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
{
var match = Regex.Match(inputString, @"\s+(\d+)");
if (!match.Success) return;
var newBlockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value));
var existingBlockItem = blockItems.OfType<FontSizeBlockItem>().FirstOrDefault();
blockItems.Remove(existingBlockItem);
blockItems.Add(newBlockItem);
}
private void AddBlockGroupToBlock(ItemFilterBlock block, string inputString) private void AddBlockGroupToBlock(ItemFilterBlock block, string inputString)
{ {
var blockGroupStart = inputString.IndexOf("#", StringComparison.Ordinal); var blockGroupStart = inputString.IndexOf("#", StringComparison.Ordinal);
@@ -413,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)
{ {
@@ -430,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

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Documents;
using Castle.Core.Internal; using Castle.Core.Internal;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.Properties; using Filtration.Properties;
@@ -20,15 +21,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 +95,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 +118,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 +127,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 +151,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,60 +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();
ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor);
List<ThemeComponent> GetComponents();
void Cleanup();
}
internal class ThemeComponentListBuilder : IThemeComponentListBuilder
{
private List<ThemeComponent> _themeComponents;
public ThemeComponentListBuilder()
{
_themeComponents = new List<ThemeComponent>();
}
public void Initialise()
{
_themeComponents = new List<ThemeComponent>();
}
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

@@ -0,0 +1,110 @@
<UserControl x:Class="Filtration.UserControls.BlockItemControl"
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:blockItemBaseTypes="clr-namespace:Filtration.ObjectModel.BlockItemBaseTypes;assembly=Filtration.ObjectModel"
xmlns:blockItemTypes="clr-namespace:Filtration.ObjectModel.BlockItemTypes;assembly=Filtration.ObjectModel"
xmlns:extensions="clr-namespace:Filtration.Extensions"
xmlns:enums="clr-namespace:Filtration.ObjectModel.Enums;assembly=Filtration.ObjectModel"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:views="clr-namespace:Filtration.Views"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=userControls:BlockItemControl}"
d:DesignHeight="200" d:DesignWidth="150">
<Border Style="{StaticResource BlockItemBorder}" Width="142">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="PowderBlue" CornerRadius="3,3,0,0">
<Grid Margin="3,0,3,0">
<TextBlock Text="{Binding BlockItem.DisplayHeading}" Grid.Row="0" VerticalAlignment="Center" Foreground="Navy" />
<userControls:CrossButton Grid.Row="0" Height="12" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding RemoveItemCommand}" CommandParameter="{Binding BlockItem}" Visibility="{Binding RemoveEnabled}"/>
</Grid>
</Border>
<ContentControl Grid.Row="1" Content="{Binding BlockItem}" Name="BlockItemContentControl" Margin="3">
<ContentControl.Resources>
<!-- Action Template -->
<DataTemplate DataType="{x:Type blockItemBaseTypes:ActionBlockItem}">
<WrapPanel VerticalAlignment="Center" Margin="5,5,5,5">
<RadioButton IsChecked="{Binding Action, Converter={StaticResource BooleanToBlockActionConverter}}" Margin="0,0,10,0">Show</RadioButton>
<RadioButton IsChecked="{Binding Action, Converter={StaticResource BooleanToBlockActionInverseConverter}}">Hide</RadioButton>
</WrapPanel>
</DataTemplate>
<!-- NumericFilterPredicate Template -->
<DataTemplate DataType="{x:Type blockItemBaseTypes:NumericFilterPredicateBlockItem}">
<userControls:NumericFilterPredicateControl Margin="5,5,5,5" NumericFilterPredicate="{Binding FilterPredicate}" Minimum="{Binding Minimum, Mode=OneTime}" Maximum="{Binding Maximum, Mode=OneTime}" />
</DataTemplate>
<!-- Rarity Template -->
<DataTemplate DataType="{x:Type blockItemTypes:RarityBlockItem}">
<StackPanel Orientation="Horizontal" Margin="5,5,5,5">
<ComboBox ItemsSource="{Binding Source={extensions:Enumeration {x:Type enums:FilterPredicateOperator}}}"
DisplayMemberPath="Description"
SelectedValue="{Binding FilterPredicate.PredicateOperator}"
SelectedValuePath="Value" Width="50" Margin="0,0,6,0" />
<ComboBox ItemsSource="{Binding Source={extensions:Enumeration {x:Type enums:ItemRarity}}}"
DisplayMemberPath="Description"
SelectedValue="{Binding FilterPredicate.PredicateOperand, Converter={StaticResource IntToItemRarityConverter}}"
SelectedValuePath="Value" />
</StackPanel>
</DataTemplate>
<!-- Class Template -->
<DataTemplate DataType="{x:Type blockItemTypes:ClassBlockItem}">
<userControls:EditableListBoxControl Margin="5,5,5,5" ItemsSource="{Binding Items}" AutoCompleteItemsSource="{Binding ElementName=TopLevelGrid, Path=DataContext.AutoCompleteItemClasses}" />
</DataTemplate>
<!-- Base Type Template -->
<DataTemplate DataType="{x:Type blockItemTypes:BaseTypeBlockItem}">
<userControls:EditableListBoxControl Margin="5,5,5,5" ItemsSource="{Binding Items}" AutoCompleteItemsSource="{Binding ElementName=TopLevelGrid, Path=DataContext.AutoCompleteItemBaseTypes}" />
</DataTemplate>
<!-- Socket Groups Template -->
<DataTemplate DataType="{x:Type blockItemTypes:SocketGroupBlockItem}">
<userControls:EditableListBoxControl Margin="5,5,5,5" ItemsSource="{Binding Items}" />
</DataTemplate>
<!-- Color Template -->
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}">
<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>
<!-- Font Size Template -->
<DataTemplate DataType="{x:Type blockItemTypes:FontSizeBlockItem}">
<WrapPanel HorizontalAlignment="Left">
<xctk:ShortUpDown Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Width="50" />
</WrapPanel>
</DataTemplate>
<!-- Sound Template -->
<DataTemplate DataType="{x:Type blockItemTypes:SoundBlockItem}">
<WrapPanel HorizontalAlignment="Left">
<Button Command="{Binding Path=DataContext.PlaySoundCommand, RelativeSource={RelativeSource AncestorType={x:Type views:ItemFilterBlockView}}}" Width="20" Height="20" Background="Transparent" BorderBrush="Transparent">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<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"/>
</WrapPanel>
</DataTemplate>
</ContentControl.Resources>
</ContentControl>
</Grid>
</Border>
</UserControl>

View File

@@ -0,0 +1,118 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using Filtration.Annotations;
using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Views;
using GalaSoft.MvvmLight.CommandWpf;
using Xceed.Wpf.Toolkit;
namespace Filtration.UserControls
{
public partial class BlockItemControl : INotifyPropertyChanged
{
public BlockItemControl()
{
InitializeComponent();
// ReSharper disable once PossibleNullReferenceException
(Content as FrameworkElement).DataContext = this;
SetBlockColorCommand = new RelayCommand(OnSetBlockColorCommmand);
}
public RelayCommand SetBlockColorCommand { get; private set; }
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
"BlockItem",
typeof(IItemFilterBlockItem),
typeof(BlockItemControl),
new FrameworkPropertyMetadata());
public static readonly DependencyProperty RemoveItemCommandProperty = DependencyProperty.Register(
"RemoveItemCommand",
typeof(RelayCommand<IItemFilterBlockItem>),
typeof(BlockItemControl),
new FrameworkPropertyMetadata());
public static readonly DependencyProperty RemoveEnabledProperty = DependencyProperty.Register(
"RemoveEnabled",
typeof(Visibility),
typeof(BlockItemControl),
new FrameworkPropertyMetadata());
public IItemFilterBlockItem BlockItem
{
get
{
return (IItemFilterBlockItem)GetValue(BlockItemProperty);
}
set
{
SetValue(BlockItemProperty, value);
OnPropertyChanged();
}
}
public RelayCommand<IItemFilterBlockItem> RemoveItemCommand
{
get
{
return (RelayCommand<IItemFilterBlockItem>)GetValue(RemoveItemCommandProperty);
}
set
{
SetValue(RemoveItemCommandProperty, value);
}
}
public Visibility RemoveEnabled
{
get
{
return (Visibility)GetValue(RemoveEnabledProperty);
}
set
{
SetValue(RemoveEnabledProperty, value);
}
}
public ObservableCollection<ColorItem> AvailableColors
{
get
{
{
return PathOfExileColors.DefaultColors;
}
}
}
public List<int> SoundsAvailable
{
get
{
return new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
}
private void OnSetBlockColorCommmand()
{
var blockItem = BlockItem as ColorBlockItem;
if (blockItem == null || blockItem.ThemeComponent == null) return;
blockItem.Color = blockItem.ThemeComponent.Color;
}
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

@@ -41,7 +41,7 @@
<KeyBinding Key="Delete" Command="{Binding Path=DeleteItemCommand}" CommandParameter="{Binding ElementName=ControlListBox, Path=SelectedValue}" /> <KeyBinding Key="Delete" Command="{Binding Path=DeleteItemCommand}" CommandParameter="{Binding ElementName=ControlListBox, Path=SelectedValue}" />
</ListBox.InputBindings> </ListBox.InputBindings>
</ListBox> </ListBox>
<toolkit:AutoCompleteBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding AutoCompleteItemsSource}" FilterMode="Contains" Text="{Binding AddItemText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" ></toolkit:AutoCompleteBox> <toolkit:AutoCompleteBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding AutoCompleteItemsSource}" FilterMode="Contains" Text="{Binding AddItemText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
<Button Grid.Row="1" Grid.Column="1" Command="{Binding AddItemCommand}" IsDefault="True">Add</Button> <Button Grid.Row="1" Grid.Column="1" Command="{Binding AddItemCommand}" IsDefault="True">Add</Button>
</Grid> </Grid>
</UserControl> </UserControl>

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
@@ -11,7 +10,6 @@ namespace Filtration.UserControls
InitializeComponent(); InitializeComponent();
// ReSharper disable once PossibleNullReferenceException // ReSharper disable once PossibleNullReferenceException
(Content as FrameworkElement).DataContext = this; (Content as FrameworkElement).DataContext = this;
} }
public static readonly DependencyProperty TextColorProperty = DependencyProperty.Register( public static readonly DependencyProperty TextColorProperty = DependencyProperty.Register(

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

@@ -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,6 +34,7 @@ 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;
@@ -63,6 +68,8 @@ namespace Filtration.ViewModels
get { return _activeDocument; } get { return _activeDocument; }
set set
{ {
if (value == _activeDocument) return;
_activeDocument = value; _activeDocument = value;
RaisePropertyChanged(); RaisePropertyChanged();
@@ -70,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)
@@ -89,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; }
@@ -106,6 +123,7 @@ namespace Filtration.ViewModels
private List<IToolViewModel> _tools; private List<IToolViewModel> _tools;
public IEnumerable<IToolViewModel> Tools public IEnumerable<IToolViewModel> Tools
{ {
get get
@@ -125,6 +143,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;
@@ -149,6 +171,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)
@@ -160,5 +195,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();
} }
@@ -33,6 +34,7 @@ namespace Filtration.ViewModels
private bool _displaySettingsPopupOpen; private bool _displaySettingsPopupOpen;
private bool _isExpanded; private bool _isExpanded;
private bool _audioVisualBlockItemsGridVisible;
public ItemFilterBlockViewModel(IStaticDataService staticDataService, IReplaceColorsViewModel replaceColorsViewModel) public ItemFilterBlockViewModel(IStaticDataService staticDataService, IReplaceColorsViewModel replaceColorsViewModel)
{ {
@@ -55,7 +57,7 @@ namespace Filtration.ViewModels
ToggleBlockActionCommand = new RelayCommand(OnToggleBlockActionCommand); ToggleBlockActionCommand = new RelayCommand(OnToggleBlockActionCommand);
AddAudioVisualBlockItemCommand = new RelayCommand<Type>(OnAddAudioVisualBlockItemCommand); AddAudioVisualBlockItemCommand = new RelayCommand<Type>(OnAddAudioVisualBlockItemCommand);
RemoveFilterBlockItemCommand = new RelayCommand<IItemFilterBlockItem>(OnRemoveFilterBlockItemCommand); RemoveFilterBlockItemCommand = new RelayCommand<IItemFilterBlockItem>(OnRemoveFilterBlockItemCommand);
RemoveAudioVisualBlockItemCommand = new RelayCommand<IItemFilterBlockItem>(OnRemoveAudioVisualBlockItemCommand); SwitchBlockItemsViewCommand = new RelayCommand(OnSwitchBlockItemsViewCommand);
PlaySoundCommand = new RelayCommand(OnPlaySoundCommand, () => HasSound); PlaySoundCommand = new RelayCommand(OnPlaySoundCommand, () => HasSound);
} }
@@ -93,8 +95,8 @@ namespace Filtration.ViewModels
public RelayCommand<Type> AddFilterBlockItemCommand { get; private set; } public RelayCommand<Type> AddFilterBlockItemCommand { get; private set; }
public RelayCommand<Type> AddAudioVisualBlockItemCommand { get; private set; } public RelayCommand<Type> AddAudioVisualBlockItemCommand { get; private set; }
public RelayCommand<IItemFilterBlockItem> RemoveFilterBlockItemCommand { get; private set; } public RelayCommand<IItemFilterBlockItem> RemoveFilterBlockItemCommand { get; private set; }
public RelayCommand<IItemFilterBlockItem> RemoveAudioVisualBlockItemCommand { get; private set; }
public RelayCommand PlaySoundCommand { get; private set; } public RelayCommand PlaySoundCommand { get; private set; }
public RelayCommand SwitchBlockItemsViewCommand { get; private set; }
public ItemFilterBlock Block { get; private set; } public ItemFilterBlock Block { get; private set; }
@@ -120,6 +122,11 @@ namespace Filtration.ViewModels
get { return Block.BlockItems.Where(b => !(b is IAudioVisualBlockItem)); } get { return Block.BlockItems.Where(b => !(b is IAudioVisualBlockItem)); }
} }
public IEnumerable<IItemFilterBlockItem> RegularBlockItems
{
get { return Block.BlockItems.Where(b => !(b is IAudioVisualBlockItem)); }
}
public IEnumerable<IItemFilterBlockItem> AudioVisualBlockItems public IEnumerable<IItemFilterBlockItem> AudioVisualBlockItems
{ {
get { return Block.BlockItems.Where(b => b is IAudioVisualBlockItem); } get { return Block.BlockItems.Where(b => b is IAudioVisualBlockItem); }
@@ -133,6 +140,20 @@ namespace Filtration.ViewModels
} }
} }
public bool AudioVisualBlockItemsGridVisible
{
get { return _audioVisualBlockItemsGridVisible; }
set
{
_audioVisualBlockItemsGridVisible = value;
RaisePropertyChanged();
if (value && IsExpanded == false)
{
IsExpanded = true;
}
}
}
public bool DisplaySettingsPopupOpen public bool DisplaySettingsPopupOpen
{ {
get { return _displaySettingsPopupOpen; } get { return _displaySettingsPopupOpen; }
@@ -153,25 +174,6 @@ namespace Filtration.ViewModels
get { return _staticDataService.ItemBaseTypes; } get { return _staticDataService.ItemBaseTypes; }
} }
public List<int> SoundsAvailable
{
get
{
return new List<int>
{
1,
2,
3,
4,
5,
6,
7,
8,
9
};
}
}
public List<Type> BlockItemTypesAvailable public List<Type> BlockItemTypesAvailable
{ {
get get
@@ -208,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
@@ -293,7 +309,6 @@ namespace Filtration.ViewModels
var fontSize = HasFontSize ? (BlockItems.OfType<FontSizeBlockItem>().First().Value / 1.8) : 19; var fontSize = HasFontSize ? (BlockItems.OfType<FontSizeBlockItem>().First().Value / 1.8) : 19;
return fontSize; return fontSize;
} }
} }
@@ -302,6 +317,17 @@ namespace Filtration.ViewModels
get { return Block.HasBlockItemOfType<SoundBlockItem>(); } get { return Block.HasBlockItemOfType<SoundBlockItem>(); }
} }
public bool HasAudioVisualBlockItems
{
get { return AudioVisualBlockItems.Any(); }
}
private void OnSwitchBlockItemsViewCommand()
{
AudioVisualBlockItemsGridVisible = !AudioVisualBlockItemsGridVisible;
}
private void OnToggleBlockActionCommand() private void OnToggleBlockActionCommand()
{ {
var actionBlock = Block.BlockItems.OfType<ActionBlockItem>().First(); var actionBlock = Block.BlockItems.OfType<ActionBlockItem>().First();
@@ -323,6 +349,13 @@ namespace Filtration.ViewModels
private void OnRemoveFilterBlockItemCommand(IItemFilterBlockItem blockItem) private void OnRemoveFilterBlockItemCommand(IItemFilterBlockItem blockItem)
{ {
BlockItems.Remove(blockItem); BlockItems.Remove(blockItem);
if (blockItem is IAudioVisualBlockItem)
{
blockItem.PropertyChanged -= OnAudioVisualBlockItemChanged;
OnAudioVisualBlockItemChanged(this, EventArgs.Empty);
}
IsDirty = true; IsDirty = true;
} }
@@ -333,15 +366,7 @@ namespace Filtration.ViewModels
newBlockItem.PropertyChanged += OnAudioVisualBlockItemChanged; newBlockItem.PropertyChanged += OnAudioVisualBlockItemChanged;
BlockItems.Add(newBlockItem); BlockItems.Add(newBlockItem);
OnAudioVisualBlockItemChanged(null, null); OnAudioVisualBlockItemChanged(this, EventArgs.Empty);
IsDirty = true;
}
private void OnRemoveAudioVisualBlockItemCommand(IItemFilterBlockItem blockItem)
{
blockItem.PropertyChanged -= OnAudioVisualBlockItemChanged;
BlockItems.Remove(blockItem);
OnAudioVisualBlockItemChanged(null, null);
IsDirty = true; IsDirty = true;
} }
@@ -437,8 +462,10 @@ namespace Filtration.ViewModels
private void OnBlockItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) private void OnBlockItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{ {
RaisePropertyChanged("RegularBlockItems");
RaisePropertyChanged("SummaryBlockItems"); RaisePropertyChanged("SummaryBlockItems");
RaisePropertyChanged("AudioVisualBlockItems"); RaisePropertyChanged("AudioVisualBlockItems");
RaisePropertyChanged("HasAudioVisualBlockItems");
} }
} }
} }

View File

@@ -9,15 +9,17 @@ 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 Castle.Core.Internal;
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 Clipboard = System.Windows.Clipboard; using Clipboard = System.Windows.Clipboard;
using MessageBox = System.Windows.MessageBox;
namespace Filtration.ViewModels namespace Filtration.ViewModels
{ {
@@ -36,9 +38,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; }
@@ -63,10 +69,13 @@ namespace Filtration.ViewModels
internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel
{ {
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory; private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory;
private readonly IItemFilterBlockTranslator _blockTranslator; private readonly IItemFilterBlockTranslator _blockTranslator;
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel; private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
private readonly IItemFilterPersistenceService _persistenceService; private readonly IItemFilterPersistenceService _persistenceService;
private readonly IMessageBoxService _messageBoxService;
private bool _isDirty; private bool _isDirty;
private IItemFilterBlockViewModel _selectedBlockViewModel; private IItemFilterBlockViewModel _selectedBlockViewModel;
@@ -78,13 +87,15 @@ namespace Filtration.ViewModels
public ItemFilterScriptViewModel(IItemFilterBlockViewModelFactory itemFilterBlockViewModelFactory, public ItemFilterScriptViewModel(IItemFilterBlockViewModelFactory itemFilterBlockViewModelFactory,
IItemFilterBlockTranslator blockTranslator, IItemFilterBlockTranslator blockTranslator,
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel, IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
IItemFilterPersistenceService persistenceService) IItemFilterPersistenceService persistenceService,
IMessageBoxService messageBoxService)
{ {
_itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory; _itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
_blockTranslator = blockTranslator; _blockTranslator = blockTranslator;
_avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel; _avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel;
_avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged; _avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
_persistenceService = persistenceService; _persistenceService = persistenceService;
_messageBoxService = messageBoxService;
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>(); _itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand); ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
@@ -97,6 +108,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);
@@ -121,6 +134,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; }
@@ -208,6 +223,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; }
@@ -314,12 +344,13 @@ namespace Filtration.ViewModels
} }
Title = Filename; Title = Filename;
ContentId = "testcontentid"; ContentId = "ScriptContentId";
} }
public void Save() public void Save()
{ {
if (!ValidateScript()) return; if (!ValidateScript()) return;
if (!CheckForUnusedThemeComponents()) return;
if (_filenameIsFake) if (_filenameIsFake)
{ {
@@ -334,7 +365,12 @@ namespace Filtration.ViewModels
} }
catch (Exception e) catch (Exception e)
{ {
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK, if (_logger.IsErrorEnabled)
{
_logger.Error(e);
}
_messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error); MessageBoxImage.Error);
} }
} }
@@ -342,6 +378,7 @@ namespace Filtration.ViewModels
public void SaveAs() public void SaveAs()
{ {
if (!ValidateScript()) return; if (!ValidateScript()) return;
if (!CheckForUnusedThemeComponents()) return;
var saveDialog = new SaveFileDialog var saveDialog = new SaveFileDialog
{ {
@@ -365,12 +402,38 @@ namespace Filtration.ViewModels
} }
catch (Exception e) catch (Exception e)
{ {
MessageBox.Show(@"Error saving filter file - " + e.Message, @"Save Error", MessageBoxButton.OK, if (_logger.IsErrorEnabled)
{
_logger.Error(e);
}
_messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK,
MessageBoxImage.Error); MessageBoxImage.Error);
Script.FilePath = previousFilePath; Script.FilePath = previousFilePath;
} }
} }
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)
{ {
if (_avalonDockWorkspaceViewModel.ActiveScriptViewModel != this) if (_avalonDockWorkspaceViewModel.ActiveScriptViewModel != this)
@@ -408,7 +471,8 @@ namespace Filtration.ViewModels
var messageText = "The following script validation errors occurred:" + Environment.NewLine + failures; var messageText = "The following script validation errors occurred:" + Environment.NewLine + failures;
MessageBox.Show(messageText, "Script Validation Failure", MessageBoxButton.OK, MessageBoxImage.Exclamation); _messageBoxService.Show("Script Validation Failure", messageText, MessageBoxButton.OK,
MessageBoxImage.Exclamation);
return false; return false;
} }
@@ -425,8 +489,9 @@ namespace Filtration.ViewModels
} }
else else
{ {
var result = MessageBox.Show(@"Want to save your changes to this script?", var result = _messageBoxService.Show("Filtration",
@"Filtration", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); "Save script \"" + Filename + "\"?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
switch (result) switch (result)
{ {
case MessageBoxResult.Yes: case MessageBoxResult.Yes:
@@ -450,6 +515,13 @@ namespace Filtration.ViewModels
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);
} }
@@ -519,11 +591,13 @@ namespace Filtration.ViewModels
} }
public void PasteBlock(IItemFilterBlockViewModel targetBlockViewModel) public void PasteBlock(IItemFilterBlockViewModel targetBlockViewModel)
{
try
{ {
var clipboardText = Clipboard.GetText(); var clipboardText = Clipboard.GetText();
if (clipboardText.IsNullOrEmpty()) return; if (clipboardText.IsNullOrEmpty()) return;
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText); var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
if (translatedBlock == null) return; if (translatedBlock == null) return;
var vm = _itemFilterBlockViewModelFactory.Create(); var vm = _itemFilterBlockViewModelFactory.Create();
@@ -531,7 +605,8 @@ namespace Filtration.ViewModels
if (ItemFilterBlockViewModels.Count > 0) if (ItemFilterBlockViewModels.Count > 0)
{ {
Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, translatedBlock); Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1,
translatedBlock);
ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm); ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm);
} }
else else
@@ -542,7 +617,15 @@ namespace Filtration.ViewModels
SelectedBlockViewModel = vm; SelectedBlockViewModel = vm;
IsDirty = true; IsDirty = true;
}
catch (Exception e)
{
_logger.Error(e);
_messageBoxService.Show("Paste Error",
e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine +
e.InnerException.Message + Environment.NewLine + e.InnerException.StackTrace, MessageBoxButton.OK,
MessageBoxImage.Error);
}
} }
private void OnMoveBlockToTopCommand() private void OnMoveBlockToTopCommand()
@@ -695,8 +778,9 @@ namespace Filtration.ViewModels
public void DeleteBlock(IItemFilterBlockViewModel targetBlockViewModel) public void DeleteBlock(IItemFilterBlockViewModel targetBlockViewModel)
{ {
var result = MessageBox.Show("Are you sure you wish to delete this block?", "Delete Confirmation", var result = _messageBoxService.Show("Delete Confirmation", "Are you sure you wish to delete this block?",
MessageBoxButton.YesNo, MessageBoxImage.Question); MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) if (result == MessageBoxResult.Yes)
{ {
@@ -706,5 +790,25 @@ namespace Filtration.ViewModels
} }
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,100 +0,0 @@
using System.Collections.Generic;
using System.Windows.Media;
using Filtration.Enums;
using Filtration.Models;
namespace Filtration.ViewModels
{
internal class LootFilterScriptViewModela : ILootFilterScriptViewModel
{
private readonly ILootFilterConditionViewModelFactory _lootFilterConditionViewModelFactory;
public LootFilterScriptViewModela(ILootFilterConditionViewModelFactory lootFilterConditionViewModelFactory)
{
_lootFilterConditionViewModelFactory = lootFilterConditionViewModelFactory;
LootFilterConditionViewModels = new List<ILootFilterConditionViewModel>();
var testCondition = new LootFilterCondition
{
BackgroundColor = Colors.DarkCyan,
TextColor = Colors.White,
BorderColor = Colors.Red,
Sockets =
new NumericFilterPredicate(FilterPredicateOperator.LessThanOrEqual, 5),
LinkedSockets =
new NumericFilterPredicate(FilterPredicateOperator.Equal, 2),
ItemRarity = new NumericFilterPredicate(FilterPredicateOperator.GreaterThan, (int) ItemRarity.Magic),
FontSize = 10,
Quality =
new NumericFilterPredicate(FilterPredicateOperator.GreaterThanOrEqual, 15),
ItemLevel =
new NumericFilterPredicate(FilterPredicateOperator.GreaterThan, 50),
DropLevel = new NumericFilterPredicate(),
FilterDescription = "My Wicked Filter"
};
var testCondition2 = new LootFilterCondition
{
BackgroundColor = Colors.Beige,
TextColor = Colors.Blue,
BorderColor = Colors.Black,
Sockets =
new NumericFilterPredicate(FilterPredicateOperator.LessThan, 4),
LinkedSockets =
new NumericFilterPredicate(FilterPredicateOperator.GreaterThanOrEqual, 3),
FontSize = 12,
Quality =
new NumericFilterPredicate(FilterPredicateOperator.GreaterThanOrEqual, 15),
ItemLevel =
new NumericFilterPredicate(FilterPredicateOperator.Equal, 32),
DropLevel = new NumericFilterPredicate(FilterPredicateOperator.GreaterThanOrEqual, 85),
FilterDescription = "This is a test filter"
};
var testCondition3 = new LootFilterCondition
{
BackgroundColor = Colors.Beige,
TextColor = new Color { A = 128, R = 0, G = 0, B = 255},
BorderColor = Colors.Black,
Sockets =
new NumericFilterPredicate(FilterPredicateOperator.LessThan, 4),
LinkedSockets =
new NumericFilterPredicate(FilterPredicateOperator.GreaterThanOrEqual, 3),
FontSize = 12,
Quality =
new NumericFilterPredicate(FilterPredicateOperator.GreaterThanOrEqual, 15),
ItemLevel =
new NumericFilterPredicate(FilterPredicateOperator.Equal, 32),
DropLevel = new NumericFilterPredicate(FilterPredicateOperator.GreaterThanOrEqual, 85),
FilterDescription = "This is a test filter"
};
var testConditionFilter = _lootFilterConditionViewModelFactory.Create();
var testConditionFilter2 = _lootFilterConditionViewModelFactory.Create();
var testConditionFilter3 = _lootFilterConditionViewModelFactory.Create();
testConditionFilter.Initialise(testCondition);
testConditionFilter2.Initialise(testCondition2);
testConditionFilter3.Initialise(testCondition3);
testConditionFilter.Classes.Add("Test Class 1");
testConditionFilter.Classes.Add("Test Class 2");
testConditionFilter.Classes.Add("Test Class 3");
testConditionFilter.Classes.Add("Test Class 4");
testConditionFilter.Classes.Add("Test Class 5");
testConditionFilter.Classes.Add("Test Class 6");
testConditionFilter.Classes.Add("Test Class 7");
testConditionFilter.Classes.Add("Test Class 8");
testConditionFilter.Classes.Add("Test Class 9");
testConditionFilter.Classes.Add("Test Class 10");
testConditionFilter.BaseTypes.Add("Test Base Type 1");
testConditionFilter.BaseTypes.Add("Test Base Type 2");
LootFilterConditionViewModels.Add(testConditionFilter);
LootFilterConditionViewModels.Add(testConditionFilter2);
LootFilterConditionViewModels.Add(testConditionFilter3);
}
public List<ILootFilterConditionViewModel> LootFilterConditionViewModels { get; private set; }
}
}

View File

@@ -1,18 +1,22 @@
using System; using System;
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.Forms; using System.Windows.Forms;
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.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;
@@ -20,6 +24,7 @@ using Filtration.Translators;
using Filtration.Views; using Filtration.Views;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
using NLog;
using Clipboard = System.Windows.Clipboard; using Clipboard = System.Windows.Clipboard;
using OpenFileDialog = Microsoft.Win32.OpenFileDialog; using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
@@ -29,10 +34,13 @@ namespace Filtration.ViewModels
{ {
RelayCommand OpenScriptCommand { get; } RelayCommand OpenScriptCommand { get; }
RelayCommand NewScriptCommand { get; } RelayCommand NewScriptCommand { get; }
bool CloseAllDocuments();
} }
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
{ {
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private readonly IItemFilterScriptRepository _itemFilterScriptRepository; private readonly IItemFilterScriptRepository _itemFilterScriptRepository;
private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator; private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator;
private readonly IReplaceColorsViewModel _replaceColorsViewModel; private readonly IReplaceColorsViewModel _replaceColorsViewModel;
@@ -42,6 +50,7 @@ namespace Filtration.ViewModels
private readonly IThemeService _themeService; private readonly IThemeService _themeService;
private readonly IUpdateCheckService _updateCheckService; private readonly IUpdateCheckService _updateCheckService;
private readonly IUpdateAvailableViewModel _updateAvailableViewModel; private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
private readonly IMessageBoxService _messageBoxService;
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository, public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
IItemFilterScriptTranslator itemFilterScriptTranslator, IItemFilterScriptTranslator itemFilterScriptTranslator,
@@ -51,7 +60,8 @@ namespace Filtration.ViewModels
IThemeProvider themeProvider, IThemeProvider themeProvider,
IThemeService themeService, IThemeService themeService,
IUpdateCheckService updateCheckService, IUpdateCheckService updateCheckService,
IUpdateAvailableViewModel updateAvailableViewModel) IUpdateAvailableViewModel updateAvailableViewModel,
IMessageBoxService messageBoxService)
{ {
_itemFilterScriptRepository = itemFilterScriptRepository; _itemFilterScriptRepository = itemFilterScriptRepository;
_itemFilterScriptTranslator = itemFilterScriptTranslator; _itemFilterScriptTranslator = itemFilterScriptTranslator;
@@ -62,6 +72,7 @@ namespace Filtration.ViewModels
_themeService = themeService; _themeService = themeService;
_updateCheckService = updateCheckService; _updateCheckService = updateCheckService;
_updateAvailableViewModel = updateAvailableViewModel; _updateAvailableViewModel = updateAvailableViewModel;
_messageBoxService = messageBoxService;
NewScriptCommand = new RelayCommand(OnNewScriptCommand); NewScriptCommand = new RelayCommand(OnNewScriptCommand);
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript); CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
@@ -70,7 +81,7 @@ namespace Filtration.ViewModels
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable); SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable); SaveAsCommand = new RelayCommand(OnSaveAsCommand, 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);
@@ -85,11 +96,24 @@ 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(OnApplyThemeToScriptCommand, () => 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);
@@ -108,6 +132,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)
@@ -122,7 +152,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;
} }
@@ -154,12 +187,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; }
@@ -175,35 +217,46 @@ namespace Filtration.ViewModels
public async void CheckForUpdates() public async void CheckForUpdates()
{ {
var assembly = Assembly.GetExecutingAssembly(); var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
var assemblyVersion = FileVersionInfo.GetVersionInfo(assembly.Location);
var currentVersion = Convert.ToDecimal(assemblyVersion.FileMajorPart + "." + assemblyVersion.FileMinorPart);
var result = await _updateCheckService.GetUpdateData();
try try
{ {
if (result.CurrentVersion > currentVersion) var result = await _updateCheckService.GetUpdateData();
if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart &&
result.LatestVersionMinorPart > assemblyVersion.FileMinorPart)
{ {
if (Settings.Default.SuppressUpdates == false || if (Settings.Default.SuppressUpdates == false ||
Settings.Default.SuppressUpdatesUpToVersion < result.CurrentVersion) LatestVersionIsNewerThanSuppressedVersion(result))
{ {
Settings.Default.SuppressUpdates = false; Settings.Default.SuppressUpdates = false;
Settings.Default.Save(); Settings.Default.Save();
var updateAvailableView = new UpdateAvailableView {DataContext = _updateAvailableViewModel}; var updateAvailableView = new UpdateAvailableView {DataContext = _updateAvailableViewModel};
_updateAvailableViewModel.Initialise(result, currentVersion); _updateAvailableViewModel.Initialise(result, assemblyVersion.FileMajorPart,
assemblyVersion.FileMinorPart);
_updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close(); _updateAvailableViewModel.OnRequestClose += (s, e) => updateAvailableView.Close();
updateAvailableView.ShowDialog(); updateAvailableView.ShowDialog();
} }
} }
} }
catch (Exception) catch (Exception e)
{ {
if (_logger.IsDebugEnabled)
{
_logger.Debug(e);
}
// We don't care if the update check fails, because it could fail for multiple reasons // We don't care if the update check fails, because it could fail for multiple reasons
// including the user blocking Filtration in their firewall. // including the user blocking Filtration in their firewall.
} }
} }
private bool LatestVersionIsNewerThanSuppressedVersion(UpdateData updateData)
{
return Settings.Default.SuppressUpdatesUpToVersionMajorPart < updateData.LatestVersionMajorPart ||
(Settings.Default.SuppressUpdatesUpToVersionMajorPart <= updateData.LatestVersionMajorPart &&
Settings.Default.SuppressUpdatesUpToVersionMinorPart < updateData.LatestVersionMinorPart);
}
public ImageSource Icon { get; private set; } public ImageSource Icon { get; private set; }
public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel
@@ -228,13 +281,12 @@ namespace Filtration.ViewModels
public bool ActiveDocumentIsScript public bool ActiveDocumentIsScript
{ {
get get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; }
{
{
var isScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
return isScript;
}
} }
public bool ActiveDocumentIsTheme
{
get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; }
} }
public bool ActiveScriptHasSelectedBlock public bool ActiveScriptHasSelectedBlock
@@ -242,9 +294,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()
@@ -266,15 +328,32 @@ namespace Filtration.ViewModels
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,9 +380,13 @@ namespace Filtration.ViewModels
} }
catch(IOException e) catch(IOException e)
{ {
MessageBox.Show(@"Error loading filter script - " + e.Message, @"Script Load Error", if (_logger.IsErrorEnabled)
MessageBoxButtons.OK, {
MessageBoxIcon.Error); _logger.Error(e);
}
_messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return; return;
} }
@@ -319,7 +402,7 @@ namespace Filtration.ViewModels
return; return;
} }
IThemeViewModel loadedViewModel; IThemeEditorViewModel loadedViewModel;
try try
{ {
@@ -327,9 +410,13 @@ namespace Filtration.ViewModels
} }
catch (IOException e) catch (IOException e)
{ {
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error", if (_logger.IsErrorEnabled)
MessageBoxButtons.OK, {
MessageBoxIcon.Error); _logger.Error(e);
}
_messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return; return;
} }
@@ -352,15 +439,20 @@ namespace Filtration.ViewModels
} }
catch (IOException e) catch (IOException e)
{ {
MessageBox.Show(@"Error loading filter theme - " + e.Message, @"Theme Load Error", if (_logger.IsErrorEnabled)
MessageBoxButtons.OK, {
MessageBoxIcon.Error); _logger.Error(e);
}
_messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message,
MessageBoxButton.OK,
MessageBoxImage.Error);
return; return;
} }
var result = MessageBox.Show(@"Are you sure you wish to apply this theme to the current filter script?", var result = _messageBoxService.Show("Confirm",
@"Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); "Are you sure you wish to apply this theme to the current filter script?", MessageBoxButton.YesNo,
if (result == DialogResult.No) MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{ {
return; return;
} }
@@ -486,6 +578,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);
@@ -505,5 +607,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 bool CloseAllDocuments()
{
var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().ToList();
foreach (var document in openDocuments)
{
var docCount = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count();
document.Close();
if (_avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count() == docCount)
{
return false;
}
}
return true;
}
} }
} }

View File

@@ -1,5 +1,6 @@
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using Filtration.Common.Services;
using Filtration.Common.ViewModels; using Filtration.Common.ViewModels;
using Filtration.Properties; using Filtration.Properties;
using Filtration.Services; using Filtration.Services;
@@ -14,10 +15,12 @@ namespace Filtration.ViewModels
internal class SettingsPageViewModel : FiltrationViewModelBase, ISettingsPageViewModel internal class SettingsPageViewModel : FiltrationViewModelBase, ISettingsPageViewModel
{ {
private readonly IItemFilterPersistenceService _itemFilterPersistenceService; private readonly IItemFilterPersistenceService _itemFilterPersistenceService;
private readonly IMessageBoxService _messageBoxService;
public SettingsPageViewModel(IItemFilterPersistenceService itemFilterPersistenceService) public SettingsPageViewModel(IItemFilterPersistenceService itemFilterPersistenceService, IMessageBoxService messageBoxService)
{ {
_itemFilterPersistenceService = itemFilterPersistenceService; _itemFilterPersistenceService = itemFilterPersistenceService;
_messageBoxService = messageBoxService;
SaveCommand = new RelayCommand(OnSaveCommand); SaveCommand = new RelayCommand(OnSaveCommand);
DefaultFilterDirectory = Settings.Default.DefaultFilterDirectory; DefaultFilterDirectory = Settings.Default.DefaultFilterDirectory;
@@ -41,7 +44,7 @@ namespace Filtration.ViewModels
} }
catch (DirectoryNotFoundException) catch (DirectoryNotFoundException)
{ {
MessageBox.Show("The entered Default Filter Directory is invalid or does not exist.", "Error", _messageBoxService.Show("Error", "The entered Default Filter Directory is invalid or does not exist.",
MessageBoxButton.OK, MessageBoxImage.Exclamation); MessageBoxButton.OK, MessageBoxImage.Exclamation);
} }
} }

View File

@@ -1,6 +1,5 @@
using Filtration.Common.ViewModels; using Filtration.Common.ViewModels;
using Filtration.Interface; using Filtration.Interface;
using Filtration.ViewModels.ToolPanes;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Messaging;
@@ -31,7 +30,6 @@ namespace Filtration.ViewModels
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
private static void OnOpenScriptCommand() private static void OnOpenScriptCommand()
{ {
Messenger.Default.Send(new NotificationMessage("OpenScript")); Messenger.Default.Send(new NotificationMessage("OpenScript"));

View File

@@ -1,10 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Filtration.Models; using Filtration.Models;
using Filtration.Properties; using Filtration.Properties;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
@@ -14,9 +9,9 @@ namespace Filtration.ViewModels
internal interface IUpdateAvailableViewModel internal interface IUpdateAvailableViewModel
{ {
event EventHandler OnRequestClose; event EventHandler OnRequestClose;
void Initialise(UpdateData updateData, decimal currentVersion); void Initialise(UpdateData updateData, int currentVersionMajorPart, int currentVersionMinorPart);
decimal CurrentVersion { get; } string CurrentVersion { get; }
decimal NewVersion { get; } string NewVersion { get; }
string ReleaseNotes { get; } string ReleaseNotes { get; }
DateTime ReleaseDate { get; } DateTime ReleaseDate { get; }
} }
@@ -24,7 +19,8 @@ namespace Filtration.ViewModels
internal class UpdateAvailableViewModel : IUpdateAvailableViewModel internal class UpdateAvailableViewModel : IUpdateAvailableViewModel
{ {
private UpdateData _updateData; private UpdateData _updateData;
private decimal _currentVersion; private int _currentVersionMajorPart;
private int _currentVersionMinorPart;
public UpdateAvailableViewModel() public UpdateAvailableViewModel()
{ {
@@ -39,20 +35,21 @@ namespace Filtration.ViewModels
public RelayCommand AskLaterCommand { get; private set; } public RelayCommand AskLaterCommand { get; private set; }
public RelayCommand DownloadCommand { get; private set; } public RelayCommand DownloadCommand { get; private set; }
public void Initialise(UpdateData updateData, decimal currentVersion) public void Initialise(UpdateData updateData, int currentVersionMajorPart, int currentVersionMinorPart)
{ {
_currentVersion = currentVersion; _currentVersionMajorPart = currentVersionMajorPart;
_currentVersionMinorPart = currentVersionMinorPart;
_updateData = updateData; _updateData = updateData;
} }
public decimal CurrentVersion public string CurrentVersion
{ {
get { return _currentVersion; } get { return _currentVersionMajorPart + "." + _currentVersionMinorPart; }
} }
public decimal NewVersion public string NewVersion
{ {
get { return _updateData.CurrentVersion; } get { return _updateData.LatestVersionMajorPart + "." + _updateData.LatestVersionMinorPart; }
} }
public string ReleaseNotes public string ReleaseNotes
@@ -73,7 +70,8 @@ namespace Filtration.ViewModels
private void OnNeverAskAgainCommand() private void OnNeverAskAgainCommand()
{ {
Settings.Default.SuppressUpdates = true; Settings.Default.SuppressUpdates = true;
Settings.Default.SuppressUpdatesUpToVersion = _updateData.CurrentVersion; Settings.Default.SuppressUpdatesUpToVersionMajorPart = _updateData.LatestVersionMajorPart;
Settings.Default.SuppressUpdatesUpToVersionMinorPart = _updateData.LatestVersionMinorPart;
Settings.Default.Save(); Settings.Default.Save();
CloseWindow(); CloseWindow();
} }

View File

@@ -56,7 +56,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

@@ -1,107 +0,0 @@
<UserControl x:Class="Filtration.Views.ItemFilterBlockDisplaySettingsView"
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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:userControls="clr-namespace:Filtration.UserControls"
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
xmlns:blockItembaseTypes="clr-namespace:Filtration.ObjectModel.BlockItemBaseTypes;assembly=Filtration.ObjectModel"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
xmlns:blockItemTypes="clr-namespace:Filtration.ObjectModel.BlockItemTypes;assembly=Filtration.ObjectModel"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterBlockViewModel}"
d:DesignHeight="120" d:DesignWidth="175">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="SharedResourcesDictionary.xaml" />
<ResourceDictionary>
<CollectionViewSource x:Key="AudioVisualBlockItemsViewSource" Source="{Binding AudioVisualBlockItems}">
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="SortOrder" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border BorderThickness="2" CornerRadius="4" BorderBrush="Black" Padding="4" Background="White">
<Grid Background="White" Name="SettingsGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ItemsControl ItemsSource="{Binding AudioVisualBlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,5">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="0,0,3,0">
<Hyperlink Command="{Binding ElementName=SettingsGrid, Path=DataContext.AddAudioVisualBlockItemCommand}" CommandParameter="{Binding}">
<TextBlock>+</TextBlock><TextBlock Text="{Binding Path=., Converter={StaticResource BlockItemTypeToStringConverter}}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl Grid.Row="1" ItemsSource="{Binding Source={StaticResource AudioVisualBlockItemsViewSource}}" Grid.IsSharedSizeScope="True">
<ItemsControl.Resources>
<Style TargetType="{x:Type TextBlock}" x:Key="DisplayHeading">
<Setter Property="Margin" Value="0,0,5,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<DataTemplate DataType="{x:Type blockItembaseTypes:ColorBlockItem}">
<Grid Margin="0,0,0,2">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemTitleColumn" Width="*" />
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemValueColumn" Width="Auto" />
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemCloseColumn" Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding DisplayHeading}" Style="{StaticResource DisplayHeading}" />
<xctk:ColorPicker Grid.Column="1" SelectedColor="{Binding Color}" HorizontalAlignment="Right" Width="100" AvailableColors="{Binding ElementName=SettingsGrid, Path=DataContext.AvailableColors}" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
<userControls:CrossButton Grid.Column="2" Height="12" Command="{Binding ElementName=SettingsGrid, Path=DataContext.RemoveAudioVisualBlockItemCommand}" CommandParameter="{Binding}" />
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type blockItembaseTypes:IntegerBlockItem}">
<Grid Margin="0,0,0,2">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemTitleColumn" Width="*" />
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemValueColumn" Width="Auto" />
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemCloseColumn" Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding DisplayHeading}" Style="{StaticResource DisplayHeading}" />
<xctk:ShortUpDown Grid.Column="1" Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Width="50" HorizontalAlignment="Right"/>
<userControls:CrossButton Grid.Column="2" Height="12" Command="{Binding ElementName=SettingsGrid, Path=DataContext.RemoveAudioVisualBlockItemCommand}" CommandParameter="{Binding}" />
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type blockItemTypes:SoundBlockItem}">
<Grid Margin="0,0,0,2">
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemTitleColumn" Width="*" />
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemValueColumn" Width="Auto" />
<ColumnDefinition SharedSizeGroup="AudioVisualBlockItemCloseColumn" Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Text="{Binding DisplayHeading}" Style="{StaticResource DisplayHeading}" />
<WrapPanel Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right">
<Button Command="{Binding ElementName=SettingsGrid, Path=DataContext.PlaySoundCommand}" Width="20" Height="20" Padding="3" Background="Transparent" BorderBrush="Transparent">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<ComboBox ItemsSource="{Binding ElementName=SettingsGrid, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" />
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="100" HorizontalAlignment="Right" ToolTip="Volume"/>
</WrapPanel>
<userControls:CrossButton Grid.Column="2" Grid.Row="0" Height="12" Command="{Binding ElementName=SettingsGrid, Path=DataContext.RemoveAudioVisualBlockItemCommand}" CommandParameter="{Binding}" />
</Grid>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
</Grid>
</Border>
</UserControl>

View File

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

View File

@@ -7,10 +7,7 @@
xmlns:userControls="clr-namespace:Filtration.UserControls" xmlns:userControls="clr-namespace:Filtration.UserControls"
xmlns:views="clr-namespace:Filtration.Views" xmlns:views="clr-namespace:Filtration.Views"
xmlns:converters="clr-namespace:Filtration.Converters" xmlns:converters="clr-namespace:Filtration.Converters"
xmlns:extensions="clr-namespace:Filtration.Extensions"
xmlns:blockItemBaseTypes="clr-namespace:Filtration.ObjectModel.BlockItemBaseTypes;assembly=Filtration.ObjectModel" xmlns:blockItemBaseTypes="clr-namespace:Filtration.ObjectModel.BlockItemBaseTypes;assembly=Filtration.ObjectModel"
xmlns:blockItemTypes="clr-namespace:Filtration.ObjectModel.BlockItemTypes;assembly=Filtration.ObjectModel"
xmlns:enums="clr-namespace:Filtration.ObjectModel.Enums;assembly=Filtration.ObjectModel"
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterBlockViewModel}" d:DataContext="{d:DesignInstance Type=viewModels:ItemFilterBlockViewModel}"
@@ -18,16 +15,37 @@
<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" />
<Style TargetType="{x:Type ContentPresenter}" x:Key="BlockItemFadeInStyle">
<Setter Property="LayoutTransform">
<Setter.Value>
<ScaleTransform x:Name="transform" />
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary> </ResourceDictionary>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</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>
@@ -49,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}" />
@@ -76,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">
@@ -110,17 +129,23 @@
</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">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" <Button Command="{Binding PlaySoundCommand}"
Width="25"
Height="25"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Height="15" Width="15"
Margin="0,0,3,0" Margin="0,0,3,0"
Visibility="{Binding HasSound, Converter={StaticResource BooleanVisibilityConverter}}" /> Visibility="{Binding HasSound, Converter={StaticResource BooleanVisibilityConverter}}"
Background="Transparent"
BorderBrush="Transparent"
ToolTip="Click to preview drop sound">
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Button>
<ToggleButton Margin="0,2,2,2" <ToggleButton Margin="0,2,2,2"
Style="{StaticResource ChromelessToggleButton}" Style="{StaticResource ChromelessToggleButton}"
x:Name="ItemPreviewButton" x:Name="ItemPreviewButton"
IsChecked="{Binding DisplaySettingsPopupOpen, Mode=OneWayToSource}" IsChecked="{Binding AudioVisualBlockItemsGridVisible}"
ToolTip="Click here to change color and font settings" Cursor="Hand" > ToolTip="Click here to change color and font settings" Cursor="Hand" >
<userControls:ItemPreviewControl TextColor="{Binding DisplayTextColor}" <userControls:ItemPreviewControl TextColor="{Binding DisplayTextColor}"
BackgroundColor="{Binding DisplayBackgroundColor}" BackgroundColor="{Binding DisplayBackgroundColor}"
@@ -128,31 +153,31 @@
BlockFontSize="{Binding DisplayFontSize}" /> BlockFontSize="{Binding DisplayFontSize}" />
</ToggleButton> </ToggleButton>
</WrapPanel> </WrapPanel>
<!-- AudioVisual BlockItem Settings Popup -->
<Popup Grid.Row="0"
Grid.Column="1"
PlacementTarget="{Binding ElementName=ItemPreviewButton}"
Placement="Left"
PopupAnimation="Slide"
StaysOpen="False"
IsOpen="{Binding DisplaySettingsPopupOpen}"
AllowsTransparency="True"
HorizontalOffset="-5"
Width="250">
<views:ItemFilterBlockDisplaySettingsView />
</Popup>
</Grid> </Grid>
</Expander.Header> </Expander.Header>
<Grid Margin="10,5,10,5" x:Name="BlockItemsGrid"> <Grid Margin="10,5,10,5" x:Name="BlockItemsGrid">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
<RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0" Visibility="{Binding AudioVisualBlockItemsGridVisible, Converter={StaticResource InverseBooleanVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<Hyperlink Command="{Binding SwitchBlockItemsViewCommand}">
Switch to Appearance Block Items
</Hyperlink>
</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>
@@ -169,159 +194,111 @@
</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 BlockItems}" x:Key="BlockItemsCollectionViewSource"> <CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource">
<CollectionViewSource.SortDescriptions> <CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="SortOrder"/> <componentModel:SortDescription PropertyName="SortOrder"/>
</CollectionViewSource.SortDescriptions> </CollectionViewSource.SortDescriptions>
</CollectionViewSource> </CollectionViewSource>
</WrapPanel.Resources> </WrapPanel.Resources>
<ItemsControl ItemsSource="{Binding Source={StaticResource BlockItemsCollectionViewSource}}"> <ItemsControl ItemsSource="{Binding Source={StaticResource BlockItemsCollectionViewSource}}"
ItemContainerStyle="{StaticResource BlockItemFadeInStyle}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" /> <WrapPanel Orientation="Vertical" />
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate>
<Style TargetType="{x:Type ContentPresenter}"> <DataTemplate>
<Setter Property="LayoutTransform"> <userControls:BlockItemControl BlockItem="{Binding}" RemoveItemCommand="{Binding ElementName=TopLevelGrid, Path=DataContext.RemoveFilterBlockItemCommand}" RemoveEnabled="{Binding Path=., Converter={StaticResource BlockItemToRemoveEnabledVisibilityConverter}}" />
<Setter.Value>
<ScaleTransform x:Name="transform" />
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.Resources>
<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="Width" Value="142" />
<Setter Property="Margin" Value="0,0,5,5" />
</Style>
<DataTemplate DataType="{x:Type blockItemBaseTypes:ActionBlockItem}">
<Border Style="{StaticResource BlockItemBorder}">
<WrapPanel VerticalAlignment="Center" Margin="5,5,5,5">
<RadioButton IsChecked="{Binding Action, Converter={StaticResource BooleanToBlockActionConverter}}" Margin="0,0,10,0">Show</RadioButton>
<RadioButton IsChecked="{Binding Action, Converter={StaticResource BooleanToBlockActionInverseConverter}}">Hide</RadioButton>
</WrapPanel>
</Border>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type blockItemBaseTypes:NumericFilterPredicateBlockItem}"> </ItemsControl.ItemTemplate>
<Border Style="{StaticResource BlockItemBorder}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Background="PowderBlue" CornerRadius="3,3,0,0">
<Grid Margin="3,0,3,0">
<TextBlock Text="{Binding DisplayHeading}" Grid.Row="0" VerticalAlignment="Center" Foreground="Navy" />
<userControls:CrossButton Grid.Row="0" Height="12" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding ElementName=TopLevelGrid, Path=DataContext.RemoveFilterBlockItemCommand}" CommandParameter="{Binding}"/>
</Grid>
</Border>
<userControls:NumericFilterPredicateControl Grid.Row="1" Grid.Column="0" Margin="5,5,5,5" NumericFilterPredicate="{Binding FilterPredicate}" Minimum="{Binding Minimum, Mode=OneTime}" Maximum="{Binding Maximum, Mode=OneTime}" />
</Grid>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type blockItemTypes:RarityBlockItem}">
<Border Style="{StaticResource BlockItemBorder}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Background="PowderBlue" CornerRadius="3,3,0,0">
<Grid Margin="3,0,3,0">
<TextBlock Text="{Binding DisplayHeading}" Grid.Row="0" VerticalAlignment="Center" Foreground="Navy" />
<userControls:CrossButton Grid.Row="0" Height="12" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding ElementName=TopLevelGrid, Path=DataContext.RemoveFilterBlockItemCommand}" CommandParameter="{Binding}"/>
</Grid>
</Border>
<StackPanel Orientation="Horizontal" Grid.Row="1" Margin="5,5,5,5">
<ComboBox ItemsSource="{Binding Source={extensions:Enumeration {x:Type enums:FilterPredicateOperator}}}"
DisplayMemberPath="Description"
SelectedValue="{Binding FilterPredicate.PredicateOperator}"
SelectedValuePath="Value" Width="50" Margin="0,0,6,0" />
<ComboBox ItemsSource="{Binding Source={extensions:Enumeration {x:Type enums:ItemRarity}}}"
DisplayMemberPath="Description"
SelectedValue="{Binding FilterPredicate.PredicateOperand, Converter={StaticResource IntToItemRarityConverter}}"
SelectedValuePath="Value" />
</StackPanel>
</Grid>
</Border>
</DataTemplate>
<!-- TODO: Sort out these messy duplicated data templates -->
<DataTemplate DataType="{x:Type blockItemTypes:ClassBlockItem}">
<Border Style="{StaticResource BlockItemBorder}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Background="PowderBlue" CornerRadius="3,3,0,0">
<Grid Margin="3,0,3,0">
<TextBlock Text="{Binding DisplayHeading}" Grid.Row="0" VerticalAlignment="Center" Foreground="Navy" />
<userControls:CrossButton Grid.Row="0" Height="12" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding ElementName=TopLevelGrid, Path=DataContext.RemoveFilterBlockItemCommand}" CommandParameter="{Binding}"/>
</Grid>
</Border>
<userControls:EditableListBoxControl Grid.Row="1" Grid.Column="0" Margin="5,5,5,5" ItemsSource="{Binding Items}" AutoCompleteItemsSource="{Binding ElementName=TopLevelGrid, Path=DataContext.AutoCompleteItemClasses}" />
</Grid>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type blockItemTypes:BaseTypeBlockItem}">
<Border Style="{StaticResource BlockItemBorder}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Background="PowderBlue" CornerRadius="3,3,0,0">
<Grid Margin="3,0,3,0">
<TextBlock Text="{Binding DisplayHeading}" Grid.Row="0" VerticalAlignment="Center" Foreground="Navy" />
<userControls:CrossButton Grid.Row="0" Height="12" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding ElementName=TopLevelGrid, Path=DataContext.RemoveFilterBlockItemCommand}" CommandParameter="{Binding}"/>
</Grid>
</Border>
<userControls:EditableListBoxControl Grid.Row="1" Grid.Column="0" Margin="5,5,5,5" ItemsSource="{Binding Items}" AutoCompleteItemsSource="{Binding ElementName=TopLevelGrid, Path=DataContext.AutoCompleteItemBaseTypes}" />
</Grid>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type blockItemTypes:SocketGroupBlockItem}">
<Border Style="{StaticResource BlockItemBorder}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Background="PowderBlue" CornerRadius="3,3,0,0">
<Grid Margin="3,0,3,0">
<TextBlock Text="{Binding DisplayHeading}" Grid.Row="0" VerticalAlignment="Center" Foreground="Navy" />
<userControls:CrossButton Grid.Row="0" Height="12" HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding ElementName=TopLevelGrid, Path=DataContext.RemoveFilterBlockItemCommand}" CommandParameter="{Binding}"/>
</Grid>
</Border>
<userControls:EditableListBoxControl Grid.Row="1" Grid.Column="0" Margin="5,5,5,5" ItemsSource="{Binding Items}" />
</Grid>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}" />
<DataTemplate DataType="{x:Type blockItemTypes:SoundBlockItem}" />
<DataTemplate DataType="{x:Type blockItemTypes:FontSizeBlockItem}" />
</ItemsControl.Resources>
</ItemsControl> </ItemsControl>
</WrapPanel> </WrapPanel>
<Grid Grid.Row="2" Margin="0,5,0,5"> </Grid>
<Grid Grid.Row="0" Visibility="{Binding AudioVisualBlockItemsGridVisible, Converter={StaticResource BooleanVisibilityConverter}}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<Hyperlink Command="{Binding SwitchBlockItemsViewCommand}">
Switch to Regular Block Items
</Hyperlink>
</TextBlock>
<!-- Add AudioVisual Block Item Links -->
<ItemsControl ItemsSource="{Binding AudioVisualBlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,10">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="0,0,3,0">
<Hyperlink Command="{Binding ElementName=TopLevelGrid, Path=DataContext.AddAudioVisualBlockItemCommand}" CommandParameter="{Binding}">
<TextBlock>+</TextBlock><TextBlock Text="{Binding Path=., Converter={StaticResource BlockItemTypeToStringConverter}}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</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 -->
<WrapPanel Grid.Row="1" MaxHeight="200">
<WrapPanel.Resources>
<CollectionViewSource Source="{Binding AudioVisualBlockItems}" x:Key="BlockItemsCollectionViewSource">
<CollectionViewSource.SortDescriptions>
<componentModel:SortDescription PropertyName="SortOrder"/>
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
</WrapPanel.Resources>
<ItemsControl ItemsSource="{Binding Source={StaticResource BlockItemsCollectionViewSource}}"
ItemContainerStyle="{StaticResource BlockItemFadeInStyle}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<userControls:BlockItemControl BlockItem="{Binding}" RemoveItemCommand="{Binding ElementName=TopLevelGrid, Path=DataContext.RemoveFilterBlockItemCommand}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>
</Grid>
<Grid Grid.Row="1" Margin="0,5,0,5">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />

View File

@@ -8,7 +8,7 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="300"> d:DesignHeight="50" d:DesignWidth="300">
<UserControl.Resources> <UserControl.Resources>
<Style TargetType="{x:Type TextBox}"> <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MetroTextBox}">
<Style.Setters> <Style.Setters>
<Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />

View File

@@ -7,20 +7,17 @@
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"
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">
<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" />
</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">
<fluent:Ribbon.Menu> <fluent:Ribbon.Menu>
<fluent:Backstage> <fluent:Backstage>
<fluent:BackstageTabControl> <fluent:BackstageTabControl>
@@ -53,16 +50,29 @@
</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}, ConverterParameter={x:Static Visibility.Hidden}, 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}"/>
</fluent:Button>
<fluent:Button Header="Paste Block" Command="{Binding PasteCommand}" Icon="{StaticResource PasteIcon}" LargeIcon="{StaticResource PasteIcon}" /> <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" /> <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" /> <fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
@@ -76,6 +86,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,16 +98,20 @@
<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>
@@ -104,3 +120,4 @@
</Grid> </Grid>
</DockPanel> </DockPanel>
</fluent:RibbonWindow> </fluent:RibbonWindow>

View File

@@ -1,4 +1,8 @@
using Filtration.ViewModels; using System;
using System.ComponentModel;
using System.Windows;
using Filtration.Annotations;
using Filtration.ViewModels;
namespace Filtration.Views namespace Filtration.Views
{ {
@@ -9,10 +13,39 @@ namespace Filtration.Views
internal partial class MainWindow : IMainWindow internal partial class MainWindow : IMainWindow
{ {
private 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.CloseAllDocuments();
if (!allDocumentsClosed)
{
e.Cancel = true;
}
}
} }
} }

View File

@@ -8,17 +8,9 @@
xmlns:userControls="clr-namespace:Filtration.UserControls" xmlns:userControls="clr-namespace:Filtration.UserControls"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ReplaceColorsViewModel}" d:DataContext="{d:DesignInstance Type=viewModels:ReplaceColorsViewModel}"
Title="Replace Script Colors" Height="245" Width="515" 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

@@ -26,4 +26,6 @@
<SolidColorBrush x:Key="GrayBrush9" Color="{StaticResource Gray9}"/> <SolidColorBrush x:Key="GrayBrush9" Color="{StaticResource Gray9}"/>
<SolidColorBrush x:Key="GrayBrush10" Color="{StaticResource Gray10}"/> <SolidColorBrush x:Key="GrayBrush10" Color="{StaticResource Gray10}"/>
<SolidColorBrush x:Key="HighlightGrayBrush" Color="{StaticResource HighlightGray}" /> <SolidColorBrush x:Key="HighlightGrayBrush" Color="{StaticResource HighlightGray}" />
<SolidColorBrush x:Key="TextBoxBackground" Color="#333337" />
<SolidColorBrush x:Key="TextBoxBackgroundSelected" Color="#3F3F46" />
</ResourceDictionary> </ResourceDictionary>

View File

@@ -0,0 +1,84 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="TextBox">
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="{StaticResource GrayBrush1}" />
<Setter Property="CaretBrush" Value="{StaticResource GrayBrush1}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border BorderBrush="{StaticResource GrayBrush1}" BorderThickness="1">
<Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ScrollViewer x:Name="PART_ContentHost" Margin="1" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="{StaticResource GrayBrush7}" />
</Trigger>
<Trigger Property="IsFocused" Value="true">
<Setter Property="Background" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--<Style TargetType="TextBox"
x:Key="SearchTextBox">
<Setter Property="Background"
Value="{StaticResource TextBoxBackground}" />
<Setter Property="Foreground"
Value="{StaticResource Foreground}" />
<Setter Property="CaretBrush"
Value="{StaticResource Foreground}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid Background="{TemplateBinding Background}"
SnapsToDevicePixels="true">
<TextBlock Foreground="{StaticResource SearchTextForeground}"
Margin="5,0,0,0"
VerticalAlignment="Center"
Name="search"
Text="Search ..."
Visibility="Hidden" />
<ScrollViewer x:Name="PART_ContentHost"
Margin="1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TextBox.Text"
Value="">
<Setter TargetName="search"
Property="Visibility"
Value="Visible" />
</Trigger>
<Trigger Property="TextBox.Text"
Value="{x:Null}">
<Setter TargetName="search"
Property="Visibility"
Value="Visible" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="true">
<Setter Property="Background"
Value="{StaticResource TextBoxBackgroundSelected}" />
<Setter TargetName="search"
Property="Foreground"
Value="{StaticResource GrayBrush6}" />
</Trigger>
<Trigger Property="IsFocused"
Value="true">
<Setter Property="Background"
Value="{StaticResource TextBoxBackgroundSelected}" />
<Setter TargetName="search"
Property="Visibility"
Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>-->
</ResourceDictionary>

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

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

@@ -6,6 +6,10 @@
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" /> <package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
<package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" /> <package id="Extended.Wpf.Toolkit" version="2.4" targetFramework="net451" />
<package id="Fluent.Ribbon" version="3.4.0" targetFramework="net451" /> <package id="Fluent.Ribbon" version="3.4.0" targetFramework="net451" />
<package id="MahApps.Metro" version="1.1.2.0" targetFramework="net451" />
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" /> <package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
<package id="NLog" 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="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-10)
<b>Installer (5.82mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.3/filtration_0.3_setup.exe">filtration_0.3_setup.exe</a> <b>Installer (6.31mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.8/filtration_0.8_setup.exe">filtration_0.8_setup.exe</a>
<b>Zip File (7.22mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.3/filtration_0.3.zip">filtration_0.3.zip</a> <b>Zip File (7.9mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.8/filtration_0.8.zip">filtration_0.8.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

View File

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