9 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
57 changed files with 1807 additions and 32 deletions

1
.gitignore vendored
View File

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

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,6 +46,10 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BlockItemBaseTypes\TestBaseTypeBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\TestClassBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\TestItemLevelBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\TestSocketGroupBlockItem.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestItemFilterBlock.cs" /> <Compile Include="TestItemFilterBlock.cs" />
<Compile Include="TestItemFilterBlockGroup.cs" /> <Compile Include="TestItemFilterBlockGroup.cs" />

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
using System; using System;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions; using Filtration.ObjectModel.Extensions;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
@@ -47,5 +48,45 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
OnPropertyChanged("FilterPredicate"); OnPropertyChanged("FilterPredicate");
OnPropertyChanged("SummaryText"); OnPropertyChanged("SummaryText");
} }
public abstract int GetLootItemProperty(LootItem lootItem);
public virtual bool MatchesLootItem(LootItem lootItem)
{
var lootItemProperty = GetLootItemProperty(lootItem);
var predicateOperand = FilterPredicate.PredicateOperand;
switch (FilterPredicate.PredicateOperator)
{
case FilterPredicateOperator.Equal:
{
return lootItemProperty == predicateOperand;
}
case FilterPredicateOperator.GreaterThan:
{
return lootItemProperty > predicateOperand;
}
case FilterPredicateOperator.GreaterThanOrEqual:
{
return lootItemProperty >= predicateOperand;
}
case FilterPredicateOperator.LessThan:
{
return lootItemProperty < predicateOperand;
}
case FilterPredicateOperator.LessThanOrEqual:
{
return lootItemProperty <= predicateOperand;
}
case FilterPredicateOperator.NotEqual:
{
return lootItemProperty != predicateOperand;
}
default:
return false;
}
}
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,10 @@
using System.Linq; using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using Filtration.ObjectModel.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.LootExplosionStudio;
namespace Filtration.ObjectModel.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
@@ -47,5 +51,68 @@ namespace Filtration.ObjectModel.BlockItemTypes
{ {
get { return 9; } get { return 9; }
} }
public override string GetLootItemProperty(LootItem lootItem)
{
return lootItem.SocketGroups.ToString();
}
public override bool MatchesLootItem(LootItem lootItem)
{
foreach (var socketGroupString in Items)
{
var socketColorList = SocketGroupStringToSocketColors(socketGroupString);
if (
lootItem.SocketGroups.Any(
g =>
g.Sockets.Count(s => s == SocketColor.Red) >=
socketColorList.Count(l => l == SocketColor.Red) &&
g.Sockets.Count(s => s == SocketColor.Green) >=
socketColorList.Count(l => l == SocketColor.Green) &&
g.Sockets.Count(s => s == SocketColor.Blue) >=
socketColorList.Count(l => l == SocketColor.Blue) &&
g.Sockets.Count(s => s == SocketColor.White) >=
socketColorList.Count(l => l == SocketColor.White)))
{
return true;
}
}
return false;
}
private List<SocketColor> SocketGroupStringToSocketColors(string socketGroupString)
{
var socketColorList = new List<SocketColor>();
foreach (var c in socketGroupString.ToCharArray())
{
switch (c)
{
case 'R':
{
socketColorList.Add(SocketColor.Red);
break;
}
case 'G':
{
socketColorList.Add(SocketColor.Green);
break;
}
case 'B':
{
socketColorList.Add(SocketColor.Blue);
break;
}
case 'W':
{
socketColorList.Add(SocketColor.White);
break;
}
}
}
return socketColorList;
}
} }
} }

View File

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

View File

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

View File

@@ -41,7 +41,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BlockItemBaseTypes\ActionBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\ActionBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\BlockItembase.cs" /> <Compile Include="BlockItemBaseTypes\BlockItemBase.cs" />
<Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" /> <Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" />
@@ -77,6 +77,10 @@
<Compile Include="ItemFilterBlockGroup.cs" /> <Compile Include="ItemFilterBlockGroup.cs" />
<Compile Include="ItemFilterScript.cs" /> <Compile Include="ItemFilterScript.cs" />
<Compile Include="ItemFilterSection.cs" /> <Compile Include="ItemFilterSection.cs" />
<Compile Include="LootExplosionStudio\DefaultLootItemAppearanceConstants.cs" />
<Compile Include="LootExplosionStudio\LootItem.cs" />
<Compile Include="LootExplosionStudio\LootItemCollection.cs" />
<Compile Include="LootExplosionStudio\SocketGroup.cs" />
<Compile Include="NumericFilterPredicate.cs" /> <Compile Include="NumericFilterPredicate.cs" />
<Compile Include="Properties\Annotations.cs" /> <Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

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

View File

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

@@ -25,6 +25,36 @@ namespace Filtration.Tests.Translators
_testUtility = new ItemFilterBlockTranslatorTestUtility(); _testUtility = new ItemFilterBlockTranslatorTestUtility();
} }
[Test]
public void TranslateStringToItemFilterBlock_NotDisabled_SetsBlockEnabledTrue()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(true, result.Enabled);
}
[Test]
public void TranslateStringToItemFilterBlock_DisabledBlock_SetsBlockEnabledFalse()
{
// Arrange
var inputString = "HideDisabled" + Environment.NewLine +
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(2, result.BlockItems.Count);
Assert.AreEqual(BlockAction.Hide, result.Action);
Assert.AreEqual(false, result.Enabled);
}
[Test] [Test]
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
{ {
@@ -1264,6 +1294,26 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
} }
[Test]
public void TranslateItemFilterBlockToString_DisabledBlock_ReturnsCorrectString()
{
// Arrange
var expectedResult = "#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# Width = 4" + Environment.NewLine +
"#Disabled Block End";
_testUtility.TestBlock.Enabled = false;
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4));
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
// Assert
Assert.AreEqual(expectedResult, result);
}
[Test] [Test]
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString() public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
{ {

View File

@@ -253,6 +253,106 @@ namespace Filtration.Tests.Translators
Assert.IsNullOrEmpty(firstBlock.Description); Assert.IsNullOrEmpty(firstBlock.Description);
} }
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlockCount()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine +
" SetTextColor 255 255 0";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlocks()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine +
" SetTextColor 255 255 0";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
var firstBlock = result.ItemFilterBlocks.First();
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
var thirdBlock = result.ItemFilterBlocks.Skip(2).First();
Assert.AreEqual(3, firstBlock.BlockItems.Count);
Assert.AreEqual(5, secondBlock.BlockItems.Count);
Assert.AreEqual(3, thirdBlock.BlockItems.Count);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_BlockDescriptionNotLost()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"# This is a disabled block" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"#Disabled Block End";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
Assert.AreEqual("This is a disabled block", secondBlock.Description);
}
private class ItemFilterScriptTranslatorTestUtility private class ItemFilterScriptTranslatorTestUtility
{ {
public ItemFilterScriptTranslatorTestUtility() public ItemFilterScriptTranslatorTestUtility()

View File

@@ -21,6 +21,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common", "Filtra
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common.Tests", "Filtration.Common.Tests\Filtration.Common.Tests.csproj", "{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.Common.Tests", "Filtration.Common.Tests\Filtration.Common.Tests.csproj", "{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.LootExplosionStudio", "Filtration.LootExplosionStudio\Filtration.LootExplosionStudio.csproj", "{C8009B11-14D0-4421-94F0-9EF4603CB363}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.LootExplosionStudio.Tests", "Filtration.LootExplosionStudio.Tests\Filtration.LootExplosionStudio.Tests.csproj", "{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -63,6 +67,14 @@ Global
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Debug|Any CPU.Build.0 = Debug|Any CPU {1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.ActiveCfg = Release|Any CPU {1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.Build.0 = Release|Any CPU {1E42A658-45C4-4DD9-83C5-2A10728DBDFA}.Release|Any CPU.Build.0 = Release|Any CPU
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8009B11-14D0-4421-94F0-9EF4603CB363}.Release|Any CPU.Build.0 = Release|Any CPU
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56D0887E-B10D-4F9C-A88E-09CF8E8E06E3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -429,6 +429,8 @@
<Resource Include="Resources\Icons\filtration_icon.png" /> <Resource Include="Resources\Icons\filtration_icon.png" />
<Resource Include="Resources\Icons\Add.ico" /> <Resource Include="Resources\Icons\Add.ico" />
<Resource Include="Resources\Icons\ThemeComponentDelete.ico" /> <Resource Include="Resources\Icons\ThemeComponentDelete.ico" />
<Resource Include="Resources\Icons\standby_disabled_icon.png" />
<Resource Include="Resources\Icons\standby_enabled_icon.png" />
<Content Include="Resources\ItemBaseTypes.txt"> <Content Include="Resources\ItemBaseTypes.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -28,6 +28,7 @@ namespace Filtration.Translators
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder; private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
private const string Indent = " "; private const string Indent = " ";
private readonly string _newLine = Environment.NewLine + Indent; private readonly string _newLine = Environment.NewLine + Indent;
private readonly string _disabledNewLine = Environment.NewLine + "#" + Indent;
private ThemeComponentCollection _masterComponentCollection; private ThemeComponentCollection _masterComponentCollection;
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder) public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
@@ -42,6 +43,7 @@ namespace Filtration.Translators
_masterComponentCollection = masterComponentCollection; _masterComponentCollection = masterComponentCollection;
var block = new ItemFilterBlock(); var block = new ItemFilterBlock();
var showHideFound = false; var showHideFound = false;
foreach (var line in new LineReader(() => new StringReader(inputString))) foreach (var line in new LineReader(() => new StringReader(inputString)))
{ {
@@ -62,6 +64,7 @@ namespace Filtration.Translators
var adjustedLine = line.Replace("#", " # "); var adjustedLine = line.Replace("#", " # ");
var trimmedLine = adjustedLine.TrimStart(' '); var trimmedLine = adjustedLine.TrimStart(' ');
var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length; var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;
var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos); var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
@@ -70,11 +73,25 @@ namespace Filtration.Translators
case "Show": case "Show":
showHideFound = true; showHideFound = true;
block.Action = BlockAction.Show; block.Action = BlockAction.Show;
block.Enabled = true;
AddBlockGroupToBlock(block, trimmedLine); AddBlockGroupToBlock(block, trimmedLine);
break; break;
case "Hide": case "Hide":
showHideFound = true; showHideFound = true;
block.Action = BlockAction.Hide; block.Action = BlockAction.Hide;
block.Enabled = true;
AddBlockGroupToBlock(block, trimmedLine);
break;
case "ShowDisabled":
showHideFound = true;
block.Action = BlockAction.Show;
block.Enabled = false;
AddBlockGroupToBlock(block, trimmedLine);
break;
case "HideDisabled":
showHideFound = true;
block.Action = BlockAction.Hide;
block.Enabled = false;
AddBlockGroupToBlock(block, trimmedLine); AddBlockGroupToBlock(block, trimmedLine);
break; break;
case "ItemLevel": case "ItemLevel":
@@ -399,12 +416,17 @@ namespace Filtration.Translators
var outputString = string.Empty; var outputString = string.Empty;
if (!block.Enabled)
{
outputString += "#Disabled Block Start" + Environment.NewLine;
}
if (!string.IsNullOrEmpty(block.Description)) if (!string.IsNullOrEmpty(block.Description))
{ {
outputString += "# " + block.Description + Environment.NewLine; outputString += "# " + block.Description + Environment.NewLine;
} }
outputString += block.Action.GetAttributeDescription(); outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription();
if (block.BlockGroup != null) if (block.BlockGroup != null)
{ {
@@ -416,10 +438,15 @@ namespace Filtration.Translators
{ {
if (blockItem.OutputText != string.Empty) if (blockItem.OutputText != string.Empty)
{ {
outputString += _newLine + blockItem.OutputText; outputString += (!block.Enabled ? _disabledNewLine : _newLine) + blockItem.OutputText;
} }
} }
if (!block.Enabled)
{
outputString += Environment.NewLine + "#Disabled Block End";
}
return outputString; return outputString;
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Documents;
using Castle.Core.Internal; using Castle.Core.Internal;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.Properties; using Filtration.Properties;
@@ -28,12 +29,76 @@ namespace Filtration.Translators
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder; _blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
} }
public string PreprocessDisabledBlocks(string inputString)
{
bool inDisabledBlock = false;
var showHideFound = false;
var lines = Regex.Split(inputString, "\r\n|\r|\n").ToList();
var linesToRemove = new List<int>();
for (var i = 0; i < lines.Count; i++)
{
if (lines[i].StartsWith("#Disabled Block Start"))
{
inDisabledBlock = true;
linesToRemove.Add(i);
continue;
}
if (inDisabledBlock)
{
if (lines[i].StartsWith("#Disabled Block End"))
{
inDisabledBlock = false;
showHideFound = false;
linesToRemove.Add(i);
continue;
}
lines[i] = lines[i].TrimStart('#');
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
// If we haven't found a Show or Hide line yet, then this is probably the block comment.
// Put its # back on and skip to the next line.
if (lineOption != "Show" && lineOption != "Hide" && showHideFound == false)
{
lines[i] = "#" + lines[i];
continue;
}
if (lineOption == "Show")
{
lines[i] = lines[i].Replace("Show", "ShowDisabled");
showHideFound = true;
}
else if (lineOption == "Hide")
{
lines[i] = lines[i].Replace("Hide", "HideDisabled");
showHideFound = true;
}
}
}
for (var i = linesToRemove.Count - 1; i >= 0; i--)
{
lines.RemoveAt(linesToRemove[i]);
}
return lines.Aggregate((c, n) => c + Environment.NewLine + n);
}
public ItemFilterScript TranslateStringToItemFilterScript(string inputString) public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
{ {
var script = new ItemFilterScript(); var script = new ItemFilterScript();
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First()); _blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
inputString = inputString.Replace("\t", ""); inputString = inputString.Replace("\t", "");
if (inputString.Contains("#Disabled Block Start"))
{
inputString = PreprocessDisabledBlocks(inputString);
}
var conditionBoundaries = IdentifyBlockBoundaries(inputString); var conditionBoundaries = IdentifyBlockBoundaries(inputString);
var lines = Regex.Split(inputString, "\r\n|\r|\n"); var lines = Regex.Split(inputString, "\r\n|\r|\n");
@@ -85,7 +150,10 @@ namespace Filtration.Translators
// as it represents the block description. // as it represents the block description.
// currentLine > 2 caters for an edge case where the script description is a single line and the first // currentLine > 2 caters for an edge case where the script description is a single line and the first
// block has no description. This prevents the script description from being assigned to the first block's description. // block has no description. This prevents the script description from being assigned to the first block's description.
blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") && currentLine > 2 ? currentLine - 2 : currentLine - 1); blockBoundaries.AddLast(previousLine.StartsWith("#") && !previousLine.StartsWith("# Section:") &&
currentLine > 2
? currentLine - 2
: currentLine - 1);
} }
previousLine = line; previousLine = line;
} }

View File

@@ -21,6 +21,7 @@ namespace Filtration.ViewModels
bool IsDirty { get; set; } bool IsDirty { get; set; }
bool IsExpanded { get; set; } bool IsExpanded { get; set; }
ItemFilterBlock Block { get; } ItemFilterBlock Block { get; }
bool BlockEnabled { get; set; }
void RefreshBlockPreview(); void RefreshBlockPreview();
} }
@@ -209,6 +210,20 @@ namespace Filtration.ViewModels
} }
} }
public bool BlockEnabled
{
get { return Block.Enabled; }
set
{
if (Block.Enabled != value)
{
Block.Enabled = value;
IsDirty = true;
RaisePropertyChanged();
}
}
}
public string BlockDescription public string BlockDescription
{ {
get get

View File

@@ -38,9 +38,13 @@ namespace Filtration.ViewModels
void Initialise(ItemFilterScript itemFilterScript, bool newScript); void Initialise(ItemFilterScript itemFilterScript, bool newScript);
void RemoveDirtyFlag(); void RemoveDirtyFlag();
void SetDirtyFlag(); void SetDirtyFlag();
bool HasSelectedEnabledBlock();
bool HasSelectedDisabledBlock();
RelayCommand AddBlockCommand { get; } RelayCommand AddBlockCommand { get; }
RelayCommand AddSectionCommand { get; } RelayCommand AddSectionCommand { get; }
RelayCommand DisableBlockCommand { get; }
RelayCommand EnableBlockCommand { get; }
RelayCommand DeleteBlockCommand { get; } RelayCommand DeleteBlockCommand { get; }
RelayCommand MoveBlockUpCommand { get; } RelayCommand MoveBlockUpCommand { get; }
RelayCommand MoveBlockDownCommand { get; } RelayCommand MoveBlockDownCommand { get; }
@@ -104,6 +108,8 @@ namespace Filtration.ViewModels
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null); MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => SelectedBlockViewModel != null);
AddBlockCommand = new RelayCommand(OnAddBlockCommand); AddBlockCommand = new RelayCommand(OnAddBlockCommand);
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null); AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => SelectedBlockViewModel != null);
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand, HasSelectedEnabledBlock);
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand, HasSelectedDisabledBlock);
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null); CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => SelectedBlockViewModel != null);
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null); CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => SelectedBlockViewModel != null);
PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null); PasteBlockCommand = new RelayCommand(OnPasteBlockCommand, () => SelectedBlockViewModel != null);
@@ -128,6 +134,8 @@ namespace Filtration.ViewModels
public RelayCommand MoveBlockToBottomCommand { get; private set; } public RelayCommand MoveBlockToBottomCommand { get; private set; }
public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddBlockCommand { get; private set; }
public RelayCommand AddSectionCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; }
public RelayCommand EnableBlockCommand { get; private set; }
public RelayCommand DisableBlockCommand { get; private set; }
public RelayCommand CopyBlockCommand { get; private set; } public RelayCommand CopyBlockCommand { get; private set; }
public RelayCommand CopyBlockStyleCommand { get; private set; } public RelayCommand CopyBlockStyleCommand { get; private set; }
public RelayCommand PasteBlockCommand { get; private set; } public RelayCommand PasteBlockCommand { get; private set; }
@@ -215,6 +223,21 @@ namespace Filtration.ViewModels
} }
} }
public bool HasSelectedBlock()
{
return SelectedBlockViewModel != null;
}
public bool HasSelectedEnabledBlock()
{
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && SelectedBlockViewModel.BlockEnabled;
}
public bool HasSelectedDisabledBlock()
{
return HasSelectedBlock() && !(SelectedBlockViewModel.Block is ItemFilterSection) && !SelectedBlockViewModel.BlockEnabled;
}
public IItemFilterBlockViewModel SelectedBlockViewModel public IItemFilterBlockViewModel SelectedBlockViewModel
{ {
get { return _selectedBlockViewModel; } get { return _selectedBlockViewModel; }
@@ -767,5 +790,25 @@ namespace Filtration.ViewModels
} }
SelectedBlockViewModel = null; SelectedBlockViewModel = null;
} }
private void OnDisableBlockCommand()
{
DisableBlock(SelectedBlockViewModel);
}
private void DisableBlock(IItemFilterBlockViewModel targetBlockViewModel)
{
targetBlockViewModel.BlockEnabled = false;
}
private void OnEnableBlockCommand()
{
EnableBlock(SelectedBlockViewModel);
}
private void EnableBlock(IItemFilterBlockViewModel targetBlockViewModel)
{
targetBlockViewModel.BlockEnabled = true;
}
} }
} }

View File

@@ -96,7 +96,10 @@ namespace Filtration.ViewModels
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript); AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript); AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock); DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
() => _activeDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
() => _activeDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand); OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => _activeDocumentIsScript); ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => _activeDocumentIsScript);
@@ -198,6 +201,8 @@ namespace Filtration.ViewModels
public RelayCommand AddBlockCommand { get; private set; } public RelayCommand AddBlockCommand { get; private set; }
public RelayCommand AddSectionCommand { get; private set; } public RelayCommand AddSectionCommand { get; private set; }
public RelayCommand DeleteBlockCommand { get; private set; } public RelayCommand DeleteBlockCommand { get; private set; }
public RelayCommand DisableBlockCommand { get; private set; }
public RelayCommand EnableBlockCommand { get; private set; }
public RelayCommand MoveBlockUpCommand { get; private set; } public RelayCommand MoveBlockUpCommand { get; private set; }
public RelayCommand MoveBlockDownCommand { get; private set; } public RelayCommand MoveBlockDownCommand { get; private set; }
@@ -306,6 +311,16 @@ namespace Filtration.ViewModels
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; } get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; }
} }
public bool ActiveScriptHasSelectedEnabledBlock
{
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedEnabledBlock(); }
}
public bool ActiveScriptHasSelectedDisabledBlock
{
get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedDisabledBlock(); }
}
public bool ActiveThemeIsEditable public bool ActiveThemeIsEditable
{ {
get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; } get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; }
@@ -580,6 +595,16 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null); _avalonDockWorkspaceViewModel.ActiveScriptViewModel.DeleteBlockCommand.Execute(null);
} }
private void OnDisableBlockCommand()
{
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.DisableBlockCommand.Execute(null);
}
private void OnEnableBlockCommand()
{
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.EnableBlockCommand.Execute(null);
}
private void OnExpandAllBlocksCommand() private void OnExpandAllBlocksCommand()
{ {
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null); _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ExpandAllBlocksCommand.Execute(null);

View File

@@ -31,4 +31,6 @@
<Image Source="/Filtration;component/Resources/Icons/filtration_icon.png" x:Key="FiltrationIcon" x:Shared="False" /> <Image Source="/Filtration;component/Resources/Icons/filtration_icon.png" x:Key="FiltrationIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/Add.ico" x:Key="AddIcon" x:Shared="False" /> <Image Source="/Filtration;component/Resources/Icons/Add.ico" x:Key="AddIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/ThemeComponentDelete.ico" x:Key="ThemeComponentDeleteIcon" x:Shared="False" /> <Image Source="/Filtration;component/Resources/Icons/ThemeComponentDelete.ico" x:Key="ThemeComponentDeleteIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/standby_enabled_icon.png" x:Key="StandbyEnabledIcon" x:Shared="False" />
<Image Source="/Filtration;component/Resources/Icons/standby_disabled_icon.png" x:Key="StandbyDisabledIcon" x:Shared="False" />
</ResourceDictionary> </ResourceDictionary>

View File

@@ -41,6 +41,11 @@
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid x:Name="TopLevelGrid"> <Grid x:Name="TopLevelGrid">
<Grid x:Name="DisabledBlockOverlay" IsHitTestVisible="False" Panel.ZIndex="1000" Visibility="{Binding BlockEnabled, Converter={StaticResource InverseBooleanVisibilityConverter}}">
<Grid.Background>
<SolidColorBrush Color="Gray" Opacity=".5" />
</Grid.Background>
</Grid>
<Border BorderThickness="1" BorderBrush="SlateGray" CornerRadius="2" Background="White"> <Border BorderThickness="1" BorderBrush="SlateGray" CornerRadius="2" Background="White">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -62,8 +67,8 @@
<Expander.ContextMenu> <Expander.ContextMenu>
<ContextMenu> <ContextMenu>
<ContextMenu.Items> <ContextMenu.Items>
<MenuItem Header="Copy" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" /> <MenuItem Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" />
<MenuItem Header="Paste" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" /> <MenuItem Header="Paste Block" Command="{Binding PasteBlockCommand}" Icon="{StaticResource PasteIcon}" />
<Separator /> <Separator />
<MenuItem Header="Block Style"> <MenuItem Header="Block Style">
<MenuItem Header="Copy Block Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" /> <MenuItem Header="Copy Block Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" />
@@ -89,6 +94,7 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- BlockItems Summary Panel --> <!-- BlockItems Summary Panel -->
<StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"> <StackPanel Grid.Row="0" Grid.Column="0" VerticalAlignment="Center">
@@ -123,7 +129,7 @@
</StackPanel> </StackPanel>
<!-- Item Preview Box --> <!-- Item Preview Box -->
<WrapPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"> <WrapPanel Grid.Row="0" Grid.Column="2" VerticalAlignment="Center">
<Button Command="{Binding PlaySoundCommand}" <Button Command="{Binding PlaySoundCommand}"
Width="25" Width="25"
Height="25" Height="25"
@@ -160,6 +166,10 @@
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"> <TextBlock Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<Hyperlink Command="{Binding SwitchBlockItemsViewCommand}"> <Hyperlink Command="{Binding SwitchBlockItemsViewCommand}">
Switch to Appearance Block Items Switch to Appearance Block Items
@@ -167,7 +177,7 @@
</TextBlock> </TextBlock>
<!-- Add Block Item Links --> <!-- Add Block Item Links -->
<ItemsControl ItemsSource="{Binding BlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,10"> <ItemsControl Grid.Column="0" ItemsSource="{Binding BlockItemTypesAvailable}" Grid.Row="0" Margin="0,0,0,10">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
<WrapPanel></WrapPanel> <WrapPanel></WrapPanel>
@@ -184,8 +194,34 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
<!-- Enable/Disable Block Button -->
<ToggleButton Grid.Row="0"
Grid.Column="1"
Style="{StaticResource ChromelessToggleButton}"
IsChecked="{Binding BlockEnabled}"
Margin="0,0,5,0"
ToolTip="Enable/Disable Block"
Cursor="Hand"
Width="25"
Height="25">
<Image RenderOptions.BitmapScalingMode="HighQuality">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding BlockEnabled}" Value="true">
<Setter Property="Source" Value="/Filtration;component/Resources/Icons/standby_enabled_icon.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding BlockEnabled}" Value="false">
<Setter Property="Source" Value="/Filtration;component/Resources/Icons/standby_disabled_icon.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</ToggleButton>
<!-- Block Items --> <!-- Block Items -->
<WrapPanel Grid.Row="1" MaxHeight="200"> <WrapPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" MaxHeight="200">
<WrapPanel.Resources> <WrapPanel.Resources>
<CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource"> <CollectionViewSource Source="{Binding RegularBlockItems}" x:Key="BlockItemsCollectionViewSource">
<CollectionViewSource.SortDescriptions> <CollectionViewSource.SortDescriptions>

View File

@@ -85,6 +85,8 @@
<fluent:Button Header="Move Up" Command="{Binding MoveBlockUpCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveUpIcon}" /> <fluent:Button Header="Move Up" Command="{Binding MoveBlockUpCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveUpIcon}" />
<fluent:Button Header="Move Down" Command="{Binding MoveBlockDownCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveDownIcon}" /> <fluent:Button Header="Move Down" Command="{Binding MoveBlockDownCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveDownIcon}" />
<fluent:Button Header="Move To Bottom" Command="{Binding MoveBlockToBottomCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveToBottomIcon}" /> <fluent:Button Header="Move To Bottom" Command="{Binding MoveBlockToBottomCommand}" SizeDefinition="Middle" Icon="{StaticResource MoveToBottomIcon}" />
<fluent:Button Header="Enable Block" Command="{Binding EnableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyEnabledIcon}" />
<fluent:Button Header="Disable Block" Command="{Binding DisableBlockCommand}" SizeDefinition="Middle" Icon="{StaticResource StandbyDisabledIcon}" />
</fluent:RibbonGroupBox> </fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Expand / Collapse"> <fluent:RibbonGroupBox Header="Expand / Collapse">
<fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" /> <fluent:Button Header="Expand All" Command="{Binding ExpandAllBlocksCommand}" SizeDefinition="Middle" Icon="{StaticResource ExpandIcon}" />

View File

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