Add alert sound theme support
This commit is contained in:
@@ -35,6 +35,10 @@ namespace Filtration.ThemeEditor.Converters
|
||||
{
|
||||
return "Font Size Theme Components";
|
||||
}
|
||||
case "Alert Sound":
|
||||
{
|
||||
return "Alert Sound Theme Components";
|
||||
}
|
||||
}
|
||||
|
||||
return type.GetAttributeDescription();
|
||||
|
||||
@@ -109,6 +109,7 @@
|
||||
<Compile Include="Services\ThemePersistenceService.cs" />
|
||||
<Compile Include="Services\ThemeService.cs" />
|
||||
<Compile Include="ViewModels\ColorThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\StrIntThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\IntegerThemeComponentViewModel.cs" />
|
||||
<Compile Include="ViewModels\IThemeViewModelFactory.cs" />
|
||||
<Compile Include="ViewModels\ThemeComponentViewModel.cs" />
|
||||
|
||||
@@ -45,6 +45,9 @@ namespace Filtration.ThemeEditor.Providers
|
||||
case ThemeComponentType.FontSize:
|
||||
c.Add(new IntegerThemeComponent(component.ComponentType, component.ComponentName, ((IntegerThemeComponent)component).Value));
|
||||
break;
|
||||
case ThemeComponentType.AlertSound:
|
||||
c.Add(new StrIntThemeComponent(component.ComponentType, component.ComponentName, ((StrIntThemeComponent)component).Value, ((StrIntThemeComponent)component).SecondValue));
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
});
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace Filtration.ThemeEditor.Services
|
||||
case ThemeComponentType.FontSize:
|
||||
mismatchedComponents = ApplyIntegerTheme(blocks, typeof(FontSizeBlockItem), component);
|
||||
break;
|
||||
case ThemeComponentType.AlertSound:
|
||||
mismatchedComponents = ApplyStrIntTheme(blocks, typeof(SoundBlockItem), component);
|
||||
mismatchedComponents = ApplyStrIntTheme(blocks, typeof(PositionalSoundBlockItem), component);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,5 +99,26 @@ namespace Filtration.ThemeEditor.Services
|
||||
|
||||
return !componentMatched;
|
||||
}
|
||||
|
||||
private bool ApplyStrIntTheme(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 = (StrIntBlockItem)blockItem;
|
||||
if (colorBlockItem.ThemeComponent != null &&
|
||||
colorBlockItem.ThemeComponent.ComponentName == component.ComponentName)
|
||||
{
|
||||
colorBlockItem.Value = ((StrIntThemeComponent)component).Value;
|
||||
colorBlockItem.SecondValue = ((StrIntThemeComponent)component).SecondValue;
|
||||
componentMatched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !componentMatched;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Filtration.ThemeEditor.ViewModels
|
||||
{
|
||||
public class StrIntThemeComponentViewModel : ThemeComponentViewModel
|
||||
{
|
||||
public int Value { get; set; }
|
||||
public int SecondValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -205,6 +205,9 @@ namespace Filtration.ThemeEditor.ViewModels
|
||||
case ThemeComponentType.FontSize:
|
||||
Components.Add(new IntegerThemeComponent(themeComponentType, "Untitled Component", 35));
|
||||
break;
|
||||
case ThemeComponentType.AlertSound:
|
||||
Components.Add(new StrIntThemeComponent(themeComponentType, "Untitled Component", "1", 100));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,18 @@
|
||||
<DataTemplate DataType="{x:Type themeEditor:IntegerThemeComponent}">
|
||||
<xctk:ShortUpDown Value="{Binding Value}" />
|
||||
</DataTemplate>
|
||||
|
||||
<!-- String Integer Theme Template -->
|
||||
<DataTemplate DataType="{x:Type themeEditor:StrIntThemeComponent}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="0" Text="{Binding Value}" Height="25" Padding="2,-15,0,0" />
|
||||
<xctk:ShortUpDown Grid.Column="1" Value="{Binding SecondValue}" HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ContentControl.Resources>
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user