Implemented ThemeComponent reading/saving in translation layer
This commit is contained in:
parent
e53e24100f
commit
cc05945108
|
@ -1,4 +1,5 @@
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using Filtration.ThemeEditor.Models;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
{
|
{
|
||||||
|
@ -20,7 +21,8 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return PrefixText + " " + +Color.R + " " + Color.G + " "
|
return PrefixText + " " + +Color.R + " " + Color.G + " "
|
||||||
+ Color.B + (Color.A < 255 ? " " + Color.A : string.Empty);
|
+ Color.B + (Color.A < 255 ? " " + Color.A : string.Empty) +
|
||||||
|
(ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +31,8 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||||
get { return string.Empty; }
|
get { return string.Empty; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ThemeComponent ThemeComponent { get; set; }
|
||||||
|
|
||||||
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; } }
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,8 @@
|
||||||
<Compile Include="Properties\Annotations.cs" />
|
<Compile Include="Properties\Annotations.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ReplaceColorsParameterSet.cs" />
|
<Compile Include="ReplaceColorsParameterSet.cs" />
|
||||||
|
<Compile Include="ThemeEditor\Theme.cs" />
|
||||||
|
<Compile Include="ThemeEditor\ThemeComponent.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Filtration.ObjectModel.BlockItemTypes;
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.ThemeEditor.Models;
|
||||||
|
|
||||||
namespace Filtration.ObjectModel
|
namespace Filtration.ObjectModel
|
||||||
{
|
{
|
||||||
|
@ -15,11 +16,14 @@ namespace Filtration.ObjectModel
|
||||||
{
|
{
|
||||||
new ItemFilterBlockGroup("Root", null)
|
new ItemFilterBlockGroup("Root", null)
|
||||||
};
|
};
|
||||||
|
ThemeComponents = new List<ThemeComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; }
|
public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; }
|
||||||
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; }
|
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; }
|
||||||
|
|
||||||
|
public List<ThemeComponent> ThemeComponents { get; set; }
|
||||||
|
|
||||||
public string FilePath { get; set; }
|
public string FilePath { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public DateTime DateModified { get; set; }
|
public DateTime DateModified { get; set; }
|
||||||
|
@ -38,7 +42,6 @@ namespace Filtration.ObjectModel
|
||||||
|
|
||||||
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.ObjectModel
|
||||||
borderColorBlockItem.Color = replaceColorsParameterSet.NewBorderColor;
|
borderColorBlockItem.Color = replaceColorsParameterSet.NewBorderColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, ItemFilterBlock block)
|
private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, ItemFilterBlock block)
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace Filtration.ThemeEditor.Models
|
||||||
|
{
|
||||||
|
public class Theme
|
||||||
|
{
|
||||||
|
private readonly List<ThemeComponent> _components;
|
||||||
|
|
||||||
|
public Theme()
|
||||||
|
{
|
||||||
|
_components = new List<ThemeComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public IEnumerable<ThemeComponent> Components
|
||||||
|
{
|
||||||
|
get { return _components; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ComponentExists(Type targetType, string componentName)
|
||||||
|
{
|
||||||
|
return _components.Exists(c => c.ComponentName == componentName && c.TargetType == targetType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddComponent(Type targetType, string componentName, Color componentColor)
|
||||||
|
{
|
||||||
|
_components.Add(new ThemeComponent(targetType, componentName, componentColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace Filtration.ThemeEditor.Models
|
||||||
|
{
|
||||||
|
public class ThemeComponent
|
||||||
|
{
|
||||||
|
public ThemeComponent(Type targetType, string componentName, Color componentColor)
|
||||||
|
{
|
||||||
|
if (targetType == null || componentName == null || componentColor == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Null parameters not allowed in ThemeComponent constructor");
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetType = targetType;
|
||||||
|
Color = componentColor;
|
||||||
|
ComponentName = componentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ComponentName { get; set; }
|
||||||
|
public Type TargetType { get; private set; }
|
||||||
|
public Color Color { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -53,6 +53,7 @@
|
||||||
<Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" />
|
<Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" />
|
||||||
<Compile Include="Translators\TestItemFilterBlockTranslator.cs" />
|
<Compile Include="Translators\TestItemFilterBlockTranslator.cs" />
|
||||||
<Compile Include="Translators\TestItemFilterScriptTranslator.cs" />
|
<Compile Include="Translators\TestItemFilterScriptTranslator.cs" />
|
||||||
|
<Compile Include="Translators\TestThemeComponentListBuilder.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
|
|
|
@ -6,6 +6,7 @@ using Filtration.ObjectModel;
|
||||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||||
using Filtration.ObjectModel.BlockItemTypes;
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
|
using Filtration.ThemeEditor.Models;
|
||||||
using Filtration.Translators;
|
using Filtration.Translators;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -490,7 +491,28 @@ namespace Filtration.Tests.Translators
|
||||||
Assert.AreEqual(255, blockItem.Color.R);
|
Assert.AreEqual(255, blockItem.Color.R);
|
||||||
Assert.AreEqual(20, blockItem.Color.G);
|
Assert.AreEqual(20, blockItem.Color.G);
|
||||||
Assert.AreEqual(100, blockItem.Color.B);
|
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(typeof(TextColorBlockItem), "testComponent", new Color());
|
||||||
|
|
||||||
|
_testUtility.MockThemeComponentListBuilder.Setup(
|
||||||
|
t =>
|
||||||
|
t.AddComponent(typeof (TextColorBlockItem), "Rare Item Text",
|
||||||
|
new Color {A = 255, R = 255, G = 20, B = 100})).Returns(testComponent).Verifiable();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
|
||||||
|
Assert.AreSame(testComponent, blockItem.ThemeComponent);
|
||||||
|
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -1085,6 +1107,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(typeof (TextColorBlockItem), "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()
|
||||||
{
|
{
|
||||||
|
@ -1291,13 +1334,16 @@ namespace Filtration.Tests.Translators
|
||||||
|
|
||||||
// Mock setups
|
// Mock setups
|
||||||
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||||
|
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
|
||||||
|
|
||||||
// Class under test instantiation
|
// Class under test instantiation
|
||||||
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object);
|
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object,
|
||||||
|
MockThemeComponentListBuilder.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemFilterBlock TestBlock { get; set; }
|
public ItemFilterBlock TestBlock { get; set; }
|
||||||
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
||||||
|
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
|
||||||
public ItemFilterBlockTranslator Translator { get; private set; }
|
public ItemFilterBlockTranslator Translator { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
using Filtration.ObjectModel;
|
using Filtration.ObjectModel;
|
||||||
using Filtration.ObjectModel.BlockItemTypes;
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
using Filtration.ObjectModel.Enums;
|
using Filtration.ObjectModel.Enums;
|
||||||
using Filtration.Properties;
|
using Filtration.Properties;
|
||||||
|
using Filtration.ThemeEditor.Models;
|
||||||
using Filtration.Translators;
|
using Filtration.Translators;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -60,6 +63,37 @@ namespace Filtration.Tests.Translators
|
||||||
Assert.AreEqual(expectedDescription, script.Description);
|
Assert.AreEqual(expectedDescription, script.Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateStringToItemFilterScript_CallsThemeComponentListBuilderInitialise()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||||
|
|
||||||
|
_testUtility.MockThemeComponentListBuilder.Setup(t => t.Initialise()).Verifiable();
|
||||||
|
// Act
|
||||||
|
_testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TranslateStringToItemFilterScript_SetsScriptThemeComponentsToComponentListBuilderResult()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||||
|
List<ThemeComponent> testThemeComponents = new List<ThemeComponent>();
|
||||||
|
|
||||||
|
_testUtility.MockThemeComponentListBuilder.Setup(t => t.GetComponents()).Returns(testThemeComponents).Verifiable();
|
||||||
|
// Act
|
||||||
|
var result = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||||
|
Assert.AreSame(testThemeComponents, result.ThemeComponents);
|
||||||
|
}
|
||||||
|
|
||||||
[Ignore("Integration Test")]
|
[Ignore("Integration Test")]
|
||||||
[Test]
|
[Test]
|
||||||
public void TranslateStringToItemFilterScript_ThioleItemFilterTest()
|
public void TranslateStringToItemFilterScript_ThioleItemFilterTest()
|
||||||
|
@ -67,10 +101,10 @@ 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>();
|
_testUtility.MockThemeComponentListBuilder.Object);
|
||||||
var blockTranslator = new ItemFilterBlockTranslator(mockBlockGroupHierarchyBuilder.Object);
|
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||||
var translator = new ItemFilterScriptTranslator(blockTranslator, mockBlockGroupHierarchyBuilder.Object);
|
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
translator.TranslateStringToItemFilterScript(testInput);
|
translator.TranslateStringToItemFilterScript(testInput);
|
||||||
|
@ -127,9 +161,10 @@ namespace Filtration.Tests.Translators
|
||||||
" Width = 3" + Environment.NewLine +
|
" Width = 3" + Environment.NewLine +
|
||||||
" SetFontSize 7" + Environment.NewLine;
|
" SetFontSize 7" + Environment.NewLine;
|
||||||
|
|
||||||
var mockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||||
var blockTranslator = new ItemFilterBlockTranslator(mockBlockGroupHierarchyBuilder.Object);
|
_testUtility.MockThemeComponentListBuilder.Object);
|
||||||
var translator = new ItemFilterScriptTranslator(blockTranslator, mockBlockGroupHierarchyBuilder.Object);
|
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||||
|
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = translator.TranslateItemFilterScriptToString(script);
|
var result = translator.TranslateItemFilterScriptToString(script);
|
||||||
|
@ -172,9 +207,10 @@ 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);
|
_testUtility.MockThemeComponentListBuilder.Object);
|
||||||
var translator = new ItemFilterScriptTranslator(blockTranslator, mockBlockGroupHierarchyBuilder.Object);
|
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||||
|
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = translator.TranslateItemFilterScriptToString(script);
|
var result = translator.TranslateItemFilterScriptToString(script);
|
||||||
|
@ -215,8 +251,10 @@ namespace Filtration.Tests.Translators
|
||||||
" SetBorderColor 255 0 255" + Environment.NewLine +
|
" SetBorderColor 255 0 255" + Environment.NewLine +
|
||||||
" SetFontSize 25";
|
" SetFontSize 25";
|
||||||
|
|
||||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||||
var translator = new ItemFilterScriptTranslator(blockTranslator, _testUtility.MockBlockGroupHierarchyBuilder.Object);
|
_testUtility.MockThemeComponentListBuilder.Object);
|
||||||
|
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||||
|
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||||
|
@ -237,14 +275,16 @@ namespace Filtration.Tests.Translators
|
||||||
// Mock setups
|
// Mock setups
|
||||||
MockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
|
MockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
|
||||||
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||||
|
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
|
||||||
|
|
||||||
// Class under test instantiation
|
// Class under test instantiation
|
||||||
ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object);
|
ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object, MockThemeComponentListBuilder.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemFilterScriptTranslator ScriptTranslator { get; private set; }
|
public ItemFilterScriptTranslator ScriptTranslator { get; private set; }
|
||||||
public Mock<IItemFilterBlockTranslator> MockItemFilterBlockTranslator { get; private set; }
|
public Mock<IItemFilterBlockTranslator> MockItemFilterBlockTranslator { get; private set; }
|
||||||
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
||||||
|
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.ObjectModel.BlockItemTypes;
|
||||||
|
using Filtration.Translators;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Filtration.Tests.Translators
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestThemeComponentListBuilder
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
|
||||||
|
var testInputTargetType = typeof (TextColorBlockItem);
|
||||||
|
var testInputComponentName = "testComponent";
|
||||||
|
var testInputColor = new Color();
|
||||||
|
|
||||||
|
var builder = new ThemeComponentListBuilder();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var firstResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||||
|
var secondResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.AreSame(firstResult, secondResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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")]
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?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="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" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
|
||||||
|
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
|
||||||
|
<Name>Filtration.ObjectModel</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Filtration.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")]
|
|
@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.ObjectModel", "F
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.ObjectModel.Tests", "Filtration.ObjectModel.Tests\Filtration.ObjectModel.Tests.csproj", "{537BE676-2FF6-4995-B05B-9CFACE852EC9}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.ObjectModel.Tests", "Filtration.ObjectModel.Tests\Filtration.ObjectModel.Tests.csproj", "{537BE676-2FF6-4995-B05B-9CFACE852EC9}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.ThemeEditor", "Filtration.ThemeEditor\Filtration.ThemeEditor.csproj", "{41B8F5C2-65AA-42F0-A20B-6F95B13A9F48}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Filtration.ThemeEditor.Tests", "Filtration.ThemeEditor.Tests\Filtration.ThemeEditor.Tests.csproj", "{450AC313-BF25-4BFD-A066-9F39F026FDCF}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -33,6 +37,14 @@ Global
|
||||||
{537BE676-2FF6-4995-B05B-9CFACE852EC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{537BE676-2FF6-4995-B05B-9CFACE852EC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{537BE676-2FF6-4995-B05B-9CFACE852EC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{537BE676-2FF6-4995-B05B-9CFACE852EC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{537BE676-2FF6-4995-B05B-9CFACE852EC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
{537BE676-2FF6-4995-B05B-9CFACE852EC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{41B8F5C2-65AA-42F0-A20B-6F95B13A9F48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{41B8F5C2-65AA-42F0-A20B-6F95B13A9F48}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{41B8F5C2-65AA-42F0-A20B-6F95B13A9F48}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{41B8F5C2-65AA-42F0-A20B-6F95B13A9F48}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{450AC313-BF25-4BFD-A066-9F39F026FDCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{450AC313-BF25-4BFD-A066-9F39F026FDCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{450AC313-BF25-4BFD-A066-9F39F026FDCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{450AC313-BF25-4BFD-A066-9F39F026FDCF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -140,6 +140,7 @@
|
||||||
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
|
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
|
||||||
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
|
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
|
||||||
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
|
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
|
||||||
|
<Compile Include="Translators\ThemeComponentListBuilder.cs" />
|
||||||
<Compile Include="UserControls\AutoScrollingListBox.cs" />
|
<Compile Include="UserControls\AutoScrollingListBox.cs" />
|
||||||
<Compile Include="UserControls\CrossButton.cs" />
|
<Compile Include="UserControls\CrossButton.cs" />
|
||||||
<Compile Include="UserControls\EditableListBoxControl.xaml.cs">
|
<Compile Include="UserControls\EditableListBoxControl.xaml.cs">
|
||||||
|
@ -425,9 +426,7 @@
|
||||||
<Name>Filtration.ObjectModel</Name>
|
<Name>Filtration.ObjectModel</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="Models\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(XamlSpyInstallPath)MSBuild\FirstFloor.XamlSpy.WPF.targets" Condition="'$(XamlSpyInstallPath)' != '' and '$(Configuration)' == 'DEBUG'" />
|
<Import Project="$(XamlSpyInstallPath)MSBuild\FirstFloor.XamlSpy.WPF.targets" Condition="'$(XamlSpyInstallPath)' != '' and '$(Configuration)' == 'DEBUG'" />
|
||||||
<Import Project="..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets')" />
|
<Import Project="..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets" Condition="Exists('..\packages\AutoMapper.3.3.1\tools\AutoMapper.targets')" />
|
||||||
|
|
|
@ -22,12 +22,14 @@ namespace Filtration.Translators
|
||||||
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
|
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
|
||||||
{
|
{
|
||||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||||
|
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
|
||||||
private const string Indent = " ";
|
private const string Indent = " ";
|
||||||
private readonly string _newLine = Environment.NewLine + Indent;
|
private readonly string _newLine = Environment.NewLine + Indent;
|
||||||
|
|
||||||
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder, IThemeComponentListBuilder themeComponentListBuilder)
|
||||||
{
|
{
|
||||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||||
|
_themeComponentListBuilder = themeComponentListBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||||
|
@ -257,13 +259,20 @@ namespace Filtration.Translators
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddColorItemToBlockItems<T>(ItemFilterBlock block, string inputString) where T : ColorBlockItem
|
private void AddColorItemToBlockItems<T>(ItemFilterBlock block, string inputString) where T : ColorBlockItem
|
||||||
{
|
{
|
||||||
var blockItem = Activator.CreateInstance<T>();
|
var blockItem = Activator.CreateInstance<T>();
|
||||||
var result = Regex.Matches(inputString, @"([\w\s]*)[#]?(.*)");
|
var result = Regex.Matches(inputString, @"([\w\s]*)[#]?(.*)");
|
||||||
|
|
||||||
// When Theme support is added result[0].Groups[2].Value will contain the ColorGroup in the comment if it exists.
|
// When Theme support is added result[0].Groups[2].Value will contain the ColorGroup in the comment if it exists.
|
||||||
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
blockItem.Color = GetColorFromString(result[0].Groups[1].Value);
|
||||||
|
|
||||||
|
var componentName = result[0].Groups[2].Value.Trim();
|
||||||
|
if (!string.IsNullOrEmpty(componentName))
|
||||||
|
{
|
||||||
|
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(typeof(T), componentName, blockItem.Color);
|
||||||
|
}
|
||||||
|
|
||||||
block.BlockItems.Add(blockItem);
|
block.BlockItems.Add(blockItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,15 @@ namespace Filtration.Translators
|
||||||
{
|
{
|
||||||
private readonly IItemFilterBlockTranslator _blockTranslator;
|
private readonly IItemFilterBlockTranslator _blockTranslator;
|
||||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||||
|
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
|
||||||
|
|
||||||
public ItemFilterScriptTranslator(IItemFilterBlockTranslator blockTranslator, IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
public ItemFilterScriptTranslator(IItemFilterBlockTranslator blockTranslator,
|
||||||
|
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder,
|
||||||
|
IThemeComponentListBuilder themeComponentListBuilder)
|
||||||
{
|
{
|
||||||
_blockTranslator = blockTranslator;
|
_blockTranslator = blockTranslator;
|
||||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||||
|
_themeComponentListBuilder = themeComponentListBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
|
public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
|
||||||
|
@ -51,6 +55,8 @@ namespace Filtration.Translators
|
||||||
script.Description = script.Description.TrimEnd('\n').TrimEnd('\r');
|
script.Description = script.Description.TrimEnd('\n').TrimEnd('\r');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_themeComponentListBuilder.Initialise();
|
||||||
|
|
||||||
// Extract each block from between boundaries and translate it into a ItemFilterBlock object
|
// Extract each block from between boundaries and translate it into a ItemFilterBlock object
|
||||||
// and add that object to the ItemFilterBlocks list
|
// and add that object to the ItemFilterBlocks list
|
||||||
for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next)
|
for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next)
|
||||||
|
@ -63,6 +69,8 @@ namespace Filtration.Translators
|
||||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString));
|
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
script.ThemeComponents = _themeComponentListBuilder.GetComponents();
|
||||||
|
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using Filtration.ThemeEditor.Models;
|
||||||
|
|
||||||
|
namespace Filtration.Translators
|
||||||
|
{
|
||||||
|
internal interface IThemeComponentListBuilder
|
||||||
|
{
|
||||||
|
void Initialise();
|
||||||
|
ThemeComponent AddComponent(Type targetType, string componentName, Color componentColor);
|
||||||
|
List<ThemeComponent> GetComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ThemeComponentListBuilder : IThemeComponentListBuilder
|
||||||
|
{
|
||||||
|
private List<ThemeComponent> _themeComponents;
|
||||||
|
|
||||||
|
public ThemeComponentListBuilder()
|
||||||
|
{
|
||||||
|
_themeComponents = new List<ThemeComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialise()
|
||||||
|
{
|
||||||
|
_themeComponents = new List<ThemeComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThemeComponent AddComponent(Type targetType, string componentName, Color componentColor)
|
||||||
|
{
|
||||||
|
if (ComponentExists(targetType, componentName))
|
||||||
|
{
|
||||||
|
return _themeComponents.FirstOrDefault(t => t.ComponentName == componentName && t.TargetType == targetType);
|
||||||
|
}
|
||||||
|
|
||||||
|
var component = new ThemeComponent(targetType, componentName, componentColor);
|
||||||
|
_themeComponents.Add(component);
|
||||||
|
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ThemeComponent> GetComponents()
|
||||||
|
{
|
||||||
|
return _themeComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ComponentExists(Type targetType, string componentName)
|
||||||
|
{
|
||||||
|
return _themeComponents.Exists(c => c.ComponentName == componentName && c.TargetType == targetType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -101,14 +101,8 @@ namespace Filtration.ViewModels
|
||||||
{
|
{
|
||||||
_itemFilterBlockViewModelsCollectionView =
|
_itemFilterBlockViewModelsCollectionView =
|
||||||
CollectionViewSource.GetDefaultView(_itemFilterBlockViewModels);
|
CollectionViewSource.GetDefaultView(_itemFilterBlockViewModels);
|
||||||
if (BlockFilterPredicate != null)
|
|
||||||
{
|
|
||||||
_itemFilterBlockViewModelsCollectionView.Filter = BlockFilter;
|
_itemFilterBlockViewModelsCollectionView.Filter = BlockFilter;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_itemFilterBlockViewModelsCollectionView.Filter = null;
|
|
||||||
}
|
|
||||||
return _itemFilterBlockViewModels;
|
return _itemFilterBlockViewModels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +110,29 @@ namespace Filtration.ViewModels
|
||||||
private bool BlockFilter(object item)
|
private bool BlockFilter(object item)
|
||||||
{
|
{
|
||||||
var blockViewModel = item as IItemFilterBlockViewModel;
|
var blockViewModel = item as IItemFilterBlockViewModel;
|
||||||
return BlockFilterPredicate(blockViewModel);
|
|
||||||
|
if (BlockFilterPredicate != null)
|
||||||
|
{
|
||||||
|
return BlockFilterPredicate(blockViewModel) && ShowBlockBasedOnAdvanced(blockViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ShowBlockBasedOnAdvanced(blockViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ShowBlockBasedOnAdvanced(IItemFilterBlockViewModel blockViewModel)
|
||||||
|
{
|
||||||
|
if (ShowAdvanced)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockViewModel.Block.BlockGroup == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !blockViewModel.Block.BlockGroup.Advanced;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Predicate<IItemFilterBlockViewModel> BlockFilterPredicate
|
public Predicate<IItemFilterBlockViewModel> BlockFilterPredicate
|
||||||
|
@ -157,6 +173,7 @@ namespace Filtration.ViewModels
|
||||||
{
|
{
|
||||||
_showAdvanced = value;
|
_showAdvanced = value;
|
||||||
RaisePropertyChanged();
|
RaisePropertyChanged();
|
||||||
|
RaisePropertyChanged("ItemFilterBlockViewModels");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace Filtration.ViewModels
|
||||||
OnRequestClose(this, new EventArgs());
|
OnRequestClose(this, new EventArgs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException e)
|
catch (DirectoryNotFoundException)
|
||||||
{
|
{
|
||||||
MessageBox.Show("The entered Default Filter Directory is invalid or does not exist.", "Error",
|
MessageBox.Show("The entered Default Filter Directory is invalid or does not exist.", "Error",
|
||||||
MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||||
|
|
|
@ -23,6 +23,11 @@ namespace Filtration.WindsorInstallers
|
||||||
Component.For<IBlockGroupHierarchyBuilder>()
|
Component.For<IBlockGroupHierarchyBuilder>()
|
||||||
.ImplementedBy<BlockGroupHierarchyBuilder>()
|
.ImplementedBy<BlockGroupHierarchyBuilder>()
|
||||||
.LifeStyle.Singleton);
|
.LifeStyle.Singleton);
|
||||||
|
|
||||||
|
container.Register(
|
||||||
|
Component.For<IThemeComponentListBuilder>()
|
||||||
|
.ImplementedBy<ThemeComponentListBuilder>()
|
||||||
|
.LifeStyle.Singleton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue