Add font size theme support & improve theme system

This commit is contained in:
azakhi
2018-08-25 15:52:16 +03:00
parent 8ba3433dcf
commit bc5a005ee7
26 changed files with 247 additions and 70 deletions

View File

@@ -1,8 +1,5 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Filtration.ObjectModel.Annotations;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
@@ -11,7 +8,6 @@ namespace Filtration.ObjectModel.ThemeEditor
public class ColorThemeComponent : ThemeComponent
{
private Color _color;
private readonly object _eventLock = new object();
public ColorThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{

View File

@@ -0,0 +1,35 @@
using System;
using System.Windows.Media;
using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
{
[Serializable]
public class IntegerThemeComponent : ThemeComponent
{
private int _value;
public IntegerThemeComponent(ThemeComponentType componentType, string componentName, int componentValue)
{
if (componentName == null)
{
throw new ArgumentException("Null parameters not allowed in IntegerThemeComponent constructor");
}
ComponentType = componentType;
Value = componentValue;
ComponentName = componentName;
}
public int Value
{
get { return _value; }
set
{
_value = value;
OnPropertyChanged();
_themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty);
}
}
}
}

View File

@@ -34,5 +34,10 @@ namespace Filtration.ObjectModel.ThemeEditor
{
_components.Add(new ColorThemeComponent(componentType, componentName, componentColor));
}
public void AddComponent(ThemeComponentType componentType, string componentName, int componentValue)
{
_components.Add(new IntegerThemeComponent(componentType, componentName, componentValue));
}
}
}

View File

@@ -16,15 +16,20 @@ namespace Filtration.ObjectModel.ThemeEditor
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
}
ThemeComponent component = null;
switch(componentType)
var component = new ColorThemeComponent(componentType, componentName, componentColor);
Items.Add(component);
return component;
}
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, int componentValue)
{
if (ComponentExists(componentType, componentName))
{
case ThemeComponentType.BackgroundColor:
case ThemeComponentType.BorderColor:
case ThemeComponentType.TextColor:
component = new ColorThemeComponent(componentType, componentName, componentColor);
break;
return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
}
var component = new IntegerThemeComponent(componentType, componentName, componentValue);
Items.Add(component);
return component;