32 Commits

Author SHA1 Message Date
Ben
b97e3d1780 BlockitemBase 2015-07-10 17:22:30 +01:00
Ben
543446b23e LootExplosionStudio WIP commit 2015-07-10 17:21:35 +01:00
Ben
2278cbdc3a Put version number back to 0.7 2015-07-10 17:20:19 +01:00
Ben
45edbecd64 Initial item filter / loot item processing done 2015-07-09 22:05:42 +01:00
Ben
6e71005e93 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-09 18:58:27 +01:00
Ben
56e163e3e0 Fix for line description being lost when reading disabled blocks 2015-07-09 18:58:22 +01:00
Ben Wallis
c856bbcee7 updated screenshots 2015-07-06 19:14:28 +01:00
Ben Wallis
490496f2f7 Updated release to 0.7 2015-07-06 18:41:14 +01:00
Ben
9fcb609a51 Implemented disabled block support 2015-07-06 18:19:05 +01:00
Ben
1b63f68eee Fixed theme serialization/deserialization and added them toolbar icons 2015-07-06 15:33:25 +01:00
Ben
a496ab9b42 Resharper Code Issues Cleanup 2015-07-06 13:45:19 +01:00
Ben
cbbc7c25fa More theme changes 2015-07-06 13:41:46 +01:00
Ben
d6bd1678b4 Fixed contextual tabs 2015-07-06 12:01:48 +01:00
Ben
bfa2341ab8 Implemented editable themes / master themes 2015-07-05 22:43:17 +01:00
Ben
511f503e88 Refactored ThemeComponentBuilder into ThemeComponentCollection 2015-07-05 16:54:09 +01:00
Ben
3ea0530c01 Added Divination Cards to Classes and Base Types lookup lists 2015-07-05 16:19:45 +01:00
Ben
aad34b1407 Changed UpdateDataUrl back to correct url 2015-07-05 11:14:44 +01:00
Ben
544b931477 Added theme component tag selection control 2015-07-05 11:09:59 +01:00
Ben
f5dcdf0af9 Removed item block display settings popup 2015-07-04 22:38:13 +01:00
Ben
da3759cd76 Refactored ItemFilterBlockView to use new usercontrol instead of datatemplate spam 2015-07-04 21:12:47 +01:00
Ben
d586492de8 Added theme component tooltip in theme editor 2015-07-04 20:24:00 +01:00
Ben
3337531161 Fixed another copy paste bug, changed speaker icon to button 2015-07-04 17:28:34 +01:00
Ben
0c470b3c97 Fixed copy paste crashes 2015-07-04 16:47:28 +01:00
Ben
3a60a5005b Changed versioning format, added grouping to theme browser, fixed styles 2015-07-04 14:29:07 +01:00
Ben
8b6207e334 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-04 12:24:56 +01:00
Ben
fea6bf6da2 Fixed bug causing clicks between documents and toolpanes not to register. 2015-07-04 12:24:50 +01:00
Ben Wallis
b6d1befd23 Delete Filtration.exe.config 2015-07-03 22:56:26 +01:00
Ben Wallis
2475d90bac Delete LootFilterScriptViewModel - Copy.cs 2015-07-03 22:55:51 +01:00
Ben
aae014b6e0 Added NLog logging 2015-07-03 22:16:17 +01:00
Ben
aadd56c473 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-03 21:19:30 +01:00
Ben
8f533e8fd7 Fixed localised decimal bug and tidied up About Window 2015-07-03 21:19:25 +01:00
Ben Wallis
272b7e8360 Update README.md 2015-07-02 22:48:57 +01:00
135 changed files with 6677 additions and 1139 deletions

1
.gitignore vendored
View File

@@ -187,3 +187,4 @@ FakesAssemblies/
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
/Releases

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -49,11 +49,13 @@
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -62,8 +64,15 @@
<Reference Include="WindowsBase" />
</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="Services\FileSystemService.cs" />
<Compile Include="Services\MessageBoxService.cs" />
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
<Compile Include="ViewModels\PaneViewModel.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
@@ -77,6 +86,12 @@
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Styles\SharedResourcesDictionary.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</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.

View File

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

View File

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

View File

@@ -1,8 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converters="clr-namespace:Filtration.Common.Converters"
mc:Ignorable="d" >
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
@@ -31,15 +31,19 @@
</Setter.Value>
</Setter>
</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:BoolInverterConverter x:Key="BoolInverterConverter" />
<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:InverseBooleanVisibilityConverter x:Key="InverseBooleanVisibilityConverter" />
</ResourceDictionary>
<ResourceDictionary Source="ExpanderStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

View File

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

View File

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

View File

@@ -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")]

View File

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

View File

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

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

View File

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

View 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")]

View File

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

View File

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

View File

@@ -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);
}
}
}
}

View File

@@ -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);
}
}
}

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

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -46,10 +46,15 @@
<Reference Include="System.Xml" />
</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="TestItemFilterBlock.cs" />
<Compile Include="TestItemFilterBlockGroup.cs" />
<Compile Include="TestItemFilterScript.cs" />
<Compile Include="ThemeEditor\TestThemeComponentCollection.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
@@ -60,6 +65,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<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.

View File

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

View File

@@ -1,6 +1,7 @@
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemBaseTypes
{

View File

@@ -1,4 +1,6 @@
using System.Windows.Media;
using System;
using System.Windows.Media;
using Filtration.ObjectModel.LootExplosionStudio;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ObjectModel.BlockItemBaseTypes
@@ -6,6 +8,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem
{
private Color _color;
private ThemeComponent _themeComponent;
protected ColorBlockItem()
{
@@ -31,7 +34,28 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
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 SummaryTextColor { get { return Colors.Transparent; } }
@@ -45,5 +69,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
OnPropertyChanged();
}
}
private void OnThemeComponentUpdated(object sender, EventArgs e)
{
Color = ((ThemeComponent) sender).Color;
}
private void OnThemeComponentDeleted(object sender, EventArgs e)
{
ThemeComponent = null;
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Windows.Media;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemBaseTypes
{

View File

@@ -1,4 +1,5 @@
using System.Windows.Media;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemBaseTypes
{

View File

@@ -1,6 +1,7 @@
using System;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemBaseTypes
{
@@ -47,5 +48,45 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
OnPropertyChanged("FilterPredicate");
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;
}
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemBaseTypes
{
@@ -36,5 +37,12 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
OnPropertyChanged("Items");
OnPropertyChanged("SummaryText");
}
public abstract string GetLootItemProperty(LootItem lootItem);
public virtual bool MatchesLootItem(LootItem lootItem)
{
return Items.Any(i => i == GetLootItemProperty(lootItem));
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -56,5 +57,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
{
get { return 11; }
}
public override string GetLootItemProperty(LootItem lootItem)
{
return lootItem.BaseType;
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -50,5 +51,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
{
get { return 10; }
}
public override string GetLootItemProperty(LootItem lootItem)
{
return lootItem.Class;
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -68,5 +69,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return 100;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return lootItem.DropLevel;
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -65,5 +66,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return 6;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return lootItem.Height;
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -67,5 +68,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return 100;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return lootItem.ItemLevel;
}
}
}

View File

@@ -1,6 +1,8 @@
using System.Windows.Media;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -68,5 +70,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return 6;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return lootItem.SocketGroups.Where(c => c.Sockets.Count > 1).Sum(socketGroup => socketGroup.Sockets.Count);
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -68,5 +69,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return 20;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return lootItem.Quality;
}
}
}

View File

@@ -2,6 +2,7 @@
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -85,5 +86,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return (int)ItemRarity.Unique;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return (int)lootItem.Rarity;
}
}
}

View File

@@ -1,6 +1,10 @@
using System.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -47,5 +51,68 @@ namespace Filtration.ObjectModel.BlockItemTypes
{
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;
}
}
}

View File

@@ -1,6 +1,8 @@
using System.Windows.Media;
using System.Linq;
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -68,5 +70,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return 6;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return lootItem.SocketGroups.Sum(c => c.Sockets.Count());
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes
{
@@ -68,5 +69,10 @@ namespace Filtration.ObjectModel.BlockItemTypes
return 2;
}
}
public override int GetLootItemProperty(LootItem lootItem)
{
return lootItem.Width;
}
}
}

View File

@@ -41,7 +41,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BlockItemBaseTypes\ActionBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\BlockItembase.cs" />
<Compile Include="BlockItemBaseTypes\BlockItemBase.cs" />
<Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" />
@@ -77,12 +77,17 @@
<Compile Include="ItemFilterBlockGroup.cs" />
<Compile Include="ItemFilterScript.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="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReplaceColorsParameterSet.cs" />
<Compile Include="ThemeEditor\Theme.cs" />
<Compile Include="ThemeEditor\ThemeComponent.cs" />
<Compile Include="ThemeEditor\ThemeComponentCollection.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

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

View File

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

View File

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

View 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; }
}
}

View File

@@ -0,0 +1,9 @@
using System.Collections.ObjectModel;
namespace Filtration.ObjectModel.LootExplosionStudio
{
public class LootItemCollection : Collection<LootItem>
{
}
}

View 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; }
}
}

View File

@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
@@ -8,24 +10,28 @@ namespace Filtration.ObjectModel.ThemeEditor
[Serializable]
public class Theme
{
private readonly List<ThemeComponent> _components;
private readonly ThemeComponentCollection _components;
public Theme()
{
_components = new List<ThemeComponent>();
_components = new ThemeComponentCollection { IsMasterCollection = false};
}
public string Name { get; set; }
[XmlIgnore]
public string FilePath { get; set; }
public List<ThemeComponent> Components
public ThemeComponentCollection Components
{
get { return _components; }
}
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)

View File

@@ -1,12 +1,20 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Annotations;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
{
[Serializable]
public class ThemeComponent
public class ThemeComponent : INotifyPropertyChanged
{
private Color _color;
private EventHandler _themeComponentUpdatedEventHandler;
private readonly object _eventLock = new object();
public ThemeComponent()
{
@@ -24,8 +32,75 @@ namespace Filtration.ObjectModel.ThemeEditor
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 ThemeComponentType ComponentType{ get; set; }
public Color Color { get; set; }
public Color Color
{
get { return _color; }
set
{
_color = value;
OnPropertyChanged();
if (_themeComponentUpdatedEventHandler != null)
{
_themeComponentUpdatedEventHandler.Invoke(this, EventArgs.Empty);
}
}
}
public int UsageCount
{
get
{
if (_themeComponentUpdatedEventHandler == null)
{
return 0;
}
return _themeComponentUpdatedEventHandler.GetInvocationList().Length;
}
}
public void TerminateComponent()
{
if (ThemeComponentDeleted != null)
{
ThemeComponentDeleted.Invoke(this, EventArgs.Empty);
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

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

View File

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

View File

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

View File

@@ -25,6 +25,36 @@ namespace Filtration.Tests.Translators
_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]
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
{
@@ -33,7 +63,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem));
@@ -51,7 +81,7 @@ namespace Filtration.Tests.Translators
// Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
@@ -66,7 +96,7 @@ namespace Filtration.Tests.Translators
// Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(true, inputBlockGroup.IsChecked);
@@ -81,7 +111,7 @@ namespace Filtration.Tests.Translators
// Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(false, inputBlockGroup.IsChecked);
@@ -95,7 +125,7 @@ namespace Filtration.Tests.Translators
// Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
@@ -109,7 +139,7 @@ namespace Filtration.Tests.Translators
// Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
@@ -124,7 +154,7 @@ namespace Filtration.Tests.Translators
// Act
_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.AreEqual(testBlockGroup, result.BlockGroup);
@@ -138,7 +168,7 @@ namespace Filtration.Tests.Translators
var inputString = "Hide" + Environment.NewLine;
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem));
@@ -154,7 +184,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual("This is a test Block", result.Description);
@@ -174,7 +204,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual("Second Line", result.Description);
@@ -192,7 +222,7 @@ namespace Filtration.Tests.Translators
" DropLevel = 40";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
@@ -210,7 +240,7 @@ namespace Filtration.Tests.Translators
" Quality < 18";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
@@ -228,7 +258,7 @@ namespace Filtration.Tests.Translators
" Rarity > Normal";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
@@ -246,7 +276,7 @@ namespace Filtration.Tests.Translators
" Rarity Normal";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
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""";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
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""";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem));
@@ -301,7 +331,7 @@ namespace Filtration.Tests.Translators
" Sockets > 2";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
@@ -319,7 +349,7 @@ namespace Filtration.Tests.Translators
" LinkedSockets != 1";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
@@ -337,7 +367,7 @@ namespace Filtration.Tests.Translators
" Width != 1";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
@@ -355,7 +385,7 @@ namespace Filtration.Tests.Translators
" Height <= 3";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
@@ -373,7 +403,7 @@ namespace Filtration.Tests.Translators
" Height <=3";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem));
@@ -390,7 +420,7 @@ namespace Filtration.Tests.Translators
" SocketGroup RRGB";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem));
@@ -408,7 +438,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 255 20 100";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -426,7 +456,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 65 0 255 12";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -445,7 +475,7 @@ namespace Filtration.Tests.Translators
" SetBackgroundColor 255 20 100";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
@@ -464,7 +494,7 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 20 100";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -483,8 +513,8 @@ namespace Filtration.Tests.Translators
// Act
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString));
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null));
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -500,20 +530,17 @@ namespace Filtration.Tests.Translators
// Arrange
var inputString = "Show" + Environment.NewLine +
" SetTextColor 255 20 100 # Rare Item Text";
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "testComponent", new Color());
_testUtility.MockThemeComponentListBuilder.Setup(
t =>
t.AddComponent(ThemeComponentType.TextColor, "Rare Item Text",
new Color {A = 255, R = 255, G = 20, B = 100})).Returns(testComponent).Verifiable();
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, testInputThemeComponentCollection);
// Assert
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
Assert.AreSame(testComponent, blockItem.ThemeComponent);
_testUtility.MockThemeComponentListBuilder.Verify();
var firstComponent = testInputThemeComponentCollection.First();
Assert.AreEqual("Rare Item Text", firstComponent.ComponentName);
}
[Test]
@@ -525,7 +552,7 @@ namespace Filtration.Tests.Translators
" SetFontSize 15";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
@@ -542,7 +569,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 4";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -560,7 +587,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 2 95";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -577,7 +604,7 @@ namespace Filtration.Tests.Translators
var inputString = "# Section: " + TestInputSectionDescription;
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.IsInstanceOf<ItemFilterSection>(result);
@@ -610,7 +637,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 3";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual("Test filter with everything", result.Description);
@@ -692,7 +719,7 @@ namespace Filtration.Tests.Translators
" Quality < 17";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem));
@@ -721,7 +748,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 255 20 100";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -742,7 +769,7 @@ namespace Filtration.Tests.Translators
" SetFontSize 27" + Environment.NewLine;
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
@@ -761,7 +788,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 2" + Environment.NewLine;
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -779,7 +806,7 @@ namespace Filtration.Tests.Translators
" SetBackgroundColor 255 20 100";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
@@ -798,7 +825,7 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 20 100";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -1267,6 +1294,26 @@ namespace Filtration.Tests.Translators
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]
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
{
@@ -1346,6 +1393,26 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color);
}
[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")]
[Test]
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
@@ -1460,6 +1527,23 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
}
[Ignore("ThemeComponentBuilder deprecated")]
[Test]
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
testInputBlockItems.Add(testInputBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
}
private class ItemFilterBlockTranslatorTestUtility
{
public ItemFilterBlockTranslatorTestUtility()
@@ -1469,16 +1553,13 @@ namespace Filtration.Tests.Translators
// Mock setups
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
// Class under test instantiation
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object,
MockThemeComponentListBuilder.Object);
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object);
}
public ItemFilterBlock TestBlock { get; set; }
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
public ItemFilterBlockTranslator Translator { get; private set; }
}
}

View File

@@ -32,7 +32,7 @@ namespace Filtration.Tests.Translators
// Arrange
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
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
@@ -54,7 +54,7 @@ namespace Filtration.Tests.Translators
"End Script Description";
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
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
@@ -63,37 +63,6 @@ namespace Filtration.Tests.Translators
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")]
[Test]
public void TranslateStringToItemFilterScript_ThioleItemFilterTest()
@@ -101,10 +70,9 @@ namespace Filtration.Tests.Translators
// Arrange
var testInput = File.ReadAllText(@"Resources/ThioleItemFilter.txt");
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
_testUtility.MockThemeComponentListBuilder.Object);
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
translator.TranslateStringToItemFilterScript(testInput);
@@ -161,10 +129,9 @@ namespace Filtration.Tests.Translators
" Width = 3" + Environment.NewLine +
" SetFontSize 7" + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
_testUtility.MockThemeComponentListBuilder.Object);
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateItemFilterScriptToString(script);
@@ -207,10 +174,9 @@ namespace Filtration.Tests.Translators
" Width = 3" + Environment.NewLine +
" SetFontSize 7" + Environment.NewLine + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
_testUtility.MockThemeComponentListBuilder.Object);
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateItemFilterScriptToString(script);
@@ -251,10 +217,9 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 0 255" + Environment.NewLine +
" SetFontSize 25";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
_testUtility.MockThemeComponentListBuilder.Object);
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
@@ -275,10 +240,9 @@ namespace Filtration.Tests.Translators
Environment.NewLine +
"Show" + Environment.NewLine +
"BaseType \"Maelström Staff\"" + Environment.NewLine + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
_testUtility.MockThemeComponentListBuilder.Object);
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
@@ -289,6 +253,106 @@ namespace Filtration.Tests.Translators
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
{
public ItemFilterScriptTranslatorTestUtility()
@@ -296,16 +360,14 @@ namespace Filtration.Tests.Translators
// Mock setups
MockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
// 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 Mock<IItemFilterBlockTranslator> MockItemFilterBlockTranslator { get; private set; }
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
}
}
}

View File

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

View File

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

View File

@@ -1,7 +1,6 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
@@ -18,6 +17,22 @@ namespace Filtration.ThemeEditor.Converters
}
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();
}

View File

@@ -54,6 +54,9 @@
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
@@ -92,18 +95,19 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" />
<Compile Include="Messages\ThemeClosedMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\ThemeProvider.cs" />
<Compile Include="Services\ThemePersistenceService.cs" />
<Compile Include="Services\ThemeService.cs" />
<Compile Include="ViewModels\IThemeViewModelFactory.cs" />
<Compile Include="ViewModels\ThemeComponentViewModel.cs" />
<Compile Include="ViewModels\ThemeViewModel.cs" />
<Compile Include="ViewModels\ThemeEditorViewModel.cs" />
<Compile Include="Views\ThemeComponentControl.xaml.cs">
<DependentUpon>ThemeComponentControl.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ThemeControl.xaml.cs">
<DependentUpon>ThemeControl.xaml</DependentUpon>
<Compile Include="Views\ThemeEditorView.xaml.cs">
<DependentUpon>ThemeEditorView.xaml</DependentUpon>
</Compile>
<Compile Include="WindsorInstallers\ProvidersInstaller.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
@@ -129,7 +133,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ThemeControl.xaml">
<Page Include="Views\ThemeEditorView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>

View File

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

View File

@@ -1,4 +1,6 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using AutoMapper;
using Filtration.ObjectModel;
using Filtration.ObjectModel.ThemeEditor;
@@ -9,10 +11,11 @@ namespace Filtration.ThemeEditor.Providers
{
public interface IThemeProvider
{
IThemeViewModel NewThemeForScript(ItemFilterScript script);
IThemeViewModel LoadThemeFromFile(string filePath);
IThemeEditorViewModel NewThemeForScript(ItemFilterScript script);
IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script);
IThemeEditorViewModel LoadThemeFromFile(string filePath);
Theme LoadThemeModelFromFile(string filePath);
void SaveTheme(IThemeViewModel themeViewModel, string filePath);
void SaveTheme(IThemeEditorViewModel themeEditorViewModel, string filePath);
}
internal class ThemeProvider : IThemeProvider
@@ -26,20 +29,35 @@ namespace Filtration.ThemeEditor.Providers
_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();
themeViewModel.Initialise(themeComponentViewModels, true);
themeViewModel.InitialiseForNewTheme(themeComponentCollection);
themeViewModel.FilePath = "Untitled.filtertheme";
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 viewModel = Mapper.Map<IThemeViewModel>(model);
var viewModel = Mapper.Map<IThemeEditorViewModel>(model);
viewModel.FilePath = filePath;
return viewModel;
}
@@ -49,9 +67,9 @@ namespace Filtration.ThemeEditor.Providers
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);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,14 +3,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns: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: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"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeComponentViewModel}"
d:DesignHeight="40" d:DesignWidth="200">
d:DataContext="{d:DesignInstance Type=themeEditor:ThemeComponent}"
d:DesignHeight="100" d:DesignWidth="200">
<UserControl.Resources>
<converters:ThemeComponentTypeToStringConverter x:Key="ThemeComponentTypeToStringConverter" />
<commonConverters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
</UserControl.Resources>
<Grid Width="200">
<Grid.RowDefinitions>
@@ -18,8 +19,47 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding ComponentType, Converter={StaticResource ThemeComponentTypeToStringConverter}}" Foreground="Red" FontSize="10" />
<TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding ComponentName}" />
<xctk:ColorPicker Grid.Row="2" Grid.Column="0" SelectedColor="{Binding Color}" />
<Grid.Resources>
<DataTemplate x:Key="EditableComponentNameTemplate">
<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>
</UserControl>

View File

@@ -1,27 +0,0 @@
<UserControl x:Class="Filtration.ThemeEditor.Views.ThemeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:Filtration.ThemeEditor.ViewModels"
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ThemeViewModel}"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding Components}" Margin="10">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<views:ThemeComponentControl DataContext="{Binding}" Margin="10,5,10,5" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,6 +21,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common", "Filtra
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common.Tests", "Filtration.Common.Tests\Filtration.Common.Tests.csproj", "{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}"
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
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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}.Release|Any CPU.ActiveCfg = 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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

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

View File

@@ -1,18 +1,48 @@
<Application x:Class="Filtration.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Filtration.Converters"
Startup="Application_Startup">
<Application.Resources>
<ResourceDictionary>
<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/windows8/silver.xaml" />
<ResourceDictionary Source="Views/Styles/Colours.xaml" />
<ResourceDictionary Source="Views/Styles/CheckBox.xaml" />
<ResourceDictionary Source="Views/Styles/ListBoxItem.xaml" />
<ResourceDictionary Source="Views/Styles/TreeViewItem.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Sizes.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ComboBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.RadioButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Scrollbars.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.TextBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.ListView.xaml" />
<ResourceDictionary Source="Views/CrossButton.xaml" />
<ResourceDictionary Source="Views/IconsDictionary.xaml" />
<ResourceDictionary Source="Views/ExpanderStyle.xaml" />
<ResourceDictionary>
<Style TargetType="ComboBox" BasedOn="{StaticResource MetroComboBox}" />
<Style TargetType="ComboBoxItem" BasedOn="{StaticResource MetroComboBoxItem}" />
<Style TargetType="ScrollBar" BasedOn="{StaticResource MetroScrollBar}" />
<Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}" />
</ResourceDictionary>
<ResourceDictionary>
<converters:BlockItemToRemoveEnabledVisibilityConverter x:Key="BlockItemToRemoveEnabledVisibilityConverter" />
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" />
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
<converters:AvailableThemeComponentsConverter x:Key="AvailableThemeComponentsConverter" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

View File

@@ -1,5 +1,4 @@
using System;
using System.IO.Compression;
using System.Linq;
using System.Windows;
using System.Windows.Threading;
@@ -14,15 +13,19 @@ using Filtration.Properties;
using Filtration.ThemeEditor.ViewModels;
using Filtration.ViewModels;
using Filtration.Views;
using NLog;
namespace Filtration
{
public partial class App
{
private IWindsorContainer _container;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private void Application_Startup(object sender, StartupEventArgs e)
{
DispatcherUnhandledException += OnDispatcherUnhandledException;
_container = new WindsorContainer();
var propInjector = _container.Kernel.ComponentModelBuilder
@@ -54,12 +57,11 @@ namespace Filtration
.ForMember(dest => dest.IsExpanded,
opts => opts.UseValue(false));
Mapper.CreateMap<Theme, IThemeViewModel>().ConstructUsingServiceLocator();
Mapper.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
Mapper.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
Mapper.CreateMap<IThemeViewModel, Theme>();
Mapper.CreateMap<IThemeEditorViewModel, Theme>();
Mapper.AssertConfigurationIsValid();
DispatcherUnhandledException += OnDispatcherUnhandledException;
var mainWindow = _container.Resolve<IMainWindow>();
mainWindow.Show();
@@ -67,6 +69,7 @@ namespace Filtration
public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
_logger.Fatal(e.Exception);
var exception = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
var innerException = e.Exception.InnerException != null
? e.Exception.InnerException.Message + Environment.NewLine +

View File

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

View File

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

View File

@@ -64,6 +64,12 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro">
<HintPath>..\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.ObjectModel" />
@@ -78,7 +84,7 @@
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Fluent.Ribbon.3.4.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<HintPath>..\packages\MahApps.Metro.1.1.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
@@ -123,19 +129,16 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Converters\ActiveDocumentConverter.cs" />
<Compile Include="Converters\AvailableThemeComponentsConverter.cs" />
<Compile Include="Converters\BlockGroupAdvancedFillConverter.cs" />
<Compile Include="Converters\BlockGroupAdvancedColorConverter.cs" />
<Compile Include="Converters\BlockGroupVisibilityConverter.cs" />
<Compile Include="Converters\BlockItemTypeToStringConverter.cs" />
<Compile Include="Converters\BooleanInverterConverter.cs" />
<Compile Include="Converters\BooleanToBlockActionInverseConverter.cs" />
<Compile Include="Converters\BooleanToBlockActionConverter.cs" />
<Compile Include="Converters\BooleanVisibilityConverterCopy.cs" />
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
<Compile Include="Converters\BlockItemToRemoveEnabledVisibilityConverter.cs" />
<Compile Include="Converters\HashSignRemovalConverter.cs" />
<Compile Include="Converters\ItemRarityConverter.cs" />
<Compile Include="Converters\BooleanVisibilityConverter.cs" />
<Compile Include="Converters\StringToVisibilityConverter.cs" />
<Compile Include="Converters\TreeViewMarginConverter.cs" />
<Compile Include="Extensions\EnumerationExtension.cs" />
<Compile Include="Extensions\HyperlinkExtensions.cs" />
@@ -150,8 +153,10 @@
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
<Compile Include="Translators\ThemeComponentListBuilder.cs" />
<Compile Include="UserControls\AutoScrollingListBox.cs" />
<Compile Include="UserControls\BlockItemControl.xaml.cs">
<DependentUpon>BlockItemControl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\CrossButton.cs" />
<Compile Include="UserControls\EditableListBoxControl.xaml.cs">
<DependentUpon>EditableListBoxControl.xaml</DependentUpon>
@@ -159,6 +164,9 @@
<Compile Include="UserControls\ItemPreviewControl.xaml.cs">
<DependentUpon>ItemPreviewControl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\ThemeComponentSelectionControl.xaml.cs">
<DependentUpon>ThemeComponentSelectionControl.xaml</DependentUpon>
</Compile>
<Compile Include="Utilities\AutoMapperHelpers.cs" />
<Compile Include="Utilities\BlockGroupMapper.cs" />
<Compile Include="Utilities\LineReader.cs" />
@@ -186,6 +194,14 @@
<Compile Include="Views\SettingsPageView.xaml.cs">
<DependentUpon>SettingsPageView.xaml</DependentUpon>
</Compile>
<Page Include="UserControls\BlockItemControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControls\ThemeComponentSelectionControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Styles\ListBoxItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -194,9 +210,6 @@
<DependentUpon>BlockGroupBrowserView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\BlockTemplateSelector.cs" />
<Compile Include="Views\ItemFilterBlockDisplaySettingsView.xaml.cs">
<DependentUpon>ItemFilterBlockDisplaySettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ItemFilterScriptView.xaml.cs">
<DependentUpon>ItemFilterScriptView.xaml</DependentUpon>
</Compile>
@@ -256,6 +269,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Styles\TextBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Styles\TreeViewItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -280,10 +297,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ItemFilterBlockDisplaySettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ToolPanes\BlockOutputPreviewView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -292,10 +305,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SharedResourcesDictionary.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ItemFilterScriptView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -360,6 +369,15 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Content Include="LICENSE.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
@@ -409,6 +427,10 @@
<Resource Include="Resources\Icons\ReplaceColors.ico" />
<Resource Include="Resources\Icons\Theme.ico" />
<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">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

339
Filtration/LICENSE.txt Normal file
View File

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

View File

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

22
Filtration/NLog.config Normal file
View File

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

2479
Filtration/NLog.xsd Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -50,7 +50,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.4.*")]
[assembly: AssemblyVersion("0.7.*")]
[assembly: InternalsVisibleTo("Filtration.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

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

View File

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

View File

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

View File

@@ -10,13 +10,15 @@ using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.Utilities;
namespace Filtration.Translators
{
internal interface IItemFilterBlockTranslator
{
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString);
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
ThemeComponentCollection masterComponentCollection);
string TranslateItemFilterBlockToString(ItemFilterBlock block);
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
}
@@ -24,22 +26,24 @@ namespace Filtration.Translators
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
{
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
private const string 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;
_themeComponentListBuilder = themeComponentListBuilder;
}
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
// 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 showHideFound = false;
foreach (var line in new LineReader(() => new StringReader(inputString)))
{
@@ -60,6 +64,7 @@ namespace Filtration.Translators
var adjustedLine = line.Replace("#", " # ");
var trimmedLine = adjustedLine.TrimStart(' ');
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
@@ -68,11 +73,25 @@ namespace Filtration.Translators
case "Show":
showHideFound = true;
block.Action = BlockAction.Show;
block.Enabled = true;
AddBlockGroupToBlock(block, trimmedLine);
break;
case "Hide":
showHideFound = true;
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);
break;
case "ItemLevel":
@@ -293,14 +312,17 @@ namespace Filtration.Translators
{
throw new Exception("Parsing error - unknown theme component type");
}
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName, blockItem.Color);
if (_masterComponentCollection != null)
{
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
blockItem.Color);
}
}
return blockItem;
}
public void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems , string inputString)
public void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
{
// Reverse iterate to remove existing IAudioVisualBlockItems
for (var idx = blockItems.Count - 1; idx >= 0; idx--)
@@ -343,25 +365,6 @@ namespace Filtration.Translators
}
}
private void ReplaceColorBlockItem<T>(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString) where T : ColorBlockItem
{
var newBlockItem = GetColorBlockItemFromString<T>(inputString);
var existingBlockItem = blockItems.OfType<T>().FirstOrDefault();
blockItems.Remove(existingBlockItem);
blockItems.Add(newBlockItem);
}
private void ReplaceFontSizeBlockItem(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString)
{
var match = Regex.Match(inputString, @"\s+(\d+)");
if (!match.Success) return;
var newBlockItem = new FontSizeBlockItem(Convert.ToInt16(match.Value));
var existingBlockItem = blockItems.OfType<FontSizeBlockItem>().FirstOrDefault();
blockItems.Remove(existingBlockItem);
blockItems.Add(newBlockItem);
}
private void AddBlockGroupToBlock(ItemFilterBlock block, string inputString)
{
var blockGroupStart = inputString.IndexOf("#", StringComparison.Ordinal);
@@ -413,12 +416,17 @@ namespace Filtration.Translators
var outputString = string.Empty;
if (!block.Enabled)
{
outputString += "#Disabled Block Start" + Environment.NewLine;
}
if (!string.IsNullOrEmpty(block.Description))
{
outputString += "# " + block.Description + Environment.NewLine;
}
outputString += block.Action.GetAttributeDescription();
outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription();
if (block.BlockGroup != null)
{
@@ -430,10 +438,15 @@ namespace Filtration.Translators
{
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;
}
}

Some files were not shown because too many files have changed in this diff Show More