From ac904c31ff8d1ada46901a387af7ec6a1a4173a6 Mon Sep 17 00:00:00 2001 From: Ben Wallis Date: Fri, 28 Sep 2018 17:47:23 +0100 Subject: [PATCH] * Added default colours for TextColor, BorderColor and BackgroundColor block items (previously the default color was completely transparent) * Bumped version to 1.0.0-beta3 --- .../BackgroundColorBlockItem.cs | 1 + .../BlockItemTypes/BorderColorBlockItem.cs | 1 + .../BlockItemTypes/TextColorBlockItem.cs | 2 + Filtration/Properties/AssemblyInfo.cs | 2 +- .../ViewModels/ItemFilterBlockViewModel.cs | 69 ++++++++----------- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs index 21b31cf..18a022f 100644 --- a/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs @@ -7,6 +7,7 @@ namespace Filtration.ObjectModel.BlockItemTypes { public BackgroundColorBlockItem() { + Color = new Color { A = 240, R = 0, G = 0, B = 0 }; } public BackgroundColorBlockItem(Color color) : base(color) diff --git a/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs index 1b79136..f8fbb64 100644 --- a/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs @@ -7,6 +7,7 @@ namespace Filtration.ObjectModel.BlockItemTypes { public BorderColorBlockItem() { + Color = new Color {A = 240, R = 0, G = 0, B = 0}; } public BorderColorBlockItem(Color color) : base(color) diff --git a/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs index 41161f8..e763371 100644 --- a/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs @@ -1,5 +1,6 @@ using System.Windows.Media; using Filtration.ObjectModel.BlockItemBaseTypes; +using Filtration.ObjectModel.Enums; namespace Filtration.ObjectModel.BlockItemTypes { @@ -7,6 +8,7 @@ namespace Filtration.ObjectModel.BlockItemTypes { public TextColorBlockItem() { + Color = PathOfExileNamedColors.Colors[PathOfExileNamedColor.WhiteItem]; } public TextColorBlockItem(Color color) : base(color) diff --git a/Filtration/Properties/AssemblyInfo.cs b/Filtration/Properties/AssemblyInfo.cs index 2dfb3b9..a368073 100644 --- a/Filtration/Properties/AssemblyInfo.cs +++ b/Filtration/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ using System.Runtime.CompilerServices; [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyInformationalVersion("1.0.0-beta2")] +[assembly: AssemblyInformationalVersion("1.0.0-beta3")] [assembly: InternalsVisibleTo("Filtration.Tests")] [assembly: InternalsVisibleTo("Filtration.ItemFilterPreview.Tests")] diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index 211f6d1..586983b 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -15,6 +15,7 @@ using GalaSoft.MvvmLight.CommandWpf; using GalaSoft.MvvmLight.Messaging; using Microsoft.Win32; using Xceed.Wpf.Toolkit; +using static System.Int32; namespace Filtration.ViewModels { @@ -59,8 +60,7 @@ namespace Filtration.ViewModels public override void Initialise(IItemFilterBlockBase itemFilterBlockBase, IItemFilterScriptViewModel parentScriptViewModel) { - var itemFilterBlock = itemFilterBlockBase as IItemFilterBlock; - if (itemFilterBlock == null || parentScriptViewModel == null) + if (!(itemFilterBlockBase is IItemFilterBlock itemFilterBlock) || parentScriptViewModel == null) { throw new ArgumentNullException(nameof(itemFilterBlock)); } @@ -136,7 +136,7 @@ namespace Filtration.ViewModels public bool AudioVisualBlockItemsGridVisible { - get { return _audioVisualBlockItemsGridVisible; } + get => _audioVisualBlockItemsGridVisible; set { _audioVisualBlockItemsGridVisible = value; @@ -150,7 +150,7 @@ namespace Filtration.ViewModels public bool DisplaySettingsPopupOpen { - get { return _displaySettingsPopupOpen; } + get => _displaySettingsPopupOpen; set { _displaySettingsPopupOpen = value; @@ -205,7 +205,7 @@ namespace Filtration.ViewModels public bool BlockEnabled { - get { return Block.Enabled; } + get => Block.Enabled; set { if (Block.Enabled != value) @@ -219,10 +219,7 @@ namespace Filtration.ViewModels public string BlockDescription { - get - { - return Block.Description; - } + get => Block.Description; set { if (Block.Description != value) @@ -269,8 +266,7 @@ namespace Filtration.ViewModels newBlockItem.PropertyChanged += OnBlockItemChanged; - var customSoundBlockItem = newBlockItem as CustomSoundBlockItem; - if(customSoundBlockItem != null && _parentScriptViewModel.CustomSoundsAvailable.Count > 0) + if(newBlockItem is CustomSoundBlockItem customSoundBlockItem && _parentScriptViewModel.CustomSoundsAvailable.Count > 0) { customSoundBlockItem.Value = _parentScriptViewModel.CustomSoundsAvailable[0]; } @@ -364,16 +360,14 @@ namespace Filtration.ViewModels private string ComputeFilePartFromNumber(string identifier) { - if (Int32.TryParse(identifier, out int x)) + if (TryParse(identifier, out int x)) { if (x <= 9) { return "AlertSound_0" + x + ".mp3"; } - else - { - return "AlertSound_" + x + ".mp3"; - } + + return "AlertSound_" + x + ".mp3"; } return ""; @@ -431,11 +425,9 @@ namespace Filtration.ViewModels { return; } - else - { - _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); - _mediaPlayer.Play(); - } + + _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); + _mediaPlayer.Play(); } private void OnPlayPositionalSoundCommand() @@ -448,11 +440,9 @@ namespace Filtration.ViewModels { return; } - else - { - _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); - _mediaPlayer.Play(); - } + + _mediaPlayer.Open(new Uri(prefix + filePart, UriKind.Relative)); + _mediaPlayer.Play(); } private void OnBlockEnabledStatusChanged(object sender, EventArgs e) @@ -462,13 +452,12 @@ namespace Filtration.ViewModels private void OnBlockItemChanged(object sender, EventArgs e) { - var itemFilterBlockItem = sender as IItemFilterBlockItem; - if ( itemFilterBlockItem != null && itemFilterBlockItem.IsDirty) + if (sender is IItemFilterBlockItem itemFilterBlockItem && itemFilterBlockItem.IsDirty) { IsDirty = true; } - var customSoundBlockItem = sender as CustomSoundBlockItem; - if (customSoundBlockItem != null) + + if (sender is CustomSoundBlockItem customSoundBlockItem) { if (!string.IsNullOrWhiteSpace(customSoundBlockItem.Value) && _parentScriptViewModel.CustomSoundsAvailable.IndexOf(customSoundBlockItem.Value) < 0) { @@ -507,12 +496,11 @@ namespace Filtration.ViewModels private void OnCustomSoundFileDialog() { - OpenFileDialog fileDialog = new OpenFileDialog(); - fileDialog.DefaultExt = ".mp3"; - var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\"; + OpenFileDialog fileDialog = new OpenFileDialog {DefaultExt = ".mp3"}; + var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\My Games\Path of Exile\"; fileDialog.InitialDirectory = poePath; - Nullable result = fileDialog.ShowDialog(); + bool? result = fileDialog.ShowDialog(); if (result == true) { var fileName = fileDialog.FileName; @@ -533,7 +521,7 @@ namespace Filtration.ViewModels private void OnPlayCustomSoundCommand() { - var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\My Games\Path of Exile\"; + var poePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\My Games\Path of Exile\"; var identifier = BlockItems.OfType().First().Value; if(!Path.IsPathRooted(identifier)) @@ -569,9 +557,11 @@ namespace Filtration.ViewModels var newGroup = new ItemFilterBlockGroup(BlockGroupSearch, null, AdvancedBlockGroup, false); if (baseBlock.BlockGroup == null) { - baseBlock.BlockGroup = new ItemFilterBlockGroup("", null, false, true); - baseBlock.BlockGroup.IsShowChecked = baseBlock.Action == BlockAction.Show; - baseBlock.BlockGroup.IsEnableChecked = BlockEnabled; + baseBlock.BlockGroup = new ItemFilterBlockGroup("", null, false, true) + { + IsShowChecked = baseBlock.Action == BlockAction.Show, + IsEnableChecked = BlockEnabled + }; } newGroup.AddOrJoinBlockGroup(baseBlock.BlockGroup); blockToAdd.AddOrJoinBlockGroup(newGroup); @@ -611,8 +601,7 @@ namespace Filtration.ViewModels private void UpdateBlockGroups() { - var baseBlock = Block as ItemFilterBlock; - if (baseBlock == null) + if (!(Block is ItemFilterBlock baseBlock)) return; var currentGroup = baseBlock.BlockGroup;