Filtration/Filtration.ObjectModel/BlockItemBaseTypes/StringBlockItem.cs

72 lines
2.1 KiB
C#
Raw Permalink Normal View History

2018-08-29 06:11:41 -04:00
using System;
using System.Windows.Media;
using Filtration.ObjectModel.ThemeEditor;
2018-08-21 10:03:42 -04:00
namespace Filtration.ObjectModel.BlockItemBaseTypes
{
2018-08-29 06:11:41 -04:00
public abstract class StringBlockItem : BlockItemBase, IAudioVisualBlockItem, IBlockItemWithTheme
2018-08-21 10:03:42 -04:00
{
private string _value;
2018-08-29 06:11:41 -04:00
private ThemeComponent _themeComponent;
2018-08-21 10:03:42 -04:00
protected StringBlockItem()
{
}
protected StringBlockItem(string value)
{
Value = value;
}
2018-08-29 06:11:41 -04:00
public override string OutputText => PrefixText + " \"" + Value + "\""
+ (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty);
2018-08-21 10:03:42 -04:00
public override string SummaryText => string.Empty;
public override Color SummaryBackgroundColor => Colors.Transparent;
public override Color SummaryTextColor => Colors.Transparent;
2018-08-29 06:11:41 -04:00
public ThemeComponent ThemeComponent
{
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();
}
}
2018-08-21 10:03:42 -04:00
public string Value
{
get { return _value; }
set
{
_value = value;
IsDirty = true;
OnPropertyChanged();
}
}
2018-08-29 06:11:41 -04:00
private void OnThemeComponentUpdated(object sender, EventArgs e)
{
Value = ((StringThemeComponent)sender).Value;
}
private void OnThemeComponentDeleted(object sender, EventArgs e)
{
ThemeComponent = null;
}
2018-08-21 10:03:42 -04:00
}
}