diff --git a/Filtration.ObjectModel/Enums/IconColor.cs b/Filtration.ObjectModel/Enums/IconColor.cs index 7b143ba..9d05dfb 100644 --- a/Filtration.ObjectModel/Enums/IconColor.cs +++ b/Filtration.ObjectModel/Enums/IconColor.cs @@ -1,17 +1,23 @@ using System.ComponentModel; namespace Filtration.ObjectModel.Enums -{ - public enum IconColor +{ + /// + /// Each of the colors supported by the MinimapIcon block rule. + /// + /// + /// The ordering here should match the ordering of the colors within the source image. + /// + public enum IconColor { - [Description("Red")] + [Description("Blue")] + Blue, + [Description("Green")] + Green, + [Description("Brown")] + Brown, + [Description("Red")] Red, - [Description("Green")] - Green, - [Description("Blue")] - Blue, - [Description("Brown")] - Brown, [Description("White")] White, [Description("Yellow")] diff --git a/Filtration.ObjectModel/Enums/IconShape.cs b/Filtration.ObjectModel/Enums/IconShape.cs index 9123d27..5704d99 100644 --- a/Filtration.ObjectModel/Enums/IconShape.cs +++ b/Filtration.ObjectModel/Enums/IconShape.cs @@ -1,8 +1,14 @@ using System.ComponentModel; namespace Filtration.ObjectModel.Enums -{ - public enum IconShape +{ + /// + /// Each of the shapes supported by the MinimapIcon block rule. + /// + /// + /// The ordering here should match the ordering of the shapes within the source image. + /// + public enum IconShape { [Description("Circle")] Circle, diff --git a/Filtration.ObjectModel/Enums/IconSize.cs b/Filtration.ObjectModel/Enums/IconSize.cs index 5cb086b..305fd62 100644 --- a/Filtration.ObjectModel/Enums/IconSize.cs +++ b/Filtration.ObjectModel/Enums/IconSize.cs @@ -1,8 +1,14 @@ using System.ComponentModel; namespace Filtration.ObjectModel.Enums -{ - public enum IconSize +{ + /// + /// Each of the sizes supported by the MinimapIcon block rule. + /// + /// + /// The ordering here should match the ordering of the sizes within the source image. + /// + public enum IconSize { [Description("Largest")] Largest, diff --git a/Filtration/Converters/IconShapeToSourceConverter.cs b/Filtration/Converters/IconShapeToSourceConverter.cs deleted file mode 100644 index c727045..0000000 --- a/Filtration/Converters/IconShapeToSourceConverter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Filtration.ObjectModel.Enums; -using System; -using System.Globalization; -using System.Windows.Data; - -namespace Filtration.Converters -{ - internal class IconShapeToSourceConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - var iconShape = (IconShape)(int)value; - switch (iconShape) - { - case IconShape.Circle: - return "/Filtration;component/Resources/DropIcons/Circle.png"; - case IconShape.Diamond: - return "/Filtration;component/Resources/DropIcons/Diamond.png"; - case IconShape.Hexagon: - return "/Filtration;component/Resources/DropIcons/Hexagon.png"; - case IconShape.Square: - return "/Filtration;component/Resources/DropIcons/Square.png"; - case IconShape.Star: - return "/Filtration;component/Resources/DropIcons/Star.png"; - case IconShape.Triangle: - return "/Filtration;component/Resources/DropIcons/Triangle.png"; - } - - return "/Filtration;component/Resources/DropIcons/NoIcon.png"; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/Filtration/Converters/MinimapIconToCroppedBitmapConverter.cs b/Filtration/Converters/MinimapIconToCroppedBitmapConverter.cs new file mode 100644 index 0000000..6b32d29 --- /dev/null +++ b/Filtration/Converters/MinimapIconToCroppedBitmapConverter.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media.Imaging; +using Filtration.ObjectModel.Enums; + +namespace Filtration.Converters +{ + internal class MinimapIconToCroppedBitmapConverter : IMultiValueConverter + { + private static readonly int cellHeight = 64; + private static readonly int cellWidth = 64; + private static readonly int gridWidth = 14; + private static readonly int startColumn = 4; + private static readonly int startRow = 3; + private static readonly int emptyColumn = 2; + private static readonly int emptyRow = 11; + private static readonly int colorCount = 6; + private static readonly int shapeCount = 6; + private static readonly int sizeCount = 3; + + private static readonly Uri uri; + private static readonly CroppedBitmap empty; + private static readonly List bitmaps; + + static MinimapIconToCroppedBitmapConverter() + { + uri = new Uri("pack://application:,,,/Filtration;component/Resources/minimap_icons.png", UriKind.Absolute); + var sourceImage = new BitmapImage(uri); + + var emptyRect = new Int32Rect + { + Width = cellWidth, + Height = cellHeight, + X = emptyColumn * cellWidth, + Y = emptyRow * cellHeight + }; + + empty = new CroppedBitmap(new BitmapImage(uri), emptyRect); + bitmaps = new List(shapeCount * colorCount * sizeCount); + + var row = startRow; + var column = startColumn; + for (var i = 0; i < shapeCount; i++) { + for (var j = 0; j < colorCount; j++) { + for (var k = 0; k < sizeCount; k++) { + if (column == gridWidth) { + column = 0; + row++; + } + + var bitmapRect = new Int32Rect + { + Width = cellWidth, + Height = cellHeight, + X = column * cellWidth, + Y = row * cellWidth + }; + + bitmaps.Add(new CroppedBitmap(sourceImage, bitmapRect)); + column++; + } + } + } + } + + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values[0] == DependencyProperty.UnsetValue || + values[1] == DependencyProperty.UnsetValue || + values[2] == DependencyProperty.UnsetValue) { + return empty; + } + + var iconSize = (int)(values[0]); + var iconColor = (int)(values[1]); + var iconShape = (int)(values[2]); + + switch ((IconSize) iconSize) { + case IconSize.Largest: + case IconSize.Medium: + case IconSize.Small: + break; + default: + return empty; + } + + switch ((IconColor) iconColor) { + case IconColor.Blue: + case IconColor.Green: + case IconColor.Brown: + case IconColor.Red: + case IconColor.White: + case IconColor.Yellow: + break; + default: + return empty; + } + + switch ((IconShape) iconShape) { + case IconShape.Circle: + case IconShape.Diamond: + case IconShape.Hexagon: + case IconShape.Square: + case IconShape.Star: + case IconShape.Triangle: + break; + default: + return empty; + } + + var shapeOffset = iconShape * (sizeCount * colorCount); + var colorOffset = iconColor * sizeCount; + var iconIndex = shapeOffset + colorOffset + iconSize; + + if (iconIndex >= bitmaps.Count) { + return empty; + } else { + return bitmaps[iconIndex]; + } + } + + public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Filtration/Converters/SizeColorToRectConverter.cs b/Filtration/Converters/SizeColorToRectConverter.cs deleted file mode 100644 index 5facce6..0000000 --- a/Filtration/Converters/SizeColorToRectConverter.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; -using System.Windows.Data; - -namespace Filtration.Converters -{ - internal class SizeColorToRectConverter : IMultiValueConverter - { - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) - { - if (values[0] == DependencyProperty.UnsetValue || - values[1] == DependencyProperty.UnsetValue) - return new Rect(0, 0, 0, 0); - - var size = (int)(values[0]); - var color = (int)(values[1]); - - if (size < 0 || color < 0) - return new Rect(0, 0, 0, 0); - - var cropArea = new Rect - { - Width = 64, - Height = 64, - X = 0 + size * 64, - Y = 0 + color * 64 - }; - - return cropArea; - } - - public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/Filtration/Filtration.csproj b/Filtration/Filtration.csproj index 6a1ac98..93982db 100644 --- a/Filtration/Filtration.csproj +++ b/Filtration/Filtration.csproj @@ -167,9 +167,8 @@ - + - @@ -190,9 +189,6 @@ EditableListBoxControl.xaml - - ImageComboBoxControl.xaml - ItemPreviewControl.xaml @@ -233,10 +229,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -545,13 +537,7 @@ - - - - - - - + diff --git a/Filtration/Resources/DropIcons/Circle.png b/Filtration/Resources/DropIcons/Circle.png deleted file mode 100644 index 296d755..0000000 Binary files a/Filtration/Resources/DropIcons/Circle.png and /dev/null differ diff --git a/Filtration/Resources/DropIcons/Diamond.png b/Filtration/Resources/DropIcons/Diamond.png deleted file mode 100644 index 3c6041d..0000000 Binary files a/Filtration/Resources/DropIcons/Diamond.png and /dev/null differ diff --git a/Filtration/Resources/DropIcons/Hexagon.png b/Filtration/Resources/DropIcons/Hexagon.png deleted file mode 100644 index 1694503..0000000 Binary files a/Filtration/Resources/DropIcons/Hexagon.png and /dev/null differ diff --git a/Filtration/Resources/DropIcons/NoIcon.png b/Filtration/Resources/DropIcons/NoIcon.png deleted file mode 100644 index fb56f36..0000000 Binary files a/Filtration/Resources/DropIcons/NoIcon.png and /dev/null differ diff --git a/Filtration/Resources/DropIcons/Square.png b/Filtration/Resources/DropIcons/Square.png deleted file mode 100644 index 3b8e6e4..0000000 Binary files a/Filtration/Resources/DropIcons/Square.png and /dev/null differ diff --git a/Filtration/Resources/DropIcons/Star.png b/Filtration/Resources/DropIcons/Star.png deleted file mode 100644 index 2695433..0000000 Binary files a/Filtration/Resources/DropIcons/Star.png and /dev/null differ diff --git a/Filtration/Resources/DropIcons/Triangle.png b/Filtration/Resources/DropIcons/Triangle.png deleted file mode 100644 index 88f8ca1..0000000 Binary files a/Filtration/Resources/DropIcons/Triangle.png and /dev/null differ diff --git a/Filtration/Resources/minimap_icons.png b/Filtration/Resources/minimap_icons.png new file mode 100644 index 0000000..21e4ebf Binary files /dev/null and b/Filtration/Resources/minimap_icons.png differ diff --git a/Filtration/UserControls/ImageComboBoxControl.xaml b/Filtration/UserControls/ImageComboBoxControl.xaml deleted file mode 100644 index 88b1726..0000000 --- a/Filtration/UserControls/ImageComboBoxControl.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Filtration/UserControls/ImageComboBoxControl.xaml.cs b/Filtration/UserControls/ImageComboBoxControl.xaml.cs deleted file mode 100644 index 0921355..0000000 --- a/Filtration/UserControls/ImageComboBoxControl.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Filtration.UserControls -{ - /// - /// Interaction logic for ImageComboBoxControl.xaml - /// - public partial class ImageComboBoxControl : UserControl - { - public ImageComboBoxControl() - { - InitializeComponent(); - } - } -} diff --git a/Filtration/Views/ItemFilterBlockView.xaml b/Filtration/Views/ItemFilterBlockView.xaml index af675b4..d2d61fa 100644 --- a/Filtration/Views/ItemFilterBlockView.xaml +++ b/Filtration/Views/ItemFilterBlockView.xaml @@ -18,8 +18,7 @@ - - +