95 Commits
0.3 ... 0.11

Author SHA1 Message Date
Ben
94146467a3 Removed async from a test that didn't need it 2015-07-31 21:43:33 +01:00
Ben
da9fad05a6 Changed maximum PlayAlertSound volume from 100 to 300 as per latest patch.
Updated version to 0.11
2015-07-31 19:52:19 +01:00
Ben
eb73767560 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-31 19:45:57 +01:00
Ben
2954cfe259 Fixed async tests 2015-07-31 19:45:51 +01:00
Ben Wallis
3694e6fa0c Updated release to 0.10 2015-07-26 17:19:53 +01:00
Ben
37258e563a Added Divination Cards to base types 2015-07-26 17:12:51 +01:00
Ben
71e1f2bf78 Revert "Removed Stackable Currency from ItemClasses"
This reverts commit f3ed386845.
2015-07-26 17:03:12 +01:00
Ben
b2b412a73c Revert "Removed Thrusting One Hand Swords from Base Types"
This reverts commit e80295cb69.
2015-07-26 17:03:06 +01:00
Ben
ae948c83a5 Updated version number to 0.10 2015-07-26 17:02:54 +01:00
Ben
3727166a44 Added drag and drop to open script/theme functionality 2015-07-26 11:48:54 +01:00
Ben
32b0a0199f Implemented async saving and loading 2015-07-25 19:02:42 +01:00
Ben
e54730d693 Added Tooltips for keyboard shortcuts and added Ctrl+N shortcut 2015-07-25 15:46:38 +01:00
Ben
d11eefaeab Fixed crash when pasting blocks with block groups assigned 2015-07-24 18:41:13 +01:00
Ben
da5b2c73a0 Moved clipboard operations to ClipboardService 2015-07-24 16:52:31 +01:00
Ben
2ff1373c6b Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-24 14:47:52 +01:00
Ben
1882687601 Fixed BlockGroupBrowser indeterminate checkbox state bug 2015-07-24 14:47:47 +01:00
Ben Wallis
3ba25b8f07 Updated release to 0.9 2015-07-15 19:55:52 +01:00
Ben
e80295cb69 Removed Thrusting One Hand Swords from Base Types 2015-07-15 19:48:51 +01:00
Ben
f3ed386845 Removed Stackable Currency from ItemClasses 2015-07-15 19:48:33 +01:00
Ben
89e0c717e8 Bumped version to 0.9 2015-07-15 19:45:49 +01:00
Ben
8924637b98 Added hint text when no audio visual block items are added. 2015-07-15 19:41:31 +01:00
Ben
b0b912c676 Added save check on close 2015-07-15 19:36:42 +01:00
Ben
92ebc51e7b Switched file save encoding to UTF-8 2015-07-15 19:17:19 +01:00
Ben
95e7581a5b Fixed Delete Theme Component button being enabled for non-master themes 2015-07-15 19:12:19 +01:00
Ben
9cb854b584 Fixed Usages: 0 being visible when editing a non-master theme 2015-07-15 19:10:51 +01:00
Ben
61c2902f0c Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-15 19:02:34 +01:00
Ben
dc157713f3 Fixed Issue #8 - Crash when Filtration cannot perform the update check on startup 2015-07-15 19:02:29 +01:00
Ben Wallis
16fe837544 updated to 0.8 2015-07-13 15:17:53 +01:00
Ben
58de6f06b9 Added Jewel to ItemClasses.txt 2015-07-10 18:13:12 +01:00
Ben
af2dace29a Fixed crash when opening a script after Filtration is invoked via file association (Issue #7) 2015-07-10 18:11:03 +01:00
Ben
59cf604430 Revert "Increased the size of the Item Preview control to cater for FontSize 45"
This reverts commit 93a51e7829.
2015-07-10 17:54:42 +01:00
Ben
93a51e7829 Increased the size of the Item Preview control to cater for FontSize 45 2015-07-10 17:52:10 +01:00
Ben
9d928a374a Fixed crash when clicking Close menu option with no script/theme open
Fixed memory leak when documents are closed.
2015-07-10 17:48:34 +01:00
Ben
b5788504cb Fixed Disabled Block Block Group Bug (Issue #6) 2015-07-10 17:29:37 +01:00
Ben
6e71005e93 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-09 18:58:27 +01:00
Ben
56e163e3e0 Fix for line description being lost when reading disabled blocks 2015-07-09 18:58:22 +01:00
Ben Wallis
c856bbcee7 updated screenshots 2015-07-06 19:14:28 +01:00
Ben Wallis
490496f2f7 Updated release to 0.7 2015-07-06 18:41:14 +01:00
Ben
9fcb609a51 Implemented disabled block support 2015-07-06 18:19:05 +01:00
Ben
1b63f68eee Fixed theme serialization/deserialization and added them toolbar icons 2015-07-06 15:33:25 +01:00
Ben
a496ab9b42 Resharper Code Issues Cleanup 2015-07-06 13:45:19 +01:00
Ben
cbbc7c25fa More theme changes 2015-07-06 13:41:46 +01:00
Ben
d6bd1678b4 Fixed contextual tabs 2015-07-06 12:01:48 +01:00
Ben
bfa2341ab8 Implemented editable themes / master themes 2015-07-05 22:43:17 +01:00
Ben
511f503e88 Refactored ThemeComponentBuilder into ThemeComponentCollection 2015-07-05 16:54:09 +01:00
Ben
3ea0530c01 Added Divination Cards to Classes and Base Types lookup lists 2015-07-05 16:19:45 +01:00
Ben
aad34b1407 Changed UpdateDataUrl back to correct url 2015-07-05 11:14:44 +01:00
Ben
544b931477 Added theme component tag selection control 2015-07-05 11:09:59 +01:00
Ben
f5dcdf0af9 Removed item block display settings popup 2015-07-04 22:38:13 +01:00
Ben
da3759cd76 Refactored ItemFilterBlockView to use new usercontrol instead of datatemplate spam 2015-07-04 21:12:47 +01:00
Ben
d586492de8 Added theme component tooltip in theme editor 2015-07-04 20:24:00 +01:00
Ben
3337531161 Fixed another copy paste bug, changed speaker icon to button 2015-07-04 17:28:34 +01:00
Ben
0c470b3c97 Fixed copy paste crashes 2015-07-04 16:47:28 +01:00
Ben
3a60a5005b Changed versioning format, added grouping to theme browser, fixed styles 2015-07-04 14:29:07 +01:00
Ben
8b6207e334 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-04 12:24:56 +01:00
Ben
fea6bf6da2 Fixed bug causing clicks between documents and toolpanes not to register. 2015-07-04 12:24:50 +01:00
Ben Wallis
b6d1befd23 Delete Filtration.exe.config 2015-07-03 22:56:26 +01:00
Ben Wallis
2475d90bac Delete LootFilterScriptViewModel - Copy.cs 2015-07-03 22:55:51 +01:00
Ben
aae014b6e0 Added NLog logging 2015-07-03 22:16:17 +01:00
Ben
aadd56c473 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-03 21:19:30 +01:00
Ben
8f533e8fd7 Fixed localised decimal bug and tidied up About Window 2015-07-03 21:19:25 +01:00
Ben Wallis
272b7e8360 Update README.md 2015-07-02 22:48:57 +01:00
Ben
2d448ed850 Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-02 22:02:55 +01:00
Ben
bf4781dbde Added application-level unhandled exception handler 2015-07-02 22:02:51 +01:00
Ben Wallis
b889f1ef9a Update README.md 2015-07-02 20:47:00 +01:00
Ben
45b9d87ddb Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-07-02 20:19:41 +01:00
Ben
eb054a5068 Added auto updater 2015-07-02 20:19:32 +01:00
Ben Wallis
30498f08eb Update README.md 2015-07-02 20:17:33 +01:00
Ben
121681906d Fixed WPF Toolkit nuget package references 2015-07-02 18:06:16 +01:00
Ben
526350e389 Moved AvalonDock to libs directory and updated references 2015-07-02 18:03:05 +01:00
Ben
0bc3cac585 Added untracked files 2015-07-02 17:57:43 +01:00
Ben
c3d11da155 Further AutoMapper changes 2015-07-01 22:28:29 +01:00
Ben
440254f3f8 More styling work, fixed automapper issue 2015-07-01 22:26:00 +01:00
Ben
3a628df744 Fixed single line script description bug
Style tweaks inc. block selection style
2015-06-28 22:46:29 +01:00
Ben
c3a40b3412 Various bug fixes and sorted app icon 2015-06-28 21:44:36 +01:00
Ben
965627d587 Moved Settings to BackStage 2015-06-27 23:19:16 +01:00
Ben
4e77075182 Fixed memory leaks 2015-06-27 22:24:35 +01:00
Ben
dce21d84b3 Major UI overhaul, implemented FluentRibbon 2015-06-27 18:08:06 +01:00
Ben
5b4c622345 Completed initial implementation of Theme Editor 2015-06-26 21:54:20 +01:00
Ben
71ad5f2d05 Implemented opening/saving themes 2015-06-26 17:42:20 +01:00
Ben
aa5cedcbba Added Theme Editor window and added to Tools menu 2015-06-26 10:17:32 +01:00
Ben
cc05945108 Implemented ThemeComponent reading/saving in translation layer 2015-06-25 23:05:24 +01:00
Ben
e53e24100f Fixed block group advanced status being lost during save 2015-06-24 23:04:54 +01:00
Ben
4faa12474a Added settings window 2015-06-24 22:34:19 +01:00
Ben
1ba3b3f850 Added Default Path of Exile directory to saved settings 2015-06-24 21:24:38 +01:00
Ben
c6f5dcda39 Moved Object Model to separate project 2015-06-24 19:57:16 +01:00
Ben
1be6fe9e7b Refactored script to text translation 2015-06-23 22:21:10 +01:00
Ben
29ed02e172 Fixed bug where closing a non-active document blanked the tool windows for the current document 2015-06-23 21:59:26 +01:00
Ben
e3505b3575 Fixed AvalonDock close tools crash, added Block Output Preview pane 2015-06-23 21:41:57 +01:00
Ben
0eafd59e79 Set BlockGroupBrowser pane to not be closeable 2015-06-22 21:00:13 +01:00
Ben
692269ddb3 Fixed ColorBlock parsing to respect comments, preventing overflow errors when numbers are present in comments on these lines. 2015-06-22 19:00:22 +01:00
Ben
72e9caec29 Added ItemFilterScriptRepository 2015-06-18 22:12:15 +01:00
Ben
e25fbe67eb Merge branch 'master' of https://github.com/ben-wallis/Filtration.git 2015-06-18 21:08:50 +01:00
Ben
c80d4825df Added AutoMapper for BlockGroup to BlockGroupViewModel translation 2015-06-18 21:08:44 +01:00
Ben Wallis
e07e7eeb3e Updated screenshots and release links for 0.3 2015-06-14 21:17:15 +01:00
234 changed files with 11781 additions and 1583 deletions

View File

@@ -0,0 +1,61 @@
<?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>{1E42A658-45C4-4DD9-83C5-2A10728DBDFA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.Common.Tests</RootNamespace>
<AssemblyName>Filtration.Common.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.1506.2515\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<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" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Filtration.Common.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.Common.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("23ba4e1b-1cb6-47fc-9a8b-6ce61fc3eb32")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1506.2515" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
</packages>

View File

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

View File

@@ -0,0 +1,43 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Filtration.Common.Converters
{
public class BooleanVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool && targetType == typeof (Visibility))
{
var val = (bool) value;
if (val)
{
return Visibility.Visible;
}
if (parameter is Visibility)
{
return parameter;
}
return Visibility.Collapsed;
}
if (value != null)
{
return Visibility.Visible;
}
if (parameter is Visibility)
{
return parameter;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

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

View File

@@ -0,0 +1,42 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Filtration.Common.Converters
{
internal class InverseBooleanVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool && targetType == typeof (Visibility))
{
var val = (bool) value;
if (val)
{
return Visibility.Collapsed;
}
if (parameter is Visibility)
{
return parameter;
}
return Visibility.Visible;
}
if (value != null)
{
return Visibility.Collapsed;
}
if (parameter is Visibility)
{
return parameter;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

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

View File

@@ -0,0 +1,103 @@
<?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>{8CB44F28-2956-4C2A-9314-72727262EDD4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.Common</RootNamespace>
<AssemblyName>Filtration.Common</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="GalaSoft.MvvmLight">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\BooleanInverterConverter.cs" />
<Compile Include="Converters\BooleanVisibilityConverter.cs" />
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
<Compile Include="Converters\InverseBooleanVisibilityConverter.cs" />
<Compile Include="Converters\StringToVisibilityConverter.cs" />
<Compile Include="Messages\ThemeClosedMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\FileSystemService.cs" />
<Compile Include="Services\MessageBoxService.cs" />
<Compile Include="ViewModels\FiltrationViewModelBase.cs" />
<Compile Include="ViewModels\PaneViewModel.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4AAC3BEB-1DC1-483E-9D11-0E9334E80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Styles\SharedResourcesDictionary.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

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

View File

@@ -0,0 +1,40 @@
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.Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.Common")]
[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("36a40512-35b4-489c-8e20-f431b9e92dc1")]
// 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.Tests")]
[assembly: InternalsVisibleTo("Filtration.Common.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]

View File

@@ -1,9 +1,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Text;
namespace Filtration.Services namespace Filtration.Common.Services
{ {
internal interface IFileSystemService public interface IFileSystemService
{ {
string ReadFileAsString(string filePath); string ReadFileAsString(string filePath);
void WriteFileFromString(string filePath, string inputString); void WriteFileFromString(string filePath, string inputString);
@@ -20,7 +21,7 @@ namespace Filtration.Services
public void WriteFileFromString(string filePath, string inputString) public void WriteFileFromString(string filePath, string inputString)
{ {
File.WriteAllText(filePath, inputString); File.WriteAllText(filePath, inputString, Encoding.UTF8);
} }
public bool DirectoryExists(string directoryPath) public bool DirectoryExists(string directoryPath)

View File

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

View File

@@ -1,14 +1,13 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Filtration.Converters"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converters="clr-namespace:Filtration.Common.Converters"
mc:Ignorable="d" > mc:Ignorable="d" >
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary> <ResourceDictionary>
<Style x:Key="PathOfExileFont"> <Style x:Key="PathOfExileFont">
<Setter Property="TextElement.FontFamily" Value="pack://application:,,,/resources/#Fontin SmallCaps" /> <Setter Property="TextElement.FontFamily" Value="pack://application:,,,/resources/#Fontin SmallCaps" />
<Setter Property="TextElement.FontSize" Value="14" />
</Style> </Style>
<Style x:Key="ChromelessToggleButton" TargetType="{x:Type ToggleButton}"> <Style x:Key="ChromelessToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="Template"> <Setter Property="Template">
@@ -32,15 +31,19 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<converters:IntToItemRarityConverter x:Key="IntToItemRarityConverter" /> <Style TargetType="{x:Type Border}" x:Key="BlockItemBorder">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Margin" Value="0,0,5,5" />
</Style>
<converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" /> <converters:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
<converters:BoolInverterConverter x:Key="BoolInverterConverter" /> <converters:BoolInverterConverter x:Key="BoolInverterConverter" />
<converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" /> <converters:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
<converters:BooleanToBlockActionConverter x:Key="BooleanToBlockActionConverter" />
<converters:BooleanToBlockActionInverseConverter x:Key="BooleanToBlockActionInverseConverter" />
<converters:BlockItemTypeToStringConverter x:Key="BlockItemTypeToStringConverter" />
<converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" /> <converters:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter" />
<converters:InverseBooleanVisibilityConverter x:Key="InverseBooleanVisibilityConverter" />
</ResourceDictionary> </ResourceDictionary>
<ResourceDictionary Source="ExpanderStyle.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -1,15 +1,14 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Filtration.Annotations; using Filtration.ObjectModel.Annotations;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
namespace Filtration.ViewModels namespace Filtration.Common.ViewModels
{ {
internal class FiltrationViewModelBase : ViewModelBase public class FiltrationViewModelBase : ViewModelBase
{ {
/// This gives us the ReSharper option to transform an autoproperty into a property with change notification /// This gives us the ReSharper option to transform an autoproperty into a property with change notification
/// Also leverages .net 4.5 callermembername attribute /// Also leverages .net 4.5 callermembername attribute
[NotifyPropertyChangedInvocator] [NotifyPropertyChangedInvocator]
protected override void RaisePropertyChanged([CallerMemberName]string property = "") protected override void RaisePropertyChanged([CallerMemberName]string property = "")
{ {
base.RaisePropertyChanged(property); base.RaisePropertyChanged(property);

View File

@@ -1,8 +1,8 @@
using System.Windows.Media; using System.Windows.Media;
namespace Filtration.ViewModels namespace Filtration.Common.ViewModels
{ {
class PaneViewModel : FiltrationViewModelBase public class PaneViewModel : FiltrationViewModelBase
{ {
private string _title; private string _title;
public string Title public string Title

View File

@@ -0,0 +1,23 @@
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Filtration.Common.Services;
namespace Filtration.Common.WindsorInstallers
{
public class ServicesInstaller :IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Component.For<IFileSystemService>()
.ImplementedBy<FileSystemService>()
.LifeStyle.Singleton);
container.Register(
Component.For<IMessageBoxService>()
.ImplementedBy<MessageBoxService>()
.LifeStyle.Singleton);
}
}
}

View File

@@ -0,0 +1,7 @@
<?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" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net451" />
<package id="MvvmLightLibs" version="5.1.1.0" targetFramework="net451" />
</packages>

View File

@@ -0,0 +1,56 @@
<?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>{0F333344-7695-47B2-B0E6-172E4DE74819}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.Interface</RootNamespace>
<AssemblyName>Filtration.Interface</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="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" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="IDocument.cs" />
<Compile Include="IEditableDocument.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,11 @@
using System.Threading.Tasks;
namespace Filtration.Interface
{
public interface IDocument
{
bool IsScript { get; }
bool IsTheme { get; }
Task Close();
}
}

View File

@@ -0,0 +1,11 @@
using System.Threading.Tasks;
namespace Filtration.Interface
{
public interface IEditableDocument : IDocument
{
bool IsDirty { get; }
Task SaveAsync();
Task SaveAsAsync();
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Filtration.Interface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.Interface")]
[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("f21659a3-839a-41ca-97b9-78cc6f6af353")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,73 @@
<?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>{537BE676-2FF6-4995-B05B-9CFACE852EC9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.ObjectModel.Tests</RootNamespace>
<AssemblyName>Filtration.ObjectModel.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.1506.2016\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="TestItemFilterBlock.cs" />
<Compile Include="TestItemFilterBlockGroup.cs" />
<Compile Include="TestItemFilterScript.cs" />
<Compile Include="ThemeEditor\TestThemeComponentCollection.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>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,35 @@
using System.Reflection;
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.ObjectModel.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.ObjectModel.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("7ed27cde-6bc5-4d11-b45d-8823de2077ce")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,8 +1,7 @@
using Filtration.Models; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.Models.BlockItemTypes;
using NUnit.Framework; using NUnit.Framework;
namespace Filtration.Tests.Models namespace Filtration.ObjectModel.Tests
{ {
[TestFixture] [TestFixture]
public class TestItemFilterBlock public class TestItemFilterBlock

View File

@@ -0,0 +1,42 @@
using NUnit.Framework;
namespace Filtration.ObjectModel.Tests
{
[TestFixture]
public class TestItemFilterBlockGroup
{
[Test]
public void ToString_ReturnsFullBlockHierarchy()
{
// Arrange
const string ExpectedResult = "Child 1 Block Group - Child 2 Block Group";
var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup);
var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup);
// Act
var result = child2BlockGroup.ToString();
// Assert
Assert.AreEqual(ExpectedResult, result);
}
[Test]
public void ToString_AddsTildeForAdvancedBlock()
{
// Arrange
const string ExpectedResult = "~Child 1 Block Group - Child 2 Block Group";
var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup, true);
var child2BlockGroup = new ItemFilterBlockGroup("Child 2 Block Group", child1BlockGroup);
// Act
var result = child2BlockGroup.ToString();
// Assert
Assert.AreEqual(ExpectedResult, result);
}
}
}

View File

@@ -1,11 +1,9 @@
using System.Collections.ObjectModel; using System.Linq;
using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.Models.BlockItemTypes;
using NUnit.Framework; using NUnit.Framework;
namespace Filtration.Tests.Models namespace Filtration.ObjectModel.Tests
{ {
[TestFixture] [TestFixture]
public class TestItemFilterScript public class TestItemFilterScript

View File

@@ -0,0 +1,30 @@
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using NUnit.Framework;
namespace Filtration.ObjectModel.Tests.ThemeEditor
{
[TestFixture]
public class TestThemeComponentCollection
{
[Test]
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
{
// Arrange
var testInputTargetType = ThemeComponentType.TextColor;
var testInputComponentName = "testComponent";
var testInputColor = new Color();
var componentCollection = new ThemeComponentCollection();
// Act
var firstResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
var secondResult = componentCollection.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
// Assert
Assert.AreSame(firstResult, secondResult);
}
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1506.2016" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
</packages>

View File

@@ -1,9 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
internal class ActionBlockItem : BlockItemBase public class ActionBlockItem : BlockItemBase
{ {
private BlockAction _action; private BlockAction _action;
@@ -25,6 +26,11 @@ namespace Filtration.Models.BlockItemBaseTypes
} }
} }
public override string OutputText
{
get { return Action.GetAttributeDescription(); }
}
public override string PrefixText public override string PrefixText
{ {
get { return string.Empty; } get { return string.Empty; }

View File

@@ -1,13 +1,14 @@
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Annotations; using Filtration.ObjectModel.Annotations;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
abstract class BlockItemBase : IItemFilterBlockItem public abstract class BlockItemBase : IItemFilterBlockItem
{ {
public abstract string PrefixText { get; } public abstract string PrefixText { get; }
public abstract string OutputText { get; }
public abstract int MaximumAllowed { get; } public abstract int MaximumAllowed { get; }
public abstract string DisplayHeading { get; } public abstract string DisplayHeading { get; }
public abstract string SummaryText { get; } public abstract string SummaryText { get; }
@@ -16,6 +17,7 @@ namespace Filtration.Models.BlockItemBaseTypes
public abstract int SortOrder { get; } public abstract int SortOrder { get; }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator] [NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{ {

View File

@@ -0,0 +1,82 @@
using System;
using System.Windows.Media;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ObjectModel.BlockItemBaseTypes
{
public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem
{
private Color _color;
private ThemeComponent _themeComponent;
protected ColorBlockItem()
{
}
protected ColorBlockItem(Color color)
{
Color = color;
}
public override string OutputText
{
get
{
return PrefixText + " " + +Color.R + " " + Color.G + " "
+ Color.B + (Color.A < 255 ? " " + Color.A : string.Empty) +
(ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty);
}
}
public override string SummaryText
{
get { return string.Empty; }
}
public ThemeComponent ThemeComponent
{
get { return _themeComponent; }
set
{
if (_themeComponent == value){ return;}
if (_themeComponent != null)
{
_themeComponent.ThemeComponentUpdated -= OnThemeComponentUpdated;
_themeComponent.ThemeComponentDeleted -= OnThemeComponentDeleted;
}
if (value != null)
{
value.ThemeComponentUpdated += OnThemeComponentUpdated;
value.ThemeComponentDeleted += OnThemeComponentDeleted;
}
_themeComponent = value;
OnPropertyChanged();
}
}
public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public override Color SummaryTextColor { get { return Colors.Transparent; } }
public Color Color
{
get { return _color; }
set
{
_color = value;
OnPropertyChanged();
}
}
private void OnThemeComponentUpdated(object sender, EventArgs e)
{
Color = ((ThemeComponent) sender).Color;
}
private void OnThemeComponentDeleted(object sender, EventArgs e)
{
ThemeComponent = null;
}
}
}

View File

@@ -1,8 +1,8 @@
using System.Windows.Media; using System.Windows.Media;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
internal abstract class DualIntegerBlockItem : BlockItemBase, IAudioVisualBlockItem public abstract class DualIntegerBlockItem : BlockItemBase, IAudioVisualBlockItem
{ {
private int _value; private int _value;
private int _secondValue; private int _secondValue;
@@ -17,6 +17,11 @@ namespace Filtration.Models.BlockItemBaseTypes
SecondValue = secondValue; SecondValue = secondValue;
} }
public override string OutputText
{
get { return PrefixText + " " + Value + " " + SecondValue; }
}
public override string SummaryText { get { return string.Empty; } } public override string SummaryText { get { return string.Empty; } }
public override Color SummaryBackgroundColor { get { return Colors.Transparent; } } public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public override Color SummaryTextColor { get { return Colors.Transparent; } } public override Color SummaryTextColor { get { return Colors.Transparent; } }

View File

@@ -1,8 +1,8 @@
using System.Windows.Media; using System.Windows.Media;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
internal abstract class IntegerBlockItem : BlockItemBase, IAudioVisualBlockItem public abstract class IntegerBlockItem : BlockItemBase, IAudioVisualBlockItem
{ {
private int _value; private int _value;
@@ -15,6 +15,11 @@ namespace Filtration.Models.BlockItemBaseTypes
Value = value; Value = value;
} }
public override string OutputText
{
get { return PrefixText + " " + Value; }
}
public override string SummaryText { get { return string.Empty; } } public override string SummaryText { get { return string.Empty; } }
public override Color SummaryBackgroundColor { get { return Colors.Transparent; } } public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
public override Color SummaryTextColor { get { return Colors.Transparent; } } public override Color SummaryTextColor { get { return Colors.Transparent; } }

View File

@@ -1,9 +1,10 @@
using System; using System;
using Filtration.Enums; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
namespace Filtration.Models.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
internal abstract class NumericFilterPredicateBlockItem : BlockItemBase public abstract class NumericFilterPredicateBlockItem : BlockItemBase
{ {
private NumericFilterPredicate _filterPredicate; private NumericFilterPredicate _filterPredicate;
@@ -19,6 +20,15 @@ namespace Filtration.Models.BlockItemBaseTypes
FilterPredicate.PropertyChanged += OnFilterPredicateChanged; FilterPredicate.PropertyChanged += OnFilterPredicateChanged;
} }
public override string OutputText
{
get
{
return PrefixText + " " + FilterPredicate.PredicateOperator.GetAttributeDescription() +
" " + FilterPredicate.PredicateOperand;
}
}
public abstract int Minimum { get; } public abstract int Minimum { get; }
public abstract int Maximum { get; } public abstract int Maximum { get; }

View File

@@ -0,0 +1,40 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
namespace Filtration.ObjectModel.BlockItemBaseTypes
{
public abstract class StringListBlockItem : BlockItemBase
{
protected StringListBlockItem()
{
Items = new ObservableCollection<string>();
Items.CollectionChanged += OnItemsCollectionChanged;
}
public override string OutputText
{
get
{
var enumerable = Items as IList<string> ?? Items.ToList();
if (enumerable.Count > 0)
{
return PrefixText + " " +
string.Format("\"{0}\"",
string.Join("\" \"", enumerable.ToArray()));
}
return string.Empty;
}
}
public ObservableCollection<string> Items { get; protected set; }
private void OnItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
OnPropertyChanged("Items");
OnPropertyChanged("SummaryText");
}
}
}

View File

@@ -1,9 +1,9 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class BackgroundColorBlockItem : ColorBlockItem public class BackgroundColorBlockItem : ColorBlockItem
{ {
public BackgroundColorBlockItem() public BackgroundColorBlockItem()
{ {

View File

@@ -1,10 +1,10 @@
using System.Linq; using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class BaseTypeBlockItem : StringListBlockItem public class BaseTypeBlockItem : StringListBlockItem
{ {
public override string PrefixText { get { return "BaseType"; } } public override string PrefixText { get { return "BaseType"; } }

View File

@@ -1,9 +1,9 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class BorderColorBlockItem : ColorBlockItem public class BorderColorBlockItem : ColorBlockItem
{ {
public BorderColorBlockItem() public BorderColorBlockItem()
{ {

View File

@@ -1,10 +1,10 @@
using System.Linq; using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class ClassBlockItem : StringListBlockItem public class ClassBlockItem : StringListBlockItem
{ {
public override string PrefixText { get { return "Class"; } } public override string PrefixText { get { return "Class"; } }

View File

@@ -1,10 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class DropLevelBlockItem : NumericFilterPredicateBlockItem public class DropLevelBlockItem : NumericFilterPredicateBlockItem
{ {
public DropLevelBlockItem() public DropLevelBlockItem()
{ {

View File

@@ -1,8 +1,8 @@
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class FontSizeBlockItem : IntegerBlockItem public class FontSizeBlockItem : IntegerBlockItem
{ {
public FontSizeBlockItem() public FontSizeBlockItem()
{ {

View File

@@ -1,10 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class HeightBlockItem : NumericFilterPredicateBlockItem public class HeightBlockItem : NumericFilterPredicateBlockItem
{ {
public HeightBlockItem() public HeightBlockItem()
{ {

View File

@@ -1,10 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class ItemLevelBlockItem : NumericFilterPredicateBlockItem public class ItemLevelBlockItem : NumericFilterPredicateBlockItem
{ {
public ItemLevelBlockItem() public ItemLevelBlockItem()
{ {

View File

@@ -1,10 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class LinkedSocketsBlockItem : NumericFilterPredicateBlockItem public class LinkedSocketsBlockItem : NumericFilterPredicateBlockItem
{ {
public LinkedSocketsBlockItem() public LinkedSocketsBlockItem()
{ {

View File

@@ -1,10 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class QualityBlockItem : NumericFilterPredicateBlockItem public class QualityBlockItem : NumericFilterPredicateBlockItem
{ {
public QualityBlockItem() public QualityBlockItem()
{ {

View File

@@ -1,11 +1,11 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Extensions; using Filtration.ObjectModel.Enums;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Extensions;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class RarityBlockItem : NumericFilterPredicateBlockItem public class RarityBlockItem : NumericFilterPredicateBlockItem
{ {
public RarityBlockItem() public RarityBlockItem()
{ {
@@ -15,12 +15,24 @@ namespace Filtration.Models.BlockItemTypes
: base(predicateOperator, predicateOperand) : base(predicateOperator, predicateOperand)
{ {
} }
public override string PrefixText public override string PrefixText
{ {
get { return "Rarity"; } get { return "Rarity"; }
} }
public override string OutputText
{
get
{
return PrefixText + " " + FilterPredicate.PredicateOperator
.GetAttributeDescription() +
" " +
((ItemRarity) FilterPredicate.PredicateOperand)
.GetAttributeDescription();
}
}
public override int MaximumAllowed public override int MaximumAllowed
{ {
get { return 2; } get { return 2; }

View File

@@ -1,10 +1,10 @@
using System.Linq; using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class SocketGroupBlockItem : StringListBlockItem public class SocketGroupBlockItem : StringListBlockItem
{ {
public override string PrefixText public override string PrefixText
{ {

View File

@@ -1,10 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class SocketsBlockItem : NumericFilterPredicateBlockItem public class SocketsBlockItem : NumericFilterPredicateBlockItem
{ {
public SocketsBlockItem() public SocketsBlockItem()
{ {

View File

@@ -1,8 +1,8 @@
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class SoundBlockItem : DualIntegerBlockItem public class SoundBlockItem : DualIntegerBlockItem
{ {
public SoundBlockItem() public SoundBlockItem()
{ {

View File

@@ -1,9 +1,9 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class TextColorBlockItem : ColorBlockItem public class TextColorBlockItem : ColorBlockItem
{ {
public TextColorBlockItem() public TextColorBlockItem()
{ {

View File

@@ -1,10 +1,10 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models.BlockItemTypes namespace Filtration.ObjectModel.BlockItemTypes
{ {
internal class WidthBlockItem : NumericFilterPredicateBlockItem public class WidthBlockItem : NumericFilterPredicateBlockItem
{ {
public WidthBlockItem() public WidthBlockItem()
{ {

View File

@@ -1,8 +1,8 @@
using System.ComponentModel; using System.ComponentModel;
namespace Filtration.Enums namespace Filtration.ObjectModel.Enums
{ {
internal enum BlockAction public enum BlockAction
{ {
[Description("Show")] [Description("Show")]
Show, Show,

View File

@@ -1,6 +1,6 @@
namespace Filtration.Enums namespace Filtration.ObjectModel.Enums
{ {
internal enum BlockItemType public enum BlockItemType
{ {
ItemLevel, ItemLevel,
DropLevel, DropLevel,

View File

@@ -1,8 +1,8 @@
using System.ComponentModel; using System.ComponentModel;
namespace Filtration.Enums namespace Filtration.ObjectModel.Enums
{ {
internal enum FilterPredicateOperator public enum FilterPredicateOperator
{ {
[Description("=")] [Description("=")]
Equal, Equal,

View File

@@ -1,8 +1,8 @@
using System.ComponentModel; using System.ComponentModel;
namespace Filtration.Enums namespace Filtration.ObjectModel.Enums
{ {
internal enum FilterType public enum FilterType
{ {
[Description("Show")] [Description("Show")]
Show, Show,

View File

@@ -1,8 +1,8 @@
using System.ComponentModel; using System.ComponentModel;
namespace Filtration.Enums namespace Filtration.ObjectModel.Enums
{ {
internal enum ItemRarity public enum ItemRarity
{ {
[Description("Normal")] [Description("Normal")]
Normal, Normal,

View File

@@ -1,8 +1,8 @@
using System.ComponentModel; using System.ComponentModel;
namespace Filtration.Enums namespace Filtration.ObjectModel.Enums
{ {
internal enum SocketColor public enum SocketColor
{ {
[Description("R")] [Description("R")]
Red, Red,

View File

@@ -0,0 +1,14 @@
using System.ComponentModel;
namespace Filtration.ObjectModel.Enums
{
public enum ThemeComponentType
{
[Description("Text")]
TextColor,
[Description("Background")]
BackgroundColor,
[Description("Border")]
BorderColor
}
}

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
namespace Filtration.Extensions namespace Filtration.ObjectModel.Extensions
{ {
internal static class EnumHelper public static class EnumHelper
{ {
public static T GetAttributeOfType<T>(this Enum enumVal) where T : Attribute public static T GetAttributeOfType<T>(this Enum enumVal) where T : Attribute
{ {

View File

@@ -0,0 +1,96 @@
<?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>{4AAC3BEB-1DC1-483E-9D11-0E9334E80227}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.ObjectModel</RootNamespace>
<AssemblyName>Filtration.ObjectModel</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="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="BlockItemBaseTypes\ActionBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\BlockItembase.cs" />
<Compile Include="BlockItemBaseTypes\ColorBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\DualIntegerBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\IntegerBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\NumericFilterPredicateBlockItem.cs" />
<Compile Include="BlockItemBaseTypes\StringListBlockItem.cs" />
<Compile Include="BlockItemTypes\BackgroundColorBlockItem.cs" />
<Compile Include="BlockItemTypes\BaseTypeBlockItem.cs" />
<Compile Include="BlockItemTypes\BorderColorBlockItem.cs" />
<Compile Include="BlockItemTypes\ClassBlockItem.cs" />
<Compile Include="BlockItemTypes\DropLevelBlockItem.cs" />
<Compile Include="BlockItemTypes\FontSizeBlockItem.cs" />
<Compile Include="BlockItemTypes\HeightBlockItem.cs" />
<Compile Include="BlockItemTypes\ItemLevelBlockItem.cs" />
<Compile Include="BlockItemTypes\LinkedSocketsBlockItem.cs" />
<Compile Include="BlockItemTypes\QualityBlockItem.cs" />
<Compile Include="BlockItemTypes\RarityBlockItem.cs" />
<Compile Include="BlockItemTypes\SocketGroupBlockItem.cs" />
<Compile Include="BlockItemTypes\SocketsBlockItem.cs" />
<Compile Include="BlockItemTypes\SoundBlockItem.cs" />
<Compile Include="BlockItemTypes\TextColorBlockItem.cs" />
<Compile Include="BlockItemTypes\WidthBlockItem.cs" />
<Compile Include="Enums\BlockAction.cs" />
<Compile Include="Enums\BlockItemType.cs" />
<Compile Include="Enums\FilterPredicateOperator.cs" />
<Compile Include="Enums\FilterType.cs" />
<Compile Include="Enums\ItemRarity.cs" />
<Compile Include="Enums\SocketColor.cs" />
<Compile Include="Enums\ThemeComponentType.cs" />
<Compile Include="Extensions\EnumHelper.cs" />
<Compile Include="IAudioVisualBlockItem.cs" />
<Compile Include="IItemFilterBlockItem.cs" />
<Compile Include="ItemFilterBlock.cs" />
<Compile Include="ItemFilterBlockGroup.cs" />
<Compile Include="ItemFilterScript.cs" />
<Compile Include="ItemFilterSection.cs" />
<Compile Include="NumericFilterPredicate.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReplaceColorsParameterSet.cs" />
<Compile Include="ThemeEditor\Theme.cs" />
<Compile Include="ThemeEditor\ThemeComponent.cs" />
<Compile Include="ThemeEditor\ThemeComponentCollection.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,8 +1,8 @@
using System.ComponentModel; using System.ComponentModel;
namespace Filtration.Models namespace Filtration.ObjectModel
{ {
internal interface IAudioVisualBlockItem public interface IAudioVisualBlockItem
{ {
event PropertyChangedEventHandler PropertyChanged; event PropertyChangedEventHandler PropertyChanged;
} }

View File

@@ -1,16 +1,17 @@
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Media; using System.Windows.Media;
namespace Filtration.Models namespace Filtration.ObjectModel
{ {
internal interface IItemFilterBlockItem : INotifyPropertyChanged public interface IItemFilterBlockItem : INotifyPropertyChanged
{ {
string PrefixText { get; } string PrefixText { get; }
int MaximumAllowed { get; } string OutputText { get; }
string DisplayHeading { get; } string DisplayHeading { get; }
string SummaryText { get; } string SummaryText { get; }
Color SummaryBackgroundColor { get; } Color SummaryBackgroundColor { get; }
Color SummaryTextColor { get; } Color SummaryTextColor { get; }
int MaximumAllowed { get; }
int SortOrder { get; } int SortOrder { get; }
} }
} }

View File

@@ -1,20 +1,22 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Filtration.Enums; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.Enums;
namespace Filtration.Models namespace Filtration.ObjectModel
{ {
internal class ItemFilterBlock public class ItemFilterBlock
{ {
private ItemFilterBlockGroup _blockGroup; private ItemFilterBlockGroup _blockGroup;
public ItemFilterBlock() public ItemFilterBlock()
{ {
BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)}; BlockItems = new ObservableCollection<IItemFilterBlockItem> {new ActionBlockItem(BlockAction.Show)};
Enabled = true;
} }
public bool Enabled { get; set; }
public string Description { get; set; } public string Description { get; set; }
public ItemFilterBlockGroup BlockGroup public ItemFilterBlockGroup BlockGroup
@@ -100,7 +102,7 @@ namespace Filtration.Models
{ {
Action = BlockAction.Hide; Action = BlockAction.Hide;
} }
else if (BlockGroup.IsChecked == true && Action == BlockAction.Hide) else if (BlockGroup.IsChecked && Action == BlockAction.Hide)
{ {
Action = BlockAction.Show; Action = BlockAction.Show;
} }

View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
namespace Filtration.ObjectModel
{
public class ItemFilterBlockGroup
{
private bool _isChecked;
public ItemFilterBlockGroup(string groupName, ItemFilterBlockGroup parent, bool advanced = false)
{
GroupName = groupName;
ParentGroup = parent;
Advanced = advanced;
ChildGroups = new List<ItemFilterBlockGroup>();
}
public event EventHandler BlockGroupStatusChanged;
public string GroupName { get; private set; }
public ItemFilterBlockGroup ParentGroup { get; private set; }
public List<ItemFilterBlockGroup> ChildGroups { get; private set; }
public bool Advanced { get; private set; }
public bool IsChecked
{
get { return _isChecked; }
set
{
if (value != _isChecked)
{
_isChecked = value;
// Raise an event to let blocks that have this block group assigned that
// they might need to change their Action due to the block group status changing.
if (BlockGroupStatusChanged != null)
{
BlockGroupStatusChanged.Invoke(null, null);
}
}
}
}
public override string ToString()
{
var currentBlockGroup = this;
var outputString = (Advanced ? "~" : string.Empty) + GroupName;
// TODO: This is retarded, fix this.
if (currentBlockGroup.ParentGroup != null)
{
while (currentBlockGroup.ParentGroup.ParentGroup != null)
{
outputString = (currentBlockGroup.ParentGroup.Advanced ? "~" : string.Empty) + currentBlockGroup.ParentGroup.GroupName + " - " + outputString;
currentBlockGroup = currentBlockGroup.ParentGroup;
}
}
return outputString;
}
}
}

View File

@@ -2,11 +2,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Filtration.Models.BlockItemTypes; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.Models namespace Filtration.ObjectModel
{ {
internal class ItemFilterScript public class ItemFilterScript
{ {
public ItemFilterScript() public ItemFilterScript()
{ {
@@ -15,10 +16,13 @@ namespace Filtration.Models
{ {
new ItemFilterBlockGroup("Root", null) new ItemFilterBlockGroup("Root", null)
}; };
ThemeComponents = new ThemeComponentCollection { IsMasterCollection = true};
} }
public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; } public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; }
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; } public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; }
public ThemeComponentCollection ThemeComponents { get; set; }
public string FilePath { get; set; } public string FilePath { get; set; }
public string Description { get; set; } public string Description { get; set; }
@@ -38,7 +42,6 @@ namespace Filtration.Models
public void ReplaceColors(ReplaceColorsParameterSet replaceColorsParameterSet) public void ReplaceColors(ReplaceColorsParameterSet replaceColorsParameterSet)
{ {
foreach ( foreach (
var block in var block in
ItemFilterBlocks.Where(b => BlockIsColorReplacementCandidate(replaceColorsParameterSet, b))) ItemFilterBlocks.Where(b => BlockIsColorReplacementCandidate(replaceColorsParameterSet, b)))
@@ -59,7 +62,6 @@ namespace Filtration.Models
borderColorBlockItem.Color = replaceColorsParameterSet.NewBorderColor; borderColorBlockItem.Color = replaceColorsParameterSet.NewBorderColor;
} }
} }
} }
private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, ItemFilterBlock block) private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, ItemFilterBlock block)

View File

@@ -0,0 +1,6 @@
namespace Filtration.ObjectModel
{
public class ItemFilterSection : ItemFilterBlock
{
}
}

View File

@@ -1,12 +1,12 @@
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Filtration.Annotations; using Filtration.ObjectModel.Annotations;
using Filtration.Enums; using Filtration.ObjectModel.Enums;
using Filtration.Extensions; using Filtration.ObjectModel.Extensions;
namespace Filtration.Models namespace Filtration.ObjectModel
{ {
internal class NumericFilterPredicate : INotifyPropertyChanged public class NumericFilterPredicate : INotifyPropertyChanged
{ {
private FilterPredicateOperator _predicateOperator; private FilterPredicateOperator _predicateOperator;
private int _predicateOperand; private int _predicateOperand;

View File

@@ -0,0 +1,937 @@
using System;
#pragma warning disable 1591
// ReSharper disable UnusedMember.Global
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable IntroduceOptionalParameters.Global
// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable InconsistentNaming
// ReSharper disable CheckNamespace
namespace Filtration.ObjectModel.Annotations
{
/// <summary>
/// Indicates that the value of the marked element could be <c>null</c> sometimes,
/// so the check for <c>null</c> is necessary before its usage.
/// </summary>
/// <example><code>
/// [CanBeNull] public object Test() { return null; }
/// public void UseTest() {
/// var p = Test();
/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
/// }
/// </code></example>
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)]
public sealed class CanBeNullAttribute : Attribute { }
/// <summary>
/// Indicates that the value of the marked element could never be <c>null</c>.
/// </summary>
/// <example><code>
/// [NotNull] public object Foo() {
/// return null; // Warning: Possible 'null' assignment
/// }
/// </code></example>
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event)]
public sealed class NotNullAttribute : Attribute { }
/// <summary>
/// Indicates that collection or enumerable value does not contain null elements.
/// </summary>
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field)]
public sealed class ItemNotNullAttribute : Attribute { }
/// <summary>
/// Indicates that collection or enumerable value can contain null elements.
/// </summary>
[AttributeUsage(
AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property |
AttributeTargets.Delegate | AttributeTargets.Field)]
public sealed class ItemCanBeNullAttribute : Attribute { }
/// <summary>
/// Indicates that the marked method builds string by format pattern and (optional) arguments.
/// Parameter, which contains format string, should be given in constructor. The format string
/// should be in <see cref="string.Format(IFormatProvider,string,object[])"/>-like form.
/// </summary>
/// <example><code>
/// [StringFormatMethod("message")]
/// public void ShowError(string message, params object[] args) { /* do something */ }
/// public void Foo() {
/// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
/// }
/// </code></example>
[AttributeUsage(
AttributeTargets.Constructor | AttributeTargets.Method |
AttributeTargets.Property | AttributeTargets.Delegate)]
public sealed class StringFormatMethodAttribute : Attribute
{
/// <param name="formatParameterName">
/// Specifies which parameter of an annotated method should be treated as format-string
/// </param>
public StringFormatMethodAttribute(string formatParameterName)
{
FormatParameterName = formatParameterName;
}
public string FormatParameterName { get; private set; }
}
/// <summary>
/// For a parameter that is expected to be one of the limited set of values.
/// Specify fields of which type should be used as values for this parameter.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
public sealed class ValueProviderAttribute : Attribute
{
public ValueProviderAttribute(string name)
{
Name = name;
}
[NotNull] public string Name { get; private set; }
}
/// <summary>
/// Indicates that the function argument should be string literal and match one
/// of the parameters of the caller function. For example, ReSharper annotates
/// the parameter of <see cref="System.ArgumentNullException"/>.
/// </summary>
/// <example><code>
/// public void Foo(string param) {
/// if (param == null)
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class InvokerParameterNameAttribute : Attribute { }
/// <summary>
/// Indicates that the method is contained in a type that implements
/// <c>System.ComponentModel.INotifyPropertyChanged</c> interface and this method
/// is used to notify that some property value changed.
/// </summary>
/// <remarks>
/// The method should be non-static and conform to one of the supported signatures:
/// <list>
/// <item><c>NotifyChanged(string)</c></item>
/// <item><c>NotifyChanged(params string[])</c></item>
/// <item><c>NotifyChanged{T}(Expression{Func{T}})</c></item>
/// <item><c>NotifyChanged{T,U}(Expression{Func{T,U}})</c></item>
/// <item><c>SetProperty{T}(ref T, T, string)</c></item>
/// </list>
/// </remarks>
/// <example><code>
/// public class Foo : INotifyPropertyChanged {
/// public event PropertyChangedEventHandler PropertyChanged;
/// [NotifyPropertyChangedInvocator]
/// protected virtual void NotifyChanged(string propertyName) { ... }
///
/// private string _name;
/// public string Name {
/// get { return _name; }
/// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
/// }
/// }
/// </code>
/// Examples of generated notifications:
/// <list>
/// <item><c>NotifyChanged("Property")</c></item>
/// <item><c>NotifyChanged(() =&gt; Property)</c></item>
/// <item><c>NotifyChanged((VM x) =&gt; x.Property)</c></item>
/// <item><c>SetProperty(ref myField, value, "Property")</c></item>
/// </list>
/// </example>
[AttributeUsage(AttributeTargets.Method)]
public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
{
public NotifyPropertyChangedInvocatorAttribute() { }
public NotifyPropertyChangedInvocatorAttribute(string parameterName)
{
ParameterName = parameterName;
}
public string ParameterName { get; private set; }
}
/// <summary>
/// Describes dependency between method input and output.
/// </summary>
/// <syntax>
/// <p>Function Definition Table syntax:</p>
/// <list>
/// <item>FDT ::= FDTRow [;FDTRow]*</item>
/// <item>FDTRow ::= Input =&gt; Output | Output &lt;= Input</item>
/// <item>Input ::= ParameterName: Value [, Input]*</item>
/// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
/// <item>Value ::= true | false | null | notnull | canbenull</item>
/// </list>
/// If method has single input parameter, it's name could be omitted.<br/>
/// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same)
/// for method output means that the methos doesn't return normally.<br/>
/// <c>canbenull</c> annotation is only applicable for output parameters.<br/>
/// You can use multiple <c>[ContractAnnotation]</c> for each FDT row,
/// or use single attribute with rows separated by semicolon.<br/>
/// </syntax>
/// <examples><list>
/// <item><code>
/// [ContractAnnotation("=> halt")]
/// public void TerminationMethod()
/// </code></item>
/// <item><code>
/// [ContractAnnotation("halt &lt;= condition: false")]
/// public void Assert(bool condition, string text) // regular assertion method
/// </code></item>
/// <item><code>
/// [ContractAnnotation("s:null => true")]
/// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
/// </code></item>
/// <item><code>
/// // A method that returns null if the parameter is null,
/// // and not null if the parameter is not null
/// [ContractAnnotation("null => null; notnull => notnull")]
/// public object Transform(object data)
/// </code></item>
/// <item><code>
/// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")]
/// public bool TryParse(string s, out Person result)
/// </code></item>
/// </list></examples>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class ContractAnnotationAttribute : Attribute
{
public ContractAnnotationAttribute([NotNull] string contract)
: this(contract, false) { }
public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
{
Contract = contract;
ForceFullStates = forceFullStates;
}
public string Contract { get; private set; }
public bool ForceFullStates { get; private set; }
}
/// <summary>
/// Indicates that marked element should be localized or not.
/// </summary>
/// <example><code>
/// [LocalizationRequiredAttribute(true)]
/// public class Foo {
/// private string str = "my string"; // Warning: Localizable string
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.All)]
public sealed class LocalizationRequiredAttribute : Attribute
{
public LocalizationRequiredAttribute() : this(true) { }
public LocalizationRequiredAttribute(bool required)
{
Required = required;
}
public bool Required { get; private set; }
}
/// <summary>
/// Indicates that the value of the marked type (or its derivatives)
/// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
/// should be used instead. However, using '==' or '!=' for comparison
/// with <c>null</c> is always permitted.
/// </summary>
/// <example><code>
/// [CannotApplyEqualityOperator]
/// class NoEquality { }
/// class UsesNoEquality {
/// public void Test() {
/// var ca1 = new NoEquality();
/// var ca2 = new NoEquality();
/// if (ca1 != null) { // OK
/// bool condition = ca1 == ca2; // Warning
/// }
/// }
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
public sealed class CannotApplyEqualityOperatorAttribute : Attribute { }
/// <summary>
/// When applied to a target attribute, specifies a requirement for any type marked
/// with the target attribute to implement or inherit specific type or types.
/// </summary>
/// <example><code>
/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
/// public class ComponentAttribute : Attribute { }
/// [Component] // ComponentAttribute requires implementing IComponent interface
/// public class MyComponent : IComponent { }
/// </code></example>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[BaseTypeRequired(typeof(Attribute))]
public sealed class BaseTypeRequiredAttribute : Attribute
{
public BaseTypeRequiredAttribute([NotNull] Type baseType)
{
BaseType = baseType;
}
[NotNull] public Type BaseType { get; private set; }
}
/// <summary>
/// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library),
/// so this symbol will not be marked as unused (as well as by other usage inspections).
/// </summary>
[AttributeUsage(AttributeTargets.All)]
public sealed class UsedImplicitlyAttribute : Attribute
{
public UsedImplicitlyAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
: this(useKindFlags, ImplicitUseTargetFlags.Default) { }
public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
: this(ImplicitUseKindFlags.Default, targetFlags) { }
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
{
UseKindFlags = useKindFlags;
TargetFlags = targetFlags;
}
public ImplicitUseKindFlags UseKindFlags { get; private set; }
public ImplicitUseTargetFlags TargetFlags { get; private set; }
}
/// <summary>
/// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes
/// as unused (as well as by other usage inspections)
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)]
public sealed class MeansImplicitUseAttribute : Attribute
{
public MeansImplicitUseAttribute()
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
: this(useKindFlags, ImplicitUseTargetFlags.Default) { }
public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
: this(ImplicitUseKindFlags.Default, targetFlags) { }
public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
{
UseKindFlags = useKindFlags;
TargetFlags = targetFlags;
}
[UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; }
[UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; }
}
[Flags]
public enum ImplicitUseKindFlags
{
Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
/// <summary>Only entity marked with attribute considered used.</summary>
Access = 1,
/// <summary>Indicates implicit assignment to a member.</summary>
Assign = 2,
/// <summary>
/// Indicates implicit instantiation of a type with fixed constructor signature.
/// That means any unused constructor parameters won't be reported as such.
/// </summary>
InstantiatedWithFixedConstructorSignature = 4,
/// <summary>Indicates implicit instantiation of a type.</summary>
InstantiatedNoFixedConstructorSignature = 8,
}
/// <summary>
/// Specify what is considered used implicitly when marked
/// with <see cref="MeansImplicitUseAttribute"/> or <see cref="UsedImplicitlyAttribute"/>.
/// </summary>
[Flags]
public enum ImplicitUseTargetFlags
{
Default = Itself,
Itself = 1,
/// <summary>Members of entity marked with attribute are considered used.</summary>
Members = 2,
/// <summary>Entity marked with attribute and all its members considered used.</summary>
WithMembers = Itself | Members
}
/// <summary>
/// This attribute is intended to mark publicly available API
/// which should not be removed and so is treated as used.
/// </summary>
[MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]
public sealed class PublicAPIAttribute : Attribute
{
public PublicAPIAttribute() { }
public PublicAPIAttribute([NotNull] string comment)
{
Comment = comment;
}
public string Comment { get; private set; }
}
/// <summary>
/// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack.
/// If the parameter is a delegate, indicates that delegate is executed while the method is executed.
/// If the parameter is an enumerable, indicates that it is enumerated while the method is executed.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class InstantHandleAttribute : Attribute { }
/// <summary>
/// Indicates that a method does not make any observable state changes.
/// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>.
/// </summary>
/// <example><code>
/// [Pure] private int Multiply(int x, int y) { return x * y; }
/// public void Foo() {
/// const int a = 2, b = 2;
/// Multiply(a, b); // Waring: Return value of pure method is not used
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Method)]
public sealed class PureAttribute : Attribute { }
/// <summary>
/// Indicates that a parameter is a path to a file or a folder within a web project.
/// Path can be relative or absolute, starting from web root (~).
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class PathReferenceAttribute : Attribute
{
public PathReferenceAttribute() { }
public PathReferenceAttribute([PathReference] string basePath)
{
BasePath = basePath;
}
public string BasePath { get; private set; }
}
/// <summary>
/// An extension method marked with this attribute is processed by ReSharper code completion
/// as a 'Source Template'. When extension method is completed over some expression, it's source code
/// is automatically expanded like a template at call site.
/// </summary>
/// <remarks>
/// Template method body can contain valid source code and/or special comments starting with '$'.
/// Text inside these comments is added as source code when the template is applied. Template parameters
/// can be used either as additional method parameters or as identifiers wrapped in two '$' signs.
/// Use the <see cref="MacroAttribute"/> attribute to specify macros for parameters.
/// </remarks>
/// <example>
/// In this example, the 'forEach' method is a source template available over all values
/// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block:
/// <code>
/// [SourceTemplate]
/// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; xs) {
/// foreach (var x in xs) {
/// //$ $END$
/// }
/// }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Method)]
public sealed class SourceTemplateAttribute : Attribute { }
/// <summary>
/// Allows specifying a macro for a parameter of a <see cref="SourceTemplateAttribute">source template</see>.
/// </summary>
/// <remarks>
/// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression
/// is defined in the <see cref="MacroAttribute.Expression"/> property. When applied on a method, the target
/// template parameter is defined in the <see cref="MacroAttribute.Target"/> property. To apply the macro silently
/// for the parameter, set the <see cref="MacroAttribute.Editable"/> property value = -1.
/// </remarks>
/// <example>
/// Applying the attribute on a source template method:
/// <code>
/// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")]
/// public static void forEach&lt;T&gt;(this IEnumerable&lt;T&gt; collection) {
/// foreach (var item in collection) {
/// //$ $END$
/// }
/// }
/// </code>
/// Applying the attribute on a template method parameter:
/// <code>
/// [SourceTemplate]
/// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) {
/// /*$ var $x$Id = "$newguid$" + x.ToString();
/// x.DoSomething($x$Id); */
/// }
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]
public sealed class MacroAttribute : Attribute
{
/// <summary>
/// Allows specifying a macro that will be executed for a <see cref="SourceTemplateAttribute">source template</see>
/// parameter when the template is expanded.
/// </summary>
public string Expression { get; set; }
/// <summary>
/// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed.
/// </summary>
/// <remarks>
/// If the target parameter is used several times in the template, only one occurrence becomes editable;
/// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence,
/// use values >= 0. To make the parameter non-editable when the template is expanded, use -1.
/// </remarks>>
public int Editable { get; set; }
/// <summary>
/// Identifies the target parameter of a <see cref="SourceTemplateAttribute">source template</see> if the
/// <see cref="MacroAttribute"/> is applied on a template method.
/// </summary>
public string Target { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
{
public AspMvcAreaMasterLocationFormatAttribute(string format)
{
Format = format;
}
public string Format { get; private set; }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
{
public AspMvcAreaPartialViewLocationFormatAttribute(string format)
{
Format = format;
}
public string Format { get; private set; }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
{
public AspMvcAreaViewLocationFormatAttribute(string format)
{
Format = format;
}
public string Format { get; private set; }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcMasterLocationFormatAttribute : Attribute
{
public AspMvcMasterLocationFormatAttribute(string format)
{
Format = format;
}
public string Format { get; private set; }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
{
public AspMvcPartialViewLocationFormatAttribute(string format)
{
Format = format;
}
public string Format { get; private set; }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class AspMvcViewLocationFormatAttribute : Attribute
{
public AspMvcViewLocationFormatAttribute(string format)
{
Format = format;
}
public string Format { get; private set; }
}
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// is an MVC action. If applied to a method, the MVC action name is calculated
/// implicitly from the context. Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcActionAttribute : Attribute
{
public AspMvcActionAttribute() { }
public AspMvcActionAttribute(string anonymousProperty)
{
AnonymousProperty = anonymousProperty;
}
public string AnonymousProperty { get; private set; }
}
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC area.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcAreaAttribute : Attribute
{
public AspMvcAreaAttribute() { }
public AspMvcAreaAttribute(string anonymousProperty)
{
AnonymousProperty = anonymousProperty;
}
public string AnonymousProperty { get; private set; }
}
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is
/// an MVC controller. If applied to a method, the MVC controller name is calculated
/// implicitly from the context. Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcControllerAttribute : Attribute
{
public AspMvcControllerAttribute() { }
public AspMvcControllerAttribute(string anonymousProperty)
{
AnonymousProperty = anonymousProperty;
}
public string AnonymousProperty { get; private set; }
}
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute
/// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcMasterAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute
/// for custom wrappers similar to <c>System.Web.Mvc.Controller.View(String, Object)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcModelTypeAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC
/// partial view. If applied to a method, the MVC partial view name is calculated implicitly
/// from the context. Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcPartialViewAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class AspMvcSupressViewErrorAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcDisplayTemplateAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcEditorTemplateAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC template.
/// Use this attribute for custom wrappers similar to
/// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AspMvcTemplateAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
/// is an MVC view. If applied to a method, the MVC view name is calculated implicitly
/// from the context. Use this attribute for custom wrappers similar to
/// <c>System.Web.Mvc.Controller.View(Object)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class AspMvcViewAttribute : Attribute { }
/// <summary>
/// ASP.NET MVC attribute. When applied to a parameter of an attribute,
/// indicates that this parameter is an MVC action name.
/// </summary>
/// <example><code>
/// [ActionName("Foo")]
/// public ActionResult Login(string returnUrl) {
/// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
/// return RedirectToAction("Bar"); // Error: Cannot resolve action
/// }
/// </code></example>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
public sealed class AspMvcActionSelectorAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)]
public sealed class HtmlElementAttributesAttribute : Attribute
{
public HtmlElementAttributesAttribute() { }
public HtmlElementAttributesAttribute(string name)
{
Name = name;
}
public string Name { get; private set; }
}
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)]
public sealed class HtmlAttributeValueAttribute : Attribute
{
public HtmlAttributeValueAttribute([NotNull] string name)
{
Name = name;
}
[NotNull] public string Name { get; private set; }
}
/// <summary>
/// Razor attribute. Indicates that a parameter or a method is a Razor section.
/// Use this attribute for custom wrappers similar to
/// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
public sealed class RazorSectionAttribute : Attribute { }
/// <summary>
/// Indicates how method invocation affects content of the collection.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class CollectionAccessAttribute : Attribute
{
public CollectionAccessAttribute(CollectionAccessType collectionAccessType)
{
CollectionAccessType = collectionAccessType;
}
public CollectionAccessType CollectionAccessType { get; private set; }
}
[Flags]
public enum CollectionAccessType
{
/// <summary>Method does not use or modify content of the collection.</summary>
None = 0,
/// <summary>Method only reads content of the collection but does not modify it.</summary>
Read = 1,
/// <summary>Method can change content of the collection but does not add new elements.</summary>
ModifyExistingContent = 2,
/// <summary>Method can add new elements to the collection.</summary>
UpdatedContent = ModifyExistingContent | 4
}
/// <summary>
/// Indicates that the marked method is assertion method, i.e. it halts control flow if
/// one of the conditions is satisfied. To set the condition, mark one of the parameters with
/// <see cref="AssertionConditionAttribute"/> attribute.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class AssertionMethodAttribute : Attribute { }
/// <summary>
/// Indicates the condition parameter of the assertion method. The method itself should be
/// marked by <see cref="AssertionMethodAttribute"/> attribute. The mandatory argument of
/// the attribute is the assertion type.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class AssertionConditionAttribute : Attribute
{
public AssertionConditionAttribute(AssertionConditionType conditionType)
{
ConditionType = conditionType;
}
public AssertionConditionType ConditionType { get; private set; }
}
/// <summary>
/// Specifies assertion type. If the assertion method argument satisfies the condition,
/// then the execution continues. Otherwise, execution is assumed to be halted.
/// </summary>
public enum AssertionConditionType
{
/// <summary>Marked parameter should be evaluated to true.</summary>
IS_TRUE = 0,
/// <summary>Marked parameter should be evaluated to false.</summary>
IS_FALSE = 1,
/// <summary>Marked parameter should be evaluated to null value.</summary>
IS_NULL = 2,
/// <summary>Marked parameter should be evaluated to not null value.</summary>
IS_NOT_NULL = 3,
}
/// <summary>
/// Indicates that the marked method unconditionally terminates control flow execution.
/// For example, it could unconditionally throw exception.
/// </summary>
[Obsolete("Use [ContractAnnotation('=> halt')] instead")]
[AttributeUsage(AttributeTargets.Method)]
public sealed class TerminatesProgramAttribute : Attribute { }
/// <summary>
/// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select,
/// .Where). This annotation allows inference of [InstantHandle] annotation for parameters
/// of delegate type by analyzing LINQ method chains.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class LinqTunnelAttribute : Attribute { }
/// <summary>
/// Indicates that IEnumerable, passed as parameter, is not enumerated.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class NoEnumerationAttribute : Attribute { }
/// <summary>
/// Indicates that parameter is regular expression pattern.
/// </summary>
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class RegexPatternAttribute : Attribute { }
/// <summary>
/// XAML attribute. Indicates the type that has <c>ItemsSource</c> property and should be treated
/// as <c>ItemsControl</c>-derived type, to enable inner items <c>DataContext</c> type resolve.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public sealed class XamlItemsControlAttribute : Attribute { }
/// <summary>
/// XAML attibute. Indicates the property of some <c>BindingBase</c>-derived type, that
/// is used to bind some item of <c>ItemsControl</c>-derived type. This annotation will
/// enable the <c>DataContext</c> type resolve for XAML bindings for such properties.
/// </summary>
/// <remarks>
/// Property should have the tree ancestor of the <c>ItemsControl</c> type or
/// marked with the <see cref="XamlItemsControlAttribute"/> attribute.
/// </remarks>
[AttributeUsage(AttributeTargets.Property)]
public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class AspChildControlTypeAttribute : Attribute
{
public AspChildControlTypeAttribute(string tagName, Type controlType)
{
TagName = tagName;
ControlType = controlType;
}
public string TagName { get; private set; }
public Type ControlType { get; private set; }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
public sealed class AspDataFieldAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)]
public sealed class AspDataFieldsAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Property)]
public sealed class AspMethodPropertyAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class AspRequiredAttributeAttribute : Attribute
{
public AspRequiredAttributeAttribute([NotNull] string attribute)
{
Attribute = attribute;
}
public string Attribute { get; private set; }
}
[AttributeUsage(AttributeTargets.Property)]
public sealed class AspTypePropertyAttribute : Attribute
{
public bool CreateConstructorReferences { get; private set; }
public AspTypePropertyAttribute(bool createConstructorReferences)
{
CreateConstructorReferences = createConstructorReferences;
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class RazorImportNamespaceAttribute : Attribute
{
public RazorImportNamespaceAttribute(string name)
{
Name = name;
}
public string Name { get; private set; }
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class RazorInjectionAttribute : Attribute
{
public RazorInjectionAttribute(string type, string fieldName)
{
Type = type;
FieldName = fieldName;
}
public string Type { get; private set; }
public string FieldName { get; private set; }
}
[AttributeUsage(AttributeTargets.Method)]
public sealed class RazorHelperCommonAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Property)]
public sealed class RazorLayoutAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Method)]
public sealed class RazorWriteLiteralMethodAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Method)]
public sealed class RazorWriteMethodAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Parameter)]
public sealed class RazorWriteMethodParameterAttribute : Attribute { }
/// <summary>
/// Prevents the Member Reordering feature from tossing members of the marked class.
/// </summary>
/// <remarks>
/// The attribute must be mentioned in your member reordering patterns
/// </remarks>
[AttributeUsage(AttributeTargets.All)]
public sealed class NoReorder : Attribute { }
}

View File

@@ -0,0 +1,35 @@
using System.Reflection;
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.ObjectModel")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.ObjectModel")]
[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("1b4dc4e6-68eb-4586-8570-63e9196fb1de")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -1,8 +1,8 @@
using System.Windows.Media; using System.Windows.Media;
namespace Filtration.Models namespace Filtration.ObjectModel
{ {
internal class ReplaceColorsParameterSet public class ReplaceColorsParameterSet
{ {
public Color OldTextColor { get; set; } public Color OldTextColor { get; set; }
public Color NewTextColor { get; set; } public Color NewTextColor { get; set; }

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
{
[Serializable]
public class Theme
{
private readonly ThemeComponentCollection _components;
public Theme()
{
_components = new ThemeComponentCollection { IsMasterCollection = false};
}
public string Name { get; set; }
[XmlIgnore]
public string FilePath { get; set; }
public ThemeComponentCollection Components
{
get { return _components; }
}
public bool ComponentExists(ThemeComponentType componentType, string componentName)
{
var componentCount =
_components.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
return componentCount > 0;
}
public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
_components.Add(new ThemeComponent(componentType, componentName, componentColor));
}
}
}

View File

@@ -0,0 +1,106 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using System.Xml.Serialization;
using Filtration.ObjectModel.Annotations;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
{
[Serializable]
public class ThemeComponent : INotifyPropertyChanged
{
private Color _color;
private EventHandler _themeComponentUpdatedEventHandler;
private readonly object _eventLock = new object();
public ThemeComponent()
{
}
public ThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
if (componentName == null || componentColor == null)
{
throw new ArgumentException("Null parameters not allowed in ThemeComponent constructor");
}
ComponentType = componentType;
Color = componentColor;
ComponentName = componentName;
}
// By implementing a custom event accessor here we can keep the UsageCount up to date.
public event EventHandler ThemeComponentUpdated
{
add
{
lock (_eventLock)
{
_themeComponentUpdatedEventHandler += value;
OnPropertyChanged("UsageCount");
}
}
remove
{
lock (_eventLock)
{
// ReSharper disable once DelegateSubtraction
_themeComponentUpdatedEventHandler -= value;
OnPropertyChanged("UsageCount");
}
}
}
public event EventHandler ThemeComponentDeleted;
public string ComponentName { get; set; }
public ThemeComponentType ComponentType{ get; set; }
public Color Color
{
get { return _color; }
set
{
_color = value;
OnPropertyChanged();
if (_themeComponentUpdatedEventHandler != null)
{
_themeComponentUpdatedEventHandler.Invoke(this, EventArgs.Empty);
}
}
}
public int UsageCount
{
get
{
if (_themeComponentUpdatedEventHandler == null)
{
return 0;
}
return _themeComponentUpdatedEventHandler.GetInvocationList().Length;
}
}
public void TerminateComponent()
{
if (ThemeComponentDeleted != null)
{
ThemeComponentDeleted.Invoke(this, EventArgs.Empty);
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

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

View File

@@ -46,23 +46,37 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Models\TestItemFilterBlock.cs" />
<Compile Include="Models\TestItemFilterBlockGroup.cs" />
<Compile Include="Models\TestItemFilterScript.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repositories\TestItemFilterScriptRepository.cs" />
<Compile Include="Services\TestHTTPService.cs" />
<Compile Include="Services\TestItemFilterPersistenceService.cs" /> <Compile Include="Services\TestItemFilterPersistenceService.cs" />
<Compile Include="Services\TestStaticDataService.cs" /> <Compile Include="Services\TestStaticDataService.cs" />
<Compile Include="Services\TestUpdateService.cs" />
<Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" /> <Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" />
<Compile Include="Translators\TestItemFilterBlockTranslator.cs" /> <Compile Include="Translators\TestItemFilterBlockTranslator.cs" />
<Compile Include="Translators\TestItemFilterScriptTranslator.cs" /> <Compile Include="Translators\TestItemFilterScriptTranslator.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="app.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Models\" />
<Folder Include="ViewModels\" /> <Folder Include="ViewModels\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Filtration.Common\Filtration.Common.csproj">
<Project>{8cb44f28-2956-4c2a-9314-72727262edd4}</Project>
<Name>Filtration.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.Interface\Filtration.Interface.csproj">
<Project>{0f333344-7695-47b2-b0e6-172e4de74819}</Project>
<Name>Filtration.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration\Filtration.csproj"> <ProjectReference Include="..\Filtration\Filtration.csproj">
<Project>{55e0a34c-e039-43d7-a024-a4045401cdda}</Project> <Project>{55e0a34c-e039-43d7-a024-a4045401cdda}</Project>
<Name>Filtration</Name> <Name>Filtration</Name>

View File

@@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following

View File

@@ -0,0 +1,120 @@
using System.IO;
using System.Threading.Tasks;
using Filtration.ObjectModel;
using Filtration.Repositories;
using Filtration.Services;
using Filtration.ViewModels;
using Moq;
using NUnit.Framework;
namespace Filtration.Tests.Repositories
{
[TestFixture]
public class TestItemFilterScriptRepository
{
[Test]
public async Task LoadScriptFromFile_CallsPersistenceServiceUsingPathAndReturnsViewModel()
{
// Arrange
var testInputPath = "C:\\TestPath.filter";
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).ReturnsAsync(new ItemFilterScript()).Verifiable();
var mockItemFilterScriptViewModel = new Mock<IItemFilterScriptViewModel>();
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
mockItemFilterScriptViewModelFactory.Setup(f => f.Create()).Returns(mockItemFilterScriptViewModel.Object);
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
// Act
var result = await repository.LoadScriptFromFileAsync(testInputPath);
// Assert
mockPersistenceService.Verify();
Assert.AreEqual(mockItemFilterScriptViewModel.Object, result);
}
[Test]
public void LoadScriptFromFile_PersistenceServiceThrows_ThrowsIOException()
{
// Arrange
var testInputPath = "C:\\TestPath.filter";
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
mockPersistenceService.Setup(p => p.LoadItemFilterScriptAsync(testInputPath)).Throws<IOException>();
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
// Act
// Assert
Assert.Throws<IOException>(async () => await repository.LoadScriptFromFileAsync(testInputPath));
}
[Test]
public void SetItemFilterScriptDirectory_CallsPersistenceServiceSetItemFilterScriptDirectory()
{
// Arrange
var testInputPath = "C:\\Test\\Path";
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
mockPersistenceService.Setup(p => p.SetItemFilterScriptDirectory(testInputPath)).Verifiable();
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
// Act
repository.SetItemFilterScriptDirectory(testInputPath);
// Assert
mockPersistenceService.Verify();
}
[Test]
public void GetItemFilterScriptDirectory_ReturnsItemFilterScriptDirectoryFromPersistenceService()
{
// Arrange
var testInputPath = "C:\\Test\\Path";
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
mockPersistenceService.SetupGet(p => p.ItemFilterScriptDirectory).Returns(testInputPath).Verifiable();
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
// Act
string result = repository.GetItemFilterScriptDirectory();
// Assert
mockPersistenceService.Verify();
Assert.AreEqual(result, testInputPath);
}
[Test]
public void NewScript_ReturnsScriptFromViewModelFactory()
{
// Arrange
var mockPersistenceService = new Mock<IItemFilterPersistenceService>();
var mockItemFilterScriptViewModel = new Mock<IItemFilterScriptViewModel>();
var mockItemFilterScriptViewModelFactory = new Mock<IItemFilterScriptViewModelFactory>();
mockItemFilterScriptViewModelFactory.Setup(f => f.Create()).Returns(mockItemFilterScriptViewModel.Object);
var repository = new ItemFilterScriptRepository(mockPersistenceService.Object, mockItemFilterScriptViewModelFactory.Object);
// Act
IItemFilterScriptViewModel result = repository.NewScript();
// Assert
Assert.AreEqual(mockItemFilterScriptViewModel.Object, result);
}
}
}

View File

@@ -0,0 +1,23 @@
using Filtration.Services;
using NUnit.Framework;
namespace Filtration.Tests.Services
{
[Ignore("Integration Test - Makes real HTTP call")]
[TestFixture]
public class TestHTTPService
{
[Test]
public async void GetContent_FetchesDataFromUrl()
{
// Arrange
var service = new HTTPService();
// Act
var result = await service.GetContentAsync("http://ben-wallis.github.io/Filtration/filtration_version.xml");
// Assert
Assert.IsNotNull(result);
}
}
}

View File

@@ -1,4 +1,7 @@
using Filtration.Models; using System.IO;
using System.Threading.Tasks;
using Filtration.Common.Services;
using Filtration.ObjectModel;
using Filtration.Services; using Filtration.Services;
using Filtration.Translators; using Filtration.Translators;
using Moq; using Moq;
@@ -10,7 +13,7 @@ namespace Filtration.Tests.Services
public class TestItemFilterPersistenceService public class TestItemFilterPersistenceService
{ {
[Test] [Test]
public void LoadItemFilterScript_CallsTranslatorAndFileSystemService() public async Task LoadItemFilterScript_CallsTranslatorAndFileSystemService()
{ {
// Arrange // Arrange
const string TestInputPath = "C:\\Test Path\\Script.Filter"; const string TestInputPath = "C:\\Test Path\\Script.Filter";
@@ -26,7 +29,7 @@ namespace Filtration.Tests.Services
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
// Act // Act
var script = service.LoadItemFilterScript(TestInputPath); var script = await service.LoadItemFilterScriptAsync(TestInputPath);
// Assert // Assert
mockFileSystemService.Verify(); mockFileSystemService.Verify();
@@ -35,7 +38,7 @@ namespace Filtration.Tests.Services
} }
[Test] [Test]
public void SaveItemFilterScript_CallsTranslatorAndFileSystemService() public async Task SaveItemFilterScript_CallsTranslatorAndFileSystemService()
{ {
// Arrange // Arrange
var testFilePath = "C:\\Test\\File.txt"; var testFilePath = "C:\\Test\\File.txt";
@@ -51,7 +54,7 @@ namespace Filtration.Tests.Services
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
// Act // Act
service.SaveItemFilterScript(testScript); await service.SaveItemFilterScriptAsync(testScript);
// Assert // Assert
mockFileSystemService.Verify(); mockFileSystemService.Verify();
@@ -74,10 +77,49 @@ namespace Filtration.Tests.Services
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
// Act // Act
var result = service.DefaultPathOfExileDirectory(); service.DefaultPathOfExileDirectory();
// Assert // Assert
mockFileSystemService.Verify(); mockFileSystemService.Verify();
} }
[Test]
public void SetItemFilterScriptDirectory_InvalidPath_ThrowsDirectoryNotFoundException()
{
// Arrange
var testInputPath = "C:\\Test\\Path";
var mockFileSystemService = new Mock<IFileSystemService>();
mockFileSystemService.Setup(f => f.DirectoryExists(testInputPath)).Returns(false).Verifiable();
var mockItemFilterScriptTranslator = new Mock<IItemFilterScriptTranslator>();
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
// Act
// Assert
Assert.Throws<DirectoryNotFoundException>(() => service.SetItemFilterScriptDirectory(testInputPath));
}
[Test]
public void SetItemFilterScriptDirectory_ValidPath_SetsItemFilterScriptDirectory()
{
// Arrange
var testInputPath = "C:\\Test\\Path";
var mockFileSystemService = new Mock<IFileSystemService>();
mockFileSystemService.Setup(f => f.DirectoryExists(testInputPath)).Returns(true).Verifiable();
var mockItemFilterScriptTranslator = new Mock<IItemFilterScriptTranslator>();
var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object);
// Act
service.SetItemFilterScriptDirectory(testInputPath);
// Assert
Assert.AreEqual(testInputPath, service.ItemFilterScriptDirectory);
}
} }
} }

View File

@@ -1,4 +1,5 @@
using Filtration.Services; using Filtration.Common.Services;
using Filtration.Services;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Filtration.Models;
using Filtration.Services;
using Moq;
using NUnit.Framework;
namespace Filtration.Tests.Services
{
[TestFixture]
public class TestUpdateService
{
[Test]
public void DeserializeUpdateData_ReturnsCorrectData()
{
// Arrange
var testInputData = @"<UpdateData>
<LatestVersionMajorPart>1</LatestVersionMajorPart>
<LatestVersionMinorPart>3</LatestVersionMinorPart>
<ReleaseDate>2015-07-01</ReleaseDate>
<DownloadUrl>http://www.google.com</DownloadUrl>
<ReleaseNotes>* Release notes line 1
* Release notes line 2
* More really great release notes!</ReleaseNotes>
</UpdateData>";
var expectedResult = new UpdateData
{
LatestVersionMajorPart = 1,
LatestVersionMinorPart = 3,
DownloadUrl = "http://www.google.com",
ReleaseDate = new DateTime(2015, 7, 1),
ReleaseNotes = @"* Release notes line 1
* Release notes line 2
* More really great release notes!"
};
var mockHTTPService = new Mock<IHTTPService>();
var service = new UpdateCheckService(mockHTTPService.Object);
// Act
var result = service.DeserializeUpdateData(testInputData);
// Assert
Assert.AreEqual(expectedResult.LatestVersionMajorPart, result.LatestVersionMajorPart);
Assert.AreEqual(expectedResult.LatestVersionMinorPart, result.LatestVersionMinorPart);
Assert.AreEqual(expectedResult.DownloadUrl, result.DownloadUrl);
Assert.AreEqual(expectedResult.ReleaseDate, result.ReleaseDate);
Assert.AreEqual(expectedResult.ReleaseNotes, result.ReleaseNotes);
}
}
}

View File

@@ -0,0 +1,121 @@
using System.Collections.Generic;
using Filtration.ObjectModel;
using Filtration.Translators;
using NUnit.Framework;
namespace Filtration.Tests.Translators
{
[TestFixture]
public class TestBlockGroupHierarchyBuilder
{
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_ReturnsBlockGroupWithCorrectName()
{
// Arrange
var inputStrings = new List<string> {"Block Group", "Sub Block Group"};
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Sub Block Group", result.GroupName);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_SingleBlockGroup()
{
// Arrange
var inputStrings = new List<string> { "Block Group" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Block Group", result.GroupName);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_AdvancedBlockGroup_MarksBlockGroupAsAdvanced()
{
// Arrange
var inputStrings = new List<string> { "~Block Group" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Block Group", result.GroupName);
Assert.AreEqual(true, result.Advanced);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_AdvancedBlockGroup_ChildrenAreCreatedAsAdvanced()
{
// Arrange
var inputStrings = new List<string> { "~Advanced Block Group", "This should be advanced too" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual(true, result.Advanced);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_ExistingAdvancedBlockGroup_SetsParentCorrectly()
{
// Arrange
var inputStrings = new List<string> { "~Block Group" };
var rootBlock = new ItemFilterBlockGroup("Root", null);
var subBlock = new ItemFilterBlockGroup("Block Group", rootBlock, true);
rootBlock.ChildGroups.Add(subBlock);
var builder = new BlockGroupHierarchyBuilder();
// Act
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(1, rootBlock.ChildGroups.Count);
Assert.AreEqual("Block Group", result.GroupName);
Assert.AreEqual(true, result.Advanced);
}
[Test]
public void IntegrateStringListIntoBlockGroupHierarchy_MultipleBlockGroups()
{
// Arrange
var rootBlock = new ItemFilterBlockGroup("Root", null);
var builder = new BlockGroupHierarchyBuilder();
// Act
var inputStrings = new List<string> { "Block Group" };
builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
inputStrings = new List<string> { "Block Group 2" };
builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
inputStrings = new List<string> { "Block Group", "Sub Block Group" };
var result = builder.IntegrateStringListIntoBlockGroupHierarchy(inputStrings, rootBlock);
// Assert
Assert.AreEqual(2, rootBlock.ChildGroups.Count);
Assert.AreEqual("Sub Block Group", result.GroupName);
}
}
}

View File

@@ -1,11 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using Filtration.Enums; using Filtration.ObjectModel;
using Filtration.Models; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.Models.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.Models.BlockItemTypes; using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.Translators; using Filtration.Translators;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
@@ -23,6 +25,36 @@ namespace Filtration.Tests.Translators
_testUtility = new ItemFilterBlockTranslatorTestUtility(); _testUtility = new ItemFilterBlockTranslatorTestUtility();
} }
[Test]
public void TranslateStringToItemFilterBlock_NotDisabled_SetsBlockEnabledTrue()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(true, result.Enabled);
}
[Test]
public void TranslateStringToItemFilterBlock_DisabledBlock_SetsBlockEnabledFalse()
{
// Arrange
var inputString = "HideDisabled" + Environment.NewLine +
" ItemLevel >= 55";
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(2, result.BlockItems.Count);
Assert.AreEqual(BlockAction.Hide, result.Action);
Assert.AreEqual(false, result.Enabled);
}
[Test] [Test]
public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_NoDescriptionComment_ReturnsCorrectObject()
{ {
@@ -31,7 +63,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem));
@@ -49,7 +81,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(); _testUtility.MockBlockGroupHierarchyBuilder.Verify();
@@ -64,7 +96,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(true, inputBlockGroup.IsChecked); Assert.AreEqual(true, inputBlockGroup.IsChecked);
@@ -79,7 +111,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(false, inputBlockGroup.IsChecked); Assert.AreEqual(false, inputBlockGroup.IsChecked);
@@ -93,7 +125,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never); _testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
@@ -107,7 +139,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never); _testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
@@ -122,7 +154,7 @@ namespace Filtration.Tests.Translators
// Act // Act
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable(); _testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable();
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(testBlockGroup, result.BlockGroup); Assert.AreEqual(testBlockGroup, result.BlockGroup);
@@ -136,7 +168,7 @@ namespace Filtration.Tests.Translators
var inputString = "Hide" + Environment.NewLine; var inputString = "Hide" + Environment.NewLine;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem));
@@ -152,7 +184,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual("This is a test Block", result.Description); Assert.AreEqual("This is a test Block", result.Description);
@@ -172,7 +204,7 @@ namespace Filtration.Tests.Translators
" ItemLevel >= 55"; " ItemLevel >= 55";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual("Second Line", result.Description); Assert.AreEqual("Second Line", result.Description);
@@ -190,7 +222,7 @@ namespace Filtration.Tests.Translators
" DropLevel = 40"; " DropLevel = 40";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -208,7 +240,7 @@ namespace Filtration.Tests.Translators
" Quality < 18"; " Quality < 18";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -226,7 +258,7 @@ namespace Filtration.Tests.Translators
" Rarity > Normal"; " Rarity > Normal";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -244,7 +276,7 @@ namespace Filtration.Tests.Translators
" Rarity Normal"; " Rarity Normal";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem));
@@ -261,7 +293,7 @@ namespace Filtration.Tests.Translators
@" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2"""; @" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2""";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem));
@@ -280,7 +312,7 @@ namespace Filtration.Tests.Translators
@" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2"""; @" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2""";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem));
@@ -299,7 +331,7 @@ namespace Filtration.Tests.Translators
" Sockets > 2"; " Sockets > 2";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -317,7 +349,7 @@ namespace Filtration.Tests.Translators
" LinkedSockets != 1"; " LinkedSockets != 1";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -335,7 +367,7 @@ namespace Filtration.Tests.Translators
" Width != 1"; " Width != 1";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -353,7 +385,7 @@ namespace Filtration.Tests.Translators
" Height <= 3"; " Height <= 3";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
@@ -371,7 +403,7 @@ namespace Filtration.Tests.Translators
" Height <=3"; " Height <=3";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem));
@@ -388,7 +420,7 @@ namespace Filtration.Tests.Translators
" SocketGroup RRGB"; " SocketGroup RRGB";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem));
@@ -406,7 +438,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 255 20 100"; " SetTextColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -424,7 +456,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 65 0 255 12"; " SetTextColor 65 0 255 12";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -443,7 +475,7 @@ namespace Filtration.Tests.Translators
" SetBackgroundColor 255 20 100"; " SetBackgroundColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
@@ -462,7 +494,7 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 20 100"; " SetBorderColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -472,6 +504,45 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(100, blockItem.Color.B); Assert.AreEqual(100, blockItem.Color.B);
} }
[Test]
public void TranslateStringToItemFilterBlock_SetBorderColor_CommentWithLargeNumber_DoesNotThrow()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" SetBorderColor 255 20 100 # Some stuff 8504 with a number in a comment";
// Act
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null));
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
var blockItem = result.BlockItems.OfType<BorderColorBlockItem>().First();
Assert.AreEqual(255, blockItem.Color.R);
Assert.AreEqual(20, blockItem.Color.G);
Assert.AreEqual(100, blockItem.Color.B);
}
[Test]
public void TranslateStringToItemFilterBlock_SetTextColorWithThemeComponent_CallsThemeListBuilderAddComponent()
{
// Arrange
var inputString = "Show" + Environment.NewLine +
" SetTextColor 255 20 100 # Rare Item Text";
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
// Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, testInputThemeComponentCollection);
// Assert
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
Assert.AreSame(testComponent, blockItem.ThemeComponent);
var firstComponent = testInputThemeComponentCollection.First();
Assert.AreEqual("Rare Item Text", firstComponent.ComponentName);
}
[Test] [Test]
public void TranslateStringToItemFilterBlock_SetFontSize_ReturnsCorrectObject() public void TranslateStringToItemFilterBlock_SetFontSize_ReturnsCorrectObject()
{ {
@@ -481,7 +552,7 @@ namespace Filtration.Tests.Translators
" SetFontSize 15"; " SetFontSize 15";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
@@ -498,7 +569,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 4"; " PlayAlertSound 4";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -516,7 +587,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 2 95"; " PlayAlertSound 2 95";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -533,7 +604,7 @@ namespace Filtration.Tests.Translators
var inputString = "# Section: " + TestInputSectionDescription; var inputString = "# Section: " + TestInputSectionDescription;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.IsInstanceOf<ItemFilterSection>(result); Assert.IsInstanceOf<ItemFilterSection>(result);
@@ -566,7 +637,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 3"; " PlayAlertSound 3";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual("Test filter with everything", result.Description); Assert.AreEqual("Test filter with everything", result.Description);
@@ -648,7 +719,7 @@ namespace Filtration.Tests.Translators
" Quality < 17"; " Quality < 17";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem)); Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem));
@@ -677,7 +748,7 @@ namespace Filtration.Tests.Translators
" SetTextColor 255 20 100"; " SetTextColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
@@ -698,7 +769,7 @@ namespace Filtration.Tests.Translators
" SetFontSize 27" + Environment.NewLine; " SetFontSize 27" + Environment.NewLine;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
@@ -717,7 +788,7 @@ namespace Filtration.Tests.Translators
" PlayAlertSound 2" + Environment.NewLine; " PlayAlertSound 2" + Environment.NewLine;
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
@@ -735,7 +806,7 @@ namespace Filtration.Tests.Translators
" SetBackgroundColor 255 20 100"; " SetBackgroundColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
@@ -754,7 +825,7 @@ namespace Filtration.Tests.Translators
" SetBorderColor 255 20 100"; " SetBorderColor 255 20 100";
// Act // Act
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString); var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
// Assert // Assert
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem)); Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
@@ -1064,6 +1135,27 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
} }
[Test]
public void TranslateItemFilterBlockToString_TextColorWithThemeComponent_ReturnsCorrectString()
{
// Arrange
var expectedResult = "Show" + Environment.NewLine +
" SetTextColor 54 102 255 # Test Theme Component";
var blockItem = new TextColorBlockItem(new Color {A = 255, R = 54, G = 102, B = 255})
{
ThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Theme Component", new Color())
};
_testUtility.TestBlock.BlockItems.Add(blockItem);
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
// Assert
Assert.AreEqual(expectedResult, result);
}
[Test] [Test]
public void TranslateItemFilterBlockToString_TextColorNotMaxAlpha_ReturnsCorrectString() public void TranslateItemFilterBlockToString_TextColorNotMaxAlpha_ReturnsCorrectString()
{ {
@@ -1165,6 +1257,7 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
} }
[Ignore("This test fails after the refactoring to use OutputText in the translator, but this situation shouldn't ever occur anyway")]
[Test] [Test]
public void TranslateItemFilterBlockToString_MultipleFontSize_UsesFirstFontSize() public void TranslateItemFilterBlockToString_MultipleFontSize_UsesFirstFontSize()
{ {
@@ -1189,7 +1282,7 @@ namespace Filtration.Tests.Translators
public void TranslateItemFilterBlockToString_Section_ReturnsCorrectString() public void TranslateItemFilterBlockToString_Section_ReturnsCorrectString()
{ {
// Arrange // Arrange
var TestInputSectionText = "Ermagerd it's a section!"; const string TestInputSectionText = "Ermagerd it's a section!";
var expectedResult = "# Section: " + TestInputSectionText; var expectedResult = "# Section: " + TestInputSectionText;
_testUtility.TestBlock = new ItemFilterSection { Description = TestInputSectionText }; _testUtility.TestBlock = new ItemFilterSection { Description = TestInputSectionText };
@@ -1201,6 +1294,26 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
} }
[Test]
public void TranslateItemFilterBlockToString_DisabledBlock_ReturnsCorrectString()
{
// Arrange
var expectedResult = "#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# Width = 4" + Environment.NewLine +
"#Disabled Block End";
_testUtility.TestBlock.Enabled = false;
_testUtility.TestBlock.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 4));
// Act
var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock);
// Assert
Assert.AreEqual(expectedResult, result);
}
[Test] [Test]
public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString() public void TranslateItemFilterBlockToString_Everything_ReturnsCorrectString()
{ {
@@ -1211,14 +1324,14 @@ namespace Filtration.Tests.Translators
" DropLevel != 56" + Environment.NewLine + " DropLevel != 56" + Environment.NewLine +
" Quality > 2" + Environment.NewLine + " Quality > 2" + Environment.NewLine +
" Rarity = Unique" + Environment.NewLine + " Rarity = Unique" + Environment.NewLine +
" Class \"Body Armour\" \"Gloves\" \"Belt\" \"Two Hand Axes\"" + Environment.NewLine +
" BaseType \"Greater Life Flask\" \"Simple Robe\" \"Full Wyrmscale\"" +
Environment.NewLine +
" Sockets <= 6" + Environment.NewLine + " Sockets <= 6" + Environment.NewLine +
" LinkedSockets >= 4" + Environment.NewLine + " LinkedSockets >= 4" + Environment.NewLine +
" Width = 3" + Environment.NewLine + " Width = 3" + Environment.NewLine +
" Height <= 6" + Environment.NewLine + " Height <= 6" + Environment.NewLine +
" Height >= 2" + Environment.NewLine + " Height >= 2" + Environment.NewLine +
" Class \"Body Armour\" \"Gloves\" \"Belt\" \"Two Hand Axes\"" + Environment.NewLine +
" BaseType \"Greater Life Flask\" \"Simple Robe\" \"Full Wyrmscale\"" +
Environment.NewLine +
" SetTextColor 255 89 0 56" + Environment.NewLine + " SetTextColor 255 89 0 56" + Environment.NewLine +
" SetBackgroundColor 0 0 0" + Environment.NewLine + " SetBackgroundColor 0 0 0" + Environment.NewLine +
" SetBorderColor 255 1 254" + Environment.NewLine + " SetBorderColor 255 1 254" + Environment.NewLine +
@@ -1260,6 +1373,177 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(expectedResult, result); Assert.AreEqual(expectedResult, result);
} }
[Test]
public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlock()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
testInputBlockItems.Add(testInputBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem);
Assert.AreNotSame(testInputBlockItem, textColorBlockItem);
Assert.AreEqual(new Color { R = 240, G = 200, B = 150, A = 255}, textColorBlockItem.Color);
}
[Test]
public void ReplaceColorBlockItemsFromString_SingleLine_ReplacesColorBlockBugTest()
{
// Arrange
var testInputString = "SetBackgroundColor 70 0 0 255";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new BackgroundColorBlockItem(new Color { R = 70, G = 0, B = 1, A = 255});
testInputBlockItems.Add(testInputBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
Assert.IsNotNull(backgroundColorBlockItem);
Assert.AreNotSame(testInputBlockItem, backgroundColorBlockItem);
Assert.AreEqual(new Color { R = 70, G = 0, B = 0, A = 255 }, backgroundColorBlockItem.Color);
}
[Ignore("Not currently possible - will not be necessary once commanding (to enable undo history) is implemented anyway")]
[Test]
public void ReplaceColorBlockItemsFromString_MalformedLine_DoesNothing()
{
// Arrange
var testInputString = "SetTextCsaolor 240 200 150 # Rarest Currency";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
testInputBlockItems.Add(testInputBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem);
Assert.AreSame(testInputBlockItem, textColorBlockItem);
}
[Test]
public void ReplaceColorBlockItemsFromString_MultipleLines_ExistingBlockItems()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputTextColorBlockItem = new TextColorBlockItem(Colors.Red);
var testInputBackgroundColorBlockItem = new BackgroundColorBlockItem(Colors.Blue);
var testInpuBorderColorBlockItem = new BorderColorBlockItem(Colors.Yellow);
testInputBlockItems.Add(testInputTextColorBlockItem);
testInputBlockItems.Add(testInputBackgroundColorBlockItem);
testInputBlockItems.Add(testInpuBorderColorBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem);
Assert.AreNotSame(testInputTextColorBlockItem, textColorBlockItem);
Assert.AreEqual(new Color {A = 255, R = 240, G = 200, B = 150}, textColorBlockItem.Color);
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
Assert.IsNotNull(backgroundColorBlockItem);
Assert.AreNotSame(testInputBackgroundColorBlockItem, backgroundColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 0, G = 0, B = 0 }, backgroundColorBlockItem.Color);
var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem;
Assert.IsNotNull(borderColorBlockItem);
Assert.AreNotSame(testInpuBorderColorBlockItem, borderColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
}
[Test]
public void ReplaceColorBlockItemsFromString_MultipleLines_NoExistingBlockItems()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background" + Environment.NewLine +
"SetBorderColor 255 255 255 # Rarest Currency Border";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 240, G = 200, B = 150 }, textColorBlockItem.Color);
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
Assert.IsNotNull(backgroundColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 0, G = 0, B = 0 }, backgroundColorBlockItem.Color);
var borderColorBlockItem = testInputBlockItems.First(b => b is BorderColorBlockItem) as BorderColorBlockItem;
Assert.IsNotNull(borderColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 255, G = 255, B = 255 }, borderColorBlockItem.Color);
}
[Test]
public void ReplaceColorBlockItemsFromString_MultipleLines_SomeExistingBlockItems()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency" + Environment.NewLine +
"SetBackgroundColor 0 0 0 # Rarest Currency Background";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputTextColorBlockItem = new TextColorBlockItem(Colors.Red);
var testInputBackgroundColorBlockItem = new BackgroundColorBlockItem(Colors.Blue);
var testInpuBorderColorBlockItem = new BorderColorBlockItem(Colors.Yellow);
testInputBlockItems.Add(testInputTextColorBlockItem);
testInputBlockItems.Add(testInputBackgroundColorBlockItem);
testInputBlockItems.Add(testInpuBorderColorBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
var textColorBlockItem = testInputBlockItems.First(b => b is TextColorBlockItem) as TextColorBlockItem;
Assert.IsNotNull(textColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 240, G = 200, B = 150 }, textColorBlockItem.Color);
var backgroundColorBlockItem = testInputBlockItems.First(b => b is BackgroundColorBlockItem) as BackgroundColorBlockItem;
Assert.IsNotNull(backgroundColorBlockItem);
Assert.AreEqual(new Color { A = 255, R = 0, G = 0, B = 0 }, backgroundColorBlockItem.Color);
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
}
[Ignore("ThemeComponentBuilder deprecated")]
[Test]
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
{
// Arrange
var testInputString = "SetTextColor 240 200 150 # Rarest Currency";
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
testInputBlockItems.Add(testInputBlockItem);
// Act
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
// Assert
}
private class ItemFilterBlockTranslatorTestUtility private class ItemFilterBlockTranslatorTestUtility
{ {
public ItemFilterBlockTranslatorTestUtility() public ItemFilterBlockTranslatorTestUtility()

View File

@@ -1,9 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Filtration.Enums; using System.Windows;
using Filtration.Models; using Filtration.ObjectModel;
using Filtration.Models.BlockItemTypes; using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.Properties;
using Filtration.Translators; using Filtration.Translators;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
@@ -19,6 +23,7 @@ namespace Filtration.Tests.Translators
public void ItemFilterScriptTranslatorTestSetup() public void ItemFilterScriptTranslatorTestSetup()
{ {
_testUtility = new ItemFilterScriptTranslatorTestUtility(); _testUtility = new ItemFilterScriptTranslatorTestUtility();
Settings.Default.Reset();
} }
[Test] [Test]
@@ -27,7 +32,7 @@ namespace Filtration.Tests.Translators
// Arrange // Arrange
var testInput = File.ReadAllText(@"Resources/testscript.txt"); var testInput = File.ReadAllText(@"Resources/testscript.txt");
_testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable(); _testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
// Act // Act
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput); var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
@@ -49,7 +54,7 @@ namespace Filtration.Tests.Translators
"End Script Description"; "End Script Description";
var mockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>(); var mockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable(); mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
// Act // Act
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput); var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
@@ -65,13 +70,12 @@ namespace Filtration.Tests.Translators
// Arrange // Arrange
var testInput = File.ReadAllText(@"Resources/ThioleItemFilter.txt"); var testInput = File.ReadAllText(@"Resources/ThioleItemFilter.txt");
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var mockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>(); var translator = new ItemFilterScriptTranslator(blockTranslator,
var blockTranslator = new ItemFilterBlockTranslator(mockBlockGroupHierarchyBuilder.Object); _testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator, mockBlockGroupHierarchyBuilder.Object);
// Act // Act
var script = translator.TranslateStringToItemFilterScript(testInput); translator.TranslateStringToItemFilterScript(testInput);
// Assert // Assert
// Not crashing out when loading a huge script means this integration test has passed! // Not crashing out when loading a huge script means this integration test has passed!
} }
@@ -85,7 +89,7 @@ namespace Filtration.Tests.Translators
var testBlock = new ItemFilterBlock(); var testBlock = new ItemFilterBlock();
testBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.Equal, 5)); testBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.Equal, 5));
var BlockOutput = "Test Script Output"; const string BlockOutput = "Test Script Output";
testScript.ItemFilterBlocks.Add(testBlock); testScript.ItemFilterBlocks.Add(testBlock);
@@ -93,12 +97,49 @@ namespace Filtration.Tests.Translators
// Act // Act
var result = _testUtility.ScriptTranslator.TranslateItemFilterScriptToString(testScript); _testUtility.ScriptTranslator.TranslateItemFilterScriptToString(testScript);
// Assert // Assert
_testUtility.MockItemFilterBlockTranslator.Verify(); _testUtility.MockItemFilterBlockTranslator.Verify();
} }
[Test]
public void TranslateItemFilterScriptToString_ExtraLineBetweenBlocksSettingFalse_ReturnsCorrectOutput()
{
Settings.Default.ExtraLineBetweenBlocks = false;
var script = new ItemFilterScript();
var block1 = new ItemFilterBlock { Description = "Test Filter 1" };
block1.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 5));
var block2 = new ItemFilterBlock();
block2.BlockItems.Add(new QualityBlockItem(FilterPredicateOperator.LessThan, 15));
block2.BlockItems.Add(new FontSizeBlockItem(7));
block2.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 3));
script.ItemFilterBlocks.Add(block1);
script.ItemFilterBlocks.Add(block2);
var expectedOutput = "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" + Environment.NewLine +
"# Test Filter 1" + Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 5" + Environment.NewLine +
"Show" + Environment.NewLine +
" Quality < 15" + Environment.NewLine +
" Width = 3" + Environment.NewLine +
" SetFontSize 7" + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateItemFilterScriptToString(script);
// Assert
Assert.AreEqual(expectedOutput, result);
}
[Test] [Test]
public void TranslateItemFilterScriptToString_FullScript_ReturnsCorrectOutput() public void TranslateItemFilterScriptToString_FullScript_ReturnsCorrectOutput()
{ {
@@ -133,9 +174,9 @@ namespace Filtration.Tests.Translators
" Width = 3" + Environment.NewLine + " Width = 3" + Environment.NewLine +
" SetFontSize 7" + Environment.NewLine + Environment.NewLine; " SetFontSize 7" + Environment.NewLine + Environment.NewLine;
var mockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>(); var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var blockTranslator = new ItemFilterBlockTranslator(mockBlockGroupHierarchyBuilder.Object); var translator = new ItemFilterScriptTranslator(blockTranslator,
var translator = new ItemFilterScriptTranslator(blockTranslator, mockBlockGroupHierarchyBuilder.Object); _testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act // Act
var result = translator.TranslateItemFilterScriptToString(script); var result = translator.TranslateItemFilterScriptToString(script);
@@ -177,7 +218,8 @@ namespace Filtration.Tests.Translators
" SetFontSize 25"; " SetFontSize 25";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object); var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator, _testUtility.MockBlockGroupHierarchyBuilder.Object); var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act // Act
var result = translator.TranslateStringToItemFilterScript(testInputScript); var result = translator.TranslateStringToItemFilterScript(testInputScript);
@@ -188,7 +230,160 @@ namespace Filtration.Tests.Translators
Assert.AreEqual(4, block.BlockItems.Count); Assert.AreEqual(4, block.BlockItems.Count);
var baseTypeItem = block.BlockItems.OfType<BaseTypeBlockItem>().First(); var baseTypeItem = block.BlockItems.OfType<BaseTypeBlockItem>().First();
Assert.AreEqual(2, baseTypeItem.Items.Count); Assert.AreEqual(2, baseTypeItem.Items.Count);
}
[Test]
public void TranslateStringToItemFilterScript_OneLineDescriptionNoBlockDescriptionAddsDescriptionToScript()
{
// Arrange
var testInputScript = "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" +
Environment.NewLine +
"Show" + Environment.NewLine +
"BaseType \"Maelström Staff\"" + Environment.NewLine + Environment.NewLine;
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual("Script edited with Filtration - https://github.com/ben-wallis/Filtration", result.Description);
var firstBlock = result.ItemFilterBlocks.First();
Assert.IsNullOrEmpty(firstBlock.Description);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlockCount()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine +
" SetTextColor 255 255 0";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_ReturnsCorrectBlocks()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"# SetTextColor 255 215 0" + Environment.NewLine +
"# SetBorderColor 255 105 180" + Environment.NewLine +
"# SetFontSize 32" + Environment.NewLine +
"#Disabled Block End" + Environment.NewLine +
Environment.NewLine +
"Show" + Environment.NewLine +
" ItemLevel > 20" + Environment.NewLine +
" SetTextColor 255 255 0";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(3, result.ItemFilterBlocks.Count);
var firstBlock = result.ItemFilterBlocks.First();
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
var thirdBlock = result.ItemFilterBlocks.Skip(2).First();
Assert.AreEqual(3, firstBlock.BlockItems.Count);
Assert.AreEqual(5, secondBlock.BlockItems.Count);
Assert.AreEqual(3, thirdBlock.BlockItems.Count);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlock_BlockDescriptionNotLost()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"# This is a disabled block" + Environment.NewLine +
"#Show" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"#Disabled Block End";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
Assert.AreEqual("This is a disabled block", secondBlock.Description);
}
[Test]
public void TranslateStringToItemFilterScript_DisabledBlockWithBlockGroup_ReturnsCorrectBlock()
{
// Arrange
var testInputScript = "Show" + Environment.NewLine +
" ItemLevel > 2" + Environment.NewLine +
" SetTextColor 255 40 0" + Environment.NewLine +
Environment.NewLine +
"#Disabled Block Start" + Environment.NewLine +
"# This is a disabled block" + Environment.NewLine +
"#Show#My Block Group" + Environment.NewLine +
"# ItemLevel > 2" + Environment.NewLine +
"#Disabled Block End";
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
_testUtility.MockBlockGroupHierarchyBuilder.Setup(
b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()))
.Returns(new ItemFilterBlockGroup("My Block Group", null));
var translator = new ItemFilterScriptTranslator(blockTranslator,
_testUtility.MockBlockGroupHierarchyBuilder.Object);
// Act
var result = translator.TranslateStringToItemFilterScript(testInputScript);
// Assert
Assert.AreEqual(2, result.ItemFilterBlocks.Count);
var secondBlock = result.ItemFilterBlocks.Skip(1).First();
Assert.AreEqual("This is a disabled block", secondBlock.Description);
Assert.AreEqual("My Block Group", secondBlock.BlockGroup.GroupName);
} }
private class ItemFilterScriptTranslatorTestUtility private class ItemFilterScriptTranslatorTestUtility

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Xceed.Wpf.AvalonDock" publicKeyToken="3e4669d2f30244f4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -0,0 +1,79 @@
<?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>{450AC313-BF25-4BFD-A066-9F39F026FDCF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.ThemeEditor.Tests</RootNamespace>
<AssemblyName>Filtration.ThemeEditor.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.1506.2515\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="Models\TestTheme.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\TestThemeProvider.cs" />
<Compile Include="Services\TestThemeService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.Common\Filtration.Common.csproj">
<Project>{8cb44f28-2956-4c2a-9314-72727262edd4}</Project>
<Name>Filtration.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ThemeEditor\Filtration.ThemeEditor.csproj">
<Project>{41b8f5c2-65aa-42f0-a20b-6f95b13a9f48}</Project>
<Name>Filtration.ThemeEditor</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,78 @@
using System.Windows.Media;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using NUnit.Framework;
namespace Filtration.ThemeEditor.Tests.Models
{
[TestFixture]
public class TestTheme
{
[Test]
public void ComponentExists_ComponentDoesExist_ReturnsTrue()
{
// Arrange
var theme = new Theme();
var testInputComponentTargetType = ThemeComponentType.TextColor;
const string TestInputComponentName = "test";
theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color());
// Act
var result = theme.ComponentExists(testInputComponentTargetType, TestInputComponentName);
// Assert
Assert.AreEqual(true, result);
}
[Test]
public void ComponentExists_ComponentDoesNotExist_DifferentNameSameType_ReturnsFalse()
{
// Arrange
var theme = new Theme();
var testInputComponentTargetType = ThemeComponentType.TextColor;
const string TestInputComponentName = "test";
theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color());
// Act
var result = theme.ComponentExists(testInputComponentTargetType, "blah");
// Assert
Assert.AreEqual(false, result);
}
[Test]
public void ComponentExists_ComponentDoesNotExist_DifferentTypeSameName_ReturnsFalse()
{
// Arrange
var theme = new Theme();
var testInputComponentTargetType = ThemeComponentType.TextColor;
const string TestInputComponentName = "test";
theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color());
// Act
var result = theme.ComponentExists(ThemeComponentType.BorderColor, TestInputComponentName);
// Assert
Assert.AreEqual(false, result);
}
[Test]
public void ComponentExists_ComponentDoesNotExist_NoComponents_ReturnsFalse()
{
// Arrange
var theme = new Theme();
// Act
var result = theme.ComponentExists(ThemeComponentType.BorderColor, "test");
// Assert
Assert.AreEqual(false, result);
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Filtration.ThemeEditor.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.ThemeEditor.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("02c5856c-03f5-4942-bdba-ccc013088c2c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,14 @@
using NUnit.Framework;
namespace Filtration.ThemeEditor.Tests.Providers
{
[TestFixture]
public class TestThemeProvider
{
[Test]
public void CreateThemeFromScript_()
{
}
}
}

View File

@@ -0,0 +1,72 @@
using System.Windows.Media;
using Filtration.Common.Services;
using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.ThemeEditor.Services;
using Moq;
using NUnit.Framework;
namespace Filtration.ThemeEditor.Tests.Services
{
[TestFixture]
public class TestThemeService
{
[Test]
public void ApplyThemeToScript_SingleBlock_ReplacesColor()
{
// Arrange
var testInputBlockItem = new TextColorBlockItem();
var testInputBlock = new ItemFilterBlock();
testInputBlock.BlockItems.Add(testInputBlockItem);
var testInputScript = new ItemFilterScript();
testInputScript.ItemFilterBlocks.Add(testInputBlock);
var testInputTheme = new Theme();
var testInputThemeComponentColor = new Color{ R = 255, G = 0, B = 1 };
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputThemeComponent;
var mockMessageBoxService = new Mock<IMessageBoxService>();
var service = new ThemeService(mockMessageBoxService.Object);
// Act
service.ApplyThemeToScript(testInputTheme, testInputScript);
// Assert
Assert.AreEqual(testInputThemeComponentColor, testInputBlockItem.Color);
}
[Test]
public void ApplyThemeToScript_SingleBlockDifferentComponentName_DoesNotReplaceColour()
{
// Arrange
var testInputBlockItem = new TextColorBlockItem();
var testInputBlock = new ItemFilterBlock();
testInputBlock.BlockItems.Add(testInputBlockItem);
var testInputScript = new ItemFilterScript();
testInputScript.ItemFilterBlocks.Add(testInputBlock);
var testInputTheme = new Theme();
var testInputThemeComponentColor = new Color { R = 255, G = 0, B = 1 };
var testInputThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
var testInputBlockItemThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Different Component", testInputThemeComponentColor);
testInputTheme.Components.Add(testInputThemeComponent);
testInputBlockItem.ThemeComponent = testInputBlockItemThemeComponent;
var mockMessageBoxService = new Mock<IMessageBoxService>();
var service = new ThemeService(mockMessageBoxService.Object);
// Act
service.ApplyThemeToScript(testInputTheme, testInputScript);
// Assert
Assert.AreNotEqual(testInputThemeComponentColor, testInputBlockItem.Color);
}
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1506.2515" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
</packages>

View File

@@ -0,0 +1,45 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
namespace Filtration.ThemeEditor.Converters
{
public class ThemeComponentTypeToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return string.Empty;
}
var type = (ThemeComponentType) value;
switch (type.GetAttributeDescription())
{
case "Text":
{
return "Text Color Theme Components";
}
case "Border":
{
return "Border Color Theme Components";
}
case "Background":
{
return "Background Color Theme Components";
}
}
return type.GetAttributeDescription();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,153 @@
<?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>{41B8F5C2-65AA-42F0-A20B-6F95B13A9F48}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Filtration.ThemeEditor</RootNamespace>
<AssemblyName>Filtration.ThemeEditor</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="AutoMapper">
<HintPath>..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="AutoMapper.Net4">
<HintPath>..\packages\AutoMapper.3.3.1\lib\net40\AutoMapper.Net4.dll</HintPath>
</Reference>
<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="GalaSoft.MvvmLight">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.4.0.1\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.ObjectModel" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.1.1.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="Xceed.Wpf.AvalonDock">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.4\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.4\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.4\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.4\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.DataGrid">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.4\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
</Reference>
<Reference Include="Xceed.Wpf.Toolkit">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.4\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\ThemeComponentTypeToStringConverter.cs" />
<Compile Include="Messages\ThemeClosedMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\ThemeProvider.cs" />
<Compile Include="Services\ThemePersistenceService.cs" />
<Compile Include="Services\ThemeService.cs" />
<Compile Include="ViewModels\IThemeViewModelFactory.cs" />
<Compile Include="ViewModels\ThemeComponentViewModel.cs" />
<Compile Include="ViewModels\ThemeEditorViewModel.cs" />
<Compile Include="Views\ThemeComponentControl.xaml.cs">
<DependentUpon>ThemeComponentControl.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ThemeEditorView.xaml.cs">
<DependentUpon>ThemeEditorView.xaml</DependentUpon>
</Compile>
<Compile Include="WindsorInstallers\ProvidersInstaller.cs" />
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
<Compile Include="WindsorInstallers\ViewModelsInstaller.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Filtration.Common\Filtration.Common.csproj">
<Project>{8cb44f28-2956-4c2a-9314-72727262edd4}</Project>
<Name>Filtration.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.Interface\Filtration.Interface.csproj">
<Project>{0f333344-7695-47b2-b0e6-172e4de74819}</Project>
<Name>Filtration.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
<Name>Filtration.ObjectModel</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Page Include="Views\ThemeComponentControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ThemeEditorView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

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

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Filtration.ThemeEditor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Filtration.ThemeEditor")]
[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("7e4e2310-7f12-497e-a3ff-7ec7282ff8e9")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,80 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Filtration.ObjectModel;
using Filtration.ObjectModel.ThemeEditor;
using Filtration.ThemeEditor.Services;
using Filtration.ThemeEditor.ViewModels;
namespace Filtration.ThemeEditor.Providers
{
public interface IThemeProvider
{
IThemeEditorViewModel NewThemeForScript(ItemFilterScript script);
IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script);
Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath);
Task<Theme> LoadThemeModelFromFile(string filePath);
Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath);
}
internal class ThemeProvider : IThemeProvider
{
private readonly IThemeViewModelFactory _themeViewModelFactory;
private readonly IThemePersistenceService _themePersistenceService;
public ThemeProvider(IThemeViewModelFactory themeViewModelFactory, IThemePersistenceService themePersistenceService)
{
_themeViewModelFactory = themeViewModelFactory;
_themePersistenceService = themePersistenceService;
}
public IThemeEditorViewModel NewThemeForScript(ItemFilterScript script)
{
var themeComponentCollection = script.ThemeComponents.Aggregate(new ThemeComponentCollection(),
(c, component) =>
{
c.Add(new ThemeComponent(component.ComponentType, component.ComponentName, component.Color));
return c;
});
var themeViewModel = _themeViewModelFactory.Create();
themeViewModel.InitialiseForNewTheme(themeComponentCollection);
themeViewModel.FilePath = "Untitled.filtertheme";
return themeViewModel;
}
public IThemeEditorViewModel MasterThemeForScript(ItemFilterScript script)
{
var themeViewModel = _themeViewModelFactory.Create();
themeViewModel.InitialiseForMasterTheme(script);
themeViewModel.FilePath = "<Master Theme> " + Path.GetFileName(script.FilePath);
return themeViewModel;
}
public async Task<IThemeEditorViewModel> LoadThemeFromFile(string filePath)
{
var model = await _themePersistenceService.LoadThemeAsync(filePath);
var viewModel = Mapper.Map<IThemeEditorViewModel>(model);
viewModel.FilePath = filePath;
return viewModel;
}
public async Task<Theme> LoadThemeModelFromFile(string filePath)
{
return await _themePersistenceService.LoadThemeAsync(filePath);
}
public async Task SaveThemeAsync(IThemeEditorViewModel themeEditorViewModel, string filePath)
{
await Task.Run(() =>
{
var theme = Mapper.Map<Theme>(themeEditorViewModel);
_themePersistenceService.SaveThemeAsync(theme, filePath);
});
}
}
}

View File

@@ -0,0 +1,48 @@
using System.IO;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ThemeEditor.Services
{
internal interface IThemePersistenceService
{
Task<Theme> LoadThemeAsync(string filePath);
Task SaveThemeAsync(Theme theme, string filePath);
}
internal class ThemePersistenceService : IThemePersistenceService
{
public async Task<Theme> LoadThemeAsync(string filePath)
{
Theme loadedTheme = null;
await Task.Run(() =>
{
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 async Task SaveThemeAsync(Theme theme, string filePath)
{
await Task.Run(() =>
{
var xmlSerializer = new XmlSerializer(typeof (Theme));
using (Stream writer = new FileStream(filePath, FileMode.Create))
{
xmlSerializer.Serialize(writer, theme);
}
});
}
}
}

View File

@@ -0,0 +1,75 @@
using System;
using System.Linq;
using System.Windows;
using Filtration.Common.Services;
using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ThemeEditor.Services
{
public interface IThemeService
{
void ApplyThemeToScript(Theme theme, ItemFilterScript script);
}
public class ThemeService : IThemeService
{
private readonly IMessageBoxService _messageBoxService;
public ThemeService(IMessageBoxService messageBoxService)
{
_messageBoxService = messageBoxService;
}
public void ApplyThemeToScript(Theme theme, ItemFilterScript script)
{
var mismatchedComponents = false;
foreach (var component in theme.Components)
{
var componentMatched = false;
Type targetType = null;
switch (component.ComponentType)
{
case ThemeComponentType.BackgroundColor:
targetType = typeof (BackgroundColorBlockItem);
break;
case ThemeComponentType.TextColor:
targetType = typeof (TextColorBlockItem);
break;
case ThemeComponentType.BorderColor:
targetType = typeof (BorderColorBlockItem);
break;
}
foreach (var block in script.ItemFilterBlocks)
{
foreach (var blockItem in block.BlockItems.Where(i => i.GetType() == targetType))
{
var colorBlockItem = (ColorBlockItem) blockItem;
if (colorBlockItem.ThemeComponent != null &&
colorBlockItem.ThemeComponent.ComponentName == component.ComponentName)
{
colorBlockItem.Color = component.Color;
componentMatched = true;
}
}
}
if (!componentMatched)
{
mismatchedComponents = true;
}
}
if (mismatchedComponents)
{
_messageBoxService.Show("Possible Theme Mismatch",
"Not all theme components had matches - are you sure this theme is designed for this script?",
MessageBoxButton.OK, MessageBoxImage.Exclamation);
}
}
}
}

View File

@@ -0,0 +1,8 @@
namespace Filtration.ThemeEditor.ViewModels
{
public interface IThemeViewModelFactory
{
IThemeEditorViewModel Create();
void Release(IThemeEditorViewModel themeEditorViewModel);
}
}

View File

@@ -0,0 +1,19 @@
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
namespace Filtration.ThemeEditor.ViewModels
{
public interface IThemeComponentViewModel
{
string ComponentName { get; set; }
ThemeComponentType ComponentType { get; set; }
Color Color { get; set; }
}
public class ThemeComponentViewModel : IThemeComponentViewModel
{
public string ComponentName { get; set; }
public ThemeComponentType ComponentType { get; set; }
public Color Color { get; set; }
}
}

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