Add requested changes

This commit is contained in:
azakhi 2018-08-30 19:56:47 +03:00
parent 8f0f73f185
commit c260014a16
1 changed files with 7 additions and 19 deletions

View File

@ -180,24 +180,16 @@ namespace Filtration.ViewModels
_scriptCommandManager = Script.CommandManager; _scriptCommandManager = Script.CommandManager;
AddItemFilterBlockViewModels(Script.ItemFilterBlocks, -1); AddItemFilterBlockViewModels(Script.ItemFilterBlocks, -1);
foreach(var block in Script.ItemFilterBlocks) foreach(var block in Script.ItemFilterBlocks.OfType<IItemFilterBlock>())
{ {
var itemBlock = block as IItemFilterBlock; foreach (var customSoundBlockItem in block.BlockItems.OfType<CustomSoundBlockItem>())
if(itemBlock != null)
{ {
foreach(var blockItem in itemBlock.BlockItems) if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && CustomSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0)
{
var customSoundBlockItem = blockItem as CustomSoundBlockItem;
if (customSoundBlockItem != null)
{
if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && _customSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0)
{ {
CustomSoundsAvailable.Add(customSoundBlockItem.Value); CustomSoundsAvailable.Add(customSoundBlockItem.Value);
} }
} }
} }
}
}
Script.ItemFilterBlocks.CollectionChanged += ItemFilterBlocksOnCollectionChanged; Script.ItemFilterBlocks.CollectionChanged += ItemFilterBlocksOnCollectionChanged;
_customSoundsAvailable.CollectionChanged += CustomSoundsAvailableOnCollectionChanged; _customSoundsAvailable.CollectionChanged += CustomSoundsAvailableOnCollectionChanged;
@ -273,12 +265,9 @@ namespace Filtration.ViewModels
var itemBlock = itemFilterBlock as IItemFilterBlock; var itemBlock = itemFilterBlock as IItemFilterBlock;
if (itemBlock != null) if (itemBlock != null)
{ {
foreach (var blockItem in itemBlock.BlockItems) foreach (var customSoundBlockItem in itemBlock.BlockItems.OfType<CustomSoundBlockItem>())
{ {
var customSoundBlockItem = blockItem as CustomSoundBlockItem; if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && CustomSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0)
if (customSoundBlockItem != null)
{
if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && _customSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0)
{ {
CustomSoundsAvailable.Add(customSoundBlockItem.Value); CustomSoundsAvailable.Add(customSoundBlockItem.Value);
} }
@ -286,7 +275,6 @@ namespace Filtration.ViewModels
} }
} }
} }
}
private void RemoveItemFilterBlockviewModels(IEnumerable<IItemFilterBlockBase> itemFilterBlocks) private void RemoveItemFilterBlockviewModels(IEnumerable<IItemFilterBlockBase> itemFilterBlocks)
{ {