Add alert sound theme support

This commit is contained in:
azakhi
2018-08-26 20:24:13 +03:00
parent bc5a005ee7
commit d92d34af05
22 changed files with 262 additions and 53 deletions

View File

@@ -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;
}
}
}