diff --git a/Filtration.Common.Tests/Properties/AssemblyInfo.cs b/Filtration.Common.Tests/Properties/AssemblyInfo.cs index 8e54ffc..8853fbd 100644 --- a/Filtration.Common.Tests/Properties/AssemblyInfo.cs +++ b/Filtration.Common.Tests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Filtration.Common/Converters/ColorToSolidColorBrushConverter.cs b/Filtration.Common/Converters/ColorToSolidColorBrushConverter.cs index 36701e1..1fa9641 100644 --- a/Filtration.Common/Converters/ColorToSolidColorBrushConverter.cs +++ b/Filtration.Common/Converters/ColorToSolidColorBrushConverter.cs @@ -13,10 +13,7 @@ namespace Filtration.Common.Converters public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { - if (value != null) - return ((SolidColorBrush)value).Color; - - return null; + return ((SolidColorBrush) value)?.Color; } } } diff --git a/Filtration.Common/Messages/ThemeClosedMessage.cs b/Filtration.Common/Messages/ThemeClosedMessage.cs index c2cc66c..07e124a 100644 --- a/Filtration.Common/Messages/ThemeClosedMessage.cs +++ b/Filtration.Common/Messages/ThemeClosedMessage.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Filtration.Common.Messages +namespace Filtration.Common.Messages { class ThemeClosedMessage { diff --git a/Filtration.Interface/Properties/AssemblyInfo.cs b/Filtration.Interface/Properties/AssemblyInfo.cs index dbc479e..b2cd977 100644 --- a/Filtration.Interface/Properties/AssemblyInfo.cs +++ b/Filtration.Interface/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Filtration.ObjectModel.Tests/TestItemFilterBlockGroup.cs b/Filtration.ObjectModel.Tests/TestItemFilterBlockGroup.cs index b17eed5..e3f264b 100644 --- a/Filtration.ObjectModel.Tests/TestItemFilterBlockGroup.cs +++ b/Filtration.ObjectModel.Tests/TestItemFilterBlockGroup.cs @@ -9,7 +9,7 @@ namespace Filtration.ObjectModel.Tests public void ToString_ReturnsFullBlockHierarchy() { // Arrange - const string ExpectedResult = "Child 1 Block Group - Child 2 Block Group"; + const string expectedResult = "Child 1 Block Group - Child 2 Block Group"; var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null); var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup); @@ -19,14 +19,14 @@ namespace Filtration.ObjectModel.Tests var result = child2BlockGroup.ToString(); // Assert - Assert.AreEqual(ExpectedResult, result); + Assert.AreEqual(expectedResult, result); } [Test] public void ToString_AddsTildeForAdvancedBlock() { // Arrange - const string ExpectedResult = "~Child 1 Block Group - Child 2 Block Group"; + const string expectedResult = "~Child 1 Block Group - Child 2 Block Group"; var rootBlockGroup = new ItemFilterBlockGroup("Root Block Group", null); var child1BlockGroup = new ItemFilterBlockGroup("Child 1 Block Group", rootBlockGroup, true); @@ -36,7 +36,7 @@ namespace Filtration.ObjectModel.Tests var result = child2BlockGroup.ToString(); // Assert - Assert.AreEqual(ExpectedResult, result); + Assert.AreEqual(expectedResult, result); } } } diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/ActionBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/ActionBlockItem.cs index 8d7d5e1..fe56cc3 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/ActionBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/ActionBlockItem.cs @@ -26,54 +26,21 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes } } - public override string OutputText - { - get { return Action.GetAttributeDescription(); } - } + public override string OutputText => Action.GetAttributeDescription(); - public override string PrefixText - { - get { return string.Empty; } - } + public override string PrefixText => string.Empty; - public override int MaximumAllowed - { - get { return 1; } - } + public override int MaximumAllowed => 1; - public override string DisplayHeading - { - get - { - return "Action"; - } - } + public override string DisplayHeading => "Action"; - public override string SummaryText - { - get - { - return Action == BlockAction.Show ? "Show" : "Hide"; - } - } + public override string SummaryText => Action == BlockAction.Show ? "Show" : "Hide"; - public override Color SummaryBackgroundColor - { - get - { - return Action == BlockAction.Show ? Colors.LimeGreen : Colors.OrangeRed; - } - } + public override Color SummaryBackgroundColor => Action == BlockAction.Show ? Colors.LimeGreen : Colors.OrangeRed; - public override Color SummaryTextColor - { - get - { - return Action == BlockAction.Show ? Colors.Black : Colors.White; - } - } + public override Color SummaryTextColor => Action == BlockAction.Show ? Colors.Black : Colors.White; - public override int SortOrder { get { return 0; } } + public override int SortOrder => 0; public void ToggleAction() { diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/BlockItembase.cs b/Filtration.ObjectModel/BlockItemBaseTypes/BlockItembase.cs index 328e193..694b0d3 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/BlockItembase.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/BlockItembase.cs @@ -22,7 +22,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; - if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs index f0c39b5..2863064 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/ColorBlockItem.cs @@ -18,20 +18,11 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes Color = color; } - public override string OutputText - { - get - { - return PrefixText + " " + +Color.R + " " + Color.G + " " - + Color.B + (Color.A < 255 ? " " + Color.A : string.Empty) + - (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty); - } - } + public override string OutputText => PrefixText + " " + +Color.R + " " + Color.G + " " + + Color.B + (Color.A < 255 ? " " + Color.A : string.Empty) + + (ThemeComponent != null ? " # " + ThemeComponent.ComponentName : string.Empty); - public override string SummaryText - { - get { return string.Empty; } - } + public override string SummaryText => string.Empty; public ThemeComponent ThemeComponent { @@ -56,8 +47,8 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes } } - public override Color SummaryBackgroundColor { get { return Colors.Transparent; } } - public override Color SummaryTextColor { get { return Colors.Transparent; } } + public override Color SummaryBackgroundColor => Colors.Transparent; + public override Color SummaryTextColor => Colors.Transparent; public Color Color { diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/DualIntegerBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/DualIntegerBlockItem.cs index a91ce86..c73392b 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/DualIntegerBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/DualIntegerBlockItem.cs @@ -17,14 +17,11 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes SecondValue = secondValue; } - public override string OutputText - { - get { return PrefixText + " " + Value + " " + SecondValue; } - } - - public override string SummaryText { get { return string.Empty; } } - public override Color SummaryBackgroundColor { get { return Colors.Transparent; } } - public override Color SummaryTextColor { get { return Colors.Transparent; } } + public override string OutputText => PrefixText + " " + Value + " " + SecondValue; + + public override string SummaryText => string.Empty; + public override Color SummaryBackgroundColor => Colors.Transparent; + public override Color SummaryTextColor => Colors.Transparent; public int Value { diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/IntegerBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/IntegerBlockItem.cs index 262ad92..c0ad306 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/IntegerBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/IntegerBlockItem.cs @@ -15,14 +15,11 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes Value = value; } - public override string OutputText - { - get { return PrefixText + " " + Value; } - } + public override string OutputText => PrefixText + " " + Value; - public override string SummaryText { get { return string.Empty; } } - public override Color SummaryBackgroundColor { get { return Colors.Transparent; } } - public override Color SummaryTextColor { get { return Colors.Transparent; } } + public override string SummaryText => string.Empty; + public override Color SummaryBackgroundColor => Colors.Transparent; + public override Color SummaryTextColor => Colors.Transparent; public abstract int Minimum { get; } public abstract int Maximum { get; } diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/NumericFilterPredicateBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/NumericFilterPredicateBlockItem.cs index bbc32c4..592f03d 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/NumericFilterPredicateBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/NumericFilterPredicateBlockItem.cs @@ -20,14 +20,8 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes FilterPredicate.PropertyChanged += OnFilterPredicateChanged; } - public override string OutputText - { - get - { - return PrefixText + " " + FilterPredicate.PredicateOperator.GetAttributeDescription() + - " " + FilterPredicate.PredicateOperand; - } - } + public override string OutputText => PrefixText + " " + FilterPredicate.PredicateOperator.GetAttributeDescription() + + " " + FilterPredicate.PredicateOperand; public abstract int Minimum { get; } public abstract int Maximum { get; } diff --git a/Filtration.ObjectModel/BlockItemBaseTypes/StringListBlockItem.cs b/Filtration.ObjectModel/BlockItemBaseTypes/StringListBlockItem.cs index 0e95c5d..56c5f3e 100644 --- a/Filtration.ObjectModel/BlockItemBaseTypes/StringListBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemBaseTypes/StringListBlockItem.cs @@ -21,8 +21,7 @@ namespace Filtration.ObjectModel.BlockItemBaseTypes if (enumerable.Count > 0) { return PrefixText + " " + - string.Format("\"{0}\"", - string.Join("\" \"", enumerable.ToArray())); + $"\"{string.Join("\" \"", enumerable.ToArray())}\""; } return string.Empty; diff --git a/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs index cfb7e6f..992c617 100644 --- a/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/BackgroundColorBlockItem.cs @@ -13,27 +13,9 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "SetBackgroundColor"; } - } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading - { - get - { - return "Background Color"; - } - } - - public override int SortOrder - { - get { return 13; } - } + public override string PrefixText => "SetBackgroundColor"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Background Color"; + public override int SortOrder => 13; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/BaseTypeBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/BaseTypeBlockItem.cs index 2dd869f..e959210 100644 --- a/Filtration.ObjectModel/BlockItemTypes/BaseTypeBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/BaseTypeBlockItem.cs @@ -6,20 +6,9 @@ namespace Filtration.ObjectModel.BlockItemTypes { public class BaseTypeBlockItem : StringListBlockItem { - public override string PrefixText { get { return "BaseType"; } } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading - { - get - { - return "Base Type"; - } - } + public override string PrefixText => "BaseType"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Base Type"; public override string SummaryText { @@ -42,19 +31,8 @@ namespace Filtration.ObjectModel.BlockItemTypes } } - public override Color SummaryBackgroundColor - { - get { return Colors.MediumTurquoise; } - } - - public override Color SummaryTextColor - { - get { return Colors.Black; } - } - - public override int SortOrder - { - get { return 11; } - } + public override Color SummaryBackgroundColor => Colors.MediumTurquoise; + public override Color SummaryTextColor => Colors.Black; + public override int SortOrder => 11; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs index c989ba8..950a97f 100644 --- a/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/BorderColorBlockItem.cs @@ -13,27 +13,9 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "SetBorderColor"; } - } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading - { - get - { - return "Border Color"; - } - } - - public override int SortOrder - { - get { return 14; } - } + public override string PrefixText => "SetBorderColor"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Border Color"; + public override int SortOrder => 14; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/ClassBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/ClassBlockItem.cs index 9360ccb..8d9e45b 100644 --- a/Filtration.ObjectModel/BlockItemTypes/ClassBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/ClassBlockItem.cs @@ -6,14 +6,9 @@ namespace Filtration.ObjectModel.BlockItemTypes { public class ClassBlockItem : StringListBlockItem { - public override string PrefixText { get { return "Class"; } } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading { get { return "Class"; } } + public override string PrefixText => "Class"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Class"; public override string SummaryText { @@ -36,19 +31,8 @@ namespace Filtration.ObjectModel.BlockItemTypes } } - public override Color SummaryBackgroundColor - { - get { return Colors.MediumSeaGreen; } - } - - public override Color SummaryTextColor - { - get { return Colors.White; } - } - - public override int SortOrder - { - get { return 10; } - } + public override Color SummaryBackgroundColor => Colors.MediumSeaGreen; + public override Color SummaryTextColor => Colors.White; + public override int SortOrder => 10; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/DropLevelBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/DropLevelBlockItem.cs index a3abc6d..3374e7f 100644 --- a/Filtration.ObjectModel/BlockItemTypes/DropLevelBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/DropLevelBlockItem.cs @@ -15,58 +15,14 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "DropLevel"; } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get - { - return "Drop Level"; - } - } - - public override string SummaryText - { - get { return "Drop Level " + FilterPredicate; } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.DodgerBlue; } - } - - public override Color SummaryTextColor - { - get { return Colors.White; } - } - - public override int SortOrder - { - get { return 2; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return 100; - } - } + public override string PrefixText => "DropLevel"; + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Drop Level"; + public override string SummaryText => "Drop Level " + FilterPredicate; + public override Color SummaryBackgroundColor => Colors.DodgerBlue; + public override Color SummaryTextColor => Colors.White; + public override int SortOrder => 2; + public override int Minimum => 0; + public override int Maximum => 100; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/FontSizeBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/FontSizeBlockItem.cs index 85bb8db..7f509be 100644 --- a/Filtration.ObjectModel/BlockItemTypes/FontSizeBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/FontSizeBlockItem.cs @@ -13,43 +13,11 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "SetFontSize"; } - } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading - { - get - { - return "Font Size"; - } - } - - public override int SortOrder - { - get { return 15; } - } - - public override int Minimum - { - get - { - return 11; - } - } - - public override int Maximum - { - get - { - return 45; - } - } + public override string PrefixText => "SetFontSize"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Font Size"; + public override int SortOrder => 15; + public override int Minimum => 11; + public override int Maximum => 45; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/HeightBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/HeightBlockItem.cs index 5c75e37..9b7b3a7 100644 --- a/Filtration.ObjectModel/BlockItemTypes/HeightBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/HeightBlockItem.cs @@ -15,55 +15,14 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "Height"; } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get { return "Height"; } - } - - public override string SummaryText - { - get { return "Height " + FilterPredicate; } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.LightBlue; } - } - - public override Color SummaryTextColor - { - get { return Colors.Black; } - } - - public override int SortOrder - { - get { return 8; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return 6; - } - } + public override string PrefixText => "Height"; + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Height"; + public override string SummaryText => "Height " + FilterPredicate; + public override Color SummaryBackgroundColor => Colors.LightBlue; + public override Color SummaryTextColor => Colors.Black; + public override int SortOrder => 8; + public override int Minimum => 0; + public override int Maximum => 6; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/ItemLevelBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/ItemLevelBlockItem.cs index 61b94d7..de772bc 100644 --- a/Filtration.ObjectModel/BlockItemTypes/ItemLevelBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/ItemLevelBlockItem.cs @@ -14,58 +14,14 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "ItemLevel"; } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get - { - return "Item Level"; - } - } - - public override string SummaryText - { - get { return "Item Level " + FilterPredicate; } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.DarkSlateGray; } - } - - public override Color SummaryTextColor - { - get { return Colors.White; } - } - - public override int SortOrder - { - get { return 1; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return 100; - } - } + public override string PrefixText => "ItemLevel"; + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Item Level"; + public override string SummaryText => "Item Level " + FilterPredicate; + public override Color SummaryBackgroundColor => Colors.DarkSlateGray; + public override Color SummaryTextColor => Colors.White; + public override int SortOrder => 1; + public override int Minimum => 0; + public override int Maximum => 100; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/LinkedSocketsBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/LinkedSocketsBlockItem.cs index abb3157..beaebd2 100644 --- a/Filtration.ObjectModel/BlockItemTypes/LinkedSocketsBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/LinkedSocketsBlockItem.cs @@ -15,58 +15,14 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "LinkedSockets"; } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get - { - return "Linked Sockets"; - } - } - - public override string SummaryText - { - get { return "Linked Sockets " + FilterPredicate; } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.Gold; } - } - - public override Color SummaryTextColor - { - get { return Colors.Black; } - } - - public override int SortOrder - { - get { return 6; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return 6; - } - } + public override string PrefixText => "LinkedSockets"; + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Linked Sockets"; + public override string SummaryText => "Linked Sockets " + FilterPredicate; + public override Color SummaryBackgroundColor => Colors.Gold; + public override Color SummaryTextColor => Colors.Black; + public override int SortOrder => 6; + public override int Minimum => 0; + public override int Maximum => 6; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/QualityBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/QualityBlockItem.cs index 4b05703..386e2b2 100644 --- a/Filtration.ObjectModel/BlockItemTypes/QualityBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/QualityBlockItem.cs @@ -15,58 +15,14 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "Quality"; } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get - { - return "Quality"; - } - } - - public override string SummaryText - { - get { return "Quality " + FilterPredicate; } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.DarkOrange; } - } - - public override Color SummaryTextColor - { - get { return Colors.White; } - } - - public override int SortOrder - { - get { return 3; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return 20; - } - } + public override string PrefixText => "Quality"; + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Quality"; + public override string SummaryText => "Quality " + FilterPredicate; + public override Color SummaryBackgroundColor => Colors.DarkOrange; + public override Color SummaryTextColor => Colors.White; + public override int SortOrder => 3; + public override int Minimum => 0; + public override int Maximum => 20; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/RarityBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/RarityBlockItem.cs index a7bc010..bb0b4bb 100644 --- a/Filtration.ObjectModel/BlockItemTypes/RarityBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/RarityBlockItem.cs @@ -16,74 +16,17 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "Rarity"; } - } - - public override string OutputText - { - get - { - return PrefixText + " " + FilterPredicate.PredicateOperator - .GetAttributeDescription() + - " " + - ((ItemRarity) FilterPredicate.PredicateOperand) - .GetAttributeDescription(); - } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get - { - return "Item Rarity"; - } - } - - public override string SummaryText - { - get - { - return "Rarity " + FilterPredicate.PredicateOperator.GetAttributeDescription() + " " + - ((ItemRarity) FilterPredicate.PredicateOperand).GetAttributeDescription(); - } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.LightCoral; } - } - - public override Color SummaryTextColor - { - get { return Colors.White; } - } - - public override int SortOrder - { - get { return 4; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return (int)ItemRarity.Unique; - } - } + public override string PrefixText => "Rarity"; + public override string OutputText => PrefixText + " " + FilterPredicate.PredicateOperator + .GetAttributeDescription() + " " + ((ItemRarity) FilterPredicate.PredicateOperand).GetAttributeDescription(); + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Item Rarity"; + public override string SummaryText => "Rarity " + FilterPredicate.PredicateOperator.GetAttributeDescription() + " " + + ((ItemRarity) FilterPredicate.PredicateOperand).GetAttributeDescription(); + public override Color SummaryBackgroundColor => Colors.LightCoral; + public override Color SummaryTextColor => Colors.White; + public override int SortOrder => 4; + public override int Minimum => 0; + public override int Maximum => (int)ItemRarity.Unique; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/SocketGroupBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/SocketGroupBlockItem.cs index 4a66b01..df58486 100644 --- a/Filtration.ObjectModel/BlockItemTypes/SocketGroupBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/SocketGroupBlockItem.cs @@ -6,24 +6,9 @@ namespace Filtration.ObjectModel.BlockItemTypes { public class SocketGroupBlockItem : StringListBlockItem { - public override string PrefixText - { - get { return "SocketGroup"; } - } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading - { - get - { - return "Socket Group"; - } - } - + public override string PrefixText => "SocketGroup"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Socket Group"; public override string SummaryText { get @@ -32,20 +17,8 @@ namespace Filtration.ObjectModel.BlockItemTypes return "Socket Group " + summaryItemText.TrimStart(' '); } } - - public override Color SummaryBackgroundColor - { - get { return Colors.GhostWhite; } - } - - public override Color SummaryTextColor - { - get { return Colors.Black; } - } - - public override int SortOrder - { - get { return 9; } - } + public override Color SummaryBackgroundColor => Colors.GhostWhite; + public override Color SummaryTextColor => Colors.Black; + public override int SortOrder => 9; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/SocketsBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/SocketsBlockItem.cs index 23e2c5a..e9bae54 100644 --- a/Filtration.ObjectModel/BlockItemTypes/SocketsBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/SocketsBlockItem.cs @@ -15,58 +15,14 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "Sockets"; } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get - { - return "Sockets"; - } - } - - public override string SummaryText - { - get { return "Sockets " + FilterPredicate; } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.LightGray; } - } - - public override Color SummaryTextColor - { - get { return Colors.Black; } - } - - public override int SortOrder - { - get { return 5; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return 6; - } - } + public override string PrefixText => "Sockets"; + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Sockets"; + public override string SummaryText => "Sockets " + FilterPredicate; + public override Color SummaryBackgroundColor => Colors.LightGray; + public override Color SummaryTextColor => Colors.Black; + public override int SortOrder => 5; + public override int Minimum => 0; + public override int Maximum => 6; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/SoundBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/SoundBlockItem.cs index 80ef44c..e117b37 100644 --- a/Filtration.ObjectModel/BlockItemTypes/SoundBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/SoundBlockItem.cs @@ -14,27 +14,9 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "PlayAlertSound"; } - } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading - { - get - { - return "Play Alert Sound"; - } - } - - public override int SortOrder - { - get { return 16; } - } + public override string PrefixText => "PlayAlertSound"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Play Alert Sound"; + public override int SortOrder => 16; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs index 0bc27d4..fe2ed6e 100644 --- a/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/TextColorBlockItem.cs @@ -13,27 +13,9 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "SetTextColor"; } - } - - public override int MaximumAllowed - { - get { return 1; } - } - - public override string DisplayHeading - { - get - { - return "Text Color"; - } - } - - public override int SortOrder - { - get { return 12; } - } + public override string PrefixText => "SetTextColor"; + public override int MaximumAllowed => 1; + public override string DisplayHeading => "Text Color"; + public override int SortOrder => 12; } } diff --git a/Filtration.ObjectModel/BlockItemTypes/WidthBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/WidthBlockItem.cs index aff1e77..5211b0b 100644 --- a/Filtration.ObjectModel/BlockItemTypes/WidthBlockItem.cs +++ b/Filtration.ObjectModel/BlockItemTypes/WidthBlockItem.cs @@ -15,58 +15,14 @@ namespace Filtration.ObjectModel.BlockItemTypes { } - public override string PrefixText - { - get { return "Width"; } - } - - public override int MaximumAllowed - { - get { return 2; } - } - - public override string DisplayHeading - { - get - { - return "Width"; - } - } - - public override string SummaryText - { - get { return "Width " + FilterPredicate; } - } - - public override Color SummaryBackgroundColor - { - get { return Colors.MediumPurple; } - } - - public override Color SummaryTextColor - { - get { return Colors.White; } - } - - public override int SortOrder - { - get { return 7; } - } - - public override int Minimum - { - get - { - return 0; - } - } - - public override int Maximum - { - get - { - return 2; - } - } + public override string PrefixText => "Width"; + public override int MaximumAllowed => 2; + public override string DisplayHeading => "Width"; + public override string SummaryText => "Width " + FilterPredicate; + public override Color SummaryBackgroundColor => Colors.MediumPurple; + public override Color SummaryTextColor => Colors.White; + public override int SortOrder => 7; + public override int Minimum => 0; + public override int Maximum => 2; } } diff --git a/Filtration.ObjectModel/Extensions/EnumHelper.cs b/Filtration.ObjectModel/Extensions/EnumHelper.cs index a8d3c76..c37b6cc 100644 --- a/Filtration.ObjectModel/Extensions/EnumHelper.cs +++ b/Filtration.ObjectModel/Extensions/EnumHelper.cs @@ -10,7 +10,7 @@ namespace Filtration.ObjectModel.Extensions var type = enumVal.GetType(); var memInfo = type.GetMember(enumVal.ToString()); var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); - return (attributes.Length > 0) ? (T)attributes[0] : null; + return attributes.Length > 0 ? (T)attributes[0] : null; } public static string GetAttributeDescription(this Enum enumValue) diff --git a/Filtration.ObjectModel/ItemFilterBlock.cs b/Filtration.ObjectModel/ItemFilterBlock.cs index 5b7e4c6..01da168 100644 --- a/Filtration.ObjectModel/ItemFilterBlock.cs +++ b/Filtration.ObjectModel/ItemFilterBlock.cs @@ -59,11 +59,11 @@ namespace Filtration.ObjectModel } } - public ObservableCollection BlockItems { get; private set; } + public ObservableCollection BlockItems { get; } public int BlockCount(Type type) { - return BlockItems != null ? BlockItems.Count(b => b.GetType() == type) : 0; + return BlockItems?.Count(b => b.GetType() == type) ?? 0; } public bool AddBlockItemAllowed(Type type) diff --git a/Filtration.ObjectModel/ItemFilterBlockGroup.cs b/Filtration.ObjectModel/ItemFilterBlockGroup.cs index 9a495f6..594069f 100644 --- a/Filtration.ObjectModel/ItemFilterBlockGroup.cs +++ b/Filtration.ObjectModel/ItemFilterBlockGroup.cs @@ -17,10 +17,10 @@ namespace Filtration.ObjectModel public event EventHandler BlockGroupStatusChanged; - public string GroupName { get; private set; } - public ItemFilterBlockGroup ParentGroup { get; private set; } - public List ChildGroups { get; private set; } - public bool Advanced { get; private set; } + public string GroupName { get; } + public ItemFilterBlockGroup ParentGroup { get; } + public List ChildGroups { get; } + public bool Advanced { get; } public bool IsChecked { @@ -32,10 +32,7 @@ namespace Filtration.ObjectModel _isChecked = value; // Raise an event to let blocks that have this block group assigned that // they might need to change their Action due to the block group status changing. - if (BlockGroupStatusChanged != null) - { - BlockGroupStatusChanged.Invoke(null, null); - } + BlockGroupStatusChanged?.Invoke(null, null); } } } diff --git a/Filtration.ObjectModel/ItemFilterScript.cs b/Filtration.ObjectModel/ItemFilterScript.cs index 57e8fac..133f382 100644 --- a/Filtration.ObjectModel/ItemFilterScript.cs +++ b/Filtration.ObjectModel/ItemFilterScript.cs @@ -19,8 +19,8 @@ namespace Filtration.ObjectModel ThemeComponents = new ThemeComponentCollection { IsMasterCollection = true}; } - public ObservableCollection ItemFilterBlocks { get; private set; } - public ObservableCollection ItemFilterBlockGroups { get; private set; } + public ObservableCollection ItemFilterBlocks { get; } + public ObservableCollection ItemFilterBlockGroups { get; } public ThemeComponentCollection ThemeComponents { get; set; } diff --git a/Filtration.ObjectModel/NumericFilterPredicate.cs b/Filtration.ObjectModel/NumericFilterPredicate.cs index d23e273..1efd969 100644 --- a/Filtration.ObjectModel/NumericFilterPredicate.cs +++ b/Filtration.ObjectModel/NumericFilterPredicate.cs @@ -53,7 +53,7 @@ namespace Filtration.ObjectModel public virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; - if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } diff --git a/Filtration.ObjectModel/ThemeEditor/Theme.cs b/Filtration.ObjectModel/ThemeEditor/Theme.cs index 91f2722..d21f2b4 100644 --- a/Filtration.ObjectModel/ThemeEditor/Theme.cs +++ b/Filtration.ObjectModel/ThemeEditor/Theme.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Windows.Media; using System.Xml.Serialization; @@ -22,10 +21,7 @@ namespace Filtration.ObjectModel.ThemeEditor [XmlIgnore] public string FilePath { get; set; } - public ThemeComponentCollection Components - { - get { return _components; } - } + public ThemeComponentCollection Components => _components; public bool ComponentExists(ThemeComponentType componentType, string componentName) { diff --git a/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs b/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs index dcfbe11..635dbb7 100644 --- a/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs +++ b/Filtration.ObjectModel/ThemeEditor/ThemeComponent.cs @@ -2,7 +2,6 @@ using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Media; -using System.Xml.Serialization; using Filtration.ObjectModel.Annotations; using Filtration.ObjectModel.Enums; @@ -66,10 +65,7 @@ namespace Filtration.ObjectModel.ThemeEditor { _color = value; OnPropertyChanged(); - if (_themeComponentUpdatedEventHandler != null) - { - _themeComponentUpdatedEventHandler.Invoke(this, EventArgs.Empty); - } + _themeComponentUpdatedEventHandler?.Invoke(this, EventArgs.Empty); } } @@ -88,10 +84,7 @@ namespace Filtration.ObjectModel.ThemeEditor public void TerminateComponent() { - if (ThemeComponentDeleted != null) - { - ThemeComponentDeleted.Invoke(this, EventArgs.Empty); - } + ThemeComponentDeleted?.Invoke(this, EventArgs.Empty); } public event PropertyChangedEventHandler PropertyChanged; @@ -100,7 +93,7 @@ namespace Filtration.ObjectModel.ThemeEditor protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; - if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } diff --git a/Filtration.Tests/Services/TestItemFilterPersistenceService.cs b/Filtration.Tests/Services/TestItemFilterPersistenceService.cs index e36fafc..bdfc4ea 100644 --- a/Filtration.Tests/Services/TestItemFilterPersistenceService.cs +++ b/Filtration.Tests/Services/TestItemFilterPersistenceService.cs @@ -16,20 +16,20 @@ namespace Filtration.Tests.Services public async Task LoadItemFilterScript_CallsTranslatorAndFileSystemService() { // Arrange - const string TestInputPath = "C:\\Test Path\\Script.Filter"; - const string TestScriptString = "This is a test item filter script"; + const string testInputPath = "C:\\Test Path\\Script.Filter"; + const string testScriptString = "This is a test item filter script"; var testItemFilterScript = new ItemFilterScript(); var mockFileSystemService = new Mock(); - mockFileSystemService.Setup(s => s.ReadFileAsString(TestInputPath)).Returns(TestScriptString).Verifiable(); + mockFileSystemService.Setup(s => s.ReadFileAsString(testInputPath)).Returns(testScriptString).Verifiable(); var mockItemFilterScriptTranslator = new Mock(); - mockItemFilterScriptTranslator.Setup(t => t.TranslateStringToItemFilterScript(TestScriptString)).Returns(testItemFilterScript).Verifiable(); + mockItemFilterScriptTranslator.Setup(t => t.TranslateStringToItemFilterScript(testScriptString)).Returns(testItemFilterScript).Verifiable(); var service = new ItemFilterPersistenceService(mockFileSystemService.Object, mockItemFilterScriptTranslator.Object); // Act - var script = await service.LoadItemFilterScriptAsync(TestInputPath); + var script = await service.LoadItemFilterScriptAsync(testInputPath); // Assert mockFileSystemService.Verify(); @@ -65,12 +65,12 @@ namespace Filtration.Tests.Services public void DefaultPathOfExileDirectoryExists_CallsFileSystemServiceWithCorrectString() { // Arrange - const string TestUserProfilePath = "C:\\Users\\TestUser"; + const string testUserProfilePath = "C:\\Users\\TestUser"; var mockFileSystemService = new Mock(); - mockFileSystemService.Setup(f => f.GetUserProfilePath()).Returns(TestUserProfilePath).Verifiable(); - mockFileSystemService.Setup(f => f.DirectoryExists(TestUserProfilePath + "\\Documents\\My Games\\Path of Exile")).Returns(true).Verifiable(); + mockFileSystemService.Setup(f => f.GetUserProfilePath()).Returns(testUserProfilePath).Verifiable(); + mockFileSystemService.Setup(f => f.DirectoryExists(testUserProfilePath + "\\Documents\\My Games\\Path of Exile")).Returns(true).Verifiable(); var mockItemFilterScriptTranslator = new Mock(); diff --git a/Filtration.Tests/Services/TestUpdateService.cs b/Filtration.Tests/Services/TestUpdateService.cs index b90fc77..2d5ed4c 100644 --- a/Filtration.Tests/Services/TestUpdateService.cs +++ b/Filtration.Tests/Services/TestUpdateService.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Filtration.Models; using Filtration.Services; using Moq; diff --git a/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs b/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs index 91e6573..fe00a80 100644 --- a/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs +++ b/Filtration.Tests/Translators/TestItemFilterBlockTranslator.cs @@ -600,15 +600,15 @@ namespace Filtration.Tests.Translators public void TranslateStringToItemFilterBlock_SectionComment_ReturnsItemFilterSectionObjectWithCorrectDescription() { // Arrange - const string TestInputSectionDescription = "Wonderful items that you definitely won't want to miss!"; - var inputString = "# Section: " + TestInputSectionDescription; + const string testInputSectionDescription = "Wonderful items that you definitely won't want to miss!"; + var inputString = "# Section: " + testInputSectionDescription; // Act var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, null); // Assert Assert.IsInstanceOf(result); - Assert.AreEqual(TestInputSectionDescription, result.Description); + Assert.AreEqual(testInputSectionDescription, result.Description); } [Test] @@ -1282,10 +1282,10 @@ namespace Filtration.Tests.Translators public void TranslateItemFilterBlockToString_Section_ReturnsCorrectString() { // Arrange - const string TestInputSectionText = "Ermagerd it's a section!"; - var expectedResult = "# Section: " + TestInputSectionText; + const string testInputSectionText = "Ermagerd it's a section!"; + var expectedResult = "# Section: " + testInputSectionText; - _testUtility.TestBlock = new ItemFilterSection { Description = TestInputSectionText }; + _testUtility.TestBlock = new ItemFilterSection { Description = testInputSectionText }; // Act var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock); @@ -1559,8 +1559,8 @@ namespace Filtration.Tests.Translators } public ItemFilterBlock TestBlock { get; set; } - public Mock MockBlockGroupHierarchyBuilder { get; private set; } - public ItemFilterBlockTranslator Translator { get; private set; } + public Mock MockBlockGroupHierarchyBuilder { get; } + public ItemFilterBlockTranslator Translator { get; } } } } diff --git a/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs b/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs index 1fca74d..648e7b8 100644 --- a/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs +++ b/Filtration.Tests/Translators/TestItemFilterScriptTranslator.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Windows; using Filtration.ObjectModel; using Filtration.ObjectModel.BlockItemTypes; using Filtration.ObjectModel.Enums; @@ -91,11 +90,11 @@ namespace Filtration.Tests.Translators var testBlock = new ItemFilterBlock(); testBlock.BlockItems.Add(new ItemLevelBlockItem(FilterPredicateOperator.Equal, 5)); - const string BlockOutput = "Test Script Output"; + const string blockOutput = "Test Script Output"; testScript.ItemFilterBlocks.Add(testBlock); - _testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateItemFilterBlockToString(testBlock)).Returns(BlockOutput).Verifiable(); + _testUtility.MockItemFilterBlockTranslator.Setup(t => t.TranslateItemFilterBlockToString(testBlock)).Returns(blockOutput).Verifiable(); // Act @@ -400,9 +399,9 @@ namespace Filtration.Tests.Translators ScriptTranslator = new ItemFilterScriptTranslator(MockItemFilterBlockTranslator.Object, MockBlockGroupHierarchyBuilder.Object); } - public ItemFilterScriptTranslator ScriptTranslator { get; private set; } - public Mock MockItemFilterBlockTranslator { get; private set; } - public Mock MockBlockGroupHierarchyBuilder { get; private set; } + public ItemFilterScriptTranslator ScriptTranslator { get; } + public Mock MockItemFilterBlockTranslator { get; } + public Mock MockBlockGroupHierarchyBuilder { get; } } } } diff --git a/Filtration.ThemeEditor.Tests/Models/TestTheme.cs b/Filtration.ThemeEditor.Tests/Models/TestTheme.cs index 49512c3..ef22d22 100644 --- a/Filtration.ThemeEditor.Tests/Models/TestTheme.cs +++ b/Filtration.ThemeEditor.Tests/Models/TestTheme.cs @@ -1,5 +1,4 @@ using System.Windows.Media; -using Filtration.ObjectModel.BlockItemTypes; using Filtration.ObjectModel.Enums; using Filtration.ObjectModel.ThemeEditor; using NUnit.Framework; @@ -16,12 +15,12 @@ namespace Filtration.ThemeEditor.Tests.Models var theme = new Theme(); var testInputComponentTargetType = ThemeComponentType.TextColor; - const string TestInputComponentName = "test"; + const string testInputComponentName = "test"; - theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color()); + theme.AddComponent(testInputComponentTargetType, testInputComponentName, new Color()); // Act - var result = theme.ComponentExists(testInputComponentTargetType, TestInputComponentName); + var result = theme.ComponentExists(testInputComponentTargetType, testInputComponentName); // Assert Assert.AreEqual(true, result); @@ -34,8 +33,8 @@ namespace Filtration.ThemeEditor.Tests.Models var theme = new Theme(); var testInputComponentTargetType = ThemeComponentType.TextColor; - const string TestInputComponentName = "test"; - theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color()); + const string testInputComponentName = "test"; + theme.AddComponent(testInputComponentTargetType, testInputComponentName, new Color()); // Act var result = theme.ComponentExists(testInputComponentTargetType, "blah"); @@ -51,12 +50,12 @@ namespace Filtration.ThemeEditor.Tests.Models var theme = new Theme(); var testInputComponentTargetType = ThemeComponentType.TextColor; - const string TestInputComponentName = "test"; + const string testInputComponentName = "test"; - theme.AddComponent(testInputComponentTargetType, TestInputComponentName, new Color()); + theme.AddComponent(testInputComponentTargetType, testInputComponentName, new Color()); // Act - var result = theme.ComponentExists(ThemeComponentType.BorderColor, TestInputComponentName); + var result = theme.ComponentExists(ThemeComponentType.BorderColor, testInputComponentName); // Assert Assert.AreEqual(false, result); diff --git a/Filtration.ThemeEditor.Tests/Properties/AssemblyInfo.cs b/Filtration.ThemeEditor.Tests/Properties/AssemblyInfo.cs index 6603374..218b79f 100644 --- a/Filtration.ThemeEditor.Tests/Properties/AssemblyInfo.cs +++ b/Filtration.ThemeEditor.Tests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Filtration.ThemeEditor/Properties/AssemblyInfo.cs b/Filtration.ThemeEditor/Properties/AssemblyInfo.cs index 677e08e..11422ee 100644 --- a/Filtration.ThemeEditor/Properties/AssemblyInfo.cs +++ b/Filtration.ThemeEditor/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/Filtration.ThemeEditor/Providers/ThemeProvider.cs b/Filtration.ThemeEditor/Providers/ThemeProvider.cs index 4600200..9cac475 100644 --- a/Filtration.ThemeEditor/Providers/ThemeProvider.cs +++ b/Filtration.ThemeEditor/Providers/ThemeProvider.cs @@ -1,5 +1,4 @@ -using System.Collections.ObjectModel; -using System.IO; +using System.IO; using System.Linq; using System.Threading.Tasks; using AutoMapper; diff --git a/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs b/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs index c5115a6..dfb0490 100644 --- a/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs +++ b/Filtration.ThemeEditor/ViewModels/ThemeEditorViewModel.cs @@ -39,7 +39,7 @@ namespace Filtration.ThemeEditor.ViewModels public class ThemeEditorViewModel : PaneViewModel, IThemeEditorViewModel { - private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly IThemeProvider _themeProvider; private readonly IMessageBoxService _messageBoxService; @@ -66,14 +66,11 @@ namespace Filtration.ThemeEditor.ViewModels } - public RelayCommand AddThemeComponentCommand { get; private set; } - public RelayCommand DeleteThemeComponentCommand { get; private set; } - public RelayCommand CloseCommand { get; private set; } + public RelayCommand AddThemeComponentCommand { get; } + public RelayCommand DeleteThemeComponentCommand { get; } + public RelayCommand CloseCommand { get; } - public bool IsMasterTheme - { - get { return Components.IsMasterCollection; } - } + public bool IsMasterTheme => Components.IsMasterCollection; public ItemFilterScript IsMasterThemeForScript { get; private set; } @@ -91,8 +88,8 @@ namespace Filtration.ThemeEditor.ViewModels } - public bool IsScript { get { return false; } } - public bool IsTheme { get { return true; } } + public bool IsScript => false; + public bool IsTheme => true; public bool IsDirty { get; private set; } public string FilePath @@ -105,10 +102,7 @@ namespace Filtration.ThemeEditor.ViewModels } } - public string Filename - { - get { return _filenameIsFake ? FilePath : Path.GetFileName(FilePath); } - } + public string Filename => _filenameIsFake ? FilePath : Path.GetFileName(FilePath); public string Name { get; set; } @@ -141,9 +135,9 @@ namespace Filtration.ThemeEditor.ViewModels } catch (Exception e) { - if (_logger.IsErrorEnabled) + if (Logger.IsErrorEnabled) { - _logger.Error(e); + Logger.Error(e); } _messageBoxService.Show("Save Error", "Error saving filter theme - " + e.Message, MessageBoxButton.OK, MessageBoxImage.Error); @@ -175,9 +169,9 @@ namespace Filtration.ThemeEditor.ViewModels } catch (Exception e) { - if (_logger.IsErrorEnabled) + if (Logger.IsErrorEnabled) { - _logger.Error(e); + Logger.Error(e); } _messageBoxService.Show("Save Error", "Error saving theme file - " + e.Message, MessageBoxButton.OK, diff --git a/Filtration/App.xaml.cs b/Filtration/App.xaml.cs index 87ea227..d152e1b 100644 --- a/Filtration/App.xaml.cs +++ b/Filtration/App.xaml.cs @@ -20,7 +20,7 @@ namespace Filtration public partial class App { private IWindsorContainer _container; - private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private void Application_Startup(object sender, StartupEventArgs e) { @@ -69,7 +69,7 @@ namespace Filtration public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - _logger.Fatal(e.Exception); + Logger.Fatal(e.Exception); var exception = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace; var innerException = e.Exception.InnerException != null ? e.Exception.InnerException.Message + Environment.NewLine + diff --git a/Filtration/Converters/ItemRarityConverter.cs b/Filtration/Converters/ItemRarityConverter.cs index df229b9..aabc724 100644 --- a/Filtration/Converters/ItemRarityConverter.cs +++ b/Filtration/Converters/ItemRarityConverter.cs @@ -9,12 +9,12 @@ namespace Filtration.Converters { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return (ItemRarity) ((int) value); + return (ItemRarity) (int) value; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return (int) ((ItemRarity) value); + return (int) (ItemRarity) value; } } } diff --git a/Filtration/Extensions/EnumerationExtension.cs b/Filtration/Extensions/EnumerationExtension.cs index 98d2c57..3498157 100644 --- a/Filtration/Extensions/EnumerationExtension.cs +++ b/Filtration/Extensions/EnumerationExtension.cs @@ -12,7 +12,7 @@ namespace Filtration.Extensions public EnumerationExtension(Type enumType) { - if (enumType == null) throw new ArgumentNullException("enumType"); + if (enumType == null) throw new ArgumentNullException(nameof(enumType)); EnumType = enumType; } diff --git a/Filtration/Services/ClipboardService.cs b/Filtration/Services/ClipboardService.cs index 73b3435..0718254 100644 --- a/Filtration/Services/ClipboardService.cs +++ b/Filtration/Services/ClipboardService.cs @@ -13,7 +13,7 @@ namespace Filtration.Services internal class ClipboardService : IClipboardService { - private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); public void SetClipboardText(string inputText) { @@ -26,7 +26,7 @@ namespace Filtration.Services } catch (Exception e) { - _logger.Error(e); + Logger.Error(e); } Thread.Sleep(10); diff --git a/Filtration/Services/UpdateCheckService.cs b/Filtration/Services/UpdateCheckService.cs index 9ccb1dc..9756c14 100644 --- a/Filtration/Services/UpdateCheckService.cs +++ b/Filtration/Services/UpdateCheckService.cs @@ -12,7 +12,7 @@ namespace Filtration.Services internal class UpdateCheckService : IUpdateCheckService { private readonly IHTTPService _httpService; - private const string UpdateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml"; + private const string _updateDataUrl = "http://ben-wallis.github.io/Filtration/filtration_version.xml"; public UpdateCheckService(IHTTPService httpService) { @@ -21,8 +21,8 @@ namespace Filtration.Services public UpdateData GetUpdateData() { - var updateXml = _httpService.GetContent(UpdateDataUrl); - return (DeserializeUpdateData(updateXml)); + var updateXml = _httpService.GetContent(_updateDataUrl); + return DeserializeUpdateData(updateXml); } public UpdateData DeserializeUpdateData(string updateDataString) diff --git a/Filtration/Translators/ItemFilterBlockTranslator.cs b/Filtration/Translators/ItemFilterBlockTranslator.cs index 78b8937..c51dc8f 100644 --- a/Filtration/Translators/ItemFilterBlockTranslator.cs +++ b/Filtration/Translators/ItemFilterBlockTranslator.cs @@ -26,9 +26,9 @@ namespace Filtration.Translators internal class ItemFilterBlockTranslator : IItemFilterBlockTranslator { private readonly IBlockGroupHierarchyBuilder _blockGroupHierarchyBuilder; - private const string Indent = " "; - private readonly string _newLine = Environment.NewLine + Indent; - private readonly string _disabledNewLine = Environment.NewLine + "#" + Indent; + private const string _indent = " "; + private readonly string _newLine = Environment.NewLine + _indent; + private readonly string _disabledNewLine = Environment.NewLine + "#" + _indent; private ThemeComponentCollection _masterComponentCollection; public ItemFilterBlockTranslator(IBlockGroupHierarchyBuilder blockGroupHierarchyBuilder) @@ -118,7 +118,7 @@ namespace Filtration.Translators blockItemValue.FilterPredicate.PredicateOperator = EnumHelper.GetEnumValueFromDescription(string.IsNullOrEmpty(result.Groups[1].Value) ? "=" : result.Groups[1].Value); blockItemValue.FilterPredicate.PredicateOperand = - (int)(EnumHelper.GetEnumValueFromDescription(result.Groups[2].Value)); + (int)EnumHelper.GetEnumValueFromDescription(result.Groups[2].Value); } block.BlockItems.Add(blockItemValue); break; diff --git a/Filtration/Translators/ItemFilterScriptTranslator.cs b/Filtration/Translators/ItemFilterScriptTranslator.cs index a13e22d..5d6d09b 100644 --- a/Filtration/Translators/ItemFilterScriptTranslator.cs +++ b/Filtration/Translators/ItemFilterScriptTranslator.cs @@ -122,7 +122,7 @@ namespace Filtration.Translators for (var boundary = conditionBoundaries.First; boundary != null; boundary = boundary.Next) { var begin = boundary.Value; - var end = boundary.Next != null ? boundary.Next.Value : lines.Length; + var end = boundary.Next?.Value ?? lines.Length; var block = new string[end - begin]; Array.Copy(lines, begin, block, 0, end - begin); var blockString = string.Join("\r\n", block); diff --git a/Filtration/UserControls/BlockItemControl.xaml.cs b/Filtration/UserControls/BlockItemControl.xaml.cs index c84f737..3026bc4 100644 --- a/Filtration/UserControls/BlockItemControl.xaml.cs +++ b/Filtration/UserControls/BlockItemControl.xaml.cs @@ -80,28 +80,14 @@ namespace Filtration.UserControls } - public ObservableCollection AvailableColors - { - get - { - { - return PathOfExileColors.DefaultColors; - } - } - } + public ObservableCollection AvailableColors => PathOfExileColors.DefaultColors; - public List SoundsAvailable - { - get - { - return new List { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - } - } + public List SoundsAvailable => new List { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; private void OnSetBlockColorCommmand() { var blockItem = BlockItem as ColorBlockItem; - if (blockItem == null || blockItem.ThemeComponent == null) return; + if (blockItem?.ThemeComponent == null) return; blockItem.Color = blockItem.ThemeComponent.Color; } @@ -112,7 +98,7 @@ namespace Filtration.UserControls protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; - if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } diff --git a/Filtration/UserControls/EditableListBoxControl.xaml.cs b/Filtration/UserControls/EditableListBoxControl.xaml.cs index 2754d72..1ea4b10 100644 --- a/Filtration/UserControls/EditableListBoxControl.xaml.cs +++ b/Filtration/UserControls/EditableListBoxControl.xaml.cs @@ -94,9 +94,8 @@ namespace Filtration.UserControls DependencyPropertyChangedEventArgs e) { var control = source as EditableListBoxControl; - if (control == null) return; - control.OnPropertyChanged("ItemsSource"); + control?.OnPropertyChanged(nameof(ItemsSource)); } public event PropertyChangedEventHandler PropertyChanged; @@ -105,7 +104,7 @@ namespace Filtration.UserControls protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; - if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } diff --git a/Filtration/UserControls/NumericFilterPredicateControl.xaml.cs b/Filtration/UserControls/NumericFilterPredicateControl.xaml.cs index d394545..f72acd5 100644 --- a/Filtration/UserControls/NumericFilterPredicateControl.xaml.cs +++ b/Filtration/UserControls/NumericFilterPredicateControl.xaml.cs @@ -50,8 +50,8 @@ namespace Filtration.UserControls { SetValue(NumericFilterPredicateProperty, value); OnPropertyChanged(); - OnPropertyChanged("FilterPredicateOperator"); - OnPropertyChanged("FilterPredicateOperand"); + OnPropertyChanged(nameof(FilterPredicateOperator)); + OnPropertyChanged(nameof(FilterPredicateOperand)); } } @@ -117,8 +117,8 @@ namespace Filtration.UserControls var control = source as NumericFilterPredicateControl; if (control == null) return; - control.OnPropertyChanged("FilterPredicateOperator"); - control.OnPropertyChanged("FilterPredicateOperand"); + control.OnPropertyChanged(nameof(FilterPredicateOperator)); + control.OnPropertyChanged(nameof(FilterPredicateOperand)); } public event PropertyChangedEventHandler PropertyChanged; @@ -127,7 +127,7 @@ namespace Filtration.UserControls protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; - if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } diff --git a/Filtration/UserControls/ThemeComponentSelectionControl.xaml.cs b/Filtration/UserControls/ThemeComponentSelectionControl.xaml.cs index 7274056..9b8d279 100644 --- a/Filtration/UserControls/ThemeComponentSelectionControl.xaml.cs +++ b/Filtration/UserControls/ThemeComponentSelectionControl.xaml.cs @@ -67,14 +67,11 @@ namespace Filtration.UserControls { _showThemeComponentComboBox = value; OnPropertyChanged(); - OnPropertyChanged("HasThemeComponent"); + OnPropertyChanged(nameof(HasThemeComponent)); } } - public bool HasThemeComponent - { - get { return ThemeComponent != null; } - } + public bool HasThemeComponent => ThemeComponent != null; private void OnAddThemeComponentCommand() { @@ -93,7 +90,7 @@ namespace Filtration.UserControls protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { var handler = PropertyChanged; - if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } } diff --git a/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs b/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs index ee87215..28ab87d 100644 --- a/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs +++ b/Filtration/ViewModels/AvalonDockWorkspaceViewModel.cs @@ -36,7 +36,6 @@ namespace Filtration.ViewModels private IItemFilterScriptViewModel _activeScriptViewModel; private IThemeEditorViewModel _activeThemeViewModel; private readonly ObservableCollection _openDocuments; - private readonly ReadOnlyObservableCollection _readOnlyOpenDocuments; public AvalonDockWorkspaceViewModel(ISectionBrowserViewModel sectionBrowserViewModel, IBlockGroupBrowserViewModel blockGroupBrowserViewModel, @@ -52,16 +51,13 @@ namespace Filtration.ViewModels _blockOutputPreviewViewModel.Initialise(this); _openDocuments = new ObservableCollection {startPageViewModel}; - _readOnlyOpenDocuments = new ReadOnlyObservableCollection(_openDocuments); + OpenDocuments = new ReadOnlyObservableCollection(_openDocuments); ActiveDocument = startPageViewModel; } public event EventHandler ActiveDocumentChanged; - public ReadOnlyObservableCollection OpenDocuments - { - get { return _readOnlyOpenDocuments; } - } + public ReadOnlyObservableCollection OpenDocuments { get; } public IDocument ActiveDocument { @@ -87,54 +83,26 @@ namespace Filtration.ViewModels _activeThemeViewModel = null; } - if (ActiveDocumentChanged != null) - { - ActiveDocumentChanged(this, EventArgs.Empty); - } + ActiveDocumentChanged?.Invoke(this, EventArgs.Empty); Messenger.Default.Send(new NotificationMessage("ActiveDocumentChanged")); } } - public IItemFilterScriptViewModel ActiveScriptViewModel - { - get { return _activeScriptViewModel; } - } - - public IThemeEditorViewModel ActiveThemeViewModel - { - get { return _activeThemeViewModel; } - } - - public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel - { - get { return _blockGroupBrowserViewModel; } - } - - public IBlockOutputPreviewViewModel BlockOutputPreviewViewModel - { - get { return _blockOutputPreviewViewModel; } - } - - public ISectionBrowserViewModel SectionBrowserViewModel - { - get { return _sectionBrowserViewModel; } - } + public IItemFilterScriptViewModel ActiveScriptViewModel => _activeScriptViewModel; + public IThemeEditorViewModel ActiveThemeViewModel => _activeThemeViewModel; + public IBlockGroupBrowserViewModel BlockGroupBrowserViewModel => _blockGroupBrowserViewModel; + public IBlockOutputPreviewViewModel BlockOutputPreviewViewModel => _blockOutputPreviewViewModel; + public ISectionBrowserViewModel SectionBrowserViewModel => _sectionBrowserViewModel; private List _tools; - public IEnumerable Tools + public IEnumerable Tools => _tools ?? (_tools = new List { - get - { - return _tools ?? (_tools = new List - { - _sectionBrowserViewModel, - _blockGroupBrowserViewModel, - _blockOutputPreviewViewModel - }); - } - } + _sectionBrowserViewModel, + _blockGroupBrowserViewModel, + _blockOutputPreviewViewModel + }); public void AddDocument(IDocument document) { diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index 4975bf1..e17c1b3 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -65,7 +65,7 @@ namespace Filtration.ViewModels { if (itemFilterBlock == null || parentScriptViewModel == null) { - throw new ArgumentNullException("itemFilterBlock"); + throw new ArgumentNullException(nameof(itemFilterBlock)); } _parentScriptViewModel = parentScriptViewModel; @@ -112,10 +112,7 @@ namespace Filtration.ViewModels } } - public ObservableCollection BlockItems - { - get { return Block.BlockItems; } - } + public ObservableCollection BlockItems => Block.BlockItems; public IEnumerable SummaryBlockItems { @@ -132,13 +129,7 @@ namespace Filtration.ViewModels get { return Block.BlockItems.Where(b => b is IAudioVisualBlockItem); } } - public bool AdvancedBlockGroup - { - get - { - return Block.BlockGroup != null && Block.BlockGroup.Advanced; - } - } + public bool AdvancedBlockGroup => Block.BlockGroup != null && Block.BlockGroup.Advanced; public bool AudioVisualBlockItemsGridVisible { @@ -164,51 +155,33 @@ namespace Filtration.ViewModels } } - public IEnumerable AutoCompleteItemClasses - { - get { return _staticDataService.ItemClasses; } - } + public IEnumerable AutoCompleteItemClasses => _staticDataService.ItemClasses; - public IEnumerable AutoCompleteItemBaseTypes - { - get { return _staticDataService.ItemBaseTypes; } - } + public IEnumerable AutoCompleteItemBaseTypes => _staticDataService.ItemBaseTypes; - public List BlockItemTypesAvailable + public List BlockItemTypesAvailable => new List { - get - { - return new List - { - typeof (ItemLevelBlockItem), - typeof (DropLevelBlockItem), - typeof (QualityBlockItem), - typeof (RarityBlockItem), - typeof (SocketsBlockItem), - typeof (LinkedSocketsBlockItem), - typeof (WidthBlockItem), - typeof (HeightBlockItem), - typeof (SocketGroupBlockItem), - typeof (ClassBlockItem), - typeof (BaseTypeBlockItem) - }; - } - } + typeof (ItemLevelBlockItem), + typeof (DropLevelBlockItem), + typeof (QualityBlockItem), + typeof (RarityBlockItem), + typeof (SocketsBlockItem), + typeof (LinkedSocketsBlockItem), + typeof (WidthBlockItem), + typeof (HeightBlockItem), + typeof (SocketGroupBlockItem), + typeof (ClassBlockItem), + typeof (BaseTypeBlockItem) + }; - public List AudioVisualBlockItemTypesAvailable + public List AudioVisualBlockItemTypesAvailable => new List { - get - { - return new List - { - typeof (TextColorBlockItem), - typeof (BackgroundColorBlockItem), - typeof (BorderColorBlockItem), - typeof (FontSizeBlockItem), - typeof (SoundBlockItem) - }; - } - } + typeof (TextColorBlockItem), + typeof (BackgroundColorBlockItem), + typeof (BorderColorBlockItem), + typeof (FontSizeBlockItem), + typeof (SoundBlockItem) + }; public bool BlockEnabled { @@ -241,87 +214,43 @@ namespace Filtration.ViewModels } } - public ObservableCollection AvailableColors - { - get - { - { - return PathOfExileColors.DefaultColors; - } - } - } + public ObservableCollection AvailableColors => PathOfExileColors.DefaultColors; - public bool HasTextColor - { - get { return Block.HasBlockItemOfType(); } - } + public bool HasTextColor => Block.HasBlockItemOfType(); - public Color DisplayTextColor - { - get - { - return HasTextColor - ? BlockItems.OfType().First().Color - : new Color { A = 255, R = 200, G = 200, B = 200 }; - } - } + public Color DisplayTextColor => HasTextColor + ? BlockItems.OfType().First().Color + : new Color {A = 255, R = 200, G = 200, B = 200}; - public bool HasBackgroundColor - { - get { return Block.HasBlockItemOfType(); } - } + public bool HasBackgroundColor => Block.HasBlockItemOfType(); - public Color DisplayBackgroundColor - { - get - { - return HasBackgroundColor - ? BlockItems.OfType().First().Color - : new Color { A = 255, R = 0, G = 0, B = 0 }; - } - } + public Color DisplayBackgroundColor => HasBackgroundColor + ? BlockItems.OfType().First().Color + : new Color { A = 255, R = 0, G = 0, B = 0 }; - public bool HasBorderColor - { - get { return Block.HasBlockItemOfType(); } - } + public bool HasBorderColor => Block.HasBlockItemOfType(); - public Color DisplayBorderColor - { - get - { - return HasBorderColor - ? BlockItems.OfType().First().Color - : new Color { A = 255, R = 0, G = 0, B = 0 }; - } - } + public Color DisplayBorderColor => HasBorderColor + ? BlockItems.OfType().First().Color + : new Color { A = 255, R = 0, G = 0, B = 0 }; - public bool HasFontSize - { - get { return Block.HasBlockItemOfType(); } - } + public bool HasFontSize => Block.HasBlockItemOfType(); public double DisplayFontSize { // Dividing by 1.8 roughly scales in-game font sizes down to WPF sizes get { - var fontSize = HasFontSize ? (BlockItems.OfType().First().Value / 1.8) : 19; + var fontSize = HasFontSize ? BlockItems.OfType().First().Value / 1.8 : 19; return fontSize; } } - public bool HasSound - { - get { return Block.HasBlockItemOfType(); } - } + public bool HasSound => Block.HasBlockItemOfType(); - public bool HasAudioVisualBlockItems - { - get { return AudioVisualBlockItems.Any(); } - } + public bool HasAudioVisualBlockItems => AudioVisualBlockItems.Any(); private void OnSwitchBlockItemsViewCommand() { @@ -331,10 +260,7 @@ namespace Filtration.ViewModels private void OnToggleBlockActionCommand() { var actionBlock = Block.BlockItems.OfType().First(); - if (actionBlock != null) - { - actionBlock.ToggleAction(); - } + actionBlock?.ToggleAction(); } private void OnAddFilterBlockItemCommand(Type blockItemType) diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index 92000b2..f3660d7 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -68,7 +68,7 @@ namespace Filtration.ViewModels internal class ItemFilterScriptViewModel : PaneViewModel, IItemFilterScriptViewModel { - private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly IItemFilterBlockViewModelFactory _itemFilterBlockViewModelFactory; private readonly IItemFilterBlockTranslator _blockTranslator; @@ -129,24 +129,24 @@ namespace Filtration.ViewModels IconSource = icon; } - public RelayCommand ToggleShowAdvancedCommand { get; private set; } - public RelayCommand ClearFilterCommand { get; private set; } - public RelayCommand CloseCommand { get; private set; } - public RelayCommand DeleteBlockCommand { get; private set; } - public RelayCommand MoveBlockToTopCommand { get; private set; } - public RelayCommand MoveBlockUpCommand { get; private set; } - public RelayCommand MoveBlockDownCommand { get; private set; } - public RelayCommand MoveBlockToBottomCommand { get; private set; } - public RelayCommand AddBlockCommand { get; private set; } - public RelayCommand AddSectionCommand { get; private set; } - public RelayCommand EnableBlockCommand { get; private set; } - public RelayCommand DisableBlockCommand { get; private set; } - public RelayCommand CopyBlockCommand { get; private set; } - public RelayCommand CopyBlockStyleCommand { get; private set; } - public RelayCommand PasteBlockCommand { get; private set; } - public RelayCommand PasteBlockStyleCommand { get; private set; } - public RelayCommand ExpandAllBlocksCommand { get; private set; } - public RelayCommand CollapseAllBlocksCommand { get; private set; } + public RelayCommand ToggleShowAdvancedCommand { get; } + public RelayCommand ClearFilterCommand { get; } + public RelayCommand CloseCommand { get; } + public RelayCommand DeleteBlockCommand { get; } + public RelayCommand MoveBlockToTopCommand { get; } + public RelayCommand MoveBlockUpCommand { get; } + public RelayCommand MoveBlockDownCommand { get; } + public RelayCommand MoveBlockToBottomCommand { get; } + public RelayCommand AddBlockCommand { get; } + public RelayCommand AddSectionCommand { get; } + public RelayCommand EnableBlockCommand { get; } + public RelayCommand DisableBlockCommand { get; } + public RelayCommand CopyBlockCommand { get; } + public RelayCommand CopyBlockStyleCommand { get; } + public RelayCommand PasteBlockCommand { get; } + public RelayCommand PasteBlockStyleCommand { get; } + public RelayCommand ExpandAllBlocksCommand { get; } + public RelayCommand CollapseAllBlocksCommand { get; } public ObservableCollection ItemFilterBlockViewModels { @@ -203,8 +203,8 @@ namespace Filtration.ViewModels get { return ItemFilterBlockViewModels.Where(b => b.Block.GetType() == typeof (ItemFilterSection)); } } - public bool IsScript { get { return true; } } - public bool IsTheme { get { return false; } } + public bool IsScript => true; + public bool IsTheme => false; public string Description { @@ -306,20 +306,11 @@ namespace Filtration.ViewModels RaisePropertyChanged("DisplayName"); } - public string DisplayName - { - get { return !string.IsNullOrEmpty(Filename) ? Filename : Description; } - } + public string DisplayName => !string.IsNullOrEmpty(Filename) ? Filename : Description; - public string Filename - { - get { return Path.GetFileName(Script.FilePath); } - } + public string Filename => Path.GetFileName(Script.FilePath); - public string Filepath - { - get { return Script.FilePath; } - } + public string Filepath => Script.FilePath; private bool _filenameIsFake; private bool _showAdvanced; @@ -371,9 +362,9 @@ namespace Filtration.ViewModels } catch (Exception e) { - if (_logger.IsErrorEnabled) + if (Logger.IsErrorEnabled) { - _logger.Error(e); + Logger.Error(e); } _messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK, @@ -383,8 +374,6 @@ namespace Filtration.ViewModels { Messenger.Default.Send(new NotificationMessage("HideLoadingBanner")); } - - return; } public async Task SaveAsAsync() @@ -416,9 +405,9 @@ namespace Filtration.ViewModels } catch (Exception e) { - if (_logger.IsErrorEnabled) + if (Logger.IsErrorEnabled) { - _logger.Error(e); + Logger.Error(e); } _messageBoxService.Show("Save Error", "Error saving filter file - " + e.Message, MessageBoxButton.OK, @@ -442,7 +431,7 @@ namespace Filtration.ViewModels if (unusedThemeComponents.Count <= 0) return true; var themeComponents = unusedThemeComponents.Aggregate(string.Empty, - (current, themeComponent) => current + (themeComponent.ComponentName + Environment.NewLine)); + (current, themeComponent) => current + themeComponent.ComponentName + Environment.NewLine); var ignoreUnusedThemeComponents = _messageBoxService.Show("Unused Theme Components", "The following theme components are unused, they will be lost when this script is reopened. Save anyway?" + @@ -655,10 +644,8 @@ namespace Filtration.ViewModels } catch (Exception e) { - _logger.Error(e); - var innerException = e.InnerException != null - ? e.InnerException.Message - : string.Empty; + Logger.Error(e); + var innerException = e.InnerException?.Message ?? string.Empty; _messageBoxService.Show("Paste Error", e.Message + Environment.NewLine + innerException, MessageBoxButton.OK, diff --git a/Filtration/ViewModels/MainWindowViewModel.cs b/Filtration/ViewModels/MainWindowViewModel.cs index 4493667..0a9ae41 100644 --- a/Filtration/ViewModels/MainWindowViewModel.cs +++ b/Filtration/ViewModels/MainWindowViewModel.cs @@ -4,14 +4,11 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; -using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Threading; using Filtration.Common.Services; using Filtration.Common.ViewModels; using Filtration.Interface; @@ -44,13 +41,12 @@ namespace Filtration.ViewModels internal class MainWindowViewModel : FiltrationViewModelBase, IMainWindowViewModel { - private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly IItemFilterScriptRepository _itemFilterScriptRepository; private readonly IItemFilterScriptTranslator _itemFilterScriptTranslator; private readonly IReplaceColorsViewModel _replaceColorsViewModel; private readonly IAvalonDockWorkspaceViewModel _avalonDockWorkspaceViewModel; - private readonly ISettingsPageViewModel _settingsPageViewModel; private readonly IThemeProvider _themeProvider; private readonly IThemeService _themeService; private readonly IUpdateCheckService _updateCheckService; @@ -75,7 +71,7 @@ namespace Filtration.ViewModels _itemFilterScriptTranslator = itemFilterScriptTranslator; _replaceColorsViewModel = replaceColorsViewModel; _avalonDockWorkspaceViewModel = avalonDockWorkspaceViewModel; - _settingsPageViewModel = settingsPageViewModel; + SettingsPageViewModel = settingsPageViewModel; _themeProvider = themeProvider; _themeService = themeService; _updateCheckService = updateCheckService; @@ -196,45 +192,45 @@ namespace Filtration.ViewModels CheckForUpdates(); } - public RelayCommand OpenScriptCommand { get; private set; } - public RelayCommand OpenThemeCommand { get; private set; } - public RelayCommand SaveCommand { get; private set; } - public RelayCommand SaveAsCommand { get; private set; } - public RelayCommand CopyBlockCommand { get; private set; } - public RelayCommand CopyBlockStyleCommand { get; private set; } - public RelayCommand PasteCommand { get; private set; } - public RelayCommand PasteBlockStyleCommand { get; private set; } - public RelayCommand CopyScriptCommand { get; private set; } - public RelayCommand NewScriptCommand { get; private set; } - public RelayCommand CloseCommand { get; private set; } - public RelayCommand OpenAboutWindowCommand { get; private set; } - public RelayCommand ReplaceColorsCommand { get; private set; } + public RelayCommand OpenScriptCommand { get; } + public RelayCommand OpenThemeCommand { get; } + public RelayCommand SaveCommand { get; } + public RelayCommand SaveAsCommand { get; } + public RelayCommand CopyBlockCommand { get; } + public RelayCommand CopyBlockStyleCommand { get; } + public RelayCommand PasteCommand { get; } + public RelayCommand PasteBlockStyleCommand { get; } + public RelayCommand CopyScriptCommand { get; } + public RelayCommand NewScriptCommand { get; } + public RelayCommand CloseCommand { get; } + public RelayCommand OpenAboutWindowCommand { get; } + public RelayCommand ReplaceColorsCommand { get; } - public RelayCommand EditMasterThemeCommand { get; private set; } - public RelayCommand CreateThemeCommand { get; private set; } - public RelayCommand ApplyThemeToScriptCommand { get; private set; } + public RelayCommand EditMasterThemeCommand { get; } + public RelayCommand CreateThemeCommand { get; } + public RelayCommand ApplyThemeToScriptCommand { get; } - public RelayCommand AddTextColorThemeComponentCommand { get; private set; } - public RelayCommand AddBackgroundColorThemeComponentCommand { get; private set; } - public RelayCommand AddBorderColorThemeComponentCommand { get; private set; } - public RelayCommand DeleteThemeComponentCommand { get; private set; } + public RelayCommand AddTextColorThemeComponentCommand { get; } + public RelayCommand AddBackgroundColorThemeComponentCommand { get; } + public RelayCommand AddBorderColorThemeComponentCommand { get; } + public RelayCommand DeleteThemeComponentCommand { get; } - public RelayCommand AddBlockCommand { get; private set; } - public RelayCommand AddSectionCommand { get; private set; } - public RelayCommand DeleteBlockCommand { get; private set; } - public RelayCommand DisableBlockCommand { get; private set; } - public RelayCommand EnableBlockCommand { get; private set; } + public RelayCommand AddBlockCommand { get; } + public RelayCommand AddSectionCommand { get; } + public RelayCommand DeleteBlockCommand { get; } + public RelayCommand DisableBlockCommand { get; } + public RelayCommand EnableBlockCommand { get; } - public RelayCommand MoveBlockUpCommand { get; private set; } - public RelayCommand MoveBlockDownCommand { get; private set; } - public RelayCommand MoveBlockToTopCommand { get; private set; } - public RelayCommand MoveBlockToBottomCommand { get; private set; } + public RelayCommand MoveBlockUpCommand { get; } + public RelayCommand MoveBlockDownCommand { get; } + public RelayCommand MoveBlockToTopCommand { get; } + public RelayCommand MoveBlockToBottomCommand { get; } - public RelayCommand ExpandAllBlocksCommand { get; private set; } - public RelayCommand CollapseAllBlocksCommand { get; private set; } + public RelayCommand ExpandAllBlocksCommand { get; } + public RelayCommand CollapseAllBlocksCommand { get; } - public RelayCommand ToggleShowAdvancedCommand { get; private set; } - public RelayCommand ClearFiltersCommand { get; private set; } + public RelayCommand ToggleShowAdvancedCommand { get; } + public RelayCommand ClearFiltersCommand { get; } public void CheckForUpdates() @@ -263,9 +259,9 @@ namespace Filtration.ViewModels } catch (Exception e) { - if (_logger.IsDebugEnabled) + if (Logger.IsDebugEnabled) { - _logger.Debug(e); + Logger.Debug(e); } // We don't care if the update check fails, because it could fail for multiple reasons // including the user blocking Filtration in their firewall. @@ -281,15 +277,9 @@ namespace Filtration.ViewModels public ImageSource Icon { get; private set; } - public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel - { - get { return _avalonDockWorkspaceViewModel; } - } + public IAvalonDockWorkspaceViewModel AvalonDockWorkspaceViewModel => _avalonDockWorkspaceViewModel; - public ISettingsPageViewModel SettingsPageViewModel - { - get { return _settingsPageViewModel; } - } + public ISettingsPageViewModel SettingsPageViewModel { get; } public string WindowTitle { @@ -311,48 +301,24 @@ namespace Filtration.ViewModels } } - public bool ActiveDocumentIsScript - { - get { return _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; } - } + public bool ActiveDocumentIsScript => _avalonDockWorkspaceViewModel.ActiveDocument != null && _avalonDockWorkspaceViewModel.ActiveDocument.IsScript; - public bool ActiveDocumentIsTheme - { - get { return _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; } - } + public bool ActiveDocumentIsTheme => _avalonDockWorkspaceViewModel.ActiveDocument!= null && _avalonDockWorkspaceViewModel.ActiveDocument.IsTheme; - public bool ActiveScriptHasSelectedBlock - { - get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; } - } + public bool ActiveScriptHasSelectedBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel != null; - public bool ActiveScriptHasSelectedEnabledBlock - { - get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedEnabledBlock(); } - } + public bool ActiveScriptHasSelectedEnabledBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedEnabledBlock(); - public bool ActiveScriptHasSelectedDisabledBlock - { - get { return AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedDisabledBlock(); } - } - - public bool ActiveThemeIsEditable - { - get { return AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; } - } + public bool ActiveScriptHasSelectedDisabledBlock => AvalonDockWorkspaceViewModel.ActiveScriptViewModel.HasSelectedDisabledBlock(); + + public bool ActiveThemeIsEditable => AvalonDockWorkspaceViewModel.ActiveThemeViewModel.IsMasterTheme; private bool ActiveDocumentIsEditable() { return AvalonDockWorkspaceViewModel.ActiveDocument is IEditableDocument; } - public bool ShowAdvancedStatus - { - get - { - return ActiveDocumentIsScript && _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ShowAdvanced; - } - } + public bool ShowAdvancedStatus => ActiveDocumentIsScript && _avalonDockWorkspaceViewModel.ActiveScriptViewModel.ShowAdvanced; public async Task OpenDroppedFilesAsync(List filenames) { @@ -442,9 +408,9 @@ namespace Filtration.ViewModels catch (IOException e) { Messenger.Default.Send(new NotificationMessage("HideLoadingBanner")); - if (_logger.IsErrorEnabled) + if (Logger.IsErrorEnabled) { - _logger.Error(e); + Logger.Error(e); } _messageBoxService.Show("Script Load Error", "Error loading filter script - " + e.Message, MessageBoxButton.OK, @@ -477,9 +443,9 @@ namespace Filtration.ViewModels } catch (IOException e) { - if (_logger.IsErrorEnabled) + if (Logger.IsErrorEnabled) { - _logger.Error(e); + Logger.Error(e); } _messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message, MessageBoxButton.OK, @@ -506,9 +472,9 @@ namespace Filtration.ViewModels } catch (IOException e) { - if (_logger.IsErrorEnabled) + if (Logger.IsErrorEnabled) { - _logger.Error(e); + Logger.Error(e); } _messageBoxService.Show("Theme Load Error", "Error loading filter theme - " + e.Message, MessageBoxButton.OK, diff --git a/Filtration/ViewModels/ReplaceColorsViewModel.cs b/Filtration/ViewModels/ReplaceColorsViewModel.cs index 688009a..db89ec5 100644 --- a/Filtration/ViewModels/ReplaceColorsViewModel.cs +++ b/Filtration/ViewModels/ReplaceColorsViewModel.cs @@ -62,15 +62,7 @@ namespace Filtration.ViewModels _itemFilterScript = itemFilterScript; } - public ObservableCollection AvailableColors - { - get - { - { - return PathOfExileColors.DefaultColors; - } - } - } + public ObservableCollection AvailableColors => PathOfExileColors.DefaultColors; public Color NewTextColor { @@ -83,15 +75,9 @@ namespace Filtration.ViewModels } } - public Color DisplayTextColor - { - get - { - return _replaceColorsParameterSet.ReplaceTextColor - ? _replaceColorsParameterSet.NewTextColor - : new Color {A = 255, R = 255, G = 255, B = 255}; - } - } + public Color DisplayTextColor => _replaceColorsParameterSet.ReplaceTextColor + ? _replaceColorsParameterSet.NewTextColor + : new Color {A = 255, R = 255, G = 255, B = 255}; public bool ReplaceTextColor { @@ -114,15 +100,9 @@ namespace Filtration.ViewModels } } - public Color DisplayBackgroundColor - { - get - { - return _replaceColorsParameterSet.ReplaceBackgroundColor - ? _replaceColorsParameterSet.NewBackgroundColor - : new Color { A = 255, R = 0, G = 0, B = 0 }; - } - } + public Color DisplayBackgroundColor => _replaceColorsParameterSet.ReplaceBackgroundColor + ? _replaceColorsParameterSet.NewBackgroundColor + : new Color { A = 255, R = 0, G = 0, B = 0 }; public bool ReplaceBackgroundColor { @@ -145,15 +125,9 @@ namespace Filtration.ViewModels } } - public Color DisplayBorderColor - { - get - { - return _replaceColorsParameterSet.ReplaceBorderColor - ? _replaceColorsParameterSet.NewBorderColor - : new Color { A = 255, R = 0, G = 0, B = 0 }; - } - } + public Color DisplayBorderColor => _replaceColorsParameterSet.ReplaceBorderColor + ? _replaceColorsParameterSet.NewBorderColor + : new Color { A = 255, R = 0, G = 0, B = 0 }; public bool ReplaceBorderColor { @@ -165,13 +139,7 @@ namespace Filtration.ViewModels } } - public ReplaceColorsParameterSet ReplaceColorsParameterSet - { - get - { - return _replaceColorsParameterSet; - } - } + public ReplaceColorsParameterSet ReplaceColorsParameterSet => _replaceColorsParameterSet; public void Initialise(ItemFilterScript itemFilterScript) { diff --git a/Filtration/ViewModels/StartPageViewModel.cs b/Filtration/ViewModels/StartPageViewModel.cs index e66e2fd..aab59e4 100644 --- a/Filtration/ViewModels/StartPageViewModel.cs +++ b/Filtration/ViewModels/StartPageViewModel.cs @@ -23,8 +23,8 @@ namespace Filtration.ViewModels public RelayCommand OpenScriptCommand { get; private set; } public RelayCommand NewScriptCommand { get; private set; } - public bool IsScript { get { return false; } } - public bool IsTheme { get { return false; } } + public bool IsScript => false; + public bool IsTheme => false; public Task Close() { diff --git a/Filtration/ViewModels/ToolPanes/BlockGroupBrowserViewModel.cs b/Filtration/ViewModels/ToolPanes/BlockGroupBrowserViewModel.cs index d4c0630..92d9152 100644 --- a/Filtration/ViewModels/ToolPanes/BlockGroupBrowserViewModel.cs +++ b/Filtration/ViewModels/ToolPanes/BlockGroupBrowserViewModel.cs @@ -69,7 +69,7 @@ namespace Filtration.ViewModels.ToolPanes } } - public RelayCommand FilterToSelectedBlockGroupCommand { get; private set; } + public RelayCommand FilterToSelectedBlockGroupCommand { get; } public ObservableCollection BlockGroupViewModels { diff --git a/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs b/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs index 6b3a722..4370b4d 100644 --- a/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs +++ b/Filtration/ViewModels/ToolPanes/BlockOutputPreviewViewModel.cs @@ -34,12 +34,12 @@ namespace Filtration.ViewModels.ToolPanes { case "SelectedBlockChanged": { - OnSelectedBlockChanged(null, null); + OnSelectedBlockChanged(this, EventArgs.Empty); break; } case "ActiveDocumentChanged": { - OnSelectedBlockChanged(null, null); + OnSelectedBlockChanged(this, EventArgs.Empty); break; } } @@ -66,8 +66,7 @@ namespace Filtration.ViewModels.ToolPanes private void OnSelectedBlockChanged(object sender, EventArgs e) { - if (AvalonDockWorkspaceViewModel.ActiveScriptViewModel == null || - AvalonDockWorkspaceViewModel.ActiveScriptViewModel.SelectedBlockViewModel == null) + if (AvalonDockWorkspaceViewModel.ActiveScriptViewModel?.SelectedBlockViewModel == null) { PreviewText = string.Empty; return; diff --git a/Filtration/ViewModels/UpdateAvailableViewModel.cs b/Filtration/ViewModels/UpdateAvailableViewModel.cs index 04a47a5..383d3f3 100644 --- a/Filtration/ViewModels/UpdateAvailableViewModel.cs +++ b/Filtration/ViewModels/UpdateAvailableViewModel.cs @@ -42,25 +42,13 @@ namespace Filtration.ViewModels _updateData = updateData; } - public string CurrentVersion - { - get { return _currentVersionMajorPart + "." + _currentVersionMinorPart; } - } + public string CurrentVersion => _currentVersionMajorPart + "." + _currentVersionMinorPart; - public string NewVersion - { - get { return _updateData.LatestVersionMajorPart + "." + _updateData.LatestVersionMinorPart; } - } + public string NewVersion => _updateData.LatestVersionMajorPart + "." + _updateData.LatestVersionMinorPart; - public string ReleaseNotes - { - get { return _updateData.ReleaseNotes; } - } + public string ReleaseNotes => _updateData.ReleaseNotes; - public DateTime ReleaseDate - { - get { return _updateData.ReleaseDate; } - } + public DateTime ReleaseDate => _updateData.ReleaseDate; private void OnDownloadCommand() { @@ -83,10 +71,7 @@ namespace Filtration.ViewModels private void CloseWindow() { - if (OnRequestClose != null) - { - OnRequestClose(this, new EventArgs()); - } + OnRequestClose?.Invoke(this, new EventArgs()); } } diff --git a/Filtration/Views/AttachedProperties/SelectingItemAttachedProperty.cs b/Filtration/Views/AttachedProperties/SelectingItemAttachedProperty.cs index 998a26c..c541d67 100644 --- a/Filtration/Views/AttachedProperties/SelectingItemAttachedProperty.cs +++ b/Filtration/Views/AttachedProperties/SelectingItemAttachedProperty.cs @@ -25,7 +25,7 @@ namespace Filtration.Views.AttachedProperties static void OnSelectingItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var listBox = sender as ListBox; - if (listBox == null || listBox.SelectedItem == null) + if (listBox?.SelectedItem == null) { return; } diff --git a/Filtration/Views/AvalonDock/LayoutInitializer.cs b/Filtration/Views/AvalonDock/LayoutInitializer.cs index ea18534..5be2905 100644 --- a/Filtration/Views/AvalonDock/LayoutInitializer.cs +++ b/Filtration/Views/AvalonDock/LayoutInitializer.cs @@ -12,8 +12,7 @@ namespace Filtration.Views.AvalonDock //just for test provide a new anchorablepane //if the pane is floating let the manager go ahead LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane; - if (destinationContainer != null && - destinationContainer.FindParent() != null) + if (destinationContainer?.FindParent() != null) return false; if (anchorableToShow.Content is SectionBrowserViewModel) diff --git a/Filtration/Views/Behaviors/BindableSelectedItemBehavior.cs b/Filtration/Views/Behaviors/BindableSelectedItemBehavior.cs index 6a82b47..a62cbdd 100644 --- a/Filtration/Views/Behaviors/BindableSelectedItemBehavior.cs +++ b/Filtration/Views/Behaviors/BindableSelectedItemBehavior.cs @@ -22,10 +22,7 @@ namespace Filtration.Views.Behaviors private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var item = e.NewValue as TreeViewItem; - if (item != null) - { - item.SetValue(TreeViewItem.IsSelectedProperty, true); - } + item?.SetValue(TreeViewItem.IsSelectedProperty, true); } #endregion diff --git a/Filtration/Views/ItemFilterBlockView.xaml b/Filtration/Views/ItemFilterBlockView.xaml index e7cfdac..724e827 100644 --- a/Filtration/Views/ItemFilterBlockView.xaml +++ b/Filtration/Views/ItemFilterBlockView.xaml @@ -16,7 +16,7 @@ - +