Compare commits
18 Commits
0.6
...
LootExplos
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b97e3d1780 | ||
|
|
543446b23e | ||
|
|
2278cbdc3a | ||
|
|
45edbecd64 | ||
|
|
6e71005e93 | ||
|
|
56e163e3e0 | ||
|
|
c856bbcee7 | ||
|
|
490496f2f7 | ||
|
|
9fcb609a51 | ||
|
|
1b63f68eee | ||
|
|
a496ab9b42 | ||
|
|
cbbc7c25fa | ||
|
|
d6bd1678b4 | ||
|
|
bfa2341ab8 | ||
|
|
511f503e88 | ||
|
|
3ea0530c01 | ||
|
|
aad34b1407 | ||
|
|
544b931477 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -186,4 +186,5 @@ FakesAssemblies/
|
|||||||
# LightSwitch generated files
|
# LightSwitch generated files
|
||||||
GeneratedArtifacts/
|
GeneratedArtifacts/
|
||||||
_Pvt_Extensions/
|
_Pvt_Extensions/
|
||||||
ModelManifest.xml
|
ModelManifest.xml
|
||||||
|
/Releases
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
@@ -3,9 +3,9 @@ using System.Globalization;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace Filtration.Converters
|
namespace Filtration.Common.Converters
|
||||||
{
|
{
|
||||||
internal class BooleanVisibilityConverterCopy : IValueConverter
|
public class BooleanVisibilityConverter : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
@@ -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
|
||||||
{
|
{
|
||||||
@@ -3,9 +3,9 @@ using System.Globalization;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace Filtration.Converters
|
namespace Filtration.Common.Converters
|
||||||
{
|
{
|
||||||
internal class BooleanVisibilityConverter : IValueConverter
|
internal class InverseBooleanVisibilityConverter : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
@@ -14,25 +14,24 @@ namespace Filtration.Converters
|
|||||||
var val = (bool) value;
|
var val = (bool) value;
|
||||||
if (val)
|
if (val)
|
||||||
{
|
{
|
||||||
return Visibility.Visible;
|
return Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
if (parameter is Visibility)
|
if (parameter is Visibility)
|
||||||
{
|
{
|
||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
return Visibility.Collapsed;
|
return Visibility.Visible;
|
||||||
}
|
}
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
return Visibility.Visible;
|
return Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (parameter is Visibility)
|
if (parameter is Visibility)
|
||||||
{
|
{
|
||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
return Visibility.Collapsed;
|
return Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
@@ -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
|
||||||
{
|
{
|
||||||
@@ -64,6 +64,12 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Converters\BooleanInverterConverter.cs" />
|
||||||
|
<Compile Include="Converters\BooleanVisibilityConverter.cs" />
|
||||||
|
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
|
||||||
|
<Compile Include="Converters\InverseBooleanVisibilityConverter.cs" />
|
||||||
|
<Compile Include="Converters\StringToVisibilityConverter.cs" />
|
||||||
|
<Compile Include="Messages\ThemeClosedMessage.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\FileSystemService.cs" />
|
<Compile Include="Services\FileSystemService.cs" />
|
||||||
<Compile Include="Services\MessageBoxService.cs" />
|
<Compile Include="Services\MessageBoxService.cs" />
|
||||||
@@ -80,6 +86,12 @@
|
|||||||
<Name>Filtration.ObjectModel</Name>
|
<Name>Filtration.ObjectModel</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Include="Styles\SharedResourcesDictionary.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
12
Filtration.Common/Messages/ThemeClosedMessage.cs
Normal file
12
Filtration.Common/Messages/ThemeClosedMessage.cs
Normal 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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:converters="clr-namespace:Filtration.Converters"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:converters="clr-namespace:Filtration.Common.Converters"
|
||||||
mc:Ignorable="d" >
|
mc:Ignorable="d" >
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
@@ -31,17 +31,19 @@
|
|||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" />
|
<Style TargetType="{x:Type Border}" x:Key="BlockItemBorder">
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="BorderBrush" Value="Black" />
|
||||||
|
<Setter Property="CornerRadius" Value="3" />
|
||||||
|
<Setter Property="Margin" Value="0,0,5,5" />
|
||||||
|
</Style>
|
||||||
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
|
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
|
||||||
<converters:BoolInverterConverter x:Key="BoolInverterConverter" />
|
<converters:BoolInverterConverter x:Key="BoolInverterConverter" />
|
||||||
<converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
|
<converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
|
||||||
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
|
|
||||||
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
|
|
||||||
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
|
|
||||||
<converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
|
<converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
|
||||||
<converters:InverseBooleanVisibilityConverter x:Key="InverseBooleanVisibilityConverter" />
|
<converters:InverseBooleanVisibilityConverter x:Key="InverseBooleanVisibilityConverter" />
|
||||||
<converters:BlockItemToRemoveEnabledVisibilityConverter x:Key="BlockItemToRemoveEnabledVisibilityConverter" />
|
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
<ResourceDictionary Source="ExpanderStyle.xaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Filtration.LootExplosionStudio.Tests</RootNamespace>
|
||||||
|
<AssemblyName>Filtration.LootExplosionStudio.Tests</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Moq">
|
||||||
|
<HintPath>..\packages\Moq.4.2.1507.0118\lib\net40\Moq.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="nunit.framework">
|
||||||
|
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Services\TestItemFilterBlockFinderService.cs" />
|
||||||
|
<Compile Include="Services\TestLootItemAppearanceService.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Filtration.LootExplosionStudio\Filtration.LootExplosionStudio.csproj">
|
||||||
|
<Project>{c8009b11-14d0-4421-94f0-9ef4603cb363}</Project>
|
||||||
|
<Name>Filtration.LootExplosionStudio</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
|
||||||
|
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
|
||||||
|
<Name>Filtration.ObjectModel</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- 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.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Filtration.LootExplosionStudio.Tests")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("Filtration.LootExplosionStudio.Tests")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("24ce1315-7f86-4389-a63c-22a40baa4c6d")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
using Filtration.LootExplosionStudio.Services;
|
||||||
|
using Filtration.ObjectModel;
|
||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.LootExplosionStudio.Tests.Services
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestItemFilterBlockFinderService
|
||||||
|
{
|
||||||
|
private ItemFilterBlockFinderServiceTestUtility _testUtility;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void ItemFilterProcessingServiceTestSetup()
|
||||||
|
{
|
||||||
|
_testUtility = new ItemFilterBlockFinderServiceTestUtility();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FindBlockForLootItem_SingleBlock_BaseType_Matches()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBaseType = "TestBaseType";
|
||||||
|
var testInputBlockItem = new BaseTypeBlockItem();
|
||||||
|
testInputBlockItem.Items.Add(testInputBaseType);
|
||||||
|
|
||||||
|
_testUtility.TestLootItem.BaseType = testInputBaseType;
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputBlockItem);
|
||||||
|
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Service.FindBlockForLootItem(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(_testUtility.TestBlock, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FindBlockForLootItem_SingleHideBlock_Matches()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
_testUtility.TestBlock.Action = BlockAction.Hide;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Service.FindBlockForLootItem(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(_testUtility.TestBlock, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FindBlockForLootItem_SingleBlock_MultipleBlockItems_Matches()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBaseType = "TestBaseType";
|
||||||
|
var testInputBaseTypeBlockItem = new BaseTypeBlockItem();
|
||||||
|
testInputBaseTypeBlockItem.Items.Add(testInputBaseType);
|
||||||
|
|
||||||
|
var testInputClass = "Test Class";
|
||||||
|
var testInputClassBlockItem = new ClassBlockItem();
|
||||||
|
testInputClassBlockItem.Items.Add(testInputClass);
|
||||||
|
|
||||||
|
var testInputItemLevel = 57;
|
||||||
|
var testInputItemLevelBlockItem = new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 50);
|
||||||
|
|
||||||
|
_testUtility.TestLootItem.BaseType = testInputBaseType;
|
||||||
|
_testUtility.TestLootItem.Class = testInputClass;
|
||||||
|
_testUtility.TestLootItem.ItemLevel = testInputItemLevel;
|
||||||
|
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputBaseTypeBlockItem);
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputClassBlockItem);
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputItemLevelBlockItem);
|
||||||
|
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Service.FindBlockForLootItem(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(_testUtility.TestBlock, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FindBlockForLootItem_SingleBlock_MultipleBlockItemsOneWithoutMatch_Matches()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBaseType = "TestBaseType";
|
||||||
|
var testInputBaseTypeBlockItem = new BaseTypeBlockItem();
|
||||||
|
testInputBaseTypeBlockItem.Items.Add(testInputBaseType);
|
||||||
|
|
||||||
|
var testInputClass = "Test Class";
|
||||||
|
var testInputClassBlockItem = new ClassBlockItem();
|
||||||
|
testInputClassBlockItem.Items.Add(testInputClass);
|
||||||
|
|
||||||
|
var testInputItemLevel = 57;
|
||||||
|
var testInputItemLevelBlockItem = new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 50);
|
||||||
|
|
||||||
|
var testInputDropLevel = 35;
|
||||||
|
var testInputDropLevelBlockItem = new DropLevelBlockItem(FilterPredicateOperator.GreaterThanOrEqual, 89);
|
||||||
|
|
||||||
|
_testUtility.TestLootItem.BaseType = testInputBaseType;
|
||||||
|
_testUtility.TestLootItem.Class = testInputClass;
|
||||||
|
_testUtility.TestLootItem.ItemLevel = testInputItemLevel;
|
||||||
|
_testUtility.TestLootItem.DropLevel = testInputDropLevel;
|
||||||
|
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputBaseTypeBlockItem);
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputClassBlockItem);
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputItemLevelBlockItem);
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputDropLevelBlockItem);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Service.FindBlockForLootItem(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsNull(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FindBlockForLootItem_MultipleBlocksBlock_Matches()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBlock1 = new ItemFilterBlock();
|
||||||
|
var testInputClass1 = "Test Class";
|
||||||
|
var testInputClassBlockItem1 = new ClassBlockItem();
|
||||||
|
testInputClassBlockItem1.Items.Add(testInputClass1);
|
||||||
|
testInputBlock1.BlockItems.Add(testInputClassBlockItem1);
|
||||||
|
|
||||||
|
_testUtility.TestScript.ItemFilterBlocks.Add(testInputBlock1);
|
||||||
|
|
||||||
|
var testInputBaseType = "TestBaseType";
|
||||||
|
var testInputBaseTypeBlockItem = new BaseTypeBlockItem();
|
||||||
|
testInputBaseTypeBlockItem.Items.Add(testInputBaseType);
|
||||||
|
|
||||||
|
var testInputClass = "Test Class";
|
||||||
|
var testInputClassBlockItem = new ClassBlockItem();
|
||||||
|
testInputClassBlockItem.Items.Add(testInputClass);
|
||||||
|
|
||||||
|
var testInputItemLevel = 57;
|
||||||
|
var testInputItemLevelBlockItem = new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 50);
|
||||||
|
|
||||||
|
_testUtility.TestLootItem.BaseType = testInputBaseType;
|
||||||
|
_testUtility.TestLootItem.Class = testInputClass;
|
||||||
|
_testUtility.TestLootItem.ItemLevel = testInputItemLevel;
|
||||||
|
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputBaseTypeBlockItem);
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputClassBlockItem);
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(testInputItemLevelBlockItem);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Service.FindBlockForLootItem(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(_testUtility.TestBlock, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemFilterBlockFinderServiceTestUtility
|
||||||
|
{
|
||||||
|
public ItemFilterBlockFinderServiceTestUtility()
|
||||||
|
{
|
||||||
|
TestBlock = new ItemFilterBlock();
|
||||||
|
TestScript = new ItemFilterScript();
|
||||||
|
TestScript.ItemFilterBlocks.Add(TestBlock);
|
||||||
|
TestLootItem = new LootItem();
|
||||||
|
|
||||||
|
Service = new ItemFilterBlockFinderService();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemFilterScript TestScript { get; private set; }
|
||||||
|
public ItemFilterBlock TestBlock { get; private set; }
|
||||||
|
public LootItem TestLootItem { get; private set; }
|
||||||
|
public ItemFilterBlockFinderService Service { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.LootExplosionStudio.Services;
|
||||||
|
using Filtration.ObjectModel;
|
||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
using Moq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.LootExplosionStudio.Tests.Services
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
class TestLootItemAppearanceService
|
||||||
|
{
|
||||||
|
private LootItemAppearanceServiceTestUtility _testUtility;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void ItemFilterProcessingServiceTestSetup()
|
||||||
|
{
|
||||||
|
_testUtility = new LootItemAppearanceServiceTestUtility();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_NoMatchingBlocks_NormalItem_SetsCorrectTextColor()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_testUtility.TestLootItem.Rarity = ItemRarity.Normal;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.NormalTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_NoMatchingBlocks_MagicItem_SetsCorrectTextColor()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_testUtility.TestLootItem.Rarity = ItemRarity.Magic;
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 99));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.MagicTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_NoMatchingBlocks_RareItem_SetsCorrectTextColor()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_testUtility.TestLootItem.Rarity = ItemRarity.Rare;
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 99));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.RareTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_NoMatchingBlocks_UniqueItem_SetsCorrectTextColor()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_testUtility.TestLootItem.Rarity = ItemRarity.Unique;
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 99));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.UniqueTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_NoMatchingBlocks_SetsCorrectBackgroundColor()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 99));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_NoMatchingBlocks_SetsCorrectBorderColor()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 99));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_MatchingTextColorOnly_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputTextColor = new Color {R = 123, G = 5, B = 22, A = 200};
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new TextColorBlockItem {Color = testInputTextColor});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.FontSize, _testUtility.TestLootItem.FontSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_MatchingBackgroundColorOnly_RarityNormal_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBackgroundColor = new Color {R = 123, G = 5, B = 22, A = 200};
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new BackgroundColorBlockItem {Color = testInputBackgroundColor});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputBackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.NormalTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.FontSize, _testUtility.TestLootItem.FontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_MatchingBackgroundColorOnly_RarityMagic_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBackgroundColor = new Color { R = 123, G = 5, B = 22, A = 200 };
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new BackgroundColorBlockItem {Color = testInputBackgroundColor});
|
||||||
|
_testUtility.TestLootItem.Rarity = ItemRarity.Magic;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputBackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.MagicTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.FontSize, _testUtility.TestLootItem.FontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_MatchingBackgroundColorOnly_RarityRare_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBackgroundColor = new Color { R = 123, G = 5, B = 22, A = 200 };
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new BackgroundColorBlockItem { Color = testInputBackgroundColor });
|
||||||
|
_testUtility.TestLootItem.Rarity = ItemRarity.Rare;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputBackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.RareTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.FontSize, _testUtility.TestLootItem.FontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_MatchingBackgroundColorOnly_RarityUnique_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBackgroundColor = new Color { R = 123, G = 5, B = 22, A = 200 };
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new BackgroundColorBlockItem { Color = testInputBackgroundColor });
|
||||||
|
_testUtility.TestLootItem.Rarity = ItemRarity.Unique;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputBackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.UniqueTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.FontSize, _testUtility.TestLootItem.FontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_MatchingBorderColorOnly_RarityUnique_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBorderColor = new Color { R = 123, G = 5, B = 22, A = 200 };
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new BorderColorBlockItem { Color = testInputBorderColor });
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputBorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.NormalTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.FontSize, _testUtility.TestLootItem.FontSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_MatchingFontSizeOnly_RarityUnique_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputFontSize = 22;
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new FontSizeBlockItem(22));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputFontSize, _testUtility.TestLootItem.FontSize);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.NormalTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(DefaultLootItemAppearanceConstants.BorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ProcessLootItemAgainstScript_AllAppearanceMatching_SetsColorsCorrectly()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputFontSize = 22;
|
||||||
|
var testInputTextColor = new Color { R = 123, G = 5, B = 22, A = 200 };
|
||||||
|
var testInputBackgroundColor = new Color { R = 123, G = 59, B = 27, A = 50 };
|
||||||
|
var testInputBorderColor = new Color { R = 166, G = 0, B = 100, A = 255 };
|
||||||
|
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new FontSizeBlockItem(22));
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new BorderColorBlockItem { Color = testInputBorderColor });
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new BackgroundColorBlockItem { Color = testInputBackgroundColor });
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new TextColorBlockItem { Color = testInputTextColor });
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Service.ProcessLootItemAgainstFilterScript(_testUtility.TestLootItem, _testUtility.TestScript);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(testInputFontSize, _testUtility.TestLootItem.FontSize);
|
||||||
|
Assert.AreEqual(testInputTextColor, _testUtility.TestLootItem.TextColor);
|
||||||
|
Assert.AreEqual(testInputBackgroundColor, _testUtility.TestLootItem.BackgroundColor);
|
||||||
|
Assert.AreEqual(testInputBorderColor, _testUtility.TestLootItem.BorderColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LootItemAppearanceServiceTestUtility
|
||||||
|
{
|
||||||
|
public LootItemAppearanceServiceTestUtility()
|
||||||
|
{
|
||||||
|
TestBlock = new ItemFilterBlock();
|
||||||
|
TestScript = new ItemFilterScript();
|
||||||
|
TestScript.ItemFilterBlocks.Add(TestBlock);
|
||||||
|
TestLootItem = new LootItem();
|
||||||
|
|
||||||
|
MockItemFilterBlockFinderService = new Mock<IItemFilterBlockFinderService>();
|
||||||
|
MockItemFilterBlockFinderService.Setup(
|
||||||
|
b => b.FindBlockForLootItem(TestLootItem, TestScript))
|
||||||
|
.Returns(TestBlock);
|
||||||
|
|
||||||
|
Service = new LootItemAppearanceService(MockItemFilterBlockFinderService.Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Mock<IItemFilterBlockFinderService> MockItemFilterBlockFinderService { get; private set; }
|
||||||
|
|
||||||
|
public ItemFilterScript TestScript { get; private set; }
|
||||||
|
public ItemFilterBlock TestBlock { get; private set; }
|
||||||
|
public LootItem TestLootItem { get; private set; }
|
||||||
|
public LootItemAppearanceService Service { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
Filtration.LootExplosionStudio.Tests/packages.config
Normal file
5
Filtration.LootExplosionStudio.Tests/packages.config
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Moq" version="4.2.1507.0118" targetFramework="net451" />
|
||||||
|
<package id="NUnit" version="2.6.4" targetFramework="net451" />
|
||||||
|
</packages>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{C8009B11-14D0-4421-94F0-9EF4603CB363}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Filtration.LootExplosionStudio</RootNamespace>
|
||||||
|
<AssemblyName>Filtration.LootExplosionStudio</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Castle.Core">
|
||||||
|
<HintPath>..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Castle.Windsor">
|
||||||
|
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Services\ItemFilterBlockFinderService.cs" />
|
||||||
|
<Compile Include="Services\LootItemAppearanceService.cs" />
|
||||||
|
<Compile Include="Services\LootItemCollectionItemFilterCombinerService.cs" />
|
||||||
|
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
|
||||||
|
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
|
||||||
|
<Name>Filtration.ObjectModel</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- 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.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
39
Filtration.LootExplosionStudio/Properties/AssemblyInfo.cs
Normal file
39
Filtration.LootExplosionStudio/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Filtration.LootExplosionStudio")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("Filtration.LootExplosionStudio")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("b33dec95-6eec-4e14-81d5-3d8ce0db77d1")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("Filtration.LootExplosionStudio.Tests")]
|
||||||
|
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Filtration.ObjectModel;
|
||||||
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
|
namespace Filtration.LootExplosionStudio.Services
|
||||||
|
{
|
||||||
|
internal interface IItemFilterBlockFinderService
|
||||||
|
{
|
||||||
|
ItemFilterBlock FindBlockForLootItem(LootItem lootItem, ItemFilterScript script);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ItemFilterBlockFinderService : IItemFilterBlockFinderService
|
||||||
|
{
|
||||||
|
public ItemFilterBlock FindBlockForLootItem(LootItem lootItem, ItemFilterScript script)
|
||||||
|
{
|
||||||
|
return script.ItemFilterBlocks.FirstOrDefault(block => BlockMatchesLootItem(lootItem, block));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool BlockMatchesLootItem(LootItem lootItem, ItemFilterBlock block)
|
||||||
|
{
|
||||||
|
if (!block.BlockItems.OfType<StringListBlockItem>().All(blockItem => blockItem.MatchesLootItem(lootItem)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!block.BlockItems.OfType<NumericFilterPredicateBlockItem>()
|
||||||
|
.All(blockItem => blockItem.MatchesLootItem(lootItem)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel;
|
||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
|
namespace Filtration.LootExplosionStudio.Services
|
||||||
|
{
|
||||||
|
internal interface ILootItemAppearanceService
|
||||||
|
{
|
||||||
|
void ProcessLootItemAgainstFilterScript(LootItem lootItem, ItemFilterScript script);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class LootItemAppearanceService : ILootItemAppearanceService
|
||||||
|
{
|
||||||
|
private readonly IItemFilterBlockFinderService _blockFinderService;
|
||||||
|
|
||||||
|
public LootItemAppearanceService(IItemFilterBlockFinderService blockFinderService)
|
||||||
|
{
|
||||||
|
_blockFinderService = blockFinderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessLootItemAgainstFilterScript(LootItem lootItem, ItemFilterScript script)
|
||||||
|
{
|
||||||
|
var matchedBlock = _blockFinderService.FindBlockForLootItem(lootItem, script);
|
||||||
|
if (matchedBlock == null)
|
||||||
|
{
|
||||||
|
lootItem.TextColor = GetDefaultTextColorForRarity(lootItem.Rarity);
|
||||||
|
lootItem.BackgroundColor = DefaultLootItemAppearanceConstants.BackgroundColor;
|
||||||
|
lootItem.BorderColor = DefaultLootItemAppearanceConstants.BorderColor;
|
||||||
|
lootItem.FontSize = 35;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lootItem.TextColor = matchedBlock.HasBlockItemOfType<TextColorBlockItem>()
|
||||||
|
? matchedBlock.BlockItems.OfType<TextColorBlockItem>().First().Color
|
||||||
|
: GetDefaultTextColorForRarity(lootItem.Rarity);
|
||||||
|
|
||||||
|
lootItem.BackgroundColor = matchedBlock.HasBlockItemOfType<BackgroundColorBlockItem>()
|
||||||
|
? matchedBlock.BlockItems.OfType<BackgroundColorBlockItem>().First().Color
|
||||||
|
: DefaultLootItemAppearanceConstants.BackgroundColor;
|
||||||
|
|
||||||
|
lootItem.BorderColor = matchedBlock.HasBlockItemOfType<BorderColorBlockItem>()
|
||||||
|
? matchedBlock.BlockItems.OfType<BorderColorBlockItem>().First().Color
|
||||||
|
: DefaultLootItemAppearanceConstants.BorderColor;
|
||||||
|
|
||||||
|
lootItem.FontSize = matchedBlock.HasBlockItemOfType<FontSizeBlockItem>()
|
||||||
|
? matchedBlock.BlockItems.OfType<FontSizeBlockItem>().First().Value
|
||||||
|
: 35;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color GetDefaultTextColorForRarity(ItemRarity rarity)
|
||||||
|
{
|
||||||
|
switch (rarity)
|
||||||
|
{
|
||||||
|
case ItemRarity.Normal:
|
||||||
|
{
|
||||||
|
return DefaultLootItemAppearanceConstants.NormalTextColor;
|
||||||
|
}
|
||||||
|
case ItemRarity.Magic:
|
||||||
|
{
|
||||||
|
return DefaultLootItemAppearanceConstants.MagicTextColor;
|
||||||
|
}
|
||||||
|
case ItemRarity.Rare:
|
||||||
|
{
|
||||||
|
return DefaultLootItemAppearanceConstants.RareTextColor;
|
||||||
|
}
|
||||||
|
case ItemRarity.Unique:
|
||||||
|
{
|
||||||
|
return DefaultLootItemAppearanceConstants.UniqueTextColor;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return DefaultLootItemAppearanceConstants.NormalTextColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using Filtration.ObjectModel;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
|
namespace Filtration.LootExplosionStudio.Services
|
||||||
|
{
|
||||||
|
internal interface ILootItemCollectionItemFilterCombinerService
|
||||||
|
{
|
||||||
|
void CombineLootItemCollectionWithItemFilterScript(LootItemCollection lootItemCollection,
|
||||||
|
ItemFilterScript script);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class LootItemCollectionItemFilterCombinerService : ILootItemCollectionItemFilterCombinerService
|
||||||
|
{
|
||||||
|
private readonly ILootItemAppearanceService _lootItemAppearanceService;
|
||||||
|
|
||||||
|
public LootItemCollectionItemFilterCombinerService(ILootItemAppearanceService lootItemAppearanceService)
|
||||||
|
{
|
||||||
|
_lootItemAppearanceService = lootItemAppearanceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CombineLootItemCollectionWithItemFilterScript(LootItemCollection lootItemCollection,
|
||||||
|
ItemFilterScript script)
|
||||||
|
{
|
||||||
|
foreach (var lootItem in lootItemCollection)
|
||||||
|
{
|
||||||
|
_lootItemAppearanceService.ProcessLootItemAgainstFilterScript(lootItem, script);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using Castle.MicroKernel.Registration;
|
||||||
|
using Castle.MicroKernel.SubSystems.Configuration;
|
||||||
|
using Castle.Windsor;
|
||||||
|
using Filtration.LootExplosionStudio.Services;
|
||||||
|
|
||||||
|
namespace Filtration.LootExplosionStudio.WindsorInstallers
|
||||||
|
{
|
||||||
|
class ServicesInstaller : IWindsorInstaller
|
||||||
|
{
|
||||||
|
public void Install(IWindsorContainer container, IConfigurationStore store)
|
||||||
|
{
|
||||||
|
container.Register(
|
||||||
|
Component.For<IItemFilterBlockFinderService>()
|
||||||
|
.ImplementedBy<ItemFilterBlockFinderService>()
|
||||||
|
.LifeStyle.Singleton);
|
||||||
|
|
||||||
|
container.Register(
|
||||||
|
Component.For<ILootItemAppearanceService>()
|
||||||
|
.ImplementedBy<LootItemAppearanceService>()
|
||||||
|
.LifeStyle.Singleton);
|
||||||
|
container.Register(
|
||||||
|
Component.For<ILootItemCollectionItemFilterCombinerService>()
|
||||||
|
.ImplementedBy<LootItemCollectionItemFilterCombinerService>()
|
||||||
|
.LifeStyle.Singleton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
Filtration.LootExplosionStudio/packages.config
Normal file
5
Filtration.LootExplosionStudio/packages.config
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Castle.Core" version="3.3.0" targetFramework="net451" />
|
||||||
|
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
|
||||||
|
</packages>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.Tests.BlockItemBaseTypes
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestBaseTypeBlockItem
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_BlankLootItem_ReturnsFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new BaseTypeBlockItem();
|
||||||
|
var testInputLootItem = new LootItem();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_StringMatch_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputBaseType = "Test Base Type";
|
||||||
|
|
||||||
|
var blockItem = new BaseTypeBlockItem();
|
||||||
|
blockItem.Items.Add("Testblah");
|
||||||
|
blockItem.Items.Add(testInputBaseType);
|
||||||
|
blockItem.Items.Add("Another Base Type");
|
||||||
|
|
||||||
|
var testInputLootItem = new LootItem { BaseType = testInputBaseType};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.Tests.BlockItemBaseTypes
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestClassBlockItem
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_BlankLootItem_ReturnsFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new ClassBlockItem();
|
||||||
|
var testInputLootItem = new LootItem();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_StringMatch_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputClass = "Test Class";
|
||||||
|
|
||||||
|
var blockItem = new ClassBlockItem();
|
||||||
|
blockItem.Items.Add("Testblah");
|
||||||
|
blockItem.Items.Add(testInputClass);
|
||||||
|
blockItem.Items.Add("Another Base Type");
|
||||||
|
|
||||||
|
var testInputLootItem = new LootItem { Class = testInputClass };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.Tests.BlockItemBaseTypes
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestItemLevelBlockItem
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_NoMatch_ReturnsFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 10);
|
||||||
|
var lootItem = new LootItem {ItemLevel = 5};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(lootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_EqualsMatch_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new ItemLevelBlockItem(FilterPredicateOperator.Equal, 10);
|
||||||
|
var lootItem = new LootItem { ItemLevel = 10 };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(lootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_GreaterThanMatch_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 10);
|
||||||
|
var lootItem = new LootItem { ItemLevel = 50 };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(lootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_GreaterThanOrEqualMatch_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new ItemLevelBlockItem(FilterPredicateOperator.GreaterThanOrEqual, 10);
|
||||||
|
var lootItem = new LootItem { ItemLevel = 50 };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(lootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_LessThan_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new ItemLevelBlockItem(FilterPredicateOperator.LessThan, 10);
|
||||||
|
var lootItem = new LootItem { ItemLevel = 1 };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(lootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_LessThanOrEqual_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new ItemLevelBlockItem(FilterPredicateOperator.LessThanOrEqual, 10);
|
||||||
|
var lootItem = new LootItem { ItemLevel = 1 };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(lootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.Tests.BlockItemBaseTypes
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSocketGroupBlockItem
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_BlankLootItem_ReturnsFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var blockItem = new SocketGroupBlockItem();
|
||||||
|
var testInputLootItem = new LootItem();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_SocketsMatch_ReturnsTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputSocketGroups = new List<SocketGroup>();
|
||||||
|
var testInputSocketGroup1 = new SocketGroup();
|
||||||
|
var testInputSocketGroup2 = new SocketGroup();
|
||||||
|
testInputSocketGroup1.Sockets = new List<SocketColor> {SocketColor.Blue, SocketColor.Red};
|
||||||
|
testInputSocketGroup2.Sockets = new List<SocketColor>
|
||||||
|
{
|
||||||
|
SocketColor.Blue,
|
||||||
|
SocketColor.Blue,
|
||||||
|
SocketColor.Blue,
|
||||||
|
SocketColor.Red
|
||||||
|
};
|
||||||
|
|
||||||
|
testInputSocketGroups.Add(testInputSocketGroup1);
|
||||||
|
testInputSocketGroups.Add(testInputSocketGroup2);
|
||||||
|
|
||||||
|
var blockItem = new SocketGroupBlockItem();
|
||||||
|
blockItem.Items.Add("RRG");
|
||||||
|
blockItem.Items.Add("BRB");
|
||||||
|
|
||||||
|
var testInputLootItem = new LootItem {SocketGroups = testInputSocketGroups};
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MatchesBlockItem_SocketsAlmostMatch_ReturnsFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputSocketGroups = new List<SocketGroup>();
|
||||||
|
var testInputSocketGroup1 = new SocketGroup();
|
||||||
|
var testInputSocketGroup2 = new SocketGroup();
|
||||||
|
testInputSocketGroup1.Sockets = new List<SocketColor> { SocketColor.Blue, SocketColor.Red };
|
||||||
|
testInputSocketGroup2.Sockets = new List<SocketColor>
|
||||||
|
{
|
||||||
|
SocketColor.Blue,
|
||||||
|
SocketColor.Blue,
|
||||||
|
SocketColor.Blue,
|
||||||
|
SocketColor.Red,
|
||||||
|
SocketColor.Green
|
||||||
|
};
|
||||||
|
|
||||||
|
testInputSocketGroups.Add(testInputSocketGroup1);
|
||||||
|
testInputSocketGroups.Add(testInputSocketGroup2);
|
||||||
|
|
||||||
|
var blockItem = new SocketGroupBlockItem();
|
||||||
|
blockItem.Items.Add("BGBRWB");
|
||||||
|
|
||||||
|
var testInputLootItem = new LootItem { SocketGroups = testInputSocketGroups };
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsFalse(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,10 +46,15 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="BlockItemBaseTypes\TestBaseTypeBlockItem.cs" />
|
||||||
|
<Compile Include="BlockItemBaseTypes\TestClassBlockItem.cs" />
|
||||||
|
<Compile Include="BlockItemBaseTypes\TestItemLevelBlockItem.cs" />
|
||||||
|
<Compile Include="BlockItemBaseTypes\TestSocketGroupBlockItem.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<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 +65,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.
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.ThemeEditor;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.Tests.ThemeEditor
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestThemeComponentCollection
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var testInputTargetType = ThemeComponentType.TextColor;
|
||||||
|
var testInputComponentName = "testComponent";
|
||||||
|
var testInputColor = new Color();
|
||||||
|
|
||||||
|
var componentCollection = new ThemeComponentCollection();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var firstResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||||
|
var secondResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreSame(firstResult, secondResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
using Filtration.ObjectModel.Extensions;
|
using Filtration.ObjectModel.Extensions;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System.Windows.Media;
|
using System;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
using Filtration.ObjectModel.ThemeEditor;
|
using Filtration.ObjectModel.ThemeEditor;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
@@ -6,6 +8,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 +34,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 +69,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
using Filtration.ObjectModel.Extensions;
|
using Filtration.ObjectModel.Extensions;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
{
|
{
|
||||||
@@ -47,5 +48,45 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||||||
OnPropertyChanged("FilterPredicate");
|
OnPropertyChanged("FilterPredicate");
|
||||||
OnPropertyChanged("SummaryText");
|
OnPropertyChanged("SummaryText");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public abstract int GetLootItemProperty(LootItem lootItem);
|
||||||
|
|
||||||
|
public virtual bool MatchesLootItem(LootItem lootItem)
|
||||||
|
{
|
||||||
|
var lootItemProperty = GetLootItemProperty(lootItem);
|
||||||
|
var predicateOperand = FilterPredicate.PredicateOperand;
|
||||||
|
|
||||||
|
switch (FilterPredicate.PredicateOperator)
|
||||||
|
{
|
||||||
|
case FilterPredicateOperator.Equal:
|
||||||
|
{
|
||||||
|
return lootItemProperty == predicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.GreaterThan:
|
||||||
|
{
|
||||||
|
return lootItemProperty > predicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.GreaterThanOrEqual:
|
||||||
|
{
|
||||||
|
return lootItemProperty >= predicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.LessThan:
|
||||||
|
{
|
||||||
|
return lootItemProperty < predicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.LessThanOrEqual:
|
||||||
|
{
|
||||||
|
return lootItemProperty <= predicateOperand;
|
||||||
|
}
|
||||||
|
case FilterPredicateOperator.NotEqual:
|
||||||
|
{
|
||||||
|
return lootItemProperty != predicateOperand;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
{
|
{
|
||||||
@@ -36,5 +37,12 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
|||||||
OnPropertyChanged("Items");
|
OnPropertyChanged("Items");
|
||||||
OnPropertyChanged("SummaryText");
|
OnPropertyChanged("SummaryText");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract string GetLootItemProperty(LootItem lootItem);
|
||||||
|
|
||||||
|
public virtual bool MatchesLootItem(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return Items.Any(i => i == GetLootItemProperty(lootItem));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -56,5 +57,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
{
|
{
|
||||||
get { return 11; }
|
get { return 11; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.BaseType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -50,5 +51,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
{
|
{
|
||||||
get { return 10; }
|
get { return 10; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.Class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -68,5 +69,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.DropLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -65,5 +66,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.Height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -67,5 +68,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.ItemLevel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Windows.Media;
|
using System.Linq;
|
||||||
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -68,5 +70,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.SocketGroups.Where(c => c.Sockets.Count > 1).Sum(socketGroup => socketGroup.Sockets.Count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -68,5 +69,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.Quality;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
using Filtration.ObjectModel.Extensions;
|
using Filtration.ObjectModel.Extensions;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -85,5 +86,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return (int)ItemRarity.Unique;
|
return (int)ItemRarity.Unique;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return (int)lootItem.Rarity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -47,5 +51,68 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
{
|
{
|
||||||
get { return 9; }
|
get { return 9; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.SocketGroups.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool MatchesLootItem(LootItem lootItem)
|
||||||
|
{
|
||||||
|
foreach (var socketGroupString in Items)
|
||||||
|
{
|
||||||
|
var socketColorList = SocketGroupStringToSocketColors(socketGroupString);
|
||||||
|
if (
|
||||||
|
lootItem.SocketGroups.Any(
|
||||||
|
g =>
|
||||||
|
g.Sockets.Count(s => s == SocketColor.Red) >=
|
||||||
|
socketColorList.Count(l => l == SocketColor.Red) &&
|
||||||
|
g.Sockets.Count(s => s == SocketColor.Green) >=
|
||||||
|
socketColorList.Count(l => l == SocketColor.Green) &&
|
||||||
|
g.Sockets.Count(s => s == SocketColor.Blue) >=
|
||||||
|
socketColorList.Count(l => l == SocketColor.Blue) &&
|
||||||
|
g.Sockets.Count(s => s == SocketColor.White) >=
|
||||||
|
socketColorList.Count(l => l == SocketColor.White)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SocketColor> SocketGroupStringToSocketColors(string socketGroupString)
|
||||||
|
{
|
||||||
|
var socketColorList = new List<SocketColor>();
|
||||||
|
|
||||||
|
foreach (var c in socketGroupString.ToCharArray())
|
||||||
|
{
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'R':
|
||||||
|
{
|
||||||
|
socketColorList.Add(SocketColor.Red);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'G':
|
||||||
|
{
|
||||||
|
socketColorList.Add(SocketColor.Green);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'B':
|
||||||
|
{
|
||||||
|
socketColorList.Add(SocketColor.Blue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'W':
|
||||||
|
{
|
||||||
|
socketColorList.Add(SocketColor.White);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return socketColorList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Windows.Media;
|
using System.Linq;
|
||||||
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -68,5 +70,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.SocketGroups.Sum(c => c.Sockets.Count());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ObjectModel.LootExplosionStudio;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemTypes
|
namespace Filtration.ObjectModel.BlockItemTypes
|
||||||
{
|
{
|
||||||
@@ -68,5 +69,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override int GetLootItemProperty(LootItem lootItem)
|
||||||
|
{
|
||||||
|
return lootItem.Width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BlockItemBaseTypes\ActionBlockItem.cs" />
|
<Compile Include="BlockItemBaseTypes\ActionBlockItem.cs" />
|
||||||
<Compile Include="BlockItemBaseTypes\BlockItembase.cs" />
|
<Compile Include="BlockItemBaseTypes\BlockItemBase.cs" />
|
||||||
<Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" />
|
<Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" />
|
||||||
<Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" />
|
<Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" />
|
||||||
<Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" />
|
<Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" />
|
||||||
@@ -77,12 +77,17 @@
|
|||||||
<Compile Include="ItemFilterBlockGroup.cs" />
|
<Compile Include="ItemFilterBlockGroup.cs" />
|
||||||
<Compile Include="ItemFilterScript.cs" />
|
<Compile Include="ItemFilterScript.cs" />
|
||||||
<Compile Include="ItemFilterSection.cs" />
|
<Compile Include="ItemFilterSection.cs" />
|
||||||
|
<Compile Include="LootExplosionStudio\DefaultLootItemAppearanceConstants.cs" />
|
||||||
|
<Compile Include="LootExplosionStudio\LootItem.cs" />
|
||||||
|
<Compile Include="LootExplosionStudio\LootItemCollection.cs" />
|
||||||
|
<Compile Include="LootExplosionStudio\SocketGroup.cs" />
|
||||||
<Compile Include="NumericFilterPredicate.cs" />
|
<Compile Include="NumericFilterPredicate.cs" />
|
||||||
<Compile Include="Properties\Annotations.cs" />
|
<Compile Include="Properties\Annotations.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<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.
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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; }
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.LootExplosionStudio
|
||||||
|
{
|
||||||
|
public static class DefaultLootItemAppearanceConstants
|
||||||
|
{
|
||||||
|
public readonly static Color NormalTextColor = new Color { A = 255, R = 200, G = 200, B = 200 };
|
||||||
|
public readonly static Color MagicTextColor = new Color { A = 255, R = 136, G = 136, B = 255 };
|
||||||
|
public readonly static Color RareTextColor = new Color { A = 255, R = 255, G = 255, B = 119 };
|
||||||
|
public readonly static Color UniqueTextColor = new Color { A = 255, R = 175, G = 96, B = 37 };
|
||||||
|
public readonly static Color QuestItemTextColor = new Color { A = 255, R = 74, G = 230, B = 58 };
|
||||||
|
public static readonly Color BackgroundColor = new Color {A = 255, R = 0, G = 0, B = 0};
|
||||||
|
public static readonly Color BorderColor = new Color { A = 255, R = 0, G = 0, B = 0 };
|
||||||
|
public static readonly int FontSize = 35;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Filtration.ObjectModel/LootExplosionStudio/LootItem.cs
Normal file
25
Filtration.ObjectModel/LootExplosionStudio/LootItem.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.LootExplosionStudio
|
||||||
|
{
|
||||||
|
public class LootItem
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int ItemLevel { get; set; }
|
||||||
|
public int DropLevel { get; set; }
|
||||||
|
public int Quality { get; set; }
|
||||||
|
public ItemRarity Rarity { get; set; }
|
||||||
|
public string Class { get; set; }
|
||||||
|
public string BaseType { get; set; }
|
||||||
|
public List<SocketGroup> SocketGroups { get; set; }
|
||||||
|
public int Width { get; set; }
|
||||||
|
public int Height { get; set; }
|
||||||
|
|
||||||
|
public Color TextColor { get; set; }
|
||||||
|
public Color BackgroundColor { get; set; }
|
||||||
|
public Color BorderColor { get; set; }
|
||||||
|
public int FontSize { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.LootExplosionStudio
|
||||||
|
{
|
||||||
|
public class LootItemCollection : Collection<LootItem>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Filtration.ObjectModel/LootExplosionStudio/SocketGroup.cs
Normal file
10
Filtration.ObjectModel/LootExplosionStudio/SocketGroup.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Filtration.ObjectModel.Enums;
|
||||||
|
|
||||||
|
namespace Filtration.ObjectModel.LootExplosionStudio
|
||||||
|
{
|
||||||
|
public class SocketGroup
|
||||||
|
{
|
||||||
|
public List<SocketColor> Sockets { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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" />
|
||||||
|
|||||||
@@ -25,6 +25,36 @@ namespace Filtration.Tests.Translators
|
|||||||
_testUtility = new ItemFilterBlockTranslatorTestUtility();
|
_testUtility = new ItemFilterBlockTranslatorTestUtility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateStringToItemFilterBlock_NotDisabled_SetsBlockEnabledTrue()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var inputString = "Show" + Environment.NewLine +
|
||||||
|
" ItemLevel >= 55";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(true, result.Enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateStringToItemFilterBlock_DisabledBlock_SetsBlockEnabledFalse()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var inputString = "HideDisabled" + Environment.NewLine +
|
||||||
|
" ItemLevel >= 55";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(2, result.BlockItems.Count);
|
||||||
|
Assert.AreEqual(BlockAction.Hide, result.Action);
|
||||||
|
Assert.AreEqual(false, result.Enabled);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
|
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
|
||||||
{
|
{
|
||||||
@@ -33,7 +63,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" ItemLevel >= 55";
|
" ItemLevel >= 55";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
||||||
@@ -51,7 +81,7 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
|
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
|
||||||
@@ -66,7 +96,7 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(true, inputBlockGroup.IsChecked);
|
Assert.AreEqual(true, inputBlockGroup.IsChecked);
|
||||||
@@ -81,7 +111,7 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(false, inputBlockGroup.IsChecked);
|
Assert.AreEqual(false, inputBlockGroup.IsChecked);
|
||||||
@@ -95,7 +125,7 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||||
@@ -109,7 +139,7 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||||
@@ -124,7 +154,7 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable();
|
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable();
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(testBlockGroup, result.BlockGroup);
|
Assert.AreEqual(testBlockGroup, result.BlockGroup);
|
||||||
@@ -138,7 +168,7 @@ namespace Filtration.Tests.Translators
|
|||||||
var inputString = "Hide" + Environment.NewLine;
|
var inputString = "Hide" + Environment.NewLine;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem));
|
||||||
@@ -154,7 +184,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" ItemLevel >= 55";
|
" ItemLevel >= 55";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual("This is a test Block", result.Description);
|
Assert.AreEqual("This is a test Block", result.Description);
|
||||||
@@ -174,7 +204,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" ItemLevel >= 55";
|
" ItemLevel >= 55";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual("Second Line", result.Description);
|
Assert.AreEqual("Second Line", result.Description);
|
||||||
@@ -192,7 +222,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" DropLevel = 40";
|
" DropLevel = 40";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
@@ -210,7 +240,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Quality < 18";
|
" Quality < 18";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
@@ -228,7 +258,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Rarity > Normal";
|
" Rarity > Normal";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
@@ -246,7 +276,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Rarity Normal";
|
" Rarity Normal";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem));
|
||||||
@@ -263,7 +293,7 @@ namespace Filtration.Tests.Translators
|
|||||||
@" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2""";
|
@" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2""";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem));
|
||||||
@@ -282,7 +312,7 @@ namespace Filtration.Tests.Translators
|
|||||||
@" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2""";
|
@" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2""";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem));
|
||||||
@@ -301,7 +331,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Sockets > 2";
|
" Sockets > 2";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
@@ -319,7 +349,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" LinkedSockets != 1";
|
" LinkedSockets != 1";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
@@ -337,7 +367,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Width != 1";
|
" Width != 1";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
@@ -355,7 +385,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Height <= 3";
|
" Height <= 3";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
||||||
@@ -373,7 +403,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Height <=3";
|
" Height <=3";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem));
|
||||||
@@ -390,7 +420,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SocketGroup RRGB";
|
" SocketGroup RRGB";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem));
|
||||||
@@ -408,7 +438,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetTextColor 255 20 100";
|
" SetTextColor 255 20 100";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||||
@@ -426,7 +456,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetTextColor 65 0 255 12";
|
" SetTextColor 65 0 255 12";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||||
@@ -445,7 +475,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetBackgroundColor 255 20 100";
|
" SetBackgroundColor 255 20 100";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
||||||
@@ -464,7 +494,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetBorderColor 255 20 100";
|
" SetBorderColor 255 20 100";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||||
@@ -483,8 +513,8 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
||||||
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString));
|
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null));
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||||
@@ -500,21 +530,17 @@ namespace Filtration.Tests.Translators
|
|||||||
// Arrange
|
// Arrange
|
||||||
var inputString = "Show" + Environment.NewLine +
|
var inputString = "Show" + Environment.NewLine +
|
||||||
" SetTextColor 255 20 100 # Rare Item Text";
|
" SetTextColor 255 20 100 # Rare Item Text";
|
||||||
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "testComponent", new Color());
|
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
|
||||||
|
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
|
||||||
_testUtility.MockThemeComponentListBuilder.Setup(
|
|
||||||
t =>
|
|
||||||
t.AddComponent(ThemeComponentType.TextColor, "Rare Item Text",
|
|
||||||
new Color {A = 255, R = 255, G = 20, B = 100})).Returns(testComponent).Verifiable();
|
|
||||||
_testUtility.MockThemeComponentListBuilder.SetupGet(t => t.IsInitialised).Returns(true);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, testInputThemeComponentCollection);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
|
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
|
||||||
Assert.AreSame(testComponent, blockItem.ThemeComponent);
|
Assert.AreSame(testComponent, blockItem.ThemeComponent);
|
||||||
_testUtility.MockThemeComponentListBuilder.Verify();
|
var firstComponent = testInputThemeComponentCollection.First();
|
||||||
|
Assert.AreEqual("Rare Item Text", firstComponent.ComponentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@@ -526,7 +552,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetFontSize 15";
|
" SetFontSize 15";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
||||||
@@ -543,7 +569,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" PlayAlertSound 4";
|
" PlayAlertSound 4";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||||
@@ -561,7 +587,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" PlayAlertSound 2 95";
|
" PlayAlertSound 2 95";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||||
@@ -578,7 +604,7 @@ namespace Filtration.Tests.Translators
|
|||||||
var inputString = "# Section: " + TestInputSectionDescription;
|
var inputString = "# Section: " + TestInputSectionDescription;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.IsInstanceOf<ItemFilterSection>(result);
|
Assert.IsInstanceOf<ItemFilterSection>(result);
|
||||||
@@ -611,7 +637,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" PlayAlertSound 3";
|
" PlayAlertSound 3";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual("Test filter with everything", result.Description);
|
Assert.AreEqual("Test filter with everything", result.Description);
|
||||||
@@ -693,7 +719,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" Quality < 17";
|
" Quality < 17";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
||||||
@@ -722,7 +748,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetTextColor 255 20 100";
|
" SetTextColor 255 20 100";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||||
@@ -743,7 +769,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetFontSize 27" + Environment.NewLine;
|
" SetFontSize 27" + Environment.NewLine;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
||||||
@@ -762,7 +788,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" PlayAlertSound 2" + Environment.NewLine;
|
" PlayAlertSound 2" + Environment.NewLine;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||||
@@ -780,7 +806,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetBackgroundColor 255 20 100";
|
" SetBackgroundColor 255 20 100";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
||||||
@@ -799,7 +825,7 @@ namespace Filtration.Tests.Translators
|
|||||||
" SetBorderColor 255 20 100";
|
" SetBorderColor 255 20 100";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||||
@@ -1268,6 +1294,26 @@ namespace Filtration.Tests.Translators
|
|||||||
Assert.AreEqual(expectedResult, result);
|
Assert.AreEqual(expectedResult, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateItemFilterBlockToString_DisabledBlock_ReturnsCorrectString()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var expectedResult = "#Disabled Block Start" + Environment.NewLine +
|
||||||
|
"#Show" + Environment.NewLine +
|
||||||
|
"# Width = 4" + Environment.NewLine +
|
||||||
|
"#Disabled Block End";
|
||||||
|
|
||||||
|
|
||||||
|
_testUtility.TestBlock.Enabled = false;
|
||||||
|
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreEqual(expectedResult, result);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
|
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
|
||||||
{
|
{
|
||||||
@@ -1347,6 +1393,26 @@ namespace Filtration.Tests.Translators
|
|||||||
Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color);
|
Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlockBugTest()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInputString = "SetBackgroundColor 70 0 0 255";
|
||||||
|
|
||||||
|
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||||
|
var testInputBlockItem = new BackgroundColorBlockItem(new Color { R = 70, G = 0, B = 1, A = 255});
|
||||||
|
testInputBlockItems.Add(testInputBlockItem);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
|
||||||
|
Assert.IsNotNull(backgroundColorBlockItem);
|
||||||
|
Assert.AreNotSame(testInputBlockItem, backgroundColorBlockItem);
|
||||||
|
Assert.AreEqual(new Color { R = 70, G = 0, B = 0, A = 255 }, backgroundColorBlockItem.Color);
|
||||||
|
}
|
||||||
|
|
||||||
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
|
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
|
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
|
||||||
@@ -1461,6 +1527,7 @@ namespace Filtration.Tests.Translators
|
|||||||
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
|
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Ignore("ThemeComponentBuilder deprecated")]
|
||||||
[Test]
|
[Test]
|
||||||
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
|
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
|
||||||
{
|
{
|
||||||
@@ -1470,13 +1537,12 @@ namespace Filtration.Tests.Translators
|
|||||||
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||||
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
|
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
|
||||||
testInputBlockItems.Add(testInputBlockItem);
|
testInputBlockItems.Add(testInputBlockItem);
|
||||||
_testUtility.MockThemeComponentListBuilder.Setup(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>())).Verifiable();
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
_testUtility.MockThemeComponentListBuilder.Verify(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>()), Times.Never);
|
|
||||||
}
|
}
|
||||||
private class ItemFilterBlockTranslatorTestUtility
|
private class ItemFilterBlockTranslatorTestUtility
|
||||||
{
|
{
|
||||||
@@ -1487,16 +1553,13 @@ namespace Filtration.Tests.Translators
|
|||||||
|
|
||||||
// Mock setups
|
// Mock setups
|
||||||
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||||
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
|
|
||||||
|
|
||||||
// Class under test instantiation
|
// Class under test instantiation
|
||||||
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object,
|
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object);
|
||||||
MockThemeComponentListBuilder.Object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemFilterBlock TestBlock { get; set; }
|
public ItemFilterBlock TestBlock { get; set; }
|
||||||
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
||||||
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
|
|
||||||
public ItemFilterBlockTranslator Translator { get; private set; }
|
public ItemFilterBlockTranslator Translator { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,106 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
private class ItemFilterScriptTranslatorTestUtility
|
private class ItemFilterScriptTranslatorTestUtility
|
||||||
{
|
{
|
||||||
public ItemFilterScriptTranslatorTestUtility()
|
public ItemFilterScriptTranslatorTestUtility()
|
||||||
@@ -296,16 +360,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; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
using System.Net.Mime;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using Filtration.ObjectModel.BlockItemTypes;
|
|
||||||
using Filtration.ObjectModel.Enums;
|
|
||||||
using Filtration.Translators;
|
|
||||||
using NUnit.Framework;
|
|
||||||
|
|
||||||
namespace Filtration.Tests.Translators
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class TestThemeComponentListBuilder
|
|
||||||
{
|
|
||||||
[Test]
|
|
||||||
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
|
|
||||||
var testInputTargetType = ThemeComponentType.TextColor;
|
|
||||||
var testInputComponentName = "testComponent";
|
|
||||||
var testInputColor = new Color();
|
|
||||||
|
|
||||||
var builder = new ThemeComponentListBuilder();
|
|
||||||
builder.Initialise();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var firstResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
|
||||||
var secondResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.AreSame(firstResult, secondResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IsInitialised_NotInitialised_ReturnsFalse()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var builder = new ThemeComponentListBuilder();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = builder.IsInitialised;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.IsFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void IsInitialised_Initialised_ReturnsTrue()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var builder = new ThemeComponentListBuilder();
|
|
||||||
builder.Initialise();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = builder.IsInitialised;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Assert.IsTrue(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,18 +95,19 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" />
|
<Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" />
|
||||||
|
<Compile Include="Messages\ThemeClosedMessage.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Providers\ThemeProvider.cs" />
|
<Compile Include="Providers\ThemeProvider.cs" />
|
||||||
<Compile Include="Services\ThemePersistenceService.cs" />
|
<Compile Include="Services\ThemePersistenceService.cs" />
|
||||||
<Compile Include="Services\ThemeService.cs" />
|
<Compile Include="Services\ThemeService.cs" />
|
||||||
<Compile Include="ViewModels\IThemeViewModelFactory.cs" />
|
<Compile Include="ViewModels\IThemeViewModelFactory.cs" />
|
||||||
<Compile Include="ViewModels\ThemeComponentViewModel.cs" />
|
<Compile Include="ViewModels\ThemeComponentViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ThemeViewModel.cs" />
|
<Compile Include="ViewModels\ThemeEditorViewModel.cs" />
|
||||||
<Compile Include="Views\ThemeComponentControl.xaml.cs">
|
<Compile Include="Views\ThemeComponentControl.xaml.cs">
|
||||||
<DependentUpon>ThemeComponentControl.xaml</DependentUpon>
|
<DependentUpon>ThemeComponentControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Views\ThemeControl.xaml.cs">
|
<Compile Include="Views\ThemeEditorView.xaml.cs">
|
||||||
<DependentUpon>ThemeControl.xaml</DependentUpon>
|
<DependentUpon>ThemeEditorView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="WindsorInstallers\ProvidersInstaller.cs" />
|
<Compile Include="WindsorInstallers\ProvidersInstaller.cs" />
|
||||||
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
|
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
|
||||||
@@ -132,7 +133,7 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Views\ThemeControl.xaml">
|
<Page Include="Views\ThemeEditorView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
9
Filtration.ThemeEditor/Messages/ThemeClosedMessage.cs
Normal file
9
Filtration.ThemeEditor/Messages/ThemeClosedMessage.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Filtration.ThemeEditor.ViewModels;
|
||||||
|
|
||||||
|
namespace Filtration.ThemeEditor.Messages
|
||||||
|
{
|
||||||
|
public class ThemeClosedMessage
|
||||||
|
{
|
||||||
|
public IThemeEditorViewModel ClosedViewModel { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public interface IThemeViewModelFactory
|
public interface IThemeViewModelFactory
|
||||||
{
|
{
|
||||||
IThemeViewModel Create();
|
IThemeEditorViewModel Create();
|
||||||
void Release(IThemeViewModel themeViewModel);
|
void Release(IThemeEditorViewModel themeEditorViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
212
Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs
Normal file
212
Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.IO;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using Filtration.Common.Services;
|
|
||||||
using Filtration.Common.ViewModels;
|
|
||||||
using Filtration.Interface;
|
|
||||||
using Filtration.ThemeEditor.Providers;
|
|
||||||
using NLog;
|
|
||||||
using MessageBox = System.Windows.MessageBox;
|
|
||||||
|
|
||||||
namespace Filtration.ThemeEditor.ViewModels
|
|
||||||
{
|
|
||||||
public interface IThemeViewModel : IEditableDocument
|
|
||||||
{
|
|
||||||
void Initialise(ObservableCollection<ThemeComponentViewModel> themeComponentViewModels, bool newTheme);
|
|
||||||
string Title { get; }
|
|
||||||
string FilePath { get; set; }
|
|
||||||
string Filename { get; }
|
|
||||||
string Name { get; set; }
|
|
||||||
ObservableCollection<ThemeComponentViewModel> Components { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ThemeViewModel : PaneViewModel, IThemeViewModel
|
|
||||||
{
|
|
||||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
|
||||||
|
|
||||||
private readonly IThemeProvider _themeProvider;
|
|
||||||
private readonly IMessageBoxService _messageBoxService;
|
|
||||||
private bool _filenameIsFake;
|
|
||||||
private string _filePath;
|
|
||||||
|
|
||||||
public ThemeViewModel(IThemeProvider themeProvider,
|
|
||||||
IMessageBoxService messageBoxService)
|
|
||||||
{
|
|
||||||
_themeProvider = themeProvider;
|
|
||||||
_messageBoxService = messageBoxService;
|
|
||||||
|
|
||||||
Components = new ObservableCollection<ThemeComponentViewModel>();
|
|
||||||
|
|
||||||
|
|
||||||
var icon = new BitmapImage();
|
|
||||||
icon.BeginInit();
|
|
||||||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/Theme.ico");
|
|
||||||
icon.EndInit();
|
|
||||||
IconSource = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialise(ObservableCollection<ThemeComponentViewModel> themeComponentViewModels, bool newTheme)
|
|
||||||
{
|
|
||||||
Components = themeComponentViewModels;
|
|
||||||
_filenameIsFake = newTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsScript { get { return false; } }
|
|
||||||
public bool IsTheme { get { return true; } }
|
|
||||||
public bool IsDirty { get; private set; }
|
|
||||||
|
|
||||||
public string FilePath
|
|
||||||
{
|
|
||||||
get { return _filePath; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_filePath = value;
|
|
||||||
Title = Filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Filename
|
|
||||||
{
|
|
||||||
get { return Path.GetFileName(FilePath); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public ObservableCollection<ThemeComponentViewModel> Components { get; set; }
|
|
||||||
|
|
||||||
public void Save()
|
|
||||||
{
|
|
||||||
if (_filenameIsFake)
|
|
||||||
{
|
|
||||||
SaveAs();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_themeProvider.SaveTheme(this, FilePath);
|
|
||||||
//RemoveDirtyFlag();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (_logger.IsErrorEnabled)
|
|
||||||
{
|
|
||||||
_logger.Error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
_messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveAs()
|
|
||||||
{
|
|
||||||
var saveDialog = new SaveFileDialog
|
|
||||||
{
|
|
||||||
DefaultExt = ".filter",
|
|
||||||
Filter = @"Filter Theme Files (*.filtertheme)|*.filtertheme|All Files (*.*)|*.*"
|
|
||||||
};
|
|
||||||
|
|
||||||
var result = saveDialog.ShowDialog();
|
|
||||||
|
|
||||||
if (result != DialogResult.OK) return;
|
|
||||||
|
|
||||||
var previousFilePath = FilePath;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FilePath = saveDialog.FileName;
|
|
||||||
_themeProvider.SaveTheme(this, FilePath);
|
|
||||||
_filenameIsFake = false;
|
|
||||||
//RemoveDirtyFlag();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (_logger.IsErrorEnabled)
|
|
||||||
{
|
|
||||||
_logger.Error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
_messageBoxService.Show("Save Error", "Error saving theme file - " + e.Message, MessageBoxButton.OK,
|
|
||||||
MessageBoxImage.Error);
|
|
||||||
FilePath = previousFilePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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,47 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="25" />
|
<RowDefinition Height="25" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding ComponentType, Converter={StaticResource ThemeComponentTypeToStringConverter}}" Foreground="Red" FontSize="10" />
|
<Grid.Resources>
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
|
<DataTemplate x:Key="EditableComponentNameTemplate">
|
||||||
<xctk:ColorPicker Grid.Row="2" Grid.Column="0" SelectedColor="{Binding Color}" />
|
<TextBox Text="{Binding ComponentName}" />
|
||||||
|
</DataTemplate>
|
||||||
|
<DataTemplate x:Key="ViewOnlyComponentNameTemplate">
|
||||||
|
<TextBlock Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</Grid.Resources>
|
||||||
|
<DockPanel LastChildFill="True">
|
||||||
|
<TextBlock DockPanel.Dock="Left"
|
||||||
|
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>
|
||||||
|
</DockPanel>
|
||||||
|
<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>
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
<UserControl x:Class="Filtration.ThemeEditor.Views.ThemeControl"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
|
|
||||||
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
|
|
||||||
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DataContext="{d:DesignInstance Type=viewModels:ThemeViewModel}"
|
|
||||||
d:DesignHeight="300" d:DesignWidth="300">
|
|
||||||
<UserControl.Resources>
|
|
||||||
<CollectionViewSource Source="{Binding Components}" x:Key="ComponentsViewSource">
|
|
||||||
<CollectionViewSource.GroupDescriptions>
|
|
||||||
<PropertyGroupDescription PropertyName="ComponentType" />
|
|
||||||
</CollectionViewSource.GroupDescriptions>
|
|
||||||
<CollectionViewSource.SortDescriptions>
|
|
||||||
<componentModel:SortDescription PropertyName="ComponentType" />
|
|
||||||
</CollectionViewSource.SortDescriptions>
|
|
||||||
</CollectionViewSource>
|
|
||||||
</UserControl.Resources>
|
|
||||||
<Grid>
|
|
||||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
|
|
||||||
<ItemsControl ItemsSource="{Binding Source={StaticResource ComponentsViewSource}}" Margin="10">
|
|
||||||
<ItemsControl.ItemsPanel>
|
|
||||||
<ItemsPanelTemplate>
|
|
||||||
<WrapPanel />
|
|
||||||
</ItemsPanelTemplate>
|
|
||||||
</ItemsControl.ItemsPanel>
|
|
||||||
<ItemsControl.GroupStyle>
|
|
||||||
<GroupStyle>
|
|
||||||
<GroupStyle.HeaderTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<TextBlock FontWeight="Bold" FontSize="15" Text="{Binding Path=Name}"/>
|
|
||||||
</DataTemplate>
|
|
||||||
</GroupStyle.HeaderTemplate>
|
|
||||||
</GroupStyle>
|
|
||||||
</ItemsControl.GroupStyle>
|
|
||||||
<ItemsControl.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<views:ThemeComponentControl DataContext="{Binding}" Margin="10,5,10,5" />
|
|
||||||
</DataTemplate>
|
|
||||||
</ItemsControl.ItemTemplate>
|
|
||||||
</ItemsControl>
|
|
||||||
</ScrollViewer>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
78
Filtration.ThemeEditor/Views/ThemeEditorView.xaml
Normal file
78
Filtration.ThemeEditor/Views/ThemeEditorView.xaml
Normal 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>
|
||||||
10
Filtration.ThemeEditor/Views/ThemeEditorView.xaml.cs
Normal file
10
Filtration.ThemeEditor/Views/ThemeEditorView.xaml.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Filtration.ThemeEditor.Views
|
||||||
|
{
|
||||||
|
public partial class ThemeEditorView
|
||||||
|
{
|
||||||
|
public ThemeEditorView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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(
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common", "Filtra
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common.Tests", "Filtration.Common.Tests\Filtration.Common.Tests.csproj", "{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common.Tests", "Filtration.Common.Tests\Filtration.Common.Tests.csproj", "{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.LootExplosionStudio", "Filtration.LootExplosionStudio\Filtration.LootExplosionStudio.csproj", "{C8009B11-14D0-4421-94F0-9EF4603CB363}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.LootExplosionStudio.Tests", "Filtration.LootExplosionStudio.Tests\Filtration.LootExplosionStudio.Tests.csproj", "{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -63,6 +67,14 @@ Global
|
|||||||
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
<Application x:Class="Filtration.App"
|
<Application x:Class="Filtration.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||||
Startup="Application_Startup">
|
Startup="Application_Startup">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/Filtration.Common;component/Styles/SharedResourcesDictionary.xaml" />
|
||||||
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Generic.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Generic.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/windows8/silver.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Fluent;component/Themes/windows8/silver.xaml" />
|
||||||
<ResourceDictionary Source="Views/Styles/Colours.xaml" />
|
<ResourceDictionary Source="Views/Styles/Colours.xaml" />
|
||||||
@@ -20,9 +23,11 @@
|
|||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.RadioButton.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.RadioButton.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Scrollbars.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Scrollbars.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBox.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBox.xaml" />
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ListView.xaml" />
|
||||||
|
|
||||||
<ResourceDictionary Source="Views/CrossButton.xaml" />
|
<ResourceDictionary Source="Views/CrossButton.xaml" />
|
||||||
<ResourceDictionary Source="Views/IconsDictionary.xaml" />
|
<ResourceDictionary Source="Views/IconsDictionary.xaml" />
|
||||||
|
<ResourceDictionary Source="Views/ExpanderStyle.xaml" />
|
||||||
|
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" />
|
<Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" />
|
||||||
@@ -30,6 +35,14 @@
|
|||||||
<Style TargetType="ScrollBar" BasedOn="{StaticResource MetroScrollBar}" />
|
<Style TargetType="ScrollBar" BasedOn="{StaticResource MetroScrollBar}" />
|
||||||
<Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}" />
|
<Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<converters:BlockItemToRemoveEnabledVisibilityConverter x:Key="BlockItemToRemoveEnabledVisibilityConverter" />
|
||||||
|
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" />
|
||||||
|
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
|
||||||
|
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
|
||||||
|
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
|
||||||
|
<converters:AvailableThemeComponentsConverter x:Key="AvailableThemeComponentsConverter" />
|
||||||
|
</ResourceDictionary>
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
@@ -58,9 +57,9 @@ namespace Filtration
|
|||||||
.ForMember(dest => dest.IsExpanded,
|
.ForMember(dest => dest.IsExpanded,
|
||||||
opts => opts.UseValue(false));
|
opts => opts.UseValue(false));
|
||||||
|
|
||||||
Mapper.CreateMap<Theme, IThemeViewModel>().ConstructUsingServiceLocator();
|
Mapper.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
|
||||||
Mapper.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
|
Mapper.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
|
||||||
Mapper.CreateMap<IThemeViewModel, Theme>();
|
Mapper.CreateMap<IThemeEditorViewModel, Theme>();
|
||||||
|
|
||||||
Mapper.AssertConfigurationIsValid();
|
Mapper.AssertConfigurationIsValid();
|
||||||
|
|
||||||
|
|||||||
49
Filtration/Converters/AvailableThemeComponentsConverter.cs
Normal file
49
Filtration/Converters/AvailableThemeComponentsConverter.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,21 +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\BooleanVisibilityConverter.cs" />
|
|
||||||
<Compile Include="Converters\BooleanVisibilityConverterCopy.cs" />
|
|
||||||
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
|
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
|
||||||
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
|
|
||||||
<Compile Include="Converters\HashSignRemovalConverter.cs" />
|
<Compile Include="Converters\HashSignRemovalConverter.cs" />
|
||||||
<Compile Include="Converters\ItemRarityConverter.cs" />
|
<Compile Include="Converters\ItemRarityConverter.cs" />
|
||||||
<Compile Include="Converters\InverseBooleanVisibilityConverter.cs" />
|
|
||||||
<Compile Include="Converters\StringToVisibilityConverter.cs" />
|
|
||||||
<Compile Include="Converters\TreeViewMarginConverter.cs" />
|
<Compile Include="Converters\TreeViewMarginConverter.cs" />
|
||||||
<Compile Include="Extensions\EnumerationExtension.cs" />
|
<Compile Include="Extensions\EnumerationExtension.cs" />
|
||||||
<Compile Include="Extensions\HyperlinkExtensions.cs" />
|
<Compile Include="Extensions\HyperlinkExtensions.cs" />
|
||||||
@@ -158,7 +153,6 @@
|
|||||||
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
|
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
|
||||||
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
|
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
|
||||||
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
|
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
|
||||||
<Compile Include="Translators\ThemeComponentListBuilder.cs" />
|
|
||||||
<Compile Include="UserControls\AutoScrollingListBox.cs" />
|
<Compile Include="UserControls\AutoScrollingListBox.cs" />
|
||||||
<Compile Include="UserControls\BlockItemControl.xaml.cs">
|
<Compile Include="UserControls\BlockItemControl.xaml.cs">
|
||||||
<DependentUpon>BlockItemControl.xaml</DependentUpon>
|
<DependentUpon>BlockItemControl.xaml</DependentUpon>
|
||||||
@@ -170,6 +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" />
|
||||||
@@ -201,6 +198,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="UserControls\ThemeComponentSelectionControl.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Styles\ListBoxItem.xaml">
|
<Page Include="Views\Styles\ListBoxItem.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@@ -304,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>
|
||||||
@@ -372,6 +369,9 @@
|
|||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<Content Include="LICENSE.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="NLog.config">
|
<Content Include="NLog.config">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@@ -427,6 +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
339
Filtration/LICENSE.txt
Normal 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.
|
||||||
@@ -50,7 +50,7 @@ using System.Windows;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.6.*")]
|
[assembly: AssemblyVersion("0.7.*")]
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
BIN
Filtration/Resources/Icons/Add.ico
Normal file
BIN
Filtration/Resources/Icons/Add.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Filtration/Resources/Icons/ThemeComponentDelete.ico
Normal file
BIN
Filtration/Resources/Icons/ThemeComponentDelete.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Filtration/Resources/Icons/standby_disabled_icon.png
Normal file
BIN
Filtration/Resources/Icons/standby_disabled_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
BIN
Filtration/Resources/Icons/standby_enabled_icon.png
Normal file
BIN
Filtration/Resources/Icons/standby_enabled_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -1068,4 +1068,32 @@ Quartz Wand
|
|||||||
Sage Wand
|
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
|
||||||
@@ -33,4 +33,5 @@ Maps
|
|||||||
Fishing Rods
|
Fishing Rods
|
||||||
Map Fragments
|
Map Fragments
|
||||||
Hideout Doodads
|
Hideout Doodads
|
||||||
Microtransactions
|
Microtransactions
|
||||||
|
Divination Card
|
||||||
@@ -13,8 +13,7 @@ namespace Filtration.Services
|
|||||||
internal class UpdateCheckService : IUpdateCheckService
|
internal class UpdateCheckService : IUpdateCheckService
|
||||||
{
|
{
|
||||||
private readonly IHTTPService _httpService;
|
private readonly IHTTPService _httpService;
|
||||||
//private const string UpdateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml";
|
private const string UpdateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml";
|
||||||
private const string UpdateDataUrl = "http://xvar.net/filtration_version.xml";
|
|
||||||
|
|
||||||
public UpdateCheckService(IHTTPService httpService)
|
public UpdateCheckService(IHTTPService httpService)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ using Filtration.ObjectModel.BlockItemBaseTypes;
|
|||||||
using Filtration.ObjectModel.BlockItemTypes;
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
using Filtration.ObjectModel.Extensions;
|
using Filtration.ObjectModel.Extensions;
|
||||||
|
using Filtration.ObjectModel.ThemeEditor;
|
||||||
using Filtration.Utilities;
|
using Filtration.Utilities;
|
||||||
|
|
||||||
namespace Filtration.Translators
|
namespace Filtration.Translators
|
||||||
{
|
{
|
||||||
internal interface IItemFilterBlockTranslator
|
internal interface IItemFilterBlockTranslator
|
||||||
{
|
{
|
||||||
void InitialiseForExistingScript(ItemFilterScript script);
|
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
|
||||||
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString);
|
ThemeComponentCollection masterComponentCollection);
|
||||||
string TranslateItemFilterBlockToString(ItemFilterBlock block);
|
string TranslateItemFilterBlockToString(ItemFilterBlock block);
|
||||||
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
||||||
}
|
}
|
||||||
@@ -25,28 +26,24 @@ namespace Filtration.Translators
|
|||||||
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
|
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
|
||||||
{
|
{
|
||||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||||
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
|
|
||||||
private const string Indent = " ";
|
private const string Indent = " ";
|
||||||
private readonly string _newLine = Environment.NewLine + Indent;
|
private readonly string _newLine = Environment.NewLine + Indent;
|
||||||
|
private readonly string _disabledNewLine = Environment.NewLine + "#" + Indent;
|
||||||
|
private ThemeComponentCollection _masterComponentCollection;
|
||||||
|
|
||||||
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder, IThemeComponentListBuilder themeComponentListBuilder)
|
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||||
{
|
{
|
||||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||||
_themeComponentListBuilder = themeComponentListBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitialiseForExistingScript(ItemFilterScript script)
|
|
||||||
{
|
|
||||||
_themeComponentListBuilder.Initialise(script.ThemeComponents);
|
|
||||||
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||||
// and reading ItemFilterScripts from a file.
|
// and reading ItemFilterScripts from a file.
|
||||||
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString)
|
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString, ThemeComponentCollection masterComponentCollection)
|
||||||
{
|
{
|
||||||
|
_masterComponentCollection = masterComponentCollection;
|
||||||
var block = new ItemFilterBlock();
|
var block = new ItemFilterBlock();
|
||||||
var showHideFound = false;
|
var showHideFound = false;
|
||||||
|
|
||||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -67,6 +64,7 @@ namespace Filtration.Translators
|
|||||||
|
|
||||||
var adjustedLine = line.Replace("#", " # ");
|
var adjustedLine = line.Replace("#", " # ");
|
||||||
var trimmedLine = adjustedLine.TrimStart(' ');
|
var trimmedLine = adjustedLine.TrimStart(' ');
|
||||||
|
|
||||||
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
|
||||||
|
|
||||||
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
|
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
|
||||||
@@ -75,11 +73,25 @@ namespace Filtration.Translators
|
|||||||
case "Show":
|
case "Show":
|
||||||
showHideFound = true;
|
showHideFound = true;
|
||||||
block.Action = BlockAction.Show;
|
block.Action = BlockAction.Show;
|
||||||
|
block.Enabled = true;
|
||||||
AddBlockGroupToBlock(block, trimmedLine);
|
AddBlockGroupToBlock(block, trimmedLine);
|
||||||
break;
|
break;
|
||||||
case "Hide":
|
case "Hide":
|
||||||
showHideFound = true;
|
showHideFound = true;
|
||||||
block.Action = BlockAction.Hide;
|
block.Action = BlockAction.Hide;
|
||||||
|
block.Enabled = true;
|
||||||
|
AddBlockGroupToBlock(block, trimmedLine);
|
||||||
|
break;
|
||||||
|
case "ShowDisabled":
|
||||||
|
showHideFound = true;
|
||||||
|
block.Action = BlockAction.Show;
|
||||||
|
block.Enabled = false;
|
||||||
|
AddBlockGroupToBlock(block, trimmedLine);
|
||||||
|
break;
|
||||||
|
case "HideDisabled":
|
||||||
|
showHideFound = true;
|
||||||
|
block.Action = BlockAction.Hide;
|
||||||
|
block.Enabled = false;
|
||||||
AddBlockGroupToBlock(block, trimmedLine);
|
AddBlockGroupToBlock(block, trimmedLine);
|
||||||
break;
|
break;
|
||||||
case "ItemLevel":
|
case "ItemLevel":
|
||||||
@@ -300,9 +312,9 @@ namespace Filtration.Translators
|
|||||||
{
|
{
|
||||||
throw new Exception("Parsing error - unknown theme component type");
|
throw new Exception("Parsing error - unknown theme component type");
|
||||||
}
|
}
|
||||||
if (_themeComponentListBuilder.IsInitialised)
|
if (_masterComponentCollection != null)
|
||||||
{
|
{
|
||||||
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName,
|
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
|
||||||
blockItem.Color);
|
blockItem.Color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,12 +416,17 @@ namespace Filtration.Translators
|
|||||||
|
|
||||||
var outputString = string.Empty;
|
var outputString = string.Empty;
|
||||||
|
|
||||||
|
if (!block.Enabled)
|
||||||
|
{
|
||||||
|
outputString += "#Disabled Block Start" + Environment.NewLine;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(block.Description))
|
if (!string.IsNullOrEmpty(block.Description))
|
||||||
{
|
{
|
||||||
outputString += "# " + block.Description + Environment.NewLine;
|
outputString += "# " + block.Description + Environment.NewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputString += block.Action.GetAttributeDescription();
|
outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription();
|
||||||
|
|
||||||
if (block.BlockGroup != null)
|
if (block.BlockGroup != null)
|
||||||
{
|
{
|
||||||
@@ -421,9 +438,14 @@ 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,71 @@ 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('#');
|
||||||
|
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
|
||||||
|
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
||||||
|
|
||||||
|
// If we haven't found a Show or Hide line yet, then this is probably the block comment.
|
||||||
|
// Put its # back on and skip to the next line.
|
||||||
|
if (lineOption != "Show" && lineOption != "Hide" && showHideFound == false)
|
||||||
|
{
|
||||||
|
lines[i] = "#" + lines[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lineOption == "Show")
|
||||||
|
{
|
||||||
|
lines[i] = lines[i].Replace("Show", "ShowDisabled");
|
||||||
|
showHideFound = true;
|
||||||
|
}
|
||||||
|
else if (lineOption == "Hide")
|
||||||
|
{
|
||||||
|
lines[i] = lines[i].Replace("Hide", "HideDisabled");
|
||||||
|
showHideFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = linesToRemove.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
lines.RemoveAt(linesToRemove[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lines.Aggregate((c, n) => c + Environment.NewLine + n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
|
public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
|
||||||
@@ -37,6 +94,11 @@ namespace Filtration.Translators
|
|||||||
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
||||||
|
|
||||||
inputString = inputString.Replace("\t", "");
|
inputString = inputString.Replace("\t", "");
|
||||||
|
if (inputString.Contains("#Disabled Block Start"))
|
||||||
|
{
|
||||||
|
inputString = PreprocessDisabledBlocks(inputString);
|
||||||
|
}
|
||||||
|
|
||||||
var conditionBoundaries = IdentifyBlockBoundaries(inputString);
|
var conditionBoundaries = IdentifyBlockBoundaries(inputString);
|
||||||
|
|
||||||
var lines = Regex.Split(inputString, "\r\n|\r|\n");
|
var lines = Regex.Split(inputString, "\r\n|\r|\n");
|
||||||
@@ -55,8 +117,6 @@ namespace Filtration.Translators
|
|||||||
script.Description = script.Description.TrimEnd('\n').TrimEnd('\r');
|
script.Description = script.Description.TrimEnd('\n').TrimEnd('\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
_themeComponentListBuilder.Initialise();
|
|
||||||
|
|
||||||
// Extract each block from between boundaries and translate it into a ItemFilterBlock object
|
// Extract each block from between boundaries and translate it into a ItemFilterBlock object
|
||||||
// and add that object to the ItemFilterBlocks list
|
// and add that object to the ItemFilterBlocks list
|
||||||
for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next)
|
for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next)
|
||||||
@@ -66,12 +126,10 @@ namespace Filtration.Translators
|
|||||||
var block = new string[end - begin];
|
var block = new string[end - begin];
|
||||||
Array.Copy(lines, begin, block, 0, end - begin);
|
Array.Copy(lines, begin, block, 0, end - begin);
|
||||||
var blockString = string.Join("\r\n", block);
|
var blockString = string.Join("\r\n", block);
|
||||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString));
|
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString, script.ThemeComponents));
|
||||||
}
|
}
|
||||||
|
|
||||||
script.ThemeComponents = _themeComponentListBuilder.GetComponents();
|
|
||||||
_blockGroupHierarchyBuilder.Cleanup();
|
_blockGroupHierarchyBuilder.Cleanup();
|
||||||
_themeComponentListBuilder.Cleanup();
|
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +150,10 @@ namespace Filtration.Translators
|
|||||||
// as it represents the block description.
|
// as it represents the block description.
|
||||||
// currentLine > 2 caters for an edge case where the script description is a single line and the first
|
// currentLine > 2 caters for an edge case where the script description is a single line and the first
|
||||||
// block has no description. This prevents the script description from being assigned to the first block's description.
|
// block has no description. This prevents the script description from being assigned to the first block's description.
|
||||||
blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") && currentLine > 2 ? currentLine - 2 : currentLine - 1);
|
blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") &&
|
||||||
|
currentLine > 2
|
||||||
|
? currentLine - 2
|
||||||
|
: currentLine - 1);
|
||||||
}
|
}
|
||||||
previousLine = line;
|
previousLine = line;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using Filtration.ObjectModel.Enums;
|
|
||||||
using Filtration.ObjectModel.ThemeEditor;
|
|
||||||
|
|
||||||
namespace Filtration.Translators
|
|
||||||
{
|
|
||||||
internal interface IThemeComponentListBuilder
|
|
||||||
{
|
|
||||||
void Initialise();
|
|
||||||
void Initialise(List<ThemeComponent> themeComponents);
|
|
||||||
bool IsInitialised { get; }
|
|
||||||
ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor);
|
|
||||||
List<ThemeComponent> GetComponents();
|
|
||||||
void Cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class ThemeComponentListBuilder : IThemeComponentListBuilder
|
|
||||||
{
|
|
||||||
private List<ThemeComponent> _themeComponents;
|
|
||||||
|
|
||||||
public ThemeComponentListBuilder()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsInitialised
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _themeComponents != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialise()
|
|
||||||
{
|
|
||||||
_themeComponents = new List<ThemeComponent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialise(List<ThemeComponent> themeComponents)
|
|
||||||
{
|
|
||||||
_themeComponents = themeComponents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Cleanup()
|
|
||||||
{
|
|
||||||
_themeComponents = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
|
||||||
{
|
|
||||||
if (ComponentExists(componentType, componentName))
|
|
||||||
{
|
|
||||||
return _themeComponents.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
|
||||||
}
|
|
||||||
|
|
||||||
var component = new ThemeComponent(componentType, componentName, componentColor);
|
|
||||||
_themeComponents.Add(component);
|
|
||||||
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ThemeComponent> GetComponents()
|
|
||||||
{
|
|
||||||
return _themeComponents;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool ComponentExists(ThemeComponentType componentType, string componentName)
|
|
||||||
{
|
|
||||||
return _themeComponents.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,21 +13,6 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance Type=userControls:BlockItemControl}"
|
d:DataContext="{d:DesignInstance Type=userControls:BlockItemControl}"
|
||||||
d:DesignHeight="200" d:DesignWidth="150">
|
d:DesignHeight="200" d:DesignWidth="150">
|
||||||
<UserControl.Resources>
|
|
||||||
<ResourceDictionary>
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceDictionary>
|
|
||||||
<Style TargetType="{x:Type Border}" x:Key="BlockItemBorder">
|
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
|
||||||
<Setter Property="BorderBrush" Value="Black" />
|
|
||||||
<Setter Property="CornerRadius" Value="3" />
|
|
||||||
<Setter Property="Margin" Value="0,0,5,5" />
|
|
||||||
</Style>
|
|
||||||
</ResourceDictionary>
|
|
||||||
<ResourceDictionary Source="../Views/SharedResourcesDictionary.xaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
</UserControl.Resources>
|
|
||||||
<Border Style="{StaticResource BlockItemBorder}" Width="142">
|
<Border Style="{StaticResource BlockItemBorder}" Width="142">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@@ -86,7 +71,19 @@
|
|||||||
|
|
||||||
<!-- Color Template -->
|
<!-- Color Template -->
|
||||||
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}">
|
<DataTemplate DataType="{x:Type blockItemBaseTypes:ColorBlockItem}">
|
||||||
<xctk:ColorPicker SelectedColor="{Binding Color}" AvailableColors="{Binding ElementName=BlockItemContentControl, Path=DataContext.AvailableColors }" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
|
<StackPanel>
|
||||||
|
<xctk:ColorPicker SelectedColor="{Binding Color}" AvailableColors="{Binding ElementName=BlockItemContentControl, Path=DataContext.AvailableColors }" ShowAvailableColors="True" AvailableColorsHeader="Path of Exile Colors"/>
|
||||||
|
<userControls:ThemeComponentSelectionControl ThemeComponent="{Binding ThemeComponent}"
|
||||||
|
|
||||||
|
Margin="0,2,0,2">
|
||||||
|
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||||
|
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
|
||||||
|
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
|
||||||
|
<Binding Path="." />
|
||||||
|
</MultiBinding>
|
||||||
|
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
|
||||||
|
</userControls:ThemeComponentSelectionControl>
|
||||||
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<!-- Font Size Template -->
|
<!-- Font Size Template -->
|
||||||
|
|||||||
@@ -19,8 +19,12 @@ namespace Filtration.UserControls
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
// ReSharper disable once PossibleNullReferenceException
|
// ReSharper disable once PossibleNullReferenceException
|
||||||
(Content as FrameworkElement).DataContext = this;
|
(Content as FrameworkElement).DataContext = this;
|
||||||
|
|
||||||
|
SetBlockColorCommand = new RelayCommand(OnSetBlockColorCommmand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RelayCommand SetBlockColorCommand { get; private set; }
|
||||||
|
|
||||||
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
|
||||||
"BlockItem",
|
"BlockItem",
|
||||||
typeof(IItemFilterBlockItem),
|
typeof(IItemFilterBlockItem),
|
||||||
@@ -93,6 +97,14 @@ namespace Filtration.UserControls
|
|||||||
return new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
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;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
|||||||
@@ -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" />
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
79
Filtration/UserControls/ThemeComponentSelectionControl.xaml
Normal file
79
Filtration/UserControls/ThemeComponentSelectionControl.xaml
Normal 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>
|
||||||
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -72,9 +77,14 @@ namespace Filtration.ViewModels
|
|||||||
{
|
{
|
||||||
_activeScriptViewModel = (IItemFilterScriptViewModel) value;
|
_activeScriptViewModel = (IItemFilterScriptViewModel) value;
|
||||||
}
|
}
|
||||||
|
else if (value.IsTheme)
|
||||||
|
{
|
||||||
|
_activeThemeViewModel = (IThemeEditorViewModel) value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_activeScriptViewModel = null;
|
_activeScriptViewModel = null;
|
||||||
|
_activeThemeViewModel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ActiveDocumentChanged != null)
|
if (ActiveDocumentChanged != null)
|
||||||
@@ -91,6 +101,11 @@ namespace Filtration.ViewModels
|
|||||||
get { return _activeScriptViewModel; }
|
get { return _activeScriptViewModel; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IThemeEditorViewModel ActiveThemeViewModel
|
||||||
|
{
|
||||||
|
get { return _activeThemeViewModel; }
|
||||||
|
}
|
||||||
|
|
||||||
public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel
|
public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel
|
||||||
{
|
{
|
||||||
get { return _blockGroupBrowserViewModel; }
|
get { return _blockGroupBrowserViewModel; }
|
||||||
@@ -107,6 +122,7 @@ namespace Filtration.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<IToolViewModel> _tools;
|
private List<IToolViewModel> _tools;
|
||||||
|
|
||||||
|
|
||||||
public IEnumerable<IToolViewModel> Tools
|
public IEnumerable<IToolViewModel> Tools
|
||||||
{
|
{
|
||||||
@@ -127,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;
|
||||||
@@ -162,5 +182,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace Filtration.ViewModels
|
|||||||
bool IsDirty { get; set; }
|
bool IsDirty { get; set; }
|
||||||
bool IsExpanded { get; set; }
|
bool IsExpanded { get; set; }
|
||||||
ItemFilterBlock Block { get; }
|
ItemFilterBlock Block { get; }
|
||||||
|
bool BlockEnabled { get; set; }
|
||||||
void RefreshBlockPreview();
|
void RefreshBlockPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +210,20 @@ namespace Filtration.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool BlockEnabled
|
||||||
|
{
|
||||||
|
get { return Block.Enabled; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Block.Enabled != value)
|
||||||
|
{
|
||||||
|
Block.Enabled = value;
|
||||||
|
IsDirty = true;
|
||||||
|
RaisePropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string BlockDescription
|
public string BlockDescription
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ 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;
|
||||||
@@ -37,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; }
|
||||||
@@ -103,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);
|
||||||
@@ -127,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; }
|
||||||
@@ -214,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; }
|
||||||
@@ -326,6 +350,7 @@ namespace Filtration.ViewModels
|
|||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
if (!ValidateScript()) return;
|
if (!ValidateScript()) return;
|
||||||
|
if (!CheckForUnusedThemeComponents()) return;
|
||||||
|
|
||||||
if (_filenameIsFake)
|
if (_filenameIsFake)
|
||||||
{
|
{
|
||||||
@@ -353,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
|
||||||
{
|
{
|
||||||
@@ -387,6 +413,27 @@ namespace Filtration.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
@@ -468,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);
|
||||||
}
|
}
|
||||||
@@ -543,8 +597,7 @@ namespace Filtration.ViewModels
|
|||||||
var clipboardText = Clipboard.GetText();
|
var clipboardText = Clipboard.GetText();
|
||||||
if (clipboardText.IsNullOrEmpty()) return;
|
if (clipboardText.IsNullOrEmpty()) return;
|
||||||
|
|
||||||
_blockTranslator.InitialiseForExistingScript(Script);
|
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
|
||||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText);
|
|
||||||
if (translatedBlock == null) return;
|
if (translatedBlock == null) return;
|
||||||
|
|
||||||
var vm = _itemFilterBlockViewModelFactory.Create();
|
var vm = _itemFilterBlockViewModelFactory.Create();
|
||||||
@@ -737,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ 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;
|
||||||
@@ -47,6 +49,8 @@ namespace Filtration.ViewModels
|
|||||||
private readonly IUpdateCheckService _updateCheckService;
|
private readonly IUpdateCheckService _updateCheckService;
|
||||||
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
||||||
private readonly IMessageBoxService _messageBoxService;
|
private readonly IMessageBoxService _messageBoxService;
|
||||||
|
private bool _activeDocumentIsScript;
|
||||||
|
private bool _activeDocumentIsTheme;
|
||||||
|
|
||||||
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
||||||
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
||||||
@@ -71,7 +75,7 @@ namespace Filtration.ViewModels
|
|||||||
_messageBoxService = messageBoxService;
|
_messageBoxService = messageBoxService;
|
||||||
|
|
||||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
|
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => _activeDocumentIsScript);
|
||||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||||
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
||||||
|
|
||||||
@@ -79,30 +83,43 @@ namespace Filtration.ViewModels
|
|||||||
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
||||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
||||||
|
|
||||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
PasteCommand = new RelayCommand(OnPasteCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
|
|
||||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||||
|
|
||||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
|
||||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
|
||||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
|
||||||
|
|
||||||
|
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
|
||||||
|
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
|
||||||
|
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);
|
|
||||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => ActiveDocumentIsScript);
|
|
||||||
|
|
||||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => _activeDocumentIsScript);
|
||||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => _activeDocumentIsScript);
|
||||||
|
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => _activeDocumentIsScript);
|
||||||
|
|
||||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
|
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);
|
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
|
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||||
|
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
||||||
|
() =>
|
||||||
|
ActiveDocumentIsTheme && _activeDocumentIsTheme &&
|
||||||
|
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||||
|
|
||||||
|
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => _activeDocumentIsScript);
|
||||||
|
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => _activeDocumentIsScript);
|
||||||
|
|
||||||
|
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => _activeDocumentIsScript);
|
||||||
|
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => _activeDocumentIsScript);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
|
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
|
||||||
{
|
{
|
||||||
@@ -115,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)
|
||||||
@@ -129,7 +152,9 @@ namespace Filtration.ViewModels
|
|||||||
PasteCommand.RaiseCanExecuteChanged();
|
PasteCommand.RaiseCanExecuteChanged();
|
||||||
ReplaceColorsCommand.RaiseCanExecuteChanged();
|
ReplaceColorsCommand.RaiseCanExecuteChanged();
|
||||||
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
||||||
|
EditMasterThemeCommand.RaiseCanExecuteChanged();
|
||||||
CreateThemeCommand.RaiseCanExecuteChanged();
|
CreateThemeCommand.RaiseCanExecuteChanged();
|
||||||
|
SetActiveDocumentStatusProperties();
|
||||||
RaisePropertyChanged("ShowAdvancedStatus");
|
RaisePropertyChanged("ShowAdvancedStatus");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -146,6 +171,8 @@ namespace Filtration.ViewModels
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
CheckForUpdates();
|
CheckForUpdates();
|
||||||
|
ActiveDocumentIsScript = false;
|
||||||
|
ActiveDocumentIsTheme = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelayCommand OpenScriptCommand { get; private set; }
|
public RelayCommand OpenScriptCommand { get; private set; }
|
||||||
@@ -161,12 +188,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; }
|
||||||
@@ -244,14 +280,29 @@ namespace Filtration.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetActiveDocumentStatusProperties()
|
||||||
|
{
|
||||||
|
ActiveDocumentIsScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
|
||||||
|
ActiveDocumentIsTheme = AvalonDockWorkspaceViewModel.ActiveDocument is ThemeEditorViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
public bool ActiveDocumentIsScript
|
public bool ActiveDocumentIsScript
|
||||||
{
|
{
|
||||||
get
|
get { return _activeDocumentIsScript; }
|
||||||
|
private set
|
||||||
{
|
{
|
||||||
{
|
_activeDocumentIsScript = value;
|
||||||
var isScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
|
RaisePropertyChanged();
|
||||||
return isScript;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ActiveDocumentIsTheme
|
||||||
|
{
|
||||||
|
get { return _activeDocumentIsTheme; }
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
_activeDocumentIsTheme = value;
|
||||||
|
RaisePropertyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,9 +311,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()
|
||||||
@@ -283,16 +344,33 @@ namespace Filtration.ViewModels
|
|||||||
var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
|
var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
|
||||||
OpenTheme(themeViewModel);
|
OpenTheme(themeViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenTheme(IThemeViewModel themeViewModel)
|
private void OnEditMasterThemeCommand()
|
||||||
{
|
{
|
||||||
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeViewModel))
|
var openMasterThemForScript =
|
||||||
|
AvalonDockWorkspaceViewModel.OpenMasterThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel);
|
||||||
|
|
||||||
|
if (openMasterThemForScript != null)
|
||||||
{
|
{
|
||||||
AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeViewModel);
|
AvalonDockWorkspaceViewModel.SwitchActiveDocument(openMasterThemForScript);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AvalonDockWorkspaceViewModel.AddDocument(themeViewModel);
|
var themeViewModel =
|
||||||
|
_themeProvider.MasterThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
|
||||||
|
OpenTheme(themeViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenTheme(IThemeEditorViewModel themeEditorViewModel)
|
||||||
|
{
|
||||||
|
if (AvalonDockWorkspaceViewModel.OpenDocuments.Contains(themeEditorViewModel))
|
||||||
|
{
|
||||||
|
AvalonDockWorkspaceViewModel.SwitchActiveDocument(themeEditorViewModel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AvalonDockWorkspaceViewModel.AddDocument(themeEditorViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +419,7 @@ namespace Filtration.ViewModels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IThemeViewModel loadedViewModel;
|
IThemeEditorViewModel loadedViewModel;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -517,6 +595,16 @@ namespace Filtration.ViewModels
|
|||||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null);
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDisableBlockCommand()
|
||||||
|
{
|
||||||
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DisableBlockCommand.Execute(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnableBlockCommand()
|
||||||
|
{
|
||||||
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableBlockCommand.Execute(null);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnExpandAllBlocksCommand()
|
private void OnExpandAllBlocksCommand()
|
||||||
{
|
{
|
||||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);
|
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);
|
||||||
@@ -536,5 +624,26 @@ 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user