Filtration/Filtration.ObjectModel/ThemeEditor/Theme.cs

53 lines
1.8 KiB
C#
Raw Permalink Normal View History

using System;
using System.Linq;
using System.Windows.Media;
using System.Xml.Serialization;
2015-06-26 12:42:20 -04:00
using Filtration.ObjectModel.Enums;
2015-06-26 12:42:20 -04:00
namespace Filtration.ObjectModel.ThemeEditor
{
2015-06-26 12:42:20 -04:00
[Serializable]
2018-11-28 16:50:42 -05:00
[XmlInclude(typeof(ColorThemeComponent))]
[XmlInclude(typeof(EffectColorThemeComponent))]
[XmlInclude(typeof(IconThemeComponent))]
[XmlInclude(typeof(IntegerThemeComponent))]
[XmlInclude(typeof(StringThemeComponent))]
[XmlInclude(typeof(StrIntThemeComponent))]
public class Theme
{
public Theme()
{
2018-11-28 16:50:42 -05:00
Components = new ThemeComponentCollection { IsMasterCollection = false};
}
public string Name { get; set; }
[XmlIgnore]
2015-06-26 12:42:20 -04:00
public string FilePath { get; set; }
2018-11-28 16:50:42 -05:00
public ThemeComponentCollection Components { get; set; }
2015-06-26 12:42:20 -04:00
public bool ComponentExists(ThemeComponentType componentType, string componentName)
{
var componentCount =
2018-11-28 16:50:42 -05:00
Components.Count(c => c.ComponentName == componentName && c.ComponentType == componentType);
return componentCount > 0;
}
2015-06-26 12:42:20 -04:00
public void AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
2018-11-28 16:50:42 -05:00
Components.Add(new ColorThemeComponent(componentType, componentName, componentColor));
}
public void AddComponent(ThemeComponentType componentType, string componentName, int componentValue)
{
2018-11-28 16:50:42 -05:00
Components.Add(new IntegerThemeComponent(componentType, componentName, componentValue));
}
2018-08-26 13:24:13 -04:00
public void AddComponent(ThemeComponentType componentType, string componentName, string componentValue, int componentSecondValue)
{
2018-11-28 16:50:42 -05:00
Components.Add(new StrIntThemeComponent(componentType, componentName, componentValue, componentSecondValue));
2018-08-26 13:24:13 -04:00
}
}
}