Implemented ThemeComponent reading/saving in translation layer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Media;
|
||||
using Filtration.ThemeEditor.Models;
|
||||
|
||||
namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
{
|
||||
@@ -20,7 +21,8 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
|
||||
get
|
||||
{
|
||||
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; }
|
||||
}
|
||||
|
||||
public ThemeComponent ThemeComponent { get; set; }
|
||||
|
||||
public override Color SummaryBackgroundColor { get { return Colors.Transparent; } }
|
||||
public override Color SummaryTextColor { get { return Colors.Transparent; } }
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReplaceColorsParameterSet.cs" />
|
||||
<Compile Include="ThemeEditor\Theme.cs" />
|
||||
<Compile Include="ThemeEditor\ThemeComponent.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.
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ThemeEditor.Models;
|
||||
|
||||
namespace Filtration.ObjectModel
|
||||
{
|
||||
@@ -15,10 +16,13 @@ namespace Filtration.ObjectModel
|
||||
{
|
||||
new ItemFilterBlockGroup("Root", null)
|
||||
};
|
||||
ThemeComponents = new List<ThemeComponent>();
|
||||
}
|
||||
|
||||
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 Description { get; set; }
|
||||
@@ -38,7 +42,6 @@ namespace Filtration.ObjectModel
|
||||
|
||||
public void ReplaceColors(ReplaceColorsParameterSet replaceColorsParameterSet)
|
||||
{
|
||||
|
||||
foreach (
|
||||
var block in
|
||||
ItemFilterBlocks.Where(b => BlockIsColorReplacementCandidate(replaceColorsParameterSet, b)))
|
||||
@@ -59,7 +62,6 @@ namespace Filtration.ObjectModel
|
||||
borderColorBlockItem.Color = replaceColorsParameterSet.NewBorderColor;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, ItemFilterBlock block)
|
||||
|
||||
33
Filtration.ObjectModel/ThemeEditor/Theme.cs
Normal file
33
Filtration.ObjectModel/ThemeEditor/Theme.cs
Normal file
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs
Normal file
24
Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user