コード例 #1
0
        public void ApplyThemeToScript_SingleBlockDifferentComponentName_DoesNotReplaceColour()
        {
            // Arrange

            var testInputBlockItem = new TextColorBlockItem();
            var testInputBlock     = new ItemFilterBlock();

            testInputBlock.BlockItems.Add(testInputBlockItem);
            var testInputScript = new ItemFilterScript();

            testInputScript.ItemFilterBlocks.Add(testInputBlock);

            var testInputTheme = new Theme();
            var testInputThemeComponentColor = new Color {
                R = 255, G = 0, B = 1
            };
            var testInputThemeComponent          = new ThemeComponent(ThemeComponentType.TextColor, "Test Component 1", testInputThemeComponentColor);
            var testInputBlockItemThemeComponent = new ThemeComponent(ThemeComponentType.TextColor, "Different Component", testInputThemeComponentColor);

            testInputTheme.Components.Add(testInputThemeComponent);
            testInputBlockItem.ThemeComponent = testInputBlockItemThemeComponent;

            var mockMessageBoxService = new Mock <IMessageBoxService>();

            var service = new ThemeService(mockMessageBoxService.Object);

            // Act
            service.ApplyThemeToScript(testInputTheme, testInputScript);

            // Assert
            Assert.AreNotEqual(testInputThemeComponentColor, testInputBlockItem.Color);
        }
コード例 #2
0
        private static void AddStringListItemToBlockItems <T>(ItemFilterBlock block, string inputString) where T : StringListBlockItem
        {
            var blockItem = Activator.CreateInstance <T>();

            PopulateListFromString(blockItem.Items, inputString.Substring(inputString.IndexOf(" ", StringComparison.Ordinal) + 1).Trim());
            block.BlockItems.Add(blockItem);
        }
コード例 #3
0
        public void TranslateItemFilterScriptToString_ExtraLineBetweenBlocksSettingFalse_ReturnsCorrectOutput()
        {
            Settings.Default.ExtraLineBetweenBlocks = false;

            var script = new ItemFilterScript();
            var block1 = new ItemFilterBlock { Description = "Test Filter 1" };
            block1.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.GreaterThan, 5));

            var block2 = new ItemFilterBlock();
            block2.BlockItems.Add(new QualityBlockItem(FilterPredicateOperator.LessThan, 15));
            block2.BlockItems.Add(new FontSizeBlockItem(7));
            block2.BlockItems.Add(new WidthBlockItem(FilterPredicateOperator.Equal, 3));

            script.ItemFilterBlocks.Add(block1);
            script.ItemFilterBlocks.Add(block2);

            var expectedOutput = "# Script edited with Filtration - https://github.com/ben-wallis/Filtration" + Environment.NewLine +
                                 "# Test Filter 1" + Environment.NewLine +
                                 "Show" + Environment.NewLine +
                                 "    ItemLevel > 5" + Environment.NewLine +
                                 "Show" + Environment.NewLine +
                                 "    Quality < 15" + Environment.NewLine +
                                 "    Width = 3" + Environment.NewLine +
                                 "    SetFontSize 7" + Environment.NewLine;

            var blockTranslator = new ItemFilterBlockTranslator(_testUtility.MockBlockGroupHierarchyBuilder.Object);
            var translator = new ItemFilterScriptTranslator(blockTranslator,
                _testUtility.MockBlockGroupHierarchyBuilder.Object);

            // Act
            var result = translator.TranslateItemFilterScriptToString(script);

            // Assert
            Assert.AreEqual(expectedOutput, result);
        }
コード例 #4
0
        public void ReplaceColors_ReplacesBackgroundColorsCorrectly()
        {
            // Arrange
            var oldColor = new Color {A = 255, R = 255, G = 0, B = 0};
            var newColor = new Color {A = 255, R = 0, G = 255, B = 100};

            var testInputReplaceColors = new ReplaceColorsParameterSet
            {
                OldBackgroundColor = oldColor,
                NewBackgroundColor = newColor,
                ReplaceBackgroundColor = true
            };

            var testInputBlock1 = new ItemFilterBlock();
            testInputBlock1.BlockItems.Add(new BackgroundColorBlockItem(new Color {A = 255, R = 255, G = 0, B = 0}));
            var testInputBlock2 = new ItemFilterBlock();
            testInputBlock2.BlockItems.Add(new BackgroundColorBlockItem(new Color { A = 255, R = 255, G = 1, B = 0 }));
            var testInputBlock3 = new ItemFilterBlock();
            testInputBlock3.BlockItems.Add(new BackgroundColorBlockItem(new Color { A = 255, R = 255, G = 0, B = 0 }));

            var script = new ItemFilterScript();

            script.ItemFilterBlocks.Add(testInputBlock1);
            script.ItemFilterBlocks.Add(testInputBlock2);
            script.ItemFilterBlocks.Add(testInputBlock3);

            // Act
            script.ReplaceColors(testInputReplaceColors);

            // Assert
            Assert.AreEqual(newColor, testInputBlock1.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
            Assert.AreNotEqual(newColor, testInputBlock2.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
            Assert.AreEqual(newColor, testInputBlock3.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
        }
コード例 #5
0
        private static void AddNumericFilterPredicateItemToBlockItems <T>(ItemFilterBlock block, string inputString) where T : NumericFilterPredicateBlockItem
        {
            var blockItem = Activator.CreateInstance <T>();

            SetNumericFilterPredicateFromString(blockItem.FilterPredicate, inputString);
            block.BlockItems.Add(blockItem);
        }
コード例 #6
0
        private static void RemoveExistingBlockItemsOfType <T>(ItemFilterBlock block)
        {
            var existingBlockItemCount = block.BlockItems.Count(b => b.GetType() == typeof(T));

            if (existingBlockItemCount > 0)
            {
                var existingBlockItem = block.BlockItems.First(b => b.GetType() == typeof(T));
                block.BlockItems.Remove(existingBlockItem);
            }
        }
コード例 #7
0
        public void ItemFilterBlock_AddBlockItemAllowed_LessThanMaximum_ReturnsTrue()
        {
            // Arrange
            var block = new ItemFilterBlock();
            block.BlockItems.Add(new ItemLevelBlockItem());

            // Act
            bool result = block.AddBlockItemAllowed(typeof (ItemLevelBlockItem));

            // Assert
            Assert.IsTrue(result);
        }
コード例 #8
0
        public void ItemFilterBlock_AddBlockItemAllowed_MoreThanMaximum_ReturnsFalse()
        {
            // Arrange
            var block = new ItemFilterBlock();
            block.BlockItems.Add(new SoundBlockItem());

            // Act
            bool result = block.AddBlockItemAllowed(typeof (SoundBlockItem));

            // Assert
            Assert.IsFalse(result);
        }
コード例 #9
0
        public void ItemFilterBlock_BlockCount_ReturnsCorrectNumber()
        {
            // Arrange
            var block = new ItemFilterBlock();
            block.BlockItems.Add(new ItemLevelBlockItem());
            block.BlockItems.Add(new ItemLevelBlockItem());
            block.BlockItems.Add(new ItemLevelBlockItem());
            block.BlockItems.Add(new ItemLevelBlockItem());

            // Act
            var count = block.BlockCount(typeof (ItemLevelBlockItem));

            // Assert
            Assert.AreEqual(4, count);
        }
コード例 #10
0
        public void HasParentInBlockGroupHierarchy_ReturnsCorrectResult()
        {
            // Arrange
            var testInputRootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null);
            var testInputSubBlockGroup = new ItemFilterBlockGroup("Sub Block Group", testInputRootBlockGroup);
            var testInputSubSubBlockGroup = new ItemFilterBlockGroup("Sub Sub Block Group", testInputSubBlockGroup);

            var block = new ItemFilterBlock {BlockGroup = testInputSubSubBlockGroup};

            // Act

            // Assert
            Assert.AreEqual(true, block.HasBlockGroupInParentHierarchy(testInputRootBlockGroup, block.BlockGroup));
            Assert.AreEqual(true, block.HasBlockGroupInParentHierarchy(testInputSubBlockGroup, block.BlockGroup));
        }
コード例 #11
0
        public void ReplaceColors_OnlyReplacesColorsWhenAllSetParametersMatched()
        {
            // Arrange
            var oldBackgroundColor = new Color { A = 255, R = 255, G = 0, B = 0 };
            var newBackgroundColor = new Color { A = 255, R = 0, G = 255, B = 100 };

            var oldTextColor = new Color { A = 255, R = 100, G = 0, B = 50 };
            var newTextColor = new Color { A = 255, R = 101, G = 255, B = 51 };

            var testInputReplaceColors = new ReplaceColorsParameterSet
            {
                OldBackgroundColor = oldBackgroundColor,
                NewBackgroundColor = newBackgroundColor,
                OldTextColor = oldTextColor,
                NewTextColor = newTextColor,
                ReplaceBackgroundColor = true,
                ReplaceTextColor = true
            };

            var testInputBlock1 = new ItemFilterBlock();
            testInputBlock1.BlockItems.Add(new BackgroundColorBlockItem(oldBackgroundColor));
            testInputBlock1.BlockItems.Add(new TextColorBlockItem(oldTextColor));
            var testInputBlock2 = new ItemFilterBlock();
            testInputBlock2.BlockItems.Add(new BackgroundColorBlockItem(oldBackgroundColor));
            testInputBlock2.BlockItems.Add(new TextColorBlockItem(new Color {A = 1, R = 2, G = 3, B = 4}));

            var script = new ItemFilterScript();
            script.ItemFilterBlocks.Add(testInputBlock1);
            script.ItemFilterBlocks.Add(testInputBlock2);

            // Act
            script.ReplaceColors(testInputReplaceColors);

            // Assert
            // First test block has had its colors changed
            Assert.AreEqual(newBackgroundColor, testInputBlock1.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
            Assert.AreEqual(newTextColor, testInputBlock1.BlockItems.OfType<TextColorBlockItem>().First().Color);

            // Second test block has not had its colors changed
            Assert.AreEqual(oldBackgroundColor, testInputBlock2.BlockItems.OfType<BackgroundColorBlockItem>().First().Color);
            Assert.AreNotEqual(newTextColor, testInputBlock2.BlockItems.OfType<TextColorBlockItem>().First().Color);
        }
コード例 #12
0
        private bool BlockIsColorReplacementCandidate(ReplaceColorsParameterSet replaceColorsParameterSet, ItemFilterBlock block)
        {
            var textColorItem = block.HasBlockItemOfType<TextColorBlockItem>()
                ? block.BlockItems.OfType<TextColorBlockItem>().First()
                : null;
            var backgroundColorItem = block.HasBlockItemOfType<BackgroundColorBlockItem>()
                ? block.BlockItems.OfType<BackgroundColorBlockItem>().First()
                : null;
            var borderColorItem = block.HasBlockItemOfType<BorderColorBlockItem>()
                ? block.BlockItems.OfType<BorderColorBlockItem>().First()
                : null;

            // If we don't have all of the things we want to replace, then we aren't a candidate for replacing those things.
            if ((textColorItem == null && replaceColorsParameterSet.ReplaceTextColor) ||
                (backgroundColorItem == null && replaceColorsParameterSet.ReplaceBackgroundColor) ||
                (borderColorItem == null && replaceColorsParameterSet.ReplaceBorderColor))
            {
                return false;
            }

            if ((replaceColorsParameterSet.ReplaceTextColor &&
                 textColorItem.Color != replaceColorsParameterSet.OldTextColor) ||
                (replaceColorsParameterSet.ReplaceBackgroundColor &&
                 backgroundColorItem.Color != replaceColorsParameterSet.OldBackgroundColor) ||
                (replaceColorsParameterSet.ReplaceBorderColor &&
                 borderColorItem.Color != replaceColorsParameterSet.OldBorderColor))
            {
                return false;
            }

            return true;
        }
コード例 #13
0
 private void AddColorItemToBlockItems <T>(ItemFilterBlock block, string inputString) where T : ColorBlockItem
 {
     block.BlockItems.Add(GetColorBlockItemFromString <T>(inputString));
 }
コード例 #14
0
        public void Initialise(ItemFilterBlock itemFilterBlock, ItemFilterScriptViewModel parentScriptViewModel)
        {
            if (itemFilterBlock == null || parentScriptViewModel == null)
            {
                throw new ArgumentNullException("itemFilterBlock");
            }

            _parentScriptViewModel = parentScriptViewModel;

            Block = itemFilterBlock;
            itemFilterBlock.BlockItems.CollectionChanged += OnBlockItemsCollectionChanged;

            foreach (var blockItem in itemFilterBlock.BlockItems.OfType<IAudioVisualBlockItem>())
            {
                blockItem.PropertyChanged += OnAudioVisualBlockItemChanged;
            }
        }
コード例 #15
0
        public void ItemBlockMatch_MultipleBlockItems_Matches_ReturnsTrue()
        {
            //Arrange
            var testInputItem = Mock.Of<IItem>(i => i.BaseType == "Base Type 1" && i.Height == 4 && i.Width == 2);
            var testInputBlock = new ItemFilterBlock();
            var baseTypeBlockItem = new BaseTypeBlockItem();
            baseTypeBlockItem.Items.Add("Base Type 1");
            var heightBlockItem = new HeightBlockItem(FilterPredicateOperator.Equal, 4);
            var widthBlockItem = new WidthBlockItem(FilterPredicateOperator.Equal, 2);

            testInputBlock.BlockItems.Add(baseTypeBlockItem);
            testInputBlock.BlockItems.Add(heightBlockItem);
            testInputBlock.BlockItems.Add(widthBlockItem);

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);

            //Assert
            Assert.IsTrue(result);
        }
コード例 #16
0
        public void ItemBlockMatch_EmptyShowBlock_ReturnsTrue()
        {
            //Arrange
            var testInputItem = Mock.Of<IItem>();
            var testInputBlock = new ItemFilterBlock();

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);

            //Assert
            Assert.IsTrue(result);
        }
コード例 #17
0
            public ItemFilterBlockTranslatorTestUtility()
            {
                // Test Data
                TestBlock = new ItemFilterBlock();

                // Mock setups
                MockBlockGroupHierarchyBuilder = new Mock<IBlockGroupHierarchyBuilder>();

                // Class under test instantiation
                Translator = new ItemFilterBlockTranslator(MockBlockGroupHierarchyBuilder.Object);
            }
コード例 #18
0
        public void Initialise(ItemFilterScript itemFilterScript, ItemFilterBlock initialiseFromBlock)
        {
            _replaceColorsParameterSet = new ReplaceColorsParameterSet();

            if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof (TextColorBlockItem)) > 0)
            {
                _replaceColorsParameterSet.ReplaceTextColor = true;
                var existingBlockColor = ((TextColorBlockItem)
                        initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof (TextColorBlockItem))).Color;
                _replaceColorsParameterSet.OldTextColor = existingBlockColor;
                _replaceColorsParameterSet.NewTextColor = existingBlockColor;
            }

            if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BackgroundColorBlockItem)) > 0)
            {
                _replaceColorsParameterSet.ReplaceBackgroundColor = true;
                var existingBlockColor = ((BackgroundColorBlockItem)
                        initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BackgroundColorBlockItem))).Color;
                _replaceColorsParameterSet.OldBackgroundColor = existingBlockColor;
                _replaceColorsParameterSet.NewBackgroundColor = existingBlockColor;
            }

            if (initialiseFromBlock.BlockItems.Count(b => b.GetType() == typeof(BorderColorBlockItem)) > 0)
            {
                _replaceColorsParameterSet.ReplaceBorderColor = true;
                var existingBlockColor = ((BorderColorBlockItem)
                        initialiseFromBlock.BlockItems.First(b => b.GetType() == typeof(BorderColorBlockItem))).Color;
                _replaceColorsParameterSet.OldBorderColor = existingBlockColor;
                _replaceColorsParameterSet.NewBorderColor = existingBlockColor;
            }

            _itemFilterScript = itemFilterScript;
        }
コード例 #19
0
        public void ItemBlockMatch_SingleBlockItem_DoesNotMatche_ReturnsFalse()
        {
            //Arrange
            var testInputItem = Mock.Of<IItem>(i => i.BaseType == "Base Type 1");
            var testInputBlock = new ItemFilterBlock();
            var baseTypeBlockItem = new BaseTypeBlockItem();
            baseTypeBlockItem.Items.Add("Base Type 2");
            testInputBlock.BlockItems.Add(baseTypeBlockItem);

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);

            //Assert
            Assert.IsFalse(result);
        }
コード例 #20
0
        public void TranslateItemFilterScriptToString_OneBlock_CallsTranslator()
        {
            // Arrange
            var testScript = new ItemFilterScript();

            var testBlock = new ItemFilterBlock();
            testBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.Equal, 5));

            const string blockOutput = "Test Script Output";

            testScript.ItemFilterBlocks.Add(testBlock);

            _testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateItemFilterBlockToString(testBlock)).Returns(blockOutput).Verifiable();

            // Act
            _testUtility.ScriptTranslator.TranslateItemFilterScriptToString(testScript);

            // Assert
            _testUtility.MockItemFilterBlockTranslator.Verify();
        }
コード例 #21
0
        public void ItemBlockMatch_SingleBlockItem_Matches_ReturnsTrue()
        {
            //Arrange
            var testBaseType = "Test Base Type";
            var testInputItem = Mock.Of<IItem>(i => i.BaseType == testBaseType);
            var testInputBlock = new ItemFilterBlock();
            var baseTypeBlockItem = new BaseTypeBlockItem();
            baseTypeBlockItem.Items.Add(testBaseType);
            testInputBlock.BlockItems.Add(baseTypeBlockItem);

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);

            //Assert
            Assert.IsTrue(result);
        }
コード例 #22
0
        public void AddBlock(IItemFilterBlockViewModel targetBlockViewModel)
        {
            var vm = _itemFilterBlockViewModelFactory.Create();
            var newBlock = new ItemFilterBlock();
            vm.Initialise(newBlock, this);

            if (targetBlockViewModel != null)
            {
                Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, newBlock);
                ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm);
            }
            else
            {
                Script.ItemFilterBlocks.Add(newBlock);
                ItemFilterBlockViewModels.Add(vm);
            }

            SelectedBlockViewModel = vm;
            vm.IsExpanded = true;
            IsDirty = true;
        }
コード例 #23
0
        // This method converts a string into a ItemFilterBlock. This is used for pasting ItemFilterBlocks
        // and reading ItemFilterScripts from a file.
        public IItemFilterBlock TranslateStringToItemFilterBlock(string inputString, IItemFilterScript parentItemFilterScript, bool initialiseBlockGroupHierarchyBuilder = false)
        {
            if (initialiseBlockGroupHierarchyBuilder)
            {
                _blockGroupHierarchyBuilder.Initialise(parentItemFilterScript.ItemFilterBlockGroups.First());
            }

            _masterComponentCollection = parentItemFilterScript.ItemFilterScriptSettings.ThemeComponentCollection;
            var block         = new ItemFilterBlock(parentItemFilterScript);
            var showHideFound = false;

            foreach (var line in new LineReader(() => new StringReader(inputString)))
            {
                if (line.StartsWith(@"#") && !showHideFound)
                {
                    block.Description = line.TrimStart('#').TrimStart(' ');
                    continue;
                }

                var trimmedLine         = line.Trim();
                var spaceOrEndOfLinePos = trimmedLine.IndexOf(" ", StringComparison.Ordinal) > 0 ? trimmedLine.IndexOf(" ", StringComparison.Ordinal) : trimmedLine.Length;

                var lineOption = trimmedLine.Substring(0, spaceOrEndOfLinePos);
                switch (lineOption)
                {
                case "Show":
                case "Hide":
                case "ShowDisabled":
                case "HideDisabled":
                {
                    showHideFound = true;
                    block.Action  = lineOption.StartsWith("Show") ? BlockAction.Show : BlockAction.Hide;
                    block.Enabled = !lineOption.EndsWith("Disabled");

                    // If block groups are enabled for this script, the comment after Show/Hide is parsed as a block
                    // group hierarchy, if block groups are disabled it is preserved as a simple text comment.
                    if (parentItemFilterScript.ItemFilterScriptSettings.BlockGroupsEnabled)
                    {
                        AddBlockGroupToBlock(block, trimmedLine);
                    }
                    else
                    {
                        block.ActionBlockItem.Comment = GetTextAfterFirstComment(trimmedLine);
                    }
                    break;
                }

                case "ItemLevel":
                {
                    AddNumericFilterPredicateItemToBlockItems <ItemLevelBlockItem>(block, trimmedLine);
                    break;
                }

                case "DropLevel":
                {
                    AddNumericFilterPredicateItemToBlockItems <DropLevelBlockItem>(block, trimmedLine);
                    break;
                }

                case "Quality":
                {
                    AddNumericFilterPredicateItemToBlockItems <QualityBlockItem>(block, trimmedLine);
                    break;
                }

                case "Rarity":
                {
                    RemoveExistingBlockItemsOfType <RarityBlockItem>(block);

                    var blockItemValue = new RarityBlockItem();
                    var result         = Regex.Match(trimmedLine, @"^\w+\s+([><!=]{0,2})\s*(\w+)$");
                    if (result.Groups.Count == 3)
                    {
                        blockItemValue.FilterPredicate.PredicateOperator =
                            EnumHelper.GetEnumValueFromDescription <FilterPredicateOperator>(string.IsNullOrEmpty(result.Groups[1].Value) ? "=" : result.Groups[1].Value);
                        blockItemValue.FilterPredicate.PredicateOperand =
                            (int)EnumHelper.GetEnumValueFromDescription <ItemRarity>(result.Groups[2].Value);
                    }

                    block.BlockItems.Add(blockItemValue);
                    break;
                }

                case "Class":
                {
                    AddStringListItemToBlockItems <ClassBlockItem>(block, trimmedLine);
                    break;
                }

                case "BaseType":
                {
                    AddStringListItemToBlockItems <BaseTypeBlockItem>(block, trimmedLine);
                    break;
                }

                case "Corrupted":
                {
                    AddBooleanItemToBlockItems <CorruptedBlockItem>(block, trimmedLine);
                    break;
                }

                case "Identified":
                {
                    AddBooleanItemToBlockItems <IdentifiedBlockItem>(block, trimmedLine);
                    break;
                }

                case "ElderItem":
                {
                    AddBooleanItemToBlockItems <ElderItemBlockItem>(block, trimmedLine);
                    break;
                }

                case "ShaperItem":
                {
                    AddBooleanItemToBlockItems <ShaperItemBlockItem>(block, trimmedLine);
                    break;
                }

                case "ShapedMap":
                {
                    AddBooleanItemToBlockItems <ShapedMapBlockItem>(block, trimmedLine);
                    break;
                }

                case "Sockets":
                {
                    AddNumericFilterPredicateItemToBlockItems <SocketsBlockItem>(block, trimmedLine);
                    break;
                }

                case "LinkedSockets":
                {
                    AddNumericFilterPredicateItemToBlockItems <LinkedSocketsBlockItem>(block, trimmedLine);
                    break;
                }

                case "Width":
                {
                    AddNumericFilterPredicateItemToBlockItems <WidthBlockItem>(block, trimmedLine);
                    break;
                }

                case "Height":
                {
                    AddNumericFilterPredicateItemToBlockItems <HeightBlockItem>(block, trimmedLine);
                    break;
                }

                case "SocketGroup":
                {
                    AddStringListItemToBlockItems <SocketGroupBlockItem>(block, trimmedLine);
                    break;
                }

                case "SetTextColor":
                {
                    // Only ever use the last SetTextColor item encountered as multiples aren't valid.
                    RemoveExistingBlockItemsOfType <TextColorBlockItem>(block);

                    AddColorItemToBlockItems <TextColorBlockItem>(block, trimmedLine);
                    break;
                }

                case "SetBackgroundColor":
                {
                    // Only ever use the last SetBackgroundColor item encountered as multiples aren't valid.
                    RemoveExistingBlockItemsOfType <BackgroundColorBlockItem>(block);

                    AddColorItemToBlockItems <BackgroundColorBlockItem>(block, trimmedLine);
                    break;
                }

                case "SetBorderColor":
                {
                    // Only ever use the last SetBorderColor item encountered as multiples aren't valid.
                    RemoveExistingBlockItemsOfType <BorderColorBlockItem>(block);

                    AddColorItemToBlockItems <BorderColorBlockItem>(block, trimmedLine);
                    break;
                }

                case "SetFontSize":
                {
                    // Only ever use the last SetFontSize item encountered as multiples aren't valid.
                    RemoveExistingBlockItemsOfType <FontSizeBlockItem>(block);

                    var match = Regex.Match(trimmedLine, @"\s+(\d+)");
                    if (match.Success)
                    {
                        var blockItemValue = new FontSizeBlockItem(Convert.ToInt16(match.Value));
                        block.BlockItems.Add(blockItemValue);
                    }
                    break;
                }

                case "PlayAlertSound":
                case "PlayAlertSoundPositional":
                {
                    // Only ever use the last PlayAlertSound item encountered as multiples aren't valid.
                    RemoveExistingBlockItemsOfType <SoundBlockItem>(block);
                    RemoveExistingBlockItemsOfType <PositionalSoundBlockItem>(block);

                    var match = Regex.Match(trimmedLine, @"\S+\s+(\S+)\s?(\d+)?");

                    if (match.Success)
                    {
                        string firstValue = match.Groups[1].Value;
                        int    secondValue;

                        if (match.Groups[2].Success)
                        {
                            secondValue = Convert.ToInt16(match.Groups[2].Value);
                        }
                        else
                        {
                            secondValue = 79;
                        }

                        if (lineOption == "PlayAlertSound")
                        {
                            var blockItemValue = new SoundBlockItem
                            {
                                Value       = firstValue,
                                SecondValue = secondValue
                            };
                            block.BlockItems.Add(blockItemValue);
                        }
                        else
                        {
                            var blockItemValue = new PositionalSoundBlockItem
                            {
                                Value       = firstValue,
                                SecondValue = secondValue
                            };
                            block.BlockItems.Add(blockItemValue);
                        }
                    }
                    break;
                }
                }
            }

            return(block);
        }