Compare commits
34 Commits
LootExplos
...
0.11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94146467a3 | ||
|
|
da9fad05a6 | ||
|
|
eb73767560 | ||
|
|
2954cfe259 | ||
|
|
3694e6fa0c | ||
|
|
37258e563a | ||
|
|
71e1f2bf78 | ||
|
|
b2b412a73c | ||
|
|
ae948c83a5 | ||
|
|
3727166a44 | ||
|
|
32b0a0199f | ||
|
|
e54730d693 | ||
|
|
d11eefaeab | ||
|
|
da5b2c73a0 | ||
|
|
2ff1373c6b | ||
|
|
1882687601 | ||
|
|
3ba25b8f07 | ||
|
|
e80295cb69 | ||
|
|
f3ed386845 | ||
|
|
89e0c717e8 | ||
|
|
8924637b98 | ||
|
|
b0b912c676 | ||
|
|
92ebc51e7b | ||
|
|
95e7581a5b | ||
|
|
9cb854b584 | ||
|
|
61c2902f0c | ||
|
|
dc157713f3 | ||
|
|
16fe837544 | ||
|
|
58de6f06b9 | ||
|
|
af2dace29a | ||
|
|
59cf604430 | ||
|
|
93a51e7829 | ||
|
|
9d928a374a | ||
|
|
b5788504cb |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -186,5 +186,4 @@ FakesAssemblies/
|
||||
# LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
/Releases
|
||||
ModelManifest.xml
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Filtration.Common.Services
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Filtration.Common.Services
|
||||
|
||||
public void WriteFileFromString(string filePath, string inputString)
|
||||
{
|
||||
File.WriteAllText(filePath, inputString);
|
||||
File.WriteAllText(filePath, inputString, Encoding.UTF8);
|
||||
}
|
||||
|
||||
public bool DirectoryExists(string directoryPath)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
namespace Filtration.Interface
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Filtration.Interface
|
||||
{
|
||||
public interface IDocument
|
||||
{
|
||||
bool IsScript { get; }
|
||||
bool IsTheme { get; }
|
||||
void Close();
|
||||
Task Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
namespace Filtration.Interface
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Filtration.Interface
|
||||
{
|
||||
public interface IEditableDocument : IDocument
|
||||
{
|
||||
bool IsDirty { get; }
|
||||
void Save();
|
||||
void SaveAs();
|
||||
Task SaveAsync();
|
||||
Task SaveAsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,36 +0,0 @@
|
||||
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")]
|
||||
@@ -1,178 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,72 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,39 +0,0 @@
|
||||
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")]
|
||||
@@ -1,37 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,48 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.ObjectModel.Tests.BlockItemBaseTypes
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSocketGroupBlockItem
|
||||
{
|
||||
[Test]
|
||||
public void MatchesBlockItem_BlankLootItem_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
var blockItem = new SocketGroupBlockItem();
|
||||
var testInputLootItem = new LootItem();
|
||||
|
||||
// Act
|
||||
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchesBlockItem_SocketsMatch_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var testInputSocketGroups = new List<SocketGroup>();
|
||||
var testInputSocketGroup1 = new SocketGroup();
|
||||
var testInputSocketGroup2 = new SocketGroup();
|
||||
testInputSocketGroup1.Sockets = new List<SocketColor> {SocketColor.Blue, SocketColor.Red};
|
||||
testInputSocketGroup2.Sockets = new List<SocketColor>
|
||||
{
|
||||
SocketColor.Blue,
|
||||
SocketColor.Blue,
|
||||
SocketColor.Blue,
|
||||
SocketColor.Red
|
||||
};
|
||||
|
||||
testInputSocketGroups.Add(testInputSocketGroup1);
|
||||
testInputSocketGroups.Add(testInputSocketGroup2);
|
||||
|
||||
var blockItem = new SocketGroupBlockItem();
|
||||
blockItem.Items.Add("RRG");
|
||||
blockItem.Items.Add("BRB");
|
||||
|
||||
var testInputLootItem = new LootItem {SocketGroups = testInputSocketGroups};
|
||||
|
||||
// Act
|
||||
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MatchesBlockItem_SocketsAlmostMatch_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var testInputSocketGroups = new List<SocketGroup>();
|
||||
var testInputSocketGroup1 = new SocketGroup();
|
||||
var testInputSocketGroup2 = new SocketGroup();
|
||||
testInputSocketGroup1.Sockets = new List<SocketColor> { SocketColor.Blue, SocketColor.Red };
|
||||
testInputSocketGroup2.Sockets = new List<SocketColor>
|
||||
{
|
||||
SocketColor.Blue,
|
||||
SocketColor.Blue,
|
||||
SocketColor.Blue,
|
||||
SocketColor.Red,
|
||||
SocketColor.Green
|
||||
};
|
||||
|
||||
testInputSocketGroups.Add(testInputSocketGroup1);
|
||||
testInputSocketGroups.Add(testInputSocketGroup2);
|
||||
|
||||
var blockItem = new SocketGroupBlockItem();
|
||||
blockItem.Items.Add("BGBRWB");
|
||||
|
||||
var testInputLootItem = new LootItem { SocketGroups = testInputSocketGroups };
|
||||
|
||||
// Act
|
||||
var result = blockItem.MatchesLootItem(testInputLootItem);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,10 +46,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
@@ -48,45 +47,5 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
@@ -37,12 +36,5 @@ 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -57,10 +56,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
get { return 11; }
|
||||
}
|
||||
|
||||
public override string GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.BaseType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -51,10 +50,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
get { return 10; }
|
||||
}
|
||||
|
||||
public override string GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.Class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -69,10 +68,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.DropLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -66,10 +65,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -68,10 +67,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.ItemLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -70,10 +68,5 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -69,10 +68,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.Quality;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -86,10 +85,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
return (int)ItemRarity.Unique;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return (int)lootItem.Rarity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -51,68 +47,5 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -70,10 +68,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.SocketGroups.Sum(c => c.Sockets.Count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemTypes
|
||||
{
|
||||
@@ -69,10 +68,5 @@ namespace Filtration.ObjectModel.BlockItemTypes
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLootItemProperty(LootItem lootItem)
|
||||
{
|
||||
return lootItem.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,10 +77,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Filtration.ObjectModel.LootExplosionStudio
|
||||
{
|
||||
public class LootItemCollection : Collection<LootItem>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
namespace Filtration.ObjectModel.LootExplosionStudio
|
||||
{
|
||||
public class SocketGroup
|
||||
{
|
||||
public List<SocketColor> Sockets { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Repositories;
|
||||
using Filtration.Services;
|
||||
using Filtration.ViewModels;
|
||||
@@ -11,14 +13,14 @@ namespace Filtration.Tests.Repositories
|
||||
public class TestItemFilterScriptRepository
|
||||
{
|
||||
[Test]
|
||||
public void LoadScriptFromFile_CallsPersistenceServiceUsingPathAndReturnsViewModel()
|
||||
public async Task LoadScriptFromFile_CallsPersistenceServiceUsingPathAndReturnsViewModel()
|
||||
{
|
||||
// Arrange
|
||||
var testInputPath = "C:\\TestPath.filter";
|
||||
|
||||
|
||||
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScript(testInputPath)).Verifiable();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).ReturnsAsync(new ItemFilterScript()).Verifiable();
|
||||
|
||||
var mockItemFilterScriptViewModel = new Mock<IItemFilterScriptViewModel>();
|
||||
|
||||
@@ -28,7 +30,7 @@ namespace Filtration.Tests.Repositories
|
||||
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
|
||||
|
||||
// Act
|
||||
var result = repository.LoadScriptFromFile(testInputPath);
|
||||
var result = await repository.LoadScriptFromFileAsync(testInputPath);
|
||||
|
||||
// Assert
|
||||
mockPersistenceService.Verify();
|
||||
@@ -42,7 +44,7 @@ namespace Filtration.Tests.Repositories
|
||||
var testInputPath = "C:\\TestPath.filter";
|
||||
|
||||
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScript(testInputPath)).Throws<IOException>();
|
||||
mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).Throws<IOException>();
|
||||
|
||||
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
|
||||
|
||||
@@ -51,7 +53,7 @@ namespace Filtration.Tests.Repositories
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
Assert.Throws<IOException>(() => repository.LoadScriptFromFile(testInputPath));
|
||||
Assert.Throws<IOException>(async () => await repository.LoadScriptFromFileAsync(testInputPath));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Services;
|
||||
@@ -12,7 +13,7 @@ namespace Filtration.Tests.Services
|
||||
public class TestItemFilterPersistenceService
|
||||
{
|
||||
[Test]
|
||||
public void LoadItemFilterScript_CallsTranslatorAndFileSystemService()
|
||||
public async Task LoadItemFilterScript_CallsTranslatorAndFileSystemService()
|
||||
{
|
||||
// Arrange
|
||||
const string TestInputPath = "C:\\Test Path\\Script.Filter";
|
||||
@@ -28,7 +29,7 @@ namespace Filtration.Tests.Services
|
||||
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
|
||||
|
||||
// Act
|
||||
var script = service.LoadItemFilterScript(TestInputPath);
|
||||
var script = await service.LoadItemFilterScriptAsync(TestInputPath);
|
||||
|
||||
// Assert
|
||||
mockFileSystemService.Verify();
|
||||
@@ -37,7 +38,7 @@ namespace Filtration.Tests.Services
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SaveItemFilterScript_CallsTranslatorAndFileSystemService()
|
||||
public async Task SaveItemFilterScript_CallsTranslatorAndFileSystemService()
|
||||
{
|
||||
// Arrange
|
||||
var testFilePath = "C:\\Test\\File.txt";
|
||||
@@ -53,7 +54,7 @@ namespace Filtration.Tests.Services
|
||||
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
|
||||
|
||||
// Act
|
||||
service.SaveItemFilterScript(testScript);
|
||||
await service.SaveItemFilterScriptAsync(testScript);
|
||||
|
||||
// Assert
|
||||
mockFileSystemService.Verify();
|
||||
|
||||
@@ -353,6 +353,39 @@ namespace Filtration.Tests.Translators
|
||||
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_DisabledBlockWithBlockGroup_ReturnsCorrectBlock()
|
||||
{
|
||||
// Arrange
|
||||
var testInputScript = "Show" + Environment.NewLine +
|
||||
" ItemLevel > 2" + Environment.NewLine +
|
||||
" SetTextColor 255 40 0" + Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
"#Disabled Block Start" + Environment.NewLine +
|
||||
"# This is a disabled block" + Environment.NewLine +
|
||||
"#Show#My Block Group" + Environment.NewLine +
|
||||
"# ItemLevel > 2" + Environment.NewLine +
|
||||
"#Disabled Block End";
|
||||
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(
|
||||
b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()))
|
||||
.Returns(new ItemFilterBlockGroup("My Block Group", null));
|
||||
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
|
||||
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
|
||||
Assert.AreEqual("This is a disabled block", secondBlock.Description);
|
||||
Assert.AreEqual("My Block Group", secondBlock.BlockGroup.GroupName);
|
||||
}
|
||||
|
||||
private class ItemFilterScriptTranslatorTestUtility
|
||||
{
|
||||
public ItemFilterScriptTranslatorTestUtility()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
@@ -13,9 +14,9 @@ namespace Filtration.ThemeEditor.Providers
|
||||
{
|
||||
IThemeEditorViewModel NewThemeForScript(ItemFilterScript script);
|
||||
IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script);
|
||||
IThemeEditorViewModel LoadThemeFromFile(string filePath);
|
||||
Theme LoadThemeModelFromFile(string filePath);
|
||||
void SaveTheme(IThemeEditorViewModel themeEditorViewModel, string filePath);
|
||||
Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath);
|
||||
Task<Theme> LoadThemeModelFromFile(string filePath);
|
||||
Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath);
|
||||
}
|
||||
|
||||
internal class ThemeProvider : IThemeProvider
|
||||
@@ -54,23 +55,26 @@ namespace Filtration.ThemeEditor.Providers
|
||||
return themeViewModel;
|
||||
}
|
||||
|
||||
public IThemeEditorViewModel LoadThemeFromFile(string filePath)
|
||||
public async Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath)
|
||||
{
|
||||
var model = _themePersistenceService.LoadTheme(filePath);
|
||||
var model = await _themePersistenceService.LoadThemeAsync(filePath);
|
||||
var viewModel = Mapper.Map<IThemeEditorViewModel>(model);
|
||||
viewModel.FilePath = filePath;
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public Theme LoadThemeModelFromFile(string filePath)
|
||||
public async Task<Theme> LoadThemeModelFromFile(string filePath)
|
||||
{
|
||||
return _themePersistenceService.LoadTheme(filePath);
|
||||
return await _themePersistenceService.LoadThemeAsync(filePath);
|
||||
}
|
||||
|
||||
public void SaveTheme(IThemeEditorViewModel themeEditorViewModel, string filePath)
|
||||
public async Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath)
|
||||
{
|
||||
var theme = Mapper.Map<Theme>(themeEditorViewModel);
|
||||
_themePersistenceService.SaveTheme(theme, filePath);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var theme = Mapper.Map<Theme>(themeEditorViewModel);
|
||||
_themePersistenceService.SaveThemeAsync(theme, filePath);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
@@ -6,35 +7,42 @@ namespace Filtration.ThemeEditor.Services
|
||||
{
|
||||
internal interface IThemePersistenceService
|
||||
{
|
||||
Theme LoadTheme(string filePath);
|
||||
void SaveTheme(Theme theme, string filePath);
|
||||
Task<Theme> LoadThemeAsync(string filePath);
|
||||
Task SaveThemeAsync(Theme theme, string filePath);
|
||||
}
|
||||
|
||||
internal class ThemePersistenceService : IThemePersistenceService
|
||||
{
|
||||
public Theme LoadTheme(string filePath)
|
||||
public async Task<Theme> LoadThemeAsync(string filePath)
|
||||
{
|
||||
var xmlSerializer = new XmlSerializer(typeof(Theme));
|
||||
Theme loadedTheme = null;
|
||||
|
||||
Theme loadedTheme;
|
||||
|
||||
using (Stream reader = new FileStream(filePath, FileMode.Open))
|
||||
await Task.Run(() =>
|
||||
{
|
||||
loadedTheme = (Theme)xmlSerializer.Deserialize(reader);
|
||||
}
|
||||
|
||||
loadedTheme.FilePath = filePath;
|
||||
var xmlSerializer = new XmlSerializer(typeof (Theme));
|
||||
|
||||
using (Stream reader = new FileStream(filePath, FileMode.Open))
|
||||
{
|
||||
loadedTheme = (Theme) xmlSerializer.Deserialize(reader);
|
||||
}
|
||||
|
||||
loadedTheme.FilePath = filePath;
|
||||
});
|
||||
|
||||
return loadedTheme;
|
||||
}
|
||||
|
||||
public void SaveTheme(Theme theme, string filePath)
|
||||
public async Task SaveThemeAsync(Theme theme, string filePath)
|
||||
{
|
||||
var xmlSerializer = new XmlSerializer(typeof(Theme));
|
||||
|
||||
using (Stream writer = new FileStream(filePath, FileMode.Create))
|
||||
await Task.Run(() =>
|
||||
{
|
||||
xmlSerializer.Serialize(writer, theme);
|
||||
}
|
||||
var xmlSerializer = new XmlSerializer(typeof (Theme));
|
||||
|
||||
using (Stream writer = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
xmlSerializer.Serialize(writer, theme);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
@@ -55,7 +56,7 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||
AddThemeComponentCommand = new RelayCommand<ThemeComponentType>(OnAddThemeComponentCommand, t => IsMasterTheme);
|
||||
DeleteThemeComponentCommand = new RelayCommand<ThemeComponent>(OnDeleteThemeComponentCommand,
|
||||
t => IsMasterTheme && SelectedThemeComponent != null);
|
||||
CloseCommand = new RelayCommand(OnCloseCommand);
|
||||
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
|
||||
|
||||
var icon = new BitmapImage();
|
||||
icon.BeginInit();
|
||||
@@ -123,19 +124,19 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
public async Task SaveAsync()
|
||||
{
|
||||
if (IsMasterTheme) return;
|
||||
|
||||
if (_filenameIsFake)
|
||||
{
|
||||
SaveAs();
|
||||
await SaveAsAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_themeProvider.SaveTheme(this, FilePath);
|
||||
await _themeProvider.SaveThemeAsync(this, FilePath);
|
||||
//RemoveDirtyFlag();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -149,7 +150,7 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAs()
|
||||
public async Task SaveAsAsync()
|
||||
{
|
||||
if (IsMasterTheme) return;
|
||||
|
||||
@@ -167,7 +168,7 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||
try
|
||||
{
|
||||
FilePath = saveDialog.FileName;
|
||||
_themeProvider.SaveTheme(this, FilePath);
|
||||
await _themeProvider.SaveThemeAsync(this, FilePath);
|
||||
_filenameIsFake = false;
|
||||
Title = Filename;
|
||||
//RemoveDirtyFlag();
|
||||
@@ -185,14 +186,16 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCloseCommand()
|
||||
public async Task OnCloseCommand()
|
||||
{
|
||||
Close();
|
||||
await Close();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
#pragma warning disable 1998
|
||||
public async Task Close()
|
||||
#pragma warning restore 1998
|
||||
{
|
||||
Messenger.Default.Send(new ThemeClosedMessage { ClosedViewModel = this });
|
||||
Messenger.Default.Send(new ThemeClosedMessage {ClosedViewModel = this});
|
||||
}
|
||||
|
||||
private void OnAddThemeComponentCommand(ThemeComponentType themeComponentType)
|
||||
|
||||
@@ -21,30 +21,29 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.Resources>
|
||||
<DataTemplate x:Key="EditableComponentNameTemplate">
|
||||
<TextBox Text="{Binding ComponentName}" />
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding UsageCount, StringFormat='Usages: {0}'}"
|
||||
FontSize="10"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="{Binding Path=DataContext.EditEnabled, RelativeSource={RelativeSource AncestorType={x:Type views:ThemeEditorView}}, Converter={StaticResource BooleanVisibilityConverter}}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding UsageCount}" Value="0">
|
||||
<Setter Property="Foreground" Value="Red" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="Foreground" Value="SteelBlue" />
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<TextBox Text="{Binding ComponentName}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="ViewOnlyComponentNameTemplate">
|
||||
<TextBlock Text="{Binding ComponentName}" ToolTip="{Binding ComponentName}" />
|
||||
</DataTemplate>
|
||||
</Grid.Resources>
|
||||
<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">
|
||||
@@ -59,7 +58,6 @@
|
||||
</Style>
|
||||
</ContentControl.Style>
|
||||
</ContentControl>
|
||||
|
||||
<xctk:ColorPicker Grid.Row="2" SelectedColor="{Binding Color}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -21,10 +21,6 @@ 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
|
||||
@@ -67,14 +63,6 @@ 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
|
||||
|
||||
@@ -94,6 +94,10 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="WpfAnimatedGif, Version=1.4.13.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\WpfAnimatedGif.1.4.13\lib\net\WpfAnimatedGif.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\WPFToolkit.3.5.50211.1\lib\WPFToolkit.dll</HintPath>
|
||||
@@ -145,6 +149,7 @@
|
||||
<Compile Include="Models\UpdateData.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Repositories\ItemFilterScriptRepository.cs" />
|
||||
<Compile Include="Services\ClipboardService.cs" />
|
||||
<Compile Include="Services\HTTPService.cs" />
|
||||
<Compile Include="Services\ItemFilterPersistenceService.cs" />
|
||||
<Compile Include="Services\StaticDataService.cs" />
|
||||
@@ -243,7 +248,6 @@
|
||||
<Compile Include="Views\UpdateAvailableView.xaml.cs">
|
||||
<DependentUpon>UpdateAvailableView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WindsorInstallers\ModelsInstaller.cs" />
|
||||
<Compile Include="WindsorInstallers\RepositoriesInstaller.cs" />
|
||||
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
|
||||
<Compile Include="WindsorInstallers\TranslatorsInstaller.cs" />
|
||||
@@ -365,6 +369,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Resource Include="Resources\loading_spinner.gif" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Windows;
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Filtration")]
|
||||
[assembly: AssemblyDescription("An item filter script manager for Path of Exile")]
|
||||
[assembly: AssemblyDescription("An item filter script editor for Path of Exile")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("XVar Industries Inc.")]
|
||||
[assembly: AssemblyProduct("Filtration")]
|
||||
@@ -50,7 +50,7 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.7.*")]
|
||||
[assembly: AssemblyVersion("0.11.*")]
|
||||
|
||||
[assembly: InternalsVisibleTo("Filtration.Tests")]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
@@ -1,4 +1,5 @@
|
||||
using Filtration.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Services;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace Filtration.Repositories
|
||||
{
|
||||
internal interface IItemFilterScriptRepository
|
||||
{
|
||||
IItemFilterScriptViewModel LoadScriptFromFile(string path);
|
||||
Task<IItemFilterScriptViewModel> LoadScriptFromFileAsync(string path);
|
||||
IItemFilterScriptViewModel NewScript();
|
||||
string GetItemFilterScriptDirectory();
|
||||
void SetItemFilterScriptDirectory(string path);
|
||||
@@ -24,9 +25,9 @@ namespace Filtration.Repositories
|
||||
_itemFilterScriptViewModelFactory = itemFilterScriptViewModelFactory;
|
||||
}
|
||||
|
||||
public IItemFilterScriptViewModel LoadScriptFromFile(string path)
|
||||
public async Task<IItemFilterScriptViewModel> LoadScriptFromFileAsync(string path)
|
||||
{
|
||||
var loadedScript = _itemFilterPersistenceService.LoadItemFilterScript(path);
|
||||
var loadedScript = await _itemFilterPersistenceService.LoadItemFilterScriptAsync(path);
|
||||
|
||||
var newViewModel = _itemFilterScriptViewModelFactory.Create();
|
||||
newViewModel.Initialise(loadedScript, false);
|
||||
|
||||
@@ -1069,31 +1069,54 @@ Sage Wand
|
||||
Serpent Wand
|
||||
Spiraled Wand
|
||||
Tornado Wand
|
||||
Emperor's Luck
|
||||
Abandoned Wealth
|
||||
The Avenger
|
||||
The Brittle Emperor
|
||||
Hope
|
||||
The Battle Born
|
||||
Birth of the Three
|
||||
The Brittle Emperor
|
||||
The Carrion Crow
|
||||
The Cataclysm
|
||||
The Celestial Justicar
|
||||
The Chains that Bind
|
||||
Chaotic Disposition
|
||||
Coveted Possession
|
||||
The Dark Mage
|
||||
The Doctor
|
||||
The Drunken Aristocrat
|
||||
Emperor's Luck
|
||||
The Explorer
|
||||
The Feast
|
||||
The Fiend
|
||||
The Gambler
|
||||
The Gemcutter
|
||||
Gemcutter's Promise
|
||||
The Gladiator
|
||||
The Hermit
|
||||
The Hoarder
|
||||
Hope
|
||||
The Hunger
|
||||
Humility
|
||||
The Incantation
|
||||
The Inventor
|
||||
Jack in the Box
|
||||
The King's Heart
|
||||
Lantador's Lost Love
|
||||
The Lover
|
||||
Lucky Connections
|
||||
The Metalsmith's Gift
|
||||
The Pact
|
||||
The Poet
|
||||
The Queen
|
||||
Rain of Chaos
|
||||
The Road to Power
|
||||
The Scarred Meadow
|
||||
The Scholar
|
||||
The Summoner
|
||||
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
|
||||
Three Faces in the Dark
|
||||
Time-Lost Relic
|
||||
The Union
|
||||
Vinia's Token
|
||||
The Warden
|
||||
The Watcher
|
||||
The Wind
|
||||
@@ -34,4 +34,5 @@ Fishing Rods
|
||||
Map Fragments
|
||||
Hideout Doodads
|
||||
Microtransactions
|
||||
Divination Card
|
||||
Divination Card
|
||||
Jewel
|
||||
BIN
Filtration/Resources/loading_spinner.gif
Normal file
BIN
Filtration/Resources/loading_spinner.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
43
Filtration/Services/ClipboardService.cs
Normal file
43
Filtration/Services/ClipboardService.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using NLog;
|
||||
|
||||
namespace Filtration.Services
|
||||
{
|
||||
internal interface IClipboardService
|
||||
{
|
||||
void SetClipboardText(string inputText);
|
||||
string GetClipboardText();
|
||||
}
|
||||
|
||||
internal class ClipboardService : IClipboardService
|
||||
{
|
||||
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public void SetClipboardText(string inputText)
|
||||
{
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Clipboard.SetText(inputText);
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e);
|
||||
}
|
||||
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
throw new Exception("Failed to copy to clipboard");
|
||||
}
|
||||
|
||||
public string GetClipboardText()
|
||||
{
|
||||
return Clipboard.GetText();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Properties;
|
||||
@@ -10,8 +11,8 @@ namespace Filtration.Services
|
||||
{
|
||||
void SetItemFilterScriptDirectory(string path);
|
||||
string ItemFilterScriptDirectory { get; }
|
||||
ItemFilterScript LoadItemFilterScript(string filePath);
|
||||
void SaveItemFilterScript(ItemFilterScript script);
|
||||
Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath);
|
||||
Task SaveItemFilterScriptAsync(ItemFilterScript script);
|
||||
string DefaultPathOfExileDirectory();
|
||||
}
|
||||
|
||||
@@ -58,20 +59,30 @@ namespace Filtration.Services
|
||||
Settings.Default.DefaultFilterDirectory = path;
|
||||
}
|
||||
|
||||
public ItemFilterScript LoadItemFilterScript(string filePath)
|
||||
public async Task<ItemFilterScript> LoadItemFilterScriptAsync(string filePath)
|
||||
{
|
||||
var script =
|
||||
_itemFilterScriptTranslator.TranslateStringToItemFilterScript(
|
||||
ItemFilterScript loadedScript = null;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
loadedScript = _itemFilterScriptTranslator.TranslateStringToItemFilterScript(
|
||||
_fileSystemService.ReadFileAsString(filePath));
|
||||
});
|
||||
|
||||
script.FilePath = filePath;
|
||||
return script;
|
||||
if (loadedScript != null)
|
||||
{
|
||||
loadedScript.FilePath = filePath;
|
||||
}
|
||||
|
||||
return loadedScript;
|
||||
}
|
||||
|
||||
public void SaveItemFilterScript(ItemFilterScript script)
|
||||
public async Task SaveItemFilterScriptAsync(ItemFilterScript script)
|
||||
{
|
||||
_fileSystemService.WriteFileFromString(script.FilePath,
|
||||
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(script));
|
||||
await Task.Run(() =>
|
||||
{
|
||||
_fileSystemService.WriteFileFromString(script.FilePath,
|
||||
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(script));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Utilities;
|
||||
|
||||
@@ -28,10 +30,10 @@ namespace Filtration.Services
|
||||
|
||||
private void PopulateStaticData()
|
||||
{
|
||||
var itemBaseTypes = _fileSystemService.ReadFileAsString("Resources\\ItemBaseTypes.txt");
|
||||
var itemBaseTypes = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemBaseTypes.txt");
|
||||
ItemBaseTypes = new LineReader(() => new StringReader(itemBaseTypes)).ToList();
|
||||
|
||||
var itemClasses = _fileSystemService.ReadFileAsString("Resources\\ItemClasses.txt");
|
||||
var itemClasses = _fileSystemService.ReadFileAsString(AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\ItemClasses.txt");
|
||||
ItemClasses = new LineReader(() => new StringReader(itemClasses)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Filtration.Services
|
||||
{
|
||||
internal interface IUpdateCheckService
|
||||
{
|
||||
Task<UpdateData> GetUpdateData();
|
||||
Task<UpdateData> GetUpdateDataAsync();
|
||||
}
|
||||
|
||||
internal class UpdateCheckService : IUpdateCheckService
|
||||
@@ -20,7 +20,7 @@ namespace Filtration.Services
|
||||
_httpService = httpService;
|
||||
}
|
||||
|
||||
public async Task<UpdateData> GetUpdateData()
|
||||
public async Task<UpdateData> GetUpdateDataAsync()
|
||||
{
|
||||
var updateXml = await _httpService.GetContentAsync(UpdateDataUrl);
|
||||
return (DeserializeUpdateData(updateXml));
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Documents;
|
||||
using Castle.Core.Internal;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.Properties;
|
||||
@@ -56,6 +55,7 @@ namespace Filtration.Translators
|
||||
}
|
||||
|
||||
lines[i] = lines[i].TrimStart('#');
|
||||
lines[i] = lines[i].Replace("#", " # ");
|
||||
var spaceOrEndOfLinePos = lines[i].IndexOf(" ", StringComparison.Ordinal) > 0 ? lines[i].IndexOf(" ", StringComparison.Ordinal) : lines[i].Length;
|
||||
var lineOption = lines[i].Substring(0, spaceOrEndOfLinePos);
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<Image Source="/Filtration;component/Resources/Icons/speaker_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Button>
|
||||
<ComboBox ItemsSource="{Binding ElementName=BlockItemContentControl, Path=DataContext.SoundsAvailable}" SelectedValue="{Binding Value}" Style="{StaticResource MetroComboBox}" />
|
||||
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="100" HorizontalAlignment="Right" ToolTip="Volume"/>
|
||||
<xctk:ShortUpDown Value="{Binding Path=SecondValue}" Minimum="1" Maximum="300" HorizontalAlignment="Right" ToolTip="Volume"/>
|
||||
</WrapPanel>
|
||||
</DataTemplate>
|
||||
</ContentControl.Resources>
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace Filtration.Utilities
|
||||
if (viewModel.ChildGroups.All(g => g.IsChecked == true))
|
||||
{
|
||||
viewModel.IsChecked = true;
|
||||
} else if (viewModel.ChildGroups.Any(g => g.IsChecked == true))
|
||||
}
|
||||
else if (viewModel.ChildGroups.Any(g => g.IsChecked == true || g.IsChecked == null))
|
||||
{
|
||||
viewModel.IsChecked = null;
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace Filtration.ViewModels
|
||||
private readonly ReadOnlyObservableCollection<IDocument> _readOnlyOpenDocuments;
|
||||
|
||||
public AvalonDockWorkspaceViewModel(ISectionBrowserViewModel sectionBrowserViewModel,
|
||||
IBlockGroupBrowserViewModel blockGroupBrowserViewModel,
|
||||
IStartPageViewModel startPageViewModel,
|
||||
IBlockOutputPreviewViewModel blockOutputPreviewViewModel)
|
||||
IBlockGroupBrowserViewModel blockGroupBrowserViewModel,
|
||||
IStartPageViewModel startPageViewModel,
|
||||
IBlockOutputPreviewViewModel blockOutputPreviewViewModel)
|
||||
{
|
||||
_sectionBrowserViewModel = sectionBrowserViewModel;
|
||||
_blockGroupBrowserViewModel = blockGroupBrowserViewModel;
|
||||
@@ -122,7 +122,6 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
|
||||
private List<IToolViewModel> _tools;
|
||||
|
||||
|
||||
public IEnumerable<IToolViewModel> Tools
|
||||
{
|
||||
@@ -171,6 +170,19 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
_activeDocument = null;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Replace _activeScriptViewModel and _activeThemeViewModel with a better solution.
|
||||
|
||||
if (document.IsScript && _activeScriptViewModel == (IItemFilterScriptViewModel) document)
|
||||
{
|
||||
_activeScriptViewModel = null;
|
||||
}
|
||||
|
||||
if (document.IsTheme && _activeThemeViewModel == (IThemeEditorViewModel)document)
|
||||
{
|
||||
_activeThemeViewModel = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchActiveDocument(IDocument document)
|
||||
|
||||
@@ -317,6 +317,12 @@ namespace Filtration.ViewModels
|
||||
get { return Block.HasBlockItemOfType<SoundBlockItem>(); }
|
||||
}
|
||||
|
||||
|
||||
public bool HasAudioVisualBlockItems
|
||||
{
|
||||
get { return AudioVisualBlockItems.Any(); }
|
||||
}
|
||||
|
||||
private void OnSwitchBlockItemsViewCommand()
|
||||
{
|
||||
AudioVisualBlockItemsGridVisible = !AudioVisualBlockItemsGridVisible;
|
||||
@@ -459,6 +465,7 @@ namespace Filtration.ViewModels
|
||||
RaisePropertyChanged("RegularBlockItems");
|
||||
RaisePropertyChanged("SummaryBlockItems");
|
||||
RaisePropertyChanged("AudioVisualBlockItems");
|
||||
RaisePropertyChanged("HasAudioVisualBlockItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Castle.Core.Internal;
|
||||
using Filtration.Common.Services;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
@@ -19,7 +19,6 @@ using Filtration.Translators;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using NLog;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
@@ -76,6 +75,8 @@ namespace Filtration.ViewModels
|
||||
private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel;
|
||||
private readonly IItemFilterPersistenceService _persistenceService;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
|
||||
private bool _isDirty;
|
||||
private IItemFilterBlockViewModel _selectedBlockViewModel;
|
||||
@@ -88,7 +89,9 @@ namespace Filtration.ViewModels
|
||||
IItemFilterBlockTranslator blockTranslator,
|
||||
IAvalonDockWorkspaceViewModel avalonDockWorkspaceViewModel,
|
||||
IItemFilterPersistenceService persistenceService,
|
||||
IMessageBoxService messageBoxService)
|
||||
IMessageBoxService messageBoxService,
|
||||
IClipboardService clipboardService,
|
||||
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||
{
|
||||
_itemFilterBlockViewModelFactory = itemFilterBlockViewModelFactory;
|
||||
_blockTranslator = blockTranslator;
|
||||
@@ -96,11 +99,13 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.ActiveDocumentChanged += OnActiveDocumentChanged;
|
||||
_persistenceService = persistenceService;
|
||||
_messageBoxService = messageBoxService;
|
||||
_clipboardService = clipboardService;
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
_itemFilterBlockViewModels = new ObservableCollection<IItemFilterBlockViewModel>();
|
||||
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand);
|
||||
ClearFilterCommand = new RelayCommand(OnClearFilterCommand, () => BlockFilterPredicate != null);
|
||||
CloseCommand = new RelayCommand(OnCloseCommand);
|
||||
CloseCommand = new RelayCommand(async () => await OnCloseCommand());
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => SelectedBlockViewModel != null);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => SelectedBlockViewModel != null);
|
||||
@@ -347,20 +352,21 @@ namespace Filtration.ViewModels
|
||||
ContentId = "ScriptContentId";
|
||||
}
|
||||
|
||||
public void Save()
|
||||
public async Task SaveAsync()
|
||||
{
|
||||
if (!ValidateScript()) return;
|
||||
if (!CheckForUnusedThemeComponents()) return;
|
||||
|
||||
if (_filenameIsFake)
|
||||
{
|
||||
SaveAs();
|
||||
await SaveAsAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
|
||||
try
|
||||
{
|
||||
_persistenceService.SaveItemFilterScript(Script);
|
||||
await _persistenceService.SaveItemFilterScriptAsync(Script);
|
||||
RemoveDirtyFlag();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -373,9 +379,15 @@ namespace Filtration.ViewModels
|
||||
_messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public void SaveAs()
|
||||
public async Task SaveAsAsync()
|
||||
{
|
||||
if (!ValidateScript()) return;
|
||||
if (!CheckForUnusedThemeComponents()) return;
|
||||
@@ -390,12 +402,14 @@ namespace Filtration.ViewModels
|
||||
var result = saveDialog.ShowDialog();
|
||||
|
||||
if (result != DialogResult.OK) return;
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
|
||||
|
||||
var previousFilePath = Script.FilePath;
|
||||
try
|
||||
{
|
||||
Script.FilePath = saveDialog.FileName;
|
||||
_persistenceService.SaveItemFilterScript(Script);
|
||||
await _persistenceService.SaveItemFilterScriptAsync(Script);
|
||||
_filenameIsFake = false;
|
||||
Title = Filename;
|
||||
RemoveDirtyFlag();
|
||||
@@ -411,6 +425,10 @@ namespace Filtration.ViewModels
|
||||
MessageBoxImage.Error);
|
||||
Script.FilePath = previousFilePath;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckForUnusedThemeComponents()
|
||||
@@ -476,12 +494,12 @@ namespace Filtration.ViewModels
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnCloseCommand()
|
||||
private async Task OnCloseCommand()
|
||||
{
|
||||
Close();
|
||||
await Close();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
public async Task Close()
|
||||
{
|
||||
if (!IsDirty)
|
||||
{
|
||||
@@ -490,25 +508,25 @@ namespace Filtration.ViewModels
|
||||
else
|
||||
{
|
||||
var result = _messageBoxService.Show("Filtration",
|
||||
"Want to save your changes to this script?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
|
||||
"Save script \"" + Filename + "\"?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case MessageBoxResult.Yes:
|
||||
{
|
||||
Save();
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
{
|
||||
await SaveAsync();
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
case MessageBoxResult.No:
|
||||
{
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
{
|
||||
CloseScript();
|
||||
break;
|
||||
}
|
||||
case MessageBoxResult.Cancel:
|
||||
{
|
||||
return;
|
||||
}
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,7 +562,16 @@ namespace Filtration.ViewModels
|
||||
|
||||
public void CopyBlock(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
Clipboard.SetText(_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block));
|
||||
try
|
||||
{
|
||||
_clipboardService.SetClipboardText(
|
||||
_blockTranslator.TranslateItemFilterBlockToString(SelectedBlockViewModel.Block));
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCopyBlockStyleCommand()
|
||||
@@ -564,8 +591,15 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
outputText += blockItem.OutputText;
|
||||
}
|
||||
|
||||
Clipboard.SetText(outputText);
|
||||
try
|
||||
{
|
||||
_clipboardService.SetClipboardText(outputText);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPasteBlockStyleCommand()
|
||||
@@ -575,7 +609,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
public void PasteBlockStyle(IItemFilterBlockViewModel targetBlockViewModel)
|
||||
{
|
||||
var clipboardText = Clipboard.GetText();
|
||||
var clipboardText = _clipboardService.GetClipboardText();
|
||||
if (string.IsNullOrEmpty(clipboardText))
|
||||
{
|
||||
return;
|
||||
@@ -594,8 +628,9 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
var clipboardText = Clipboard.GetText();
|
||||
if (clipboardText.IsNullOrEmpty()) return;
|
||||
var clipboardText = _clipboardService.GetClipboardText();
|
||||
if (string.IsNullOrEmpty(clipboardText)) return;
|
||||
_blockGroupHierarchyBuilder.Initialise(Script.ItemFilterBlockGroups.First());
|
||||
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
|
||||
if (translatedBlock == null) return;
|
||||
@@ -621,9 +656,12 @@ namespace Filtration.ViewModels
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e);
|
||||
var innerException = e.InnerException != null
|
||||
? e.InnerException.Message
|
||||
: string.Empty;
|
||||
|
||||
_messageBoxService.Show("Paste Error",
|
||||
e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine +
|
||||
e.InnerException.Message + Environment.NewLine + e.InnerException.StackTrace, MessageBoxButton.OK,
|
||||
e.Message + Environment.NewLine + innerException, MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
@@ -753,6 +791,7 @@ namespace Filtration.ViewModels
|
||||
IsDirty = true;
|
||||
SelectedBlockViewModel = vm;
|
||||
RaisePropertyChanged("ItemFilterSectionViewModels");
|
||||
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
||||
}
|
||||
|
||||
private void OnExpandAllBlocksCommand()
|
||||
@@ -784,9 +823,17 @@ namespace Filtration.ViewModels
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
var isSection = targetBlockViewModel.Block is ItemFilterSection;
|
||||
|
||||
Script.ItemFilterBlocks.Remove(targetBlockViewModel.Block);
|
||||
ItemFilterBlockViewModels.Remove(targetBlockViewModel);
|
||||
IsDirty = true;
|
||||
|
||||
if (isSection)
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
|
||||
}
|
||||
|
||||
}
|
||||
SelectedBlockViewModel = null;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Filtration.Common.Services;
|
||||
@@ -24,7 +28,6 @@ using Filtration.Views;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using NLog;
|
||||
using Clipboard = System.Windows.Clipboard;
|
||||
using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
@@ -33,6 +36,8 @@ namespace Filtration.ViewModels
|
||||
{
|
||||
RelayCommand OpenScriptCommand { get; }
|
||||
RelayCommand NewScriptCommand { get; }
|
||||
Task<bool> CloseAllDocumentsAsync();
|
||||
Task OpenDroppedFilesAsync(List<string> filenames);
|
||||
}
|
||||
|
||||
internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel
|
||||
@@ -49,8 +54,8 @@ namespace Filtration.ViewModels
|
||||
private readonly IUpdateCheckService _updateCheckService;
|
||||
private readonly IUpdateAvailableViewModel _updateAvailableViewModel;
|
||||
private readonly IMessageBoxService _messageBoxService;
|
||||
private bool _activeDocumentIsScript;
|
||||
private bool _activeDocumentIsTheme;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private bool _showLoadingBanner;
|
||||
|
||||
public MainWindowViewModel(IItemFilterScriptRepository itemFilterScriptRepository,
|
||||
IItemFilterScriptTranslator itemFilterScriptTranslator,
|
||||
@@ -61,7 +66,8 @@ namespace Filtration.ViewModels
|
||||
IThemeService themeService,
|
||||
IUpdateCheckService updateCheckService,
|
||||
IUpdateAvailableViewModel updateAvailableViewModel,
|
||||
IMessageBoxService messageBoxService)
|
||||
IMessageBoxService messageBoxService,
|
||||
IClipboardService clipboardService)
|
||||
{
|
||||
_itemFilterScriptRepository = itemFilterScriptRepository;
|
||||
_itemFilterScriptTranslator = itemFilterScriptTranslator;
|
||||
@@ -73,53 +79,54 @@ namespace Filtration.ViewModels
|
||||
_updateCheckService = updateCheckService;
|
||||
_updateAvailableViewModel = updateAvailableViewModel;
|
||||
_messageBoxService = messageBoxService;
|
||||
_clipboardService = clipboardService;
|
||||
|
||||
NewScriptCommand = new RelayCommand(OnNewScriptCommand);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => _activeDocumentIsScript);
|
||||
OpenScriptCommand = new RelayCommand(OnOpenScriptCommand);
|
||||
OpenThemeCommand = new RelayCommand(OnOpenThemeCommand);
|
||||
CopyScriptCommand = new RelayCommand(OnCopyScriptCommand, () => ActiveDocumentIsScript);
|
||||
OpenScriptCommand = new RelayCommand(async () => await OnOpenScriptCommand());
|
||||
OpenThemeCommand = new RelayCommand(async () => await OnOpenThemeCommandAsync());
|
||||
|
||||
SaveCommand = new RelayCommand(OnSaveDocumentCommand, ActiveDocumentIsEditable);
|
||||
SaveAsCommand = new RelayCommand(OnSaveAsCommand, ActiveDocumentIsEditable);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, () => AvalonDockWorkspaceViewModel.ActiveDocument != null);
|
||||
SaveCommand = new RelayCommand(async () => await OnSaveDocumentCommandAsync(), ActiveDocumentIsEditable);
|
||||
SaveAsCommand = new RelayCommand(async () => await OnSaveAsCommandAsync(), ActiveDocumentIsEditable);
|
||||
CloseCommand = new RelayCommand(OnCloseDocumentCommand, ActiveDocumentIsEditable);
|
||||
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockCommand = new RelayCommand(OnCopyBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
CopyBlockStyleCommand = new RelayCommand(OnCopyBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteCommand = new RelayCommand(OnPasteCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
PasteBlockStyleCommand = new RelayCommand(OnPasteBlockStyleCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockUpCommand = new RelayCommand(OnMoveBlockUpCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockDownCommand = new RelayCommand(OnMoveBlockDownCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToTopCommand = new RelayCommand(OnMoveBlockToTopCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
MoveBlockToBottomCommand = new RelayCommand(OnMoveBlockToBottomCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => _activeDocumentIsScript);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => _activeDocumentIsScript);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => _activeDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
AddBlockCommand = new RelayCommand(OnAddBlockCommand, () => ActiveDocumentIsScript);
|
||||
AddSectionCommand = new RelayCommand(OnAddSectionCommand, () => ActiveDocumentIsScript);
|
||||
DeleteBlockCommand = new RelayCommand(OnDeleteBlockCommand, () => ActiveDocumentIsScript && ActiveScriptHasSelectedBlock);
|
||||
DisableBlockCommand = new RelayCommand(OnDisableBlockCommand,
|
||||
() => _activeDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedEnabledBlock);
|
||||
EnableBlockCommand = new RelayCommand(OnEnableBlockCommand,
|
||||
() => _activeDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||
() => ActiveDocumentIsScript && ActiveScriptHasSelectedDisabledBlock);
|
||||
OpenAboutWindowCommand = new RelayCommand(OnOpenAboutWindowCommand);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => _activeDocumentIsScript);
|
||||
ReplaceColorsCommand = new RelayCommand(OnReplaceColorsCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => _activeDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(OnApplyThemeToScriptCommand, () => _activeDocumentIsScript);
|
||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => _activeDocumentIsScript);
|
||||
CreateThemeCommand = new RelayCommand(OnCreateThemeCommand, () => ActiveDocumentIsScript);
|
||||
ApplyThemeToScriptCommand = new RelayCommand(async () => await OnApplyThemeToScriptCommandAsync(), () => ActiveDocumentIsScript);
|
||||
EditMasterThemeCommand = new RelayCommand(OnEditMasterThemeCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => _activeDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
|
||||
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand,
|
||||
() =>
|
||||
ActiveDocumentIsTheme && _activeDocumentIsTheme &&
|
||||
ActiveDocumentIsTheme && ActiveThemeIsEditable &&
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
|
||||
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => _activeDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => _activeDocumentIsScript);
|
||||
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
CollapseAllBlocksCommand = new RelayCommand(OnCollapseAllBlocksCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => _activeDocumentIsScript);
|
||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => _activeDocumentIsScript);
|
||||
ToggleShowAdvancedCommand = new RelayCommand<bool>(OnToggleShowAdvancedCommand, s => ActiveDocumentIsScript);
|
||||
ClearFiltersCommand = new RelayCommand(OnClearFiltersCommand, () => ActiveDocumentIsScript);
|
||||
|
||||
if (string.IsNullOrEmpty(_itemFilterScriptRepository.GetItemFilterScriptDirectory()))
|
||||
{
|
||||
@@ -154,7 +161,8 @@ namespace Filtration.ViewModels
|
||||
ApplyThemeToScriptCommand.RaiseCanExecuteChanged();
|
||||
EditMasterThemeCommand.RaiseCanExecuteChanged();
|
||||
CreateThemeCommand.RaiseCanExecuteChanged();
|
||||
SetActiveDocumentStatusProperties();
|
||||
RaisePropertyChanged("ActiveDocumentIsScript");
|
||||
RaisePropertyChanged("ActiveDocumentIsTheme");
|
||||
RaisePropertyChanged("ShowAdvancedStatus");
|
||||
break;
|
||||
}
|
||||
@@ -165,14 +173,28 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
case "OpenScript":
|
||||
{
|
||||
#pragma warning disable 4014
|
||||
OnOpenScriptCommand();
|
||||
#pragma warning restore 4014
|
||||
break;
|
||||
}
|
||||
case "ShowLoadingBanner":
|
||||
{
|
||||
ShowLoadingBanner = true;
|
||||
break;
|
||||
}
|
||||
case "HideLoadingBanner":
|
||||
{
|
||||
ShowLoadingBanner = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
CheckForUpdates();
|
||||
ActiveDocumentIsScript = false;
|
||||
ActiveDocumentIsTheme = false;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await CheckForUpdatesAsync();
|
||||
}).Wait();
|
||||
}
|
||||
|
||||
public RelayCommand OpenScriptCommand { get; private set; }
|
||||
@@ -216,14 +238,14 @@ namespace Filtration.ViewModels
|
||||
public RelayCommand ClearFiltersCommand { get; private set; }
|
||||
|
||||
|
||||
public async void CheckForUpdates()
|
||||
public async Task CheckForUpdatesAsync()
|
||||
{
|
||||
var assemblyVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
var result = await _updateCheckService.GetUpdateData();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var result = await _updateCheckService.GetUpdateDataAsync();
|
||||
|
||||
if (result.LatestVersionMajorPart >= assemblyVersion.FileMajorPart &&
|
||||
result.LatestVersionMinorPart > assemblyVersion.FileMinorPart)
|
||||
{
|
||||
@@ -280,30 +302,24 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void SetActiveDocumentStatusProperties()
|
||||
public bool ShowLoadingBanner
|
||||
{
|
||||
ActiveDocumentIsScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
|
||||
ActiveDocumentIsTheme = AvalonDockWorkspaceViewModel.ActiveDocument is ThemeEditorViewModel;
|
||||
get { return _showLoadingBanner; }
|
||||
private set
|
||||
{
|
||||
_showLoadingBanner = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsScript
|
||||
{
|
||||
get { return _activeDocumentIsScript; }
|
||||
private set
|
||||
{
|
||||
_activeDocumentIsScript = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; }
|
||||
}
|
||||
|
||||
public bool ActiveDocumentIsTheme
|
||||
{
|
||||
get { return _activeDocumentIsTheme; }
|
||||
private set
|
||||
{
|
||||
_activeDocumentIsTheme = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; }
|
||||
}
|
||||
|
||||
public bool ActiveScriptHasSelectedBlock
|
||||
@@ -339,6 +355,29 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OpenDroppedFilesAsync(List<string> filenames)
|
||||
{
|
||||
foreach (var filename in filenames)
|
||||
{
|
||||
var extension = Path.GetExtension(filename);
|
||||
if (extension == null) continue;
|
||||
|
||||
switch (extension.ToUpperInvariant())
|
||||
{
|
||||
case ".FILTER":
|
||||
{
|
||||
await LoadScriptAsync(filename);
|
||||
break;
|
||||
}
|
||||
case ".FILTERTHEME":
|
||||
{
|
||||
await LoadThemeAsync(filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCreateThemeCommand()
|
||||
{
|
||||
var themeViewModel = _themeProvider.NewThemeForScript(AvalonDockWorkspaceViewModel.ActiveScriptViewModel.Script);
|
||||
@@ -379,24 +418,31 @@ namespace Filtration.ViewModels
|
||||
var aboutWindow = new AboutWindow();
|
||||
aboutWindow.ShowDialog();
|
||||
}
|
||||
private void OnOpenScriptCommand()
|
||||
|
||||
private async Task OnOpenScriptCommand()
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
var filePath = ShowOpenScriptDialog();
|
||||
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
Filter = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*",
|
||||
InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
if (openFileDialog.ShowDialog() != true) return;
|
||||
await LoadScriptAsync(filePath);
|
||||
}
|
||||
|
||||
private async Task LoadScriptAsync(string scriptFilename)
|
||||
{
|
||||
IItemFilterScriptViewModel loadedViewModel;
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("ShowLoadingBanner"));
|
||||
try
|
||||
{
|
||||
loadedViewModel = _itemFilterScriptRepository.LoadScriptFromFile(openFileDialog.FileName);
|
||||
loadedViewModel = await _itemFilterScriptRepository.LoadScriptFromFileAsync(scriptFilename);
|
||||
}
|
||||
catch(IOException e)
|
||||
catch (IOException e)
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
if (_logger.IsErrorEnabled)
|
||||
{
|
||||
_logger.Error(e);
|
||||
@@ -407,23 +453,28 @@ namespace Filtration.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
Messenger.Default.Send(new NotificationMessage("HideLoadingBanner"));
|
||||
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
|
||||
}
|
||||
|
||||
private void OnOpenThemeCommand()
|
||||
private async Task OnOpenThemeCommandAsync()
|
||||
{
|
||||
|
||||
var filePath = ShowOpenThemeDialog();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await LoadThemeAsync(filePath);
|
||||
}
|
||||
|
||||
private async Task LoadThemeAsync(string themeFilename)
|
||||
{
|
||||
IThemeEditorViewModel loadedViewModel;
|
||||
|
||||
try
|
||||
{
|
||||
loadedViewModel = _themeProvider.LoadThemeFromFile(filePath);
|
||||
loadedViewModel = await _themeProvider.LoadThemeFromFile(themeFilename);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -436,11 +487,11 @@ namespace Filtration.ViewModels
|
||||
MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_avalonDockWorkspaceViewModel.AddDocument(loadedViewModel);
|
||||
}
|
||||
|
||||
private void OnApplyThemeToScriptCommand()
|
||||
private async Task OnApplyThemeToScriptCommandAsync()
|
||||
{
|
||||
var filePath = ShowOpenThemeDialog();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
@@ -452,7 +503,7 @@ namespace Filtration.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
loadedTheme = _themeProvider.LoadThemeModelFromFile(filePath);
|
||||
loadedTheme = await _themeProvider.LoadThemeModelFromFile(filePath);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@@ -478,6 +529,16 @@ namespace Filtration.ViewModels
|
||||
AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SetDirtyFlag();
|
||||
}
|
||||
|
||||
private string ShowOpenScriptDialog()
|
||||
{
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "Filter Files (*.filter)|*.filter|All Files (*.*)|*.*",
|
||||
InitialDirectory = _itemFilterScriptRepository.GetItemFilterScriptDirectory()
|
||||
};
|
||||
|
||||
return openFileDialog.ShowDialog() != true ? string.Empty : openFileDialog.FileName;
|
||||
}
|
||||
|
||||
private string ShowOpenThemeDialog()
|
||||
{
|
||||
@@ -490,8 +551,6 @@ namespace Filtration.ViewModels
|
||||
return openFileDialog.ShowDialog() != true ? string.Empty : openFileDialog.FileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetItemFilterScriptDirectory()
|
||||
{
|
||||
var dlg = new FolderBrowserDialog
|
||||
@@ -507,14 +566,14 @@ namespace Filtration.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSaveDocumentCommand()
|
||||
private async Task OnSaveDocumentCommandAsync()
|
||||
{
|
||||
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).Save();
|
||||
await ((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAsync();
|
||||
}
|
||||
|
||||
private void OnSaveAsCommand()
|
||||
private async Task OnSaveAsCommandAsync()
|
||||
{
|
||||
((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAs();
|
||||
await ((IEditableDocument)_avalonDockWorkspaceViewModel.ActiveDocument).SaveAsAsync();
|
||||
}
|
||||
|
||||
private void OnReplaceColorsCommand()
|
||||
@@ -526,7 +585,18 @@ namespace Filtration.ViewModels
|
||||
|
||||
private void OnCopyScriptCommand()
|
||||
{
|
||||
Clipboard.SetText(_itemFilterScriptTranslator.TranslateItemFilterScriptToString(_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script));
|
||||
try
|
||||
{
|
||||
|
||||
_clipboardService.SetClipboardText(
|
||||
_itemFilterScriptTranslator.TranslateItemFilterScriptToString(
|
||||
_avalonDockWorkspaceViewModel.ActiveScriptViewModel.Script));
|
||||
}
|
||||
catch
|
||||
{
|
||||
_messageBoxService.Show("Clipboard Error", "Failed to access the clipboard, copy command not completed.",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCopyBlockCommand()
|
||||
@@ -645,5 +715,22 @@ namespace Filtration.ViewModels
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute(
|
||||
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent);
|
||||
}
|
||||
|
||||
public async Task<bool> CloseAllDocumentsAsync()
|
||||
{
|
||||
var openDocuments = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().ToList();
|
||||
|
||||
foreach (var document in openDocuments)
|
||||
{
|
||||
var docCount = _avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count();
|
||||
await document.Close();
|
||||
if (_avalonDockWorkspaceViewModel.OpenDocuments.OfType<IEditableDocument>().Count() == docCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Filtration.Common.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
using Filtration.Common.ViewModels;
|
||||
using Filtration.Interface;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
@@ -25,7 +26,7 @@ namespace Filtration.ViewModels
|
||||
public bool IsScript { get { return false; } }
|
||||
public bool IsTheme { get { return false; } }
|
||||
|
||||
public void Close()
|
||||
public Task Close()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media.Imaging;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
|
||||
namespace Filtration.ViewModels.ToolPanes
|
||||
{
|
||||
@@ -23,6 +24,18 @@ namespace Filtration.ViewModels.ToolPanes
|
||||
icon.UriSource = new Uri("pack://application:,,,/Filtration;component/Resources/Icons/add_section_icon.png");
|
||||
icon.EndInit();
|
||||
IconSource = icon;
|
||||
|
||||
Messenger.Default.Register<NotificationMessage>(this, message =>
|
||||
{
|
||||
switch (message.Notification)
|
||||
{
|
||||
case "SectionsChanged":
|
||||
{
|
||||
OnActiveDocumentChanged(this, EventArgs.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public const string ToolContentId = "SectionBrowserTool";
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
xmlns:converters="clr-namespace:Filtration.Converters"
|
||||
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
|
||||
xmlns:themeEditorViews="clr-namespace:Filtration.ThemeEditor.Views;assembly=Filtration.ThemeEditor"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance d:Type=viewModels:AvalonDockWorkspaceViewModel}"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
d:DesignHeight="300" d:DesignWidth="700">
|
||||
<UserControl.Resources>
|
||||
<xcad:BoolToVisibilityConverter x:Key="AvalonBoolToVisibilityConverter" />
|
||||
<converters:ActiveDocumentConverter x:Key="ActiveDocumentConverter" />
|
||||
|
||||
@@ -271,7 +271,9 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="1" FontStyle="Italic" Visibility="{Binding HasAudioVisualBlockItems, Converter={StaticResource InverseBooleanVisibilityConverter}}">To change the appearance of this block, add a Text, Background or Border Block Item above.</TextBlock>
|
||||
|
||||
<!-- Block Items -->
|
||||
<WrapPanel Grid.Row="1" MaxHeight="200">
|
||||
<WrapPanel.Resources>
|
||||
|
||||
@@ -8,15 +8,18 @@
|
||||
xmlns:viewModels="clr-namespace:Filtration.ViewModels"
|
||||
xmlns:viewsAvalonDock="clr-namespace:Filtration.Views.AvalonDock"
|
||||
xmlns:views="clr-namespace:Filtration.Views"
|
||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance Type=viewModels:MainWindowViewModel}"
|
||||
Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True" >
|
||||
Title="{Binding WindowTitle}" Height="762" Width="1126" IsIconVisible="True"
|
||||
Closing="MainWindow_OnClosing" Drop="MainWindow_OnDrop" AllowDrop="True">
|
||||
<fluent:RibbonWindow.InputBindings>
|
||||
<KeyBinding Command="{Binding SaveCommand}" Modifiers="Control" Key="S" />
|
||||
<KeyBinding Command="{Binding OpenScriptCommand}" Modifiers="Control" Key="O" />
|
||||
<KeyBinding Command="{Binding NewScriptCommand}" Modifiers="Control" Key="N" />
|
||||
</fluent:RibbonWindow.InputBindings>
|
||||
<DockPanel x:Name="RootDockPanel">
|
||||
<fluent:Ribbon DockPanel.Dock="Top" x:Name="RibbonRoot">
|
||||
<fluent:Ribbon DockPanel.Dock="Top" x:Name="RibbonRoot" IsEnabled="{Binding ShowLoadingBanner, Converter={StaticResource BoolInverterConverter}}">
|
||||
<fluent:Ribbon.Menu>
|
||||
<fluent:Backstage>
|
||||
<fluent:BackstageTabControl>
|
||||
@@ -29,10 +32,10 @@
|
||||
</DataTemplate>
|
||||
</fluent:BackstageTabItem.ContentTemplate>
|
||||
</fluent:BackstageTabItem>
|
||||
<fluent:Button Header="New Script" Command="{Binding NewScriptCommand}" Icon="{StaticResource NewIcon}" />
|
||||
<fluent:Button Header="Open Script" Command="{Binding OpenScriptCommand}" Icon="{StaticResource OpenIcon}" />
|
||||
<fluent:Button Header="New Script" Command="{Binding NewScriptCommand}" Icon="{StaticResource NewIcon}" ToolTip="New Script (Ctrl+N)" />
|
||||
<fluent:Button Header="Open Script" Command="{Binding OpenScriptCommand}" Icon="{StaticResource OpenIcon}" ToolTip="Open Script (Ctrl+O)" />
|
||||
<fluent:Button Header="Open Theme" Command="{Binding OpenThemeCommand}" Icon="{StaticResource OpenIcon}" />
|
||||
<fluent:Button Header="Save" Command="{Binding SaveCommand}" Icon="{StaticResource SaveIcon}" />
|
||||
<fluent:Button Header="Save" Command="{Binding SaveCommand}" Icon="{StaticResource SaveIcon}" ToolTip="Save (Ctrl+S)" />
|
||||
<fluent:Button Header="Save As" Command="{Binding SaveAsCommand}" Icon="{StaticResource SaveIcon}" />
|
||||
<fluent:Button Header="Close" Command="{Binding CloseCommand}" />
|
||||
<fluent:SeparatorTabItem />
|
||||
@@ -71,10 +74,10 @@
|
||||
</fluent:RibbonTabItem>
|
||||
<fluent:RibbonTabItem x:Name="ScriptToolsTabItem" Header="Script Tools" Group="{Binding ElementName=ScriptToolsGroup}" Visibility="{Binding ActiveDocumentIsScript, Converter={StaticResource BooleanVisibilityConverter}, Mode=OneWay}" >
|
||||
<fluent:RibbonGroupBox Header="Clipboard">
|
||||
<fluent:Button Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}"/>
|
||||
<fluent:Button Header="Paste Block" Command="{Binding PasteCommand}" Icon="{StaticResource PasteIcon}" LargeIcon="{StaticResource PasteIcon}" />
|
||||
<fluent:Button Header="Copy Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" SizeDefinition="Middle" />
|
||||
<fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
|
||||
<fluent:Button Header="Copy Block" Command="{Binding CopyBlockCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" ToolTip="Copy Block (Ctrl+C)"/>
|
||||
<fluent:Button Header="Paste Block" Command="{Binding PasteCommand}" Icon="{StaticResource PasteIcon}" LargeIcon="{StaticResource PasteIcon}" ToolTip="Paste Block (Ctrl+V)"/>
|
||||
<fluent:Button Header="Copy Style" Command="{Binding CopyBlockStyleCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource CopyIcon}" SizeDefinition="Middle" ToolTip="Copy Style (Ctrl+Shift+C)" />
|
||||
<fluent:Button Header="Paste Style" Command="{Binding PasteBlockStyleCommand}" Icon="{StaticResource PasteStyleIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" ToolTip="Paste Style (Ctrl+Shift+V)" />
|
||||
<fluent:Button Header="Copy Script" Command="{Binding CopyScriptCommand}" Icon="{StaticResource CopyIcon}" LargeIcon="{StaticResource PasteIcon}" SizeDefinition="Middle" />
|
||||
</fluent:RibbonGroupBox>
|
||||
<fluent:RibbonGroupBox Header="Blocks">
|
||||
@@ -116,6 +119,30 @@
|
||||
</fluent:Ribbon>
|
||||
<Grid>
|
||||
<viewsAvalonDock:AvalonDockWorkspaceView DataContext="{Binding AvalonDockWorkspaceViewModel}" />
|
||||
<Grid ZIndex="9999" Visibility="{Binding ShowLoadingBanner, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}">
|
||||
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="Black" Opacity="0.5" />
|
||||
</Grid.Background>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="1" Grid.Column="1" BorderBrush="Black" BorderThickness="1" Background="White" Padding="20">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" FontWeight="DemiBold">Working...</TextBlock>
|
||||
<Image gif:ImageBehavior.AnimatedSource="/Filtration;component/Resources/loading_spinner.gif" Height="32" Margin="10,0,0,0"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</fluent:RibbonWindow>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
using System.Windows;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Filtration.ViewModels;
|
||||
|
||||
namespace Filtration.Views
|
||||
@@ -10,8 +14,11 @@ namespace Filtration.Views
|
||||
|
||||
internal partial class MainWindow : IMainWindow
|
||||
{
|
||||
private readonly IMainWindowViewModel _mainWindowViewModel;
|
||||
|
||||
public MainWindow(IMainWindowViewModel mainWindowViewModel)
|
||||
{
|
||||
_mainWindowViewModel = mainWindowViewModel;
|
||||
InitializeComponent();
|
||||
DataContext = mainWindowViewModel;
|
||||
}
|
||||
@@ -31,5 +38,38 @@ namespace Filtration.Views
|
||||
RibbonRoot.SelectedTabItem = ThemeToolsTabItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void MainWindow_OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
var allDocumentsClosed = _mainWindowViewModel.CloseAllDocumentsAsync().Result;
|
||||
if (!allDocumentsClosed)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private async void MainWindow_OnDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) return;
|
||||
|
||||
var filenames = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
var droppedFilterFiles = new List<string>();
|
||||
|
||||
foreach (var filename in filenames)
|
||||
{
|
||||
var extension = Path.GetExtension(filename);
|
||||
if (extension != null &&
|
||||
(extension.ToUpperInvariant() == ".FILTER" || extension.ToUpperInvariant() == ".FILTERTHEME"))
|
||||
{
|
||||
droppedFilterFiles.Add(filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (droppedFilterFiles.Count > 0)
|
||||
{
|
||||
await _mainWindowViewModel.OpenDroppedFilesAsync(droppedFilterFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Castle.MicroKernel.Registration;
|
||||
using Castle.MicroKernel.SubSystems.Configuration;
|
||||
using Castle.Windsor;
|
||||
|
||||
namespace Filtration.WindsorInstallers
|
||||
{
|
||||
public class ModelsInstaller : IWindsorInstaller
|
||||
{
|
||||
public void Install(IWindsorContainer container, IConfigurationStore store)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,11 @@ namespace Filtration.WindsorInstallers
|
||||
Component.For<IUpdateCheckService>()
|
||||
.ImplementedBy<UpdateCheckService>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<IClipboardService>()
|
||||
.ImplementedBy<ClipboardService>()
|
||||
.LifeStyle.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,6 @@
|
||||
<package id="NLog" version="4.0.1" targetFramework="net451" />
|
||||
<package id="NLog.Config" version="4.0.1" targetFramework="net451" />
|
||||
<package id="NLog.Schema" version="4.0.1" targetFramework="net451" />
|
||||
<package id="WpfAnimatedGif" version="1.4.13" targetFramework="net451" />
|
||||
<package id="WPFToolkit" version="3.5.50211.1" targetFramework="net451" />
|
||||
</packages>
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
Filtration is an editor for Path of Exile item filter scripts.
|
||||
|
||||
## Current Release (Released 2015-07-06)
|
||||
<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>
|
||||
## Current Release (Released 2015-07-26)
|
||||
<b>Installer (6.37mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.10/filtration_0.10_setup.exe">filtration_0.10_setup.exe</a>
|
||||
|
||||
<b>Zip File (7.91mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.7/filtration_0.7.zip">filtration_0.7.zip</a>
|
||||
<b>Zip File (7.97mb)</b> <a href="https://github.com/ben-wallis/Filtration/releases/download/0.10/filtration_0.10.zip">filtration_0.10.zip</a>
|
||||
|
||||
## System Requirements
|
||||
Filtration requires .NET Framework 4.5.1 installed.
|
||||
|
||||
Reference in New Issue
Block a user