diff --git a/Filtration/Converters/BooleanVisibilityConverter.cs b/Filtration.Common/Converters/BooleanVisibilityConverter.cs
similarity index 91%
rename from Filtration/Converters/BooleanVisibilityConverter.cs
rename to Filtration.Common/Converters/BooleanVisibilityConverter.cs
index 3be867a..a5be81c 100644
--- a/Filtration/Converters/BooleanVisibilityConverter.cs
+++ b/Filtration.Common/Converters/BooleanVisibilityConverter.cs
@@ -3,9 +3,9 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace Filtration.Converters
+namespace Filtration.Common.Converters
{
- internal class BooleanVisibilityConverterCopy : IValueConverter
+ public class BooleanVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
diff --git a/Filtration.Common/Filtration.Common.csproj b/Filtration.Common/Filtration.Common.csproj
index 5b368c2..fad75f1 100644
--- a/Filtration.Common/Filtration.Common.csproj
+++ b/Filtration.Common/Filtration.Common.csproj
@@ -64,6 +64,7 @@
+
diff --git a/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs b/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs
index 19835ae..27ab695 100644
--- a/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs
+++ b/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs
@@ -11,12 +11,9 @@ namespace Filtration.ObjectModel.ThemeEditor
public class ThemeComponent : INotifyPropertyChanged
{
private Color _color;
-
- public ThemeComponent()
- {
-
- }
-
+ private EventHandler _themeComponentUpdatedEventHandler;
+ private readonly object _eventLock = new object();
+
public ThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor)
{
if (componentName == null || componentColor == null)
@@ -29,7 +26,28 @@ namespace Filtration.ObjectModel.ThemeEditor
ComponentName = componentName;
}
- public event EventHandler ThemeComponentUpdated;
+ // By implementing a custom event accessor here we can keep the UsageCount up to date.
+ public event EventHandler ThemeComponentUpdated
+ {
+ add
+ {
+ lock (_eventLock)
+ {
+ _themeComponentUpdatedEventHandler += value;
+ OnPropertyChanged("UsageCount");
+ }
+ }
+ remove
+ {
+ lock (_eventLock)
+ {
+ // ReSharper disable once DelegateSubtraction
+ _themeComponentUpdatedEventHandler -= value;
+ OnPropertyChanged("UsageCount");
+ }
+ }
+ }
+
public event EventHandler ThemeComponentDeleted;
public string ComponentName { get; set; }
@@ -42,13 +60,26 @@ namespace Filtration.ObjectModel.ThemeEditor
{
_color = value;
OnPropertyChanged();
- if (ThemeComponentUpdated != null)
+ if (_themeComponentUpdatedEventHandler != null)
{
- ThemeComponentUpdated.Invoke(this, EventArgs.Empty);
+ _themeComponentUpdatedEventHandler.Invoke(this, EventArgs.Empty);
}
}
}
+ public int UsageCount
+ {
+ get
+ {
+ if (_themeComponentUpdatedEventHandler == null)
+ {
+ return 0;
+ }
+
+ return _themeComponentUpdatedEventHandler.GetInvocationList().Length;
+ }
+ }
+
public void TerminateComponent()
{
if (ThemeComponentDeleted != null)
diff --git a/Filtration.ThemeEditor/Converters/ThemeComponentTypeToStringConverter.cs b/Filtration.ThemeEditor/Converters/ThemeComponentTypeToStringConverter.cs
index c71dd6b..264a599 100644
--- a/Filtration.ThemeEditor/Converters/ThemeComponentTypeToStringConverter.cs
+++ b/Filtration.ThemeEditor/Converters/ThemeComponentTypeToStringConverter.cs
@@ -1,7 +1,6 @@
using System;
using System.Globalization;
using System.Windows.Data;
-using Filtration.ObjectModel.BlockItemTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.Extensions;
@@ -18,6 +17,22 @@ namespace Filtration.ThemeEditor.Converters
}
var type = (ThemeComponentType) value;
+ switch (type.GetAttributeDescription())
+ {
+ case "TextColor":
+ {
+ return "Text";
+ }
+ case "BorderColor":
+ {
+ return "Border";
+ }
+ case "BackgroundColor":
+ {
+ return "Background";
+ }
+ }
+
return type.GetAttributeDescription();
}
diff --git a/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml b/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml
index bc323b3..18c9b9c 100644
--- a/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml
+++ b/Filtration.ThemeEditor/Views/ThemeComponentControl.xaml
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:converters="clr-namespace:Filtration.ThemeEditor.Converters"
+ xmlns:commonConverters="clr-namespace:Filtration.Common.Converters;assembly=Filtration.Common"
xmlns:themeEditor="clr-namespace:Filtration.ObjectModel.ThemeEditor;assembly=Filtration.ObjectModel"
xmlns:views="clr-namespace:Filtration.ThemeEditor.Views"
mc:Ignorable="d"
@@ -12,6 +13,7 @@
d:DesignHeight="40" d:DesignWidth="200">
+
@@ -19,6 +21,10 @@
+
+
+
+
@@ -27,8 +33,23 @@
-
-
+
+
+
+
+
+