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

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

View File

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

View File

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

View File

@@ -42,6 +42,9 @@ namespace Filtration.ThemeEditor.Services
case ThemeComponentType.BorderColor:
mismatchedComponents = ApplyColorTheme(blocks, typeof(BorderColorBlockItem), component);
break;
case ThemeComponentType.FontSize:
mismatchedComponents = ApplyIntegerTheme(blocks, typeof(FontSizeBlockItem), component);
break;
}
}
@@ -72,5 +75,25 @@ namespace Filtration.ThemeEditor.Services
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 Filtration.ObjectModel.Enums;
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",
new Color { A = 255, R = 255, G = 255, B = 255 }));
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}">
<xctk:ColorPicker SelectedColor="{Binding Color}" />
</DataTemplate>
<!-- Integer Theme Template -->
<DataTemplate DataType="{x:Type themeEditor:IntegerThemeComponent}">
<xctk:ShortUpDown Value="{Binding Value}" />
</DataTemplate>
</ContentControl.Resources>
</ContentControl>
</Grid>