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

@ -4,7 +4,7 @@ using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ObjectModel.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem public abstract class ColorBlockItem : BlockItemBase, IAudioVisualBlockItem, IBlockItemWithTheme
{ {
private Color _color; private Color _color;
private ThemeComponent _themeComponent; private ThemeComponent _themeComponent;

View File

@ -1,10 +1,13 @@
using System.Windows.Media; using System;
using System.Windows.Media;
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ObjectModel.BlockItemBaseTypes namespace Filtration.ObjectModel.BlockItemBaseTypes
{ {
public abstract class IntegerBlockItem : BlockItemBase, IAudioVisualBlockItem public abstract class IntegerBlockItem : BlockItemBase, IAudioVisualBlockItem, IBlockItemWithTheme
{ {
private int _value; private int _value;
private ThemeComponent _themeComponent;
protected IntegerBlockItem() protected IntegerBlockItem()
{ {
@ -15,7 +18,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
Value = value; Value = value;
} }
public override string OutputText => PrefixText + " " + Value; public override string OutputText => PrefixText + " " + Value + (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty);
public override string SummaryText => string.Empty; public override string SummaryText => string.Empty;
public override Color SummaryBackgroundColor => Colors.Transparent; public override Color SummaryBackgroundColor => Colors.Transparent;
@ -24,6 +27,29 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
public abstract int Minimum { get; } public abstract int Minimum { get; }
public abstract int Maximum { get; } public abstract int Maximum { get; }
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();
}
}
public int Value public int Value
{ {
get { return _value; } get { return _value; }
@ -34,5 +60,15 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes
OnPropertyChanged(); OnPropertyChanged();
} }
} }
private void OnThemeComponentUpdated(object sender, EventArgs e)
{
Value = ((IntegerBlockItem)sender).Value;
}
private void OnThemeComponentDeleted(object sender, EventArgs e)
{
ThemeComponent = null;
}
} }
} }

View File

@ -9,6 +9,8 @@ namespace Filtration.ObjectModel.Enums
[Description("Background")] [Description("Background")]
BackgroundColor, BackgroundColor,
[Description("Border")] [Description("Border")]
BorderColor BorderColor,
[Description("Font Size")]
FontSize
} }
} }

View File

@ -115,6 +115,7 @@
<Compile Include="Factories\IItemFilterScriptFactory.cs" /> <Compile Include="Factories\IItemFilterScriptFactory.cs" />
<Compile Include="FilteredItem.cs" /> <Compile Include="FilteredItem.cs" />
<Compile Include="IAudioVisualBlockItem.cs" /> <Compile Include="IAudioVisualBlockItem.cs" />
<Compile Include="IBlockItemWithTheme.cs" />
<Compile Include="IItemFilterBlockItem.cs" /> <Compile Include="IItemFilterBlockItem.cs" />
<Compile Include="Item.cs" /> <Compile Include="Item.cs" />
<Compile Include="ItemFilterBlock.cs" /> <Compile Include="ItemFilterBlock.cs" />
@ -130,6 +131,7 @@
<Compile Include="ReplaceColorsParameterSet.cs" /> <Compile Include="ReplaceColorsParameterSet.cs" />
<Compile Include="Socket.cs" /> <Compile Include="Socket.cs" />
<Compile Include="SocketGroup.cs" /> <Compile Include="SocketGroup.cs" />
<Compile Include="ThemeEditor\IntegerThemeComponent.cs" />
<Compile Include="ThemeEditor\Theme.cs" /> <Compile Include="ThemeEditor\Theme.cs" />
<Compile Include="ThemeEditor\ColorThemeComponent.cs" /> <Compile Include="ThemeEditor\ColorThemeComponent.cs" />
<Compile Include="ThemeEditor\ThemeComponent.cs" /> <Compile Include="ThemeEditor\ThemeComponent.cs" />

View File

@ -0,0 +1,9 @@
using Filtration.ObjectModel.ThemeEditor;
namespace Filtration.ObjectModel
{
public interface IBlockItemWithTheme : IItemFilterBlockItem
{
ThemeComponent ThemeComponent { get; }
}
}

View File

@ -1,8 +1,5 @@
using System; using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media; using System.Windows.Media;
using Filtration.ObjectModel.Annotations;
using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.Enums;
namespace Filtration.ObjectModel.ThemeEditor namespace Filtration.ObjectModel.ThemeEditor
@ -11,7 +8,6 @@ namespace Filtration.ObjectModel.ThemeEditor
public class ColorThemeComponent : ThemeComponent public class ColorThemeComponent : ThemeComponent
{ {
private Color _color; private Color _color;
private readonly object _eventLock = new object();
public ColorThemeComponent(ThemeComponentType componentType, string componentName, Color componentColor) 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)); _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); return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
} }
ThemeComponent component = null; var component = new ColorThemeComponent(componentType, componentName, componentColor);
switch(componentType) Items.Add(component);
return component;
}
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, int componentValue)
{
if (ComponentExists(componentType, componentName))
{ {
case ThemeComponentType.BackgroundColor: return Items.FirstOrDefault(t => t.ComponentName == componentName && t.ComponentType == componentType);
case ThemeComponentType.BorderColor:
case ThemeComponentType.TextColor:
component = new ColorThemeComponent(componentType, componentName, componentColor);
break;
} }
var component = new IntegerThemeComponent(componentType, componentName, componentValue);
Items.Add(component); Items.Add(component);
return component; return component;

View File

@ -217,11 +217,15 @@ namespace Filtration.Parser.Services
// Only ever use the last SetFontSize item encountered as multiples aren't valid. // Only ever use the last SetFontSize item encountered as multiples aren't valid.
RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block); RemoveExistingBlockItemsOfType<FontSizeBlockItem>(block);
var match = Regex.Match(trimmedLine, @"\s+(\d+)"); var match = Regex.Matches(trimmedLine, @"(\s+(\d+)\s*)([#]?)(.*)");
if (match.Success) if (match.Count > 0)
{ {
var blockItemValue = new FontSizeBlockItem(Convert.ToInt16(match.Value)); var blockItem = new FontSizeBlockItem(Convert.ToInt16(match[0].Groups[2].Value));
block.BlockItems.Add(blockItemValue); if(match[0].Groups[3].Value == "#" && !string.IsNullOrWhiteSpace(match[0].Groups[4].Value))
{
blockItem.ThemeComponent = _masterComponentCollection.AddComponent(ThemeComponentType.FontSize, match[0].Groups[4].Value.Trim(), blockItem.Value);
}
block.BlockItems.Add(blockItem);
} }
break; break;
} }

View File

@ -31,6 +31,10 @@ namespace Filtration.ThemeEditor.Converters
{ {
return "Background Color Theme Components"; return "Background Color Theme Components";
} }
case "Font Size":
{
return "Font Size Theme Components";
}
} }
return type.GetAttributeDescription(); return type.GetAttributeDescription();

View File

@ -109,6 +109,7 @@
<Compile Include="Services\ThemePersistenceService.cs" /> <Compile Include="Services\ThemePersistenceService.cs" />
<Compile Include="Services\ThemeService.cs" /> <Compile Include="Services\ThemeService.cs" />
<Compile Include="ViewModels\ColorThemeComponentViewModel.cs" /> <Compile Include="ViewModels\ColorThemeComponentViewModel.cs" />
<Compile Include="ViewModels\IntegerThemeComponentViewModel.cs" />
<Compile Include="ViewModels\IThemeViewModelFactory.cs" /> <Compile Include="ViewModels\IThemeViewModelFactory.cs" />
<Compile Include="ViewModels\ThemeComponentViewModel.cs" /> <Compile Include="ViewModels\ThemeComponentViewModel.cs" />
<Compile Include="ViewModels\ThemeEditorViewModel.cs" /> <Compile Include="ViewModels\ThemeEditorViewModel.cs" />

View File

@ -42,6 +42,9 @@ namespace Filtration.ThemeEditor.Providers
case ThemeComponentType.TextColor: case ThemeComponentType.TextColor:
c.Add(new ColorThemeComponent(component.ComponentType, component.ComponentName, ((ColorThemeComponent)component).Color)); c.Add(new ColorThemeComponent(component.ComponentType, component.ComponentName, ((ColorThemeComponent)component).Color));
break; break;
case ThemeComponentType.FontSize:
c.Add(new IntegerThemeComponent(component.ComponentType, component.ComponentName, ((IntegerThemeComponent)component).Value));
break;
} }
return c; return c;
}); });

View File

@ -42,6 +42,9 @@ namespace Filtration.ThemeEditor.Services
case ThemeComponentType.BorderColor: case ThemeComponentType.BorderColor:
mismatchedComponents = ApplyColorTheme(blocks, typeof(BorderColorBlockItem), component); mismatchedComponents = ApplyColorTheme(blocks, typeof(BorderColorBlockItem), component);
break; break;
case ThemeComponentType.FontSize:
mismatchedComponents = ApplyIntegerTheme(blocks, typeof(FontSizeBlockItem), component);
break;
} }
} }
@ -72,5 +75,25 @@ namespace Filtration.ThemeEditor.Services
return !componentMatched; return !componentMatched;
} }
private bool ApplyIntegerTheme(IEnumerable<ItemFilterBlock> blocks, Type type, ThemeComponent component)
{
var componentMatched = false;
foreach (var block in blocks)
{
foreach (var blockItem in block.BlockItems.Where(i => i.GetType() == type))
{
var colorBlockItem = (IntegerBlockItem)blockItem;
if (colorBlockItem.ThemeComponent != null &&
colorBlockItem.ThemeComponent.ComponentName == component.ComponentName)
{
colorBlockItem.Value = ((IntegerThemeComponent)component).Value;
componentMatched = true;
}
}
}
return !componentMatched;
}
} }
} }

View File

@ -1,5 +1,4 @@
using System.Windows.Media; using System.Windows.Media;
using Filtration.ObjectModel.Enums;
namespace Filtration.ThemeEditor.ViewModels namespace Filtration.ThemeEditor.ViewModels
{ {

View File

@ -0,0 +1,7 @@
namespace Filtration.ThemeEditor.ViewModels
{
public class IntegerThemeComponentViewModel : ThemeComponentViewModel
{
public int Value { get; set; }
}
}

View File

@ -202,6 +202,9 @@ namespace Filtration.ThemeEditor.ViewModels
Components.Add(new ColorThemeComponent(themeComponentType, "Untitled Component", Components.Add(new ColorThemeComponent(themeComponentType, "Untitled Component",
new Color { A = 255, R = 255, G = 255, B = 255 })); new Color { A = 255, R = 255, G = 255, B = 255 }));
break; break;
case ThemeComponentType.FontSize:
Components.Add(new IntegerThemeComponent(themeComponentType, "Untitled Component", 35));
break;
} }
} }

View File

@ -64,6 +64,11 @@
<DataTemplate DataType="{x:Type themeEditor:ColorThemeComponent}"> <DataTemplate DataType="{x:Type themeEditor:ColorThemeComponent}">
<xctk:ColorPicker SelectedColor="{Binding Color}" /> <xctk:ColorPicker SelectedColor="{Binding Color}" />
</DataTemplate> </DataTemplate>
<!-- Integer Theme Template -->
<DataTemplate DataType="{x:Type themeEditor:IntegerThemeComponent}">
<xctk:ShortUpDown Value="{Binding Value}" />
</DataTemplate>
</ContentControl.Resources> </ContentControl.Resources>
</ContentControl> </ContentControl>
</Grid> </Grid>

View File

@ -47,6 +47,7 @@ namespace Filtration
cfg.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator(); cfg.CreateMap<Theme, IThemeEditorViewModel>().ConstructUsingServiceLocator();
cfg.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap(); cfg.CreateMap<ThemeComponent, ThemeComponentViewModel>().ReverseMap();
cfg.CreateMap<ColorThemeComponent, ColorThemeComponentViewModel>().ReverseMap(); cfg.CreateMap<ColorThemeComponent, ColorThemeComponentViewModel>().ReverseMap();
cfg.CreateMap<IntegerThemeComponent, IntegerThemeComponentViewModel>().ReverseMap();
cfg.CreateMap<IThemeEditorViewModel, Theme>(); cfg.CreateMap<IThemeEditorViewModel, Theme>();
}); });

View File

@ -16,7 +16,7 @@ namespace Filtration.Converters
var themeComponentsList = values[0] as ThemeComponentCollection; var themeComponentsList = values[0] as ThemeComponentCollection;
if (themeComponentsList == null || themeComponentsList.Count == 0) return null; if (themeComponentsList == null || themeComponentsList.Count == 0) return null;
var blockItem = values[1] as ColorBlockItem; var blockItem = values[1] as BlockItemBase;
if (blockItem == null) return null; if (blockItem == null) return null;
ThemeComponentType themeComponentType; ThemeComponentType themeComponentType;
@ -33,6 +33,10 @@ namespace Filtration.Converters
{ {
themeComponentType = ThemeComponentType.BorderColor; themeComponentType = ThemeComponentType.BorderColor;
} }
else if (blockItem.GetType() == typeof(FontSizeBlockItem))
{
themeComponentType = ThemeComponentType.FontSize;
}
else else
{ {
return null; return null;

View File

@ -116,9 +116,21 @@
<!-- Font Size Template --> <!-- Font Size Template -->
<DataTemplate DataType="{x:Type blockItemTypes:FontSizeBlockItem}"> <DataTemplate DataType="{x:Type blockItemTypes:FontSizeBlockItem}">
<WrapPanel HorizontalAlignment="Left"> <Grid>
<xctk:ShortUpDown Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Width="50" /> <Grid.ColumnDefinitions>
</WrapPanel> <ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<xctk:ShortUpDown Grid.Column="0" Value="{Binding Value}" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}" Margin="0,0,10,0" />
<userControls:ThemeComponentSelectionControl Grid.Column="1" ThemeComponent="{Binding ThemeComponent}">
<userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
<MultiBinding Converter="{StaticResource AvailableThemeComponentsConverter}">
<Binding Path="DataContext.Script.ThemeComponents" RelativeSource="{RelativeSource AncestorType={x:Type views:ItemFilterScriptView}}"/>
<Binding Path="." />
</MultiBinding>
</userControls:ThemeComponentSelectionControl.AvailableThemeComponents>
</userControls:ThemeComponentSelectionControl>
</Grid>
</DataTemplate> </DataTemplate>
<!-- Sound Template --> <!-- Sound Template -->

View File

@ -6,6 +6,7 @@ using System.Windows;
using Filtration.Annotations; using Filtration.Annotations;
using Filtration.ObjectModel; using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes; using Filtration.ObjectModel.BlockItemBaseTypes;
using Filtration.ObjectModel.Enums;
using Filtration.ObjectModel.ThemeEditor; using Filtration.ObjectModel.ThemeEditor;
using Filtration.Views; using Filtration.Views;
using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.CommandWpf;
@ -21,10 +22,10 @@ namespace Filtration.UserControls
// ReSharper disable once PossibleNullReferenceException // ReSharper disable once PossibleNullReferenceException
(Content as FrameworkElement).DataContext = this; (Content as FrameworkElement).DataContext = this;
SetBlockColorCommand = new RelayCommand(OnSetBlockColorCommmand); SetBlockValueCommand = new RelayCommand(OnSetBlockValueCommmand);
} }
public RelayCommand SetBlockColorCommand { get; private set; } public RelayCommand SetBlockValueCommand { get; private set; }
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register( public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
"BlockItem", "BlockItem",
@ -93,12 +94,25 @@ namespace Filtration.UserControls
"Icon1", "Icon2", "Icon3", "Icon4", "Icon5", "Icon6" "Icon1", "Icon2", "Icon3", "Icon4", "Icon5", "Icon6"
}; };
private void OnSetBlockColorCommmand() private void OnSetBlockValueCommmand()
{ {
var blockItem = BlockItem as ColorBlockItem; var blockItemWithTheme = BlockItem as IBlockItemWithTheme;
if (blockItem?.ThemeComponent == null) return; if (blockItemWithTheme?.ThemeComponent == null) return;
blockItem.Color = ((ColorThemeComponent)blockItem.ThemeComponent).Color; var componentType = ((IBlockItemWithTheme)BlockItem).ThemeComponent.ComponentType;
switch(componentType)
{
case ThemeComponentType.BackgroundColor:
case ThemeComponentType.BorderColor:
case ThemeComponentType.TextColor:
var colorBlockItem = BlockItem as ColorBlockItem;
colorBlockItem.Color = ((ColorThemeComponent)colorBlockItem.ThemeComponent).Color;
break;
case ThemeComponentType.FontSize:
var integerBlockItem = BlockItem as IntegerBlockItem;
integerBlockItem.Value = ((IntegerThemeComponent)integerBlockItem.ThemeComponent).Value;
break;
}
} }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;

View File

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:userControls="clr-namespace:Filtration.UserControls" xmlns:userControls="clr-namespace:Filtration.UserControls"
xmlns:themeEditor="clr-namespace:Filtration.ObjectModel.ThemeEditor;assembly=Filtration.ObjectModel"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=userControls:ThemeComponentSelectionControl}" d:DataContext="{d:DesignInstance Type=userControls:ThemeComponentSelectionControl}"
@ -21,7 +22,7 @@
<Setter Property="MinHeight" Value="0" /> <Setter Property="MinHeight" Value="0" />
</Style> </Style>
</Grid.Resources> </Grid.Resources>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -32,44 +33,42 @@
Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}"> Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}">
<i:Interaction.Triggers> <i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged"> <i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SetBlockColorCommand, RelativeSource={RelativeSource AncestorType=userControls:BlockItemControl}}" /> <i:InvokeCommandAction Command="{Binding SetBlockValueCommand, RelativeSource={RelativeSource AncestorType=userControls:BlockItemControl}}" />
</i:EventTrigger> </i:EventTrigger>
</i:Interaction.Triggers> </i:Interaction.Triggers>
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate > <DataTemplate >
<ContentControl Content="{Binding}"> <ContentControl Content="{Binding}">
<ContentControl.Style> <ContentControl.Style>
<Style TargetType="{x:Type ContentControl}"> <Style TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate"> <Setter Property="ContentTemplate">
<Setter.Value> <Setter.Value>
<DataTemplate> <DataTemplate>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="ComponentNameColumn" Width="Auto" /> <ColumnDefinition SharedSizeGroup="ComponentNameColumn" Width="Auto" />
<ColumnDefinition SharedSizeGroup="ComponentColorColumn" Width="20" /> <ColumnDefinition SharedSizeGroup="ComponentValueColumn" Width="20" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding ComponentName}" Margin="0,0,2,0" /> <TextBlock Grid.Column="0" Text="{Binding ComponentName}" Margin="0,0,2,0" />
<Border Grid.Column="1" Background="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}" /> <ContentControl Content="{Binding Mode=OneWay}" Grid.Column="1">
</Grid> <ContentControl.Resources>
</DataTemplate> <DataTemplate DataType="{x:Type themeEditor:ColorThemeComponent}">
</Setter.Value> <Border Background="{Binding Color, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Setter> </DataTemplate>
<Style.Triggers> <DataTemplate DataType="{x:Type themeEditor:IntegerThemeComponent}">
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ComboBoxItem}}" Value="{x:Null}"> <TextBlock Text="{Binding Value}" FontWeight="Bold" />
<Setter Property="ContentTemplate"> </DataTemplate>
<Setter.Value> </ContentControl.Resources>
<DataTemplate> </ContentControl>
<TextBlock Text="{Binding ComponentName}" /> </Grid>
</DataTemplate> </DataTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</DataTrigger> </Style>
</Style.Triggers> </ContentControl.Style>
</Style> </ContentControl>
</ContentControl.Style> </DataTemplate>
</ContentControl> </ComboBox.ItemTemplate>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
<userControls:CrossButton Grid.Column="1" Height="12" Command="{Binding RemoveThemeComponentCommand}" VerticalAlignment="Top" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}" /> <userControls:CrossButton Grid.Column="1" Height="12" Command="{Binding RemoveThemeComponentCommand}" VerticalAlignment="Top" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource BooleanToVisibilityConverter}}" />
<TextBlock Grid.Column="0" Grid.ColumnSpan="2" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource InverseBooleanVisibilityConverter}}" VerticalAlignment="Center"> <TextBlock Grid.Column="0" Grid.ColumnSpan="2" Visibility="{Binding ShowThemeComponentComboBox, Converter={StaticResource InverseBooleanVisibilityConverter}}" VerticalAlignment="Center">

View File

@ -563,7 +563,7 @@ namespace Filtration.ViewModels
Script.ThemeComponents.Where( Script.ThemeComponents.Where(
t => t =>
Script.ItemFilterBlocks.OfType<ItemFilterBlock>().Count( Script.ItemFilterBlocks.OfType<ItemFilterBlock>().Count(
b => b.BlockItems.OfType<ColorBlockItem>().Count(i => i.ThemeComponent == t) > 0) == 0).ToList(); b => b.BlockItems.OfType<IBlockItemWithTheme>().Count(i => i.ThemeComponent == t) > 0) == 0).ToList();
if (unusedThemeComponents.Count <= 0) return true; if (unusedThemeComponents.Count <= 0) return true;

View File

@ -114,6 +114,7 @@ namespace Filtration.ViewModels
AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); AddTextColorThemeComponentCommand = new RelayCommand(OnAddTextColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); AddBackgroundColorThemeComponentCommand = new RelayCommand(OnAddBackgroundColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable); AddBorderColorThemeComponentCommand = new RelayCommand(OnAddBorderColorThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
AddFontSizeThemeComponentCommand = new RelayCommand(OnAddFontSizeThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable);
DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable && _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null); DeleteThemeComponentCommand = new RelayCommand(OnDeleteThemeComponentCommand, () => ActiveDocumentIsTheme && ActiveThemeIsEditable && _avalonDockWorkspaceViewModel.ActiveThemeViewModel.SelectedThemeComponent != null);
ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript); ExpandAllBlocksCommand = new RelayCommand(OnExpandAllBlocksCommand, () => ActiveDocumentIsScript);
@ -213,6 +214,7 @@ namespace Filtration.ViewModels
public RelayCommand AddTextColorThemeComponentCommand { get; } public RelayCommand AddTextColorThemeComponentCommand { get; }
public RelayCommand AddBackgroundColorThemeComponentCommand { get; } public RelayCommand AddBackgroundColorThemeComponentCommand { get; }
public RelayCommand AddBorderColorThemeComponentCommand { get; } public RelayCommand AddBorderColorThemeComponentCommand { get; }
public RelayCommand AddFontSizeThemeComponentCommand { get; }
public RelayCommand DeleteThemeComponentCommand { get; } public RelayCommand DeleteThemeComponentCommand { get; }
public RelayCommand AddBlockCommand { get; } public RelayCommand AddBlockCommand { get; }
@ -677,6 +679,11 @@ namespace Filtration.ViewModels
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BorderColor); _avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.BorderColor);
} }
private void OnAddFontSizeThemeComponentCommand()
{
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.AddThemeComponentCommand.Execute(ThemeComponentType.FontSize);
}
private void OnDeleteThemeComponentCommand() private void OnDeleteThemeComponentCommand()
{ {
_avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute( _avalonDockWorkspaceViewModel.ActiveThemeViewModel.DeleteThemeComponentCommand.Execute(

View File

@ -129,6 +129,7 @@
<fluent:Button SizeDefinition="Middle" Header="Add Text Color" Icon="{StaticResource AddIcon}" Command="{Binding AddTextColorThemeComponentCommand}" /> <fluent:Button SizeDefinition="Middle" Header="Add Text Color" Icon="{StaticResource AddIcon}" Command="{Binding AddTextColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Background Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBackgroundColorThemeComponentCommand}" /> <fluent:Button SizeDefinition="Middle" Header="Add Background Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBackgroundColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Border Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBorderColorThemeComponentCommand}" /> <fluent:Button SizeDefinition="Middle" Header="Add Border Color" Icon="{StaticResource AddIcon}" Command="{Binding AddBorderColorThemeComponentCommand}" />
<fluent:Button SizeDefinition="Middle" Header="Add Font Size" Icon="{StaticResource AddIcon}" Command="{Binding AddFontSizeThemeComponentCommand}" />
</fluent:RibbonGroupBox> </fluent:RibbonGroupBox>
<fluent:RibbonGroupBox Header="Delete"> <fluent:RibbonGroupBox Header="Delete">
<fluent:Button Header="Delete Theme Component" Icon="{StaticResource ThemeComponentDeleteIcon}" LargeIcon="{StaticResource ThemeComponentDeleteIcon}" Command="{Binding DeleteThemeComponentCommand}" /> <fluent:Button Header="Delete Theme Component" Icon="{StaticResource ThemeComponentDeleteIcon}" LargeIcon="{StaticResource ThemeComponentDeleteIcon}" Command="{Binding DeleteThemeComponentCommand}" />