Implemented editable themes / master themes

This commit is contained in:
Ben
2015-07-05 22:43:17 +01:00
parent 511f503e88
commit bfa2341ab8
20 changed files with 354 additions and 89 deletions

View File

@@ -1,4 +1,4 @@
using System.ComponentModel;
using System;
using System.Windows.Media;
using Filtration.ObjectModel.ThemeEditor;
@@ -38,6 +38,19 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
get { return _themeComponent; }
set
{
if (_themeComponent == value){ return;}
if (_themeComponent != null)
{
_themeComponent.ThemeComponentUpdated -= OnThemeComponentUpdated;
_themeComponent.ThemeComponentDeleted -= OnThemeComponentDeleted;
}
if (value != null)
{
value.ThemeComponentUpdated += OnThemeComponentUpdated;
value.ThemeComponentDeleted += OnThemeComponentDeleted;
}
_themeComponent = value;
OnPropertyChanged();
}
@@ -55,5 +68,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
OnPropertyChanged();
}
}
private void OnThemeComponentUpdated(object sender, EventArgs e)
{
Color = ((ThemeComponent) sender).Color;
}
private void OnThemeComponentDeleted(object sender, EventArgs e)
{
ThemeComponent = null;
}
}
}

View File

@@ -1,12 +1,17 @@
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
{
[Serializable]
public class ThemeComponent
public class ThemeComponent : INotifyPropertyChanged
{
private Color _color;
public ThemeComponent()
{
@@ -24,8 +29,41 @@ namespace Filtration.ObjectModel.ThemeEditor
ComponentName = componentName;
}
public event EventHandler ThemeComponentUpdated;
public event EventHandler ThemeComponentDeleted;
public string ComponentName { get; set; }
public ThemeComponentType ComponentType{ get; set; }
public Color Color { get; set; }
public ThemeComponentType ComponentType{ get; private set; }
public Color Color
{
get { return _color; }
set
{
_color = value;
OnPropertyChanged();
if (ThemeComponentUpdated != null)
{
ThemeComponentUpdated.Invoke(this, EventArgs.Empty);
}
}
}
public void TerminateComponent()
{
if (ThemeComponentDeleted != null)
{
ThemeComponentDeleted.Invoke(this, EventArgs.Empty);
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -5,7 +5,7 @@ using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor
{
public class ThemeComponentCollection : Collection<ThemeComponent>
public class ThemeComponentCollection : ObservableCollection<ThemeComponent>
{
public bool IsMasterCollection { get; set; }