Refactored ThemeComponentBuilder into ThemeComponentCollection
This commit is contained in:
parent
3ea0530c01
commit
511f503e88
|
@ -50,6 +50,7 @@
|
|||
<Compile Include="TestItemFilterBlock.cs" />
|
||||
<Compile Include="TestItemFilterBlockGroup.cs" />
|
||||
<Compile Include="TestItemFilterScript.cs" />
|
||||
<Compile Include="ThemeEditor\TestThemeComponentCollection.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
|
||||
|
@ -60,6 +61,7 @@
|
|||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
<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.
|
||||
|
|
|
@ -16,13 +16,13 @@ namespace Filtration.ObjectModel
|
|||
{
|
||||
new ItemFilterBlockGroup("Root", null)
|
||||
};
|
||||
ThemeComponents = new List<ThemeComponent>();
|
||||
ThemeComponents = new ThemeComponentCollection { IsMasterCollection = true};
|
||||
}
|
||||
|
||||
public ObservableCollection<ItemFilterBlock> ItemFilterBlocks { get; private set; }
|
||||
public ObservableCollection<ItemFilterBlockGroup> ItemFilterBlockGroups { get; private set; }
|
||||
|
||||
public List<ThemeComponent> ThemeComponents { get; set; }
|
||||
public ThemeComponentCollection ThemeComponents { get; set; }
|
||||
|
||||
public string FilePath { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
|
||||
|
@ -8,24 +9,26 @@ namespace Filtration.ObjectModel.ThemeEditor
|
|||
[Serializable]
|
||||
public class Theme
|
||||
{
|
||||
private readonly List<ThemeComponent> _components;
|
||||
private readonly ThemeComponentCollection _components;
|
||||
|
||||
public Theme()
|
||||
{
|
||||
_components = new List<ThemeComponent>();
|
||||
_components = new ThemeComponentCollection { IsMasterCollection = false};
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public List<ThemeComponent> Components
|
||||
public ThemeComponentCollection Components
|
||||
{
|
||||
get { return _components; }
|
||||
}
|
||||
|
||||
public bool ComponentExists(ThemeComponentType componentType, string componentName)
|
||||
{
|
||||
return _components.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
var componentCount =
|
||||
_components.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
return componentCount > 0;
|
||||
}
|
||||
|
||||
public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
|
|
|
@ -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 : Collection<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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,7 +55,6 @@
|
|||
<Compile Include="Translators\TestBlockGroupHierarchyBuilder.cs" />
|
||||
<Compile Include="Translators\TestItemFilterBlockTranslator.cs" />
|
||||
<Compile Include="Translators\TestItemFilterScriptTranslator.cs" />
|
||||
<Compile Include="Translators\TestThemeComponentListBuilder.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Filtration.Tests.Translators
|
|||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
||||
|
@ -51,7 +51,7 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify();
|
||||
|
@ -66,7 +66,7 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(true, inputBlockGroup.IsChecked);
|
||||
|
@ -81,7 +81,7 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(inputBlockGroup).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(false, inputBlockGroup.IsChecked);
|
||||
|
@ -95,7 +95,7 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||
|
@ -109,7 +109,7 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Verifiable();
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
_testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Verify(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>()), Times.Never);
|
||||
|
@ -124,7 +124,7 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Act
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Setup(b => b.IntegrateStringListIntoBlockGroupHierarchy(It.IsAny<IEnumerable<string>>())).Returns(testBlockGroup).Verifiable();
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(testBlockGroup, result.BlockGroup);
|
||||
|
@ -138,7 +138,7 @@ namespace Filtration.Tests.Translators
|
|||
var inputString = "Hide" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ActionBlockItem));
|
||||
|
@ -154,7 +154,7 @@ namespace Filtration.Tests.Translators
|
|||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("This is a test Block", result.Description);
|
||||
|
@ -174,7 +174,7 @@ namespace Filtration.Tests.Translators
|
|||
" ItemLevel >= 55";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Second Line", result.Description);
|
||||
|
@ -192,7 +192,7 @@ namespace Filtration.Tests.Translators
|
|||
" DropLevel = 40";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
|
@ -210,7 +210,7 @@ namespace Filtration.Tests.Translators
|
|||
" Quality < 18";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
|
@ -228,7 +228,7 @@ namespace Filtration.Tests.Translators
|
|||
" Rarity > Normal";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
|
@ -246,7 +246,7 @@ namespace Filtration.Tests.Translators
|
|||
" Rarity Normal";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is RarityBlockItem));
|
||||
|
@ -263,7 +263,7 @@ namespace Filtration.Tests.Translators
|
|||
@" Class ""Test Class 1"" ""TestOneWordClassInQuotes"" TestOneWordClassNotInQuotes ""Test Class 2""";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is ClassBlockItem));
|
||||
|
@ -282,7 +282,7 @@ namespace Filtration.Tests.Translators
|
|||
@" BaseType ""Test Base Type 1"" ""TestOneWordBaseTypeInQuotes"" TestOneWordBaseTypeNotInQuotes ""Test BaseType 2""";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BaseTypeBlockItem));
|
||||
|
@ -301,7 +301,7 @@ namespace Filtration.Tests.Translators
|
|||
" Sockets > 2";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
|
@ -319,7 +319,7 @@ namespace Filtration.Tests.Translators
|
|||
" LinkedSockets != 1";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
|
@ -337,7 +337,7 @@ namespace Filtration.Tests.Translators
|
|||
" Width != 1";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
|
@ -355,7 +355,7 @@ namespace Filtration.Tests.Translators
|
|||
" Height <= 3";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
|
||||
|
@ -373,7 +373,7 @@ namespace Filtration.Tests.Translators
|
|||
" Height <=3";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is HeightBlockItem));
|
||||
|
@ -390,7 +390,7 @@ namespace Filtration.Tests.Translators
|
|||
" SocketGroup RRGB";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SocketGroupBlockItem));
|
||||
|
@ -408,7 +408,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetTextColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||
|
@ -426,7 +426,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetTextColor 65 0 255 12";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||
|
@ -445,7 +445,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetBackgroundColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
||||
|
@ -464,7 +464,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetBorderColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||
|
@ -483,8 +483,8 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Act
|
||||
|
||||
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString));
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
Assert.DoesNotThrow(() => _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null));
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||
|
@ -500,21 +500,17 @@ namespace Filtration.Tests.Translators
|
|||
// Arrange
|
||||
var inputString = "Show" + Environment.NewLine +
|
||||
" SetTextColor 255 20 100 # Rare Item Text";
|
||||
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "testComponent", new Color());
|
||||
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(
|
||||
t =>
|
||||
t.AddComponent(ThemeComponentType.TextColor, "Rare Item Text",
|
||||
new Color {A = 255, R = 255, G = 20, B = 100})).Returns(testComponent).Verifiable();
|
||||
_testUtility.MockThemeComponentListBuilder.SetupGet(t => t.IsInitialised).Returns(true);
|
||||
|
||||
var testComponent = new ThemeComponent(ThemeComponentType.TextColor, "Rare Item Text", new Color { R = 255, G = 20, B = 100});
|
||||
var testInputThemeComponentCollection = new ThemeComponentCollection { testComponent };
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, testInputThemeComponentCollection);
|
||||
|
||||
// Assert
|
||||
var blockItem = result.BlockItems.OfType<TextColorBlockItem>().First();
|
||||
Assert.AreSame(testComponent, blockItem.ThemeComponent);
|
||||
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||
var firstComponent = testInputThemeComponentCollection.First();
|
||||
Assert.AreEqual("Rare Item Text", firstComponent.ComponentName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -526,7 +522,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetFontSize 15";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
||||
|
@ -543,7 +539,7 @@ namespace Filtration.Tests.Translators
|
|||
" PlayAlertSound 4";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||
|
@ -561,7 +557,7 @@ namespace Filtration.Tests.Translators
|
|||
" PlayAlertSound 2 95";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||
|
@ -578,7 +574,7 @@ namespace Filtration.Tests.Translators
|
|||
var inputString = "# Section: " + TestInputSectionDescription;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.IsInstanceOf<ItemFilterSection>(result);
|
||||
|
@ -611,7 +607,7 @@ namespace Filtration.Tests.Translators
|
|||
" PlayAlertSound 3";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual("Test filter with everything", result.Description);
|
||||
|
@ -693,7 +689,7 @@ namespace Filtration.Tests.Translators
|
|||
" Quality < 17";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(2, result.BlockItems.Count(b => b is ItemLevelBlockItem));
|
||||
|
@ -722,7 +718,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetTextColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is TextColorBlockItem));
|
||||
|
@ -743,7 +739,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetFontSize 27" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is FontSizeBlockItem));
|
||||
|
@ -762,7 +758,7 @@ namespace Filtration.Tests.Translators
|
|||
" PlayAlertSound 2" + Environment.NewLine;
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is SoundBlockItem));
|
||||
|
@ -780,7 +776,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetBackgroundColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BackgroundColorBlockItem));
|
||||
|
@ -799,7 +795,7 @@ namespace Filtration.Tests.Translators
|
|||
" SetBorderColor 255 20 100";
|
||||
|
||||
// Act
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString);
|
||||
var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, result.BlockItems.Count(b => b is BorderColorBlockItem));
|
||||
|
@ -1481,6 +1477,7 @@ namespace Filtration.Tests.Translators
|
|||
Assert.AreEqual(0, testInputBlockItems.Count(b => b is BorderColorBlockItem));
|
||||
}
|
||||
|
||||
[Ignore("ThemeComponentBuilder deprecated")]
|
||||
[Test]
|
||||
public void ReplaceColorBlockItemsFromString_ThemeComponentBuilderNotInitialised_DoesNotCallAddComponent()
|
||||
{
|
||||
|
@ -1490,13 +1487,12 @@ namespace Filtration.Tests.Translators
|
|||
var testInputBlockItems = new ObservableCollection<IItemFilterBlockItem>();
|
||||
var testInputBlockItem = new TextColorBlockItem(Colors.Red);
|
||||
testInputBlockItems.Add(testInputBlockItem);
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>())).Verifiable();
|
||||
|
||||
// Act
|
||||
_testUtility.Translator.ReplaceColorBlockItemsFromString(testInputBlockItems, testInputString);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockThemeComponentListBuilder.Verify(t => t.AddComponent(It.IsAny<ThemeComponentType>(), It.IsAny<string>(), It.IsAny<Color>()), Times.Never);
|
||||
|
||||
}
|
||||
private class ItemFilterBlockTranslatorTestUtility
|
||||
{
|
||||
|
@ -1507,16 +1503,13 @@ namespace Filtration.Tests.Translators
|
|||
|
||||
// Mock setups
|
||||
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
|
||||
|
||||
// Class under test instantiation
|
||||
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object,
|
||||
MockThemeComponentListBuilder.Object);
|
||||
Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object);
|
||||
}
|
||||
|
||||
public ItemFilterBlock TestBlock { get; set; }
|
||||
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
||||
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
|
||||
public ItemFilterBlockTranslator Translator { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Filtration.Tests.Translators
|
|||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||
|
||||
_testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable();
|
||||
_testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
|
||||
|
||||
// Act
|
||||
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
|
@ -54,7 +54,7 @@ namespace Filtration.Tests.Translators
|
|||
"End Script Description";
|
||||
|
||||
var mockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
|
||||
mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>())).Verifiable();
|
||||
mockItemFilterBlockTranslator.Setup(t => t.TranslateStringToItemFilterBlock(It.IsAny<string>(), It.IsAny<ThemeComponentCollection>())).Verifiable();
|
||||
|
||||
// Act
|
||||
var script = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
|
@ -63,37 +63,6 @@ namespace Filtration.Tests.Translators
|
|||
Assert.AreEqual(expectedDescription, script.Description);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_CallsThemeComponentListBuilderInitialise()
|
||||
{
|
||||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(t => t.Initialise()).Verifiable();
|
||||
// Act
|
||||
_testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_SetsScriptThemeComponentsToComponentListBuilderResult()
|
||||
{
|
||||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/testscript.txt");
|
||||
List<ThemeComponent> testThemeComponents = new List<ThemeComponent>();
|
||||
|
||||
_testUtility.MockThemeComponentListBuilder.Setup(t => t.GetComponents()).Returns(testThemeComponents).Verifiable();
|
||||
// Act
|
||||
var result = _testUtility.ScriptTranslator.TranslateStringToItemFilterScript(testInput);
|
||||
|
||||
// Assert
|
||||
_testUtility.MockThemeComponentListBuilder.Verify();
|
||||
Assert.AreSame(testThemeComponents, result.ThemeComponents);
|
||||
}
|
||||
|
||||
[Ignore("Integration Test")]
|
||||
[Test]
|
||||
public void TranslateStringToItemFilterScript_ThioleItemFilterTest()
|
||||
|
@ -101,10 +70,9 @@ namespace Filtration.Tests.Translators
|
|||
// Arrange
|
||||
var testInput = File.ReadAllText(@"Resources/ThioleItemFilter.txt");
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
translator.TranslateStringToItemFilterScript(testInput);
|
||||
|
@ -161,10 +129,9 @@ namespace Filtration.Tests.Translators
|
|||
" Width = 3" + Environment.NewLine +
|
||||
" SetFontSize 7" + Environment.NewLine;
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateItemFilterScriptToString(script);
|
||||
|
@ -207,10 +174,9 @@ namespace Filtration.Tests.Translators
|
|||
" Width = 3" + Environment.NewLine +
|
||||
" SetFontSize 7" + Environment.NewLine + Environment.NewLine;
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateItemFilterScriptToString(script);
|
||||
|
@ -251,10 +217,9 @@ namespace Filtration.Tests.Translators
|
|||
" SetBorderColor 255 0 255" + Environment.NewLine +
|
||||
" SetFontSize 25";
|
||||
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
|
@ -275,10 +240,9 @@ namespace Filtration.Tests.Translators
|
|||
Environment.NewLine +
|
||||
"Show" + Environment.NewLine +
|
||||
"BaseType \"Maelström Staff\"" + Environment.NewLine + Environment.NewLine;
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object,
|
||||
_testUtility.MockThemeComponentListBuilder.Object);
|
||||
var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
var translator = new ItemFilterScriptTranslator(blockTranslator,
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object, _testUtility.MockThemeComponentListBuilder.Object);
|
||||
_testUtility.MockBlockGroupHierarchyBuilder.Object);
|
||||
|
||||
// Act
|
||||
var result = translator.TranslateStringToItemFilterScript(testInputScript);
|
||||
|
@ -296,16 +260,14 @@ namespace Filtration.Tests.Translators
|
|||
// Mock setups
|
||||
MockItemFilterBlockTranslator = new Mock<IItemFilterBlockTranslator>();
|
||||
MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();
|
||||
MockThemeComponentListBuilder = new Mock<IThemeComponentListBuilder>();
|
||||
|
||||
// Class under test instantiation
|
||||
ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object, MockThemeComponentListBuilder.Object);
|
||||
ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object);
|
||||
}
|
||||
|
||||
public ItemFilterScriptTranslator ScriptTranslator { get; private set; }
|
||||
public Mock<IItemFilterBlockTranslator> MockItemFilterBlockTranslator { get; private set; }
|
||||
public Mock<IBlockGroupHierarchyBuilder> MockBlockGroupHierarchyBuilder { get; private set; }
|
||||
public Mock<IThemeComponentListBuilder> MockThemeComponentListBuilder { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
using System.Net.Mime;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.Translators;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Filtration.Tests.Translators
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestThemeComponentListBuilder
|
||||
{
|
||||
[Test]
|
||||
public void AddComponent_ReturnsFirstAddedComponent_WhenComponentAddedTwice()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
var testInputTargetType = ThemeComponentType.TextColor;
|
||||
var testInputComponentName = "testComponent";
|
||||
var testInputColor = new Color();
|
||||
|
||||
var builder = new ThemeComponentListBuilder();
|
||||
builder.Initialise();
|
||||
|
||||
// Act
|
||||
var firstResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||
var secondResult = builder.AddComponent(testInputTargetType, testInputComponentName, testInputColor);
|
||||
|
||||
// Assert
|
||||
Assert.AreSame(firstResult, secondResult);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsInitialised_NotInitialised_ReturnsFalse()
|
||||
{
|
||||
// Arrange
|
||||
var builder = new ThemeComponentListBuilder();
|
||||
|
||||
// Act
|
||||
var result = builder.IsInitialised;
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsInitialised_Initialised_ReturnsTrue()
|
||||
{
|
||||
// Arrange
|
||||
var builder = new ThemeComponentListBuilder();
|
||||
builder.Initialise();
|
||||
|
||||
// Act
|
||||
var result = builder.IsInitialised;
|
||||
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace Filtration.Converters
|
|||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var themeComponentsList = values[0] as List<ThemeComponent>;
|
||||
var themeComponentsList = values[0] as ThemeComponentCollection;
|
||||
if (themeComponentsList == null || themeComponentsList.Count == 0) return null;
|
||||
|
||||
var blockItem = values[1] as ColorBlockItem;
|
||||
|
|
|
@ -159,7 +159,6 @@
|
|||
<Compile Include="Translators\BlockGroupHierarchyBuilder.cs" />
|
||||
<Compile Include="Translators\ItemFilterBlockTranslator.cs" />
|
||||
<Compile Include="Translators\ItemFilterScriptTranslator.cs" />
|
||||
<Compile Include="Translators\ThemeComponentListBuilder.cs" />
|
||||
<Compile Include="UserControls\AutoScrollingListBox.cs" />
|
||||
<Compile Include="UserControls\BlockItemControl.xaml.cs">
|
||||
<DependentUpon>BlockItemControl.xaml</DependentUpon>
|
||||
|
|
|
@ -10,14 +10,15 @@ using Filtration.ObjectModel.BlockItemBaseTypes;
|
|||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.Extensions;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
using Filtration.Utilities;
|
||||
|
||||
namespace Filtration.Translators
|
||||
{
|
||||
internal interface IItemFilterBlockTranslator
|
||||
{
|
||||
void InitialiseForExistingScript(ItemFilterScript script);
|
||||
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString);
|
||||
ItemFilterBlock TranslateStringToItemFilterBlock(string inputString,
|
||||
ThemeComponentCollection masterComponentCollection);
|
||||
string TranslateItemFilterBlockToString(ItemFilterBlock block);
|
||||
void ReplaceColorBlockItemsFromString(ObservableCollection<IItemFilterBlockItem> blockItems, string inputString);
|
||||
}
|
||||
|
@ -25,26 +26,20 @@ namespace Filtration.Translators
|
|||
internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator
|
||||
{
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
|
||||
private const string Indent = " ";
|
||||
private readonly string _newLine = Environment.NewLine + Indent;
|
||||
private ThemeComponentCollection _masterComponentCollection;
|
||||
|
||||
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder, IThemeComponentListBuilder themeComponentListBuilder)
|
||||
public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||
{
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
_themeComponentListBuilder = themeComponentListBuilder;
|
||||
}
|
||||
|
||||
public void InitialiseForExistingScript(ItemFilterScript script)
|
||||
{
|
||||
_themeComponentListBuilder.Initialise(script.ThemeComponents);
|
||||
_blockGroupHierarchyBuilder.Initialise(script.ItemFilterBlockGroups.First());
|
||||
}
|
||||
|
||||
// This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
|
||||
// and reading ItemFilterScripts from a file.
|
||||
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString)
|
||||
public ItemFilterBlock TranslateStringToItemFilterBlock(string inputString, ThemeComponentCollection masterComponentCollection)
|
||||
{
|
||||
_masterComponentCollection = masterComponentCollection;
|
||||
var block = new ItemFilterBlock();
|
||||
var showHideFound = false;
|
||||
foreach (var line in new LineReader(() => new StringReader(inputString)))
|
||||
|
@ -300,9 +295,9 @@ namespace Filtration.Translators
|
|||
{
|
||||
throw new Exception("Parsing error - unknown theme component type");
|
||||
}
|
||||
if (_themeComponentListBuilder.IsInitialised)
|
||||
if (_masterComponentCollection != null)
|
||||
{
|
||||
blockItem.ThemeComponent = _themeComponentListBuilder.AddComponent(componentType, componentName,
|
||||
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(componentType, componentName,
|
||||
blockItem.Color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,15 +20,12 @@ namespace Filtration.Translators
|
|||
{
|
||||
private readonly IItemFilterBlockTranslator _blockTranslator;
|
||||
private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder;
|
||||
private readonly IThemeComponentListBuilder _themeComponentListBuilder;
|
||||
|
||||
public ItemFilterScriptTranslator(IItemFilterBlockTranslator blockTranslator,
|
||||
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder,
|
||||
IThemeComponentListBuilder themeComponentListBuilder)
|
||||
IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder)
|
||||
{
|
||||
_blockTranslator = blockTranslator;
|
||||
_blockGroupHierarchyBuilder = blockGroupHierarchyBuilder;
|
||||
_themeComponentListBuilder = themeComponentListBuilder;
|
||||
}
|
||||
|
||||
public ItemFilterScript TranslateStringToItemFilterScript(string inputString)
|
||||
|
@ -55,8 +52,6 @@ namespace Filtration.Translators
|
|||
script.Description = script.Description.TrimEnd('\n').TrimEnd('\r');
|
||||
}
|
||||
|
||||
_themeComponentListBuilder.Initialise();
|
||||
|
||||
// Extract each block from between boundaries and translate it into a ItemFilterBlock object
|
||||
// and add that object to the ItemFilterBlocks list
|
||||
for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next)
|
||||
|
@ -66,12 +61,10 @@ namespace Filtration.Translators
|
|||
var block = new string[end - begin];
|
||||
Array.Copy(lines, begin, block, 0, end - begin);
|
||||
var blockString = string.Join("\r\n", block);
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString));
|
||||
script.ItemFilterBlocks.Add(_blockTranslator.TranslateStringToItemFilterBlock(blockString, script.ThemeComponents));
|
||||
}
|
||||
|
||||
script.ThemeComponents = _themeComponentListBuilder.GetComponents();
|
||||
_blockGroupHierarchyBuilder.Cleanup();
|
||||
_themeComponentListBuilder.Cleanup();
|
||||
return script;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.ThemeEditor;
|
||||
|
||||
namespace Filtration.Translators
|
||||
{
|
||||
internal interface IThemeComponentListBuilder
|
||||
{
|
||||
void Initialise();
|
||||
void Initialise(List<ThemeComponent> themeComponents);
|
||||
bool IsInitialised { get; }
|
||||
ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor);
|
||||
List<ThemeComponent> GetComponents();
|
||||
void Cleanup();
|
||||
}
|
||||
|
||||
internal class ThemeComponentListBuilder : IThemeComponentListBuilder
|
||||
{
|
||||
private List<ThemeComponent> _themeComponents;
|
||||
|
||||
public ThemeComponentListBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsInitialised
|
||||
{
|
||||
get
|
||||
{
|
||||
return _themeComponents != null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
_themeComponents = new List<ThemeComponent>();
|
||||
}
|
||||
|
||||
public void Initialise(List<ThemeComponent> themeComponents)
|
||||
{
|
||||
_themeComponents = themeComponents;
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
_themeComponents = null;
|
||||
}
|
||||
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
if (ComponentExists(componentType, componentName))
|
||||
{
|
||||
return _themeComponents.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
|
||||
}
|
||||
|
||||
var component = new ThemeComponent(componentType, componentName, componentColor);
|
||||
_themeComponents.Add(component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public List<ThemeComponent> GetComponents()
|
||||
{
|
||||
return _themeComponents;
|
||||
}
|
||||
|
||||
private bool ComponentExists(ThemeComponentType componentType, string componentName)
|
||||
{
|
||||
return _themeComponents.Exists(c => c.ComponentName == componentName && c.ComponentType == componentType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -543,8 +543,7 @@ namespace Filtration.ViewModels
|
|||
var clipboardText = Clipboard.GetText();
|
||||
if (clipboardText.IsNullOrEmpty()) return;
|
||||
|
||||
_blockTranslator.InitialiseForExistingScript(Script);
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText);
|
||||
var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
|
||||
if (translatedBlock == null) return;
|
||||
|
||||
var vm = _itemFilterBlockViewModelFactory.Create();
|
||||
|
|
|
@ -23,11 +23,6 @@ namespace Filtration.WindsorInstallers
|
|||
Component.For<IBlockGroupHierarchyBuilder>()
|
||||
.ImplementedBy<BlockGroupHierarchyBuilder>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<IThemeComponentListBuilder>()
|
||||
.ImplementedBy<ThemeComponentListBuilder>()
|
||||
.LifeStyle.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue