From 20ad39ae31b5a7a677e35d5e26c353dd15d4237b Mon Sep 17 00:00:00 2001 From: Anthony Purchase Date: Tue, 30 Jan 2018 22:50:32 +0000 Subject: [PATCH] Replaced search criteria and results lists with DataGrids ListView out. DataGrid in. Enables scrolling and better font-size handling. Added font size setting. Click a dot on the map to highlight the result in the list. Closes #11 --- Common/SearchCriteria.cs | 4 - Larkator.sln | 18 - LarkatorGUI/AddIntConverter.cs | 22 + LarkatorGUI/App.xaml | 3 + LarkatorGUI/DinoViewModel.cs | 5 - LarkatorGUI/DummyMainWindow.cs | 55 + LarkatorGUI/FontSizeHelper.cs | 35 + LarkatorGUI/LarkatorGUI.csproj | 7 +- LarkatorGUI/MainWindow.xaml | 590 ++++---- LarkatorGUI/MainWindow.xaml.cs | 1458 ++++++++++--------- LarkatorGUI/Properties/Settings.Designer.cs | 24 + LarkatorGUI/Properties/Settings.settings | 6 + LarkatorGUI/SettingsWindow.xaml | 18 +- LarkatorGUI/app.config | 6 + ListViewLayout/ConverterGridViewColumn.cs | 69 - ListViewLayout/FixedColumn.cs | 68 - ListViewLayout/ImageGridViewColumn.cs | 67 - ListViewLayout/LayoutColumn.cs | 54 - ListViewLayout/ListViewLayout.csproj | 109 -- ListViewLayout/ListViewLayout2008.csproj | 71 - ListViewLayout/ListViewLayoutManager.cs | 609 -------- ListViewLayout/Properties/AssemblyInfo.cs | 30 - ListViewLayout/ProportionalColumn.cs | 68 - ListViewLayout/RangeColumn.cs | 143 -- 24 files changed, 1193 insertions(+), 2346 deletions(-) create mode 100644 LarkatorGUI/AddIntConverter.cs create mode 100644 LarkatorGUI/DummyMainWindow.cs create mode 100644 LarkatorGUI/FontSizeHelper.cs delete mode 100644 ListViewLayout/ConverterGridViewColumn.cs delete mode 100644 ListViewLayout/FixedColumn.cs delete mode 100644 ListViewLayout/ImageGridViewColumn.cs delete mode 100644 ListViewLayout/LayoutColumn.cs delete mode 100644 ListViewLayout/ListViewLayout.csproj delete mode 100644 ListViewLayout/ListViewLayout2008.csproj delete mode 100644 ListViewLayout/ListViewLayoutManager.cs delete mode 100644 ListViewLayout/Properties/AssemblyInfo.cs delete mode 100644 ListViewLayout/ProportionalColumn.cs delete mode 100644 ListViewLayout/RangeColumn.cs diff --git a/Common/SearchCriteria.cs b/Common/SearchCriteria.cs index 8392060..d9292c3 100644 --- a/Common/SearchCriteria.cs +++ b/Common/SearchCriteria.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Larkator.Common { diff --git a/Larkator.sln b/Larkator.sln index 627ef70..9bf970c 100644 --- a/Larkator.sln +++ b/Larkator.sln @@ -9,8 +9,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LarkatorGUI", "LarkatorGUI\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{3C4C5A9E-9165-4074-AE85-DF62931457EB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListViewLayout", "ListViewLayout\ListViewLayout.csproj", "{916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{084A8862-6DEB-4188-9A7F-B587D700B59D}" ProjectSection(SolutionItems) = preProject README.md = README.md @@ -76,22 +74,6 @@ Global {3C4C5A9E-9165-4074-AE85-DF62931457EB}.Release|x64.Build.0 = Release|Any CPU {3C4C5A9E-9165-4074-AE85-DF62931457EB}.Release|x86.ActiveCfg = Release|Any CPU {3C4C5A9E-9165-4074-AE85-DF62931457EB}.Release|x86.Build.0 = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|ARM.ActiveCfg = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|ARM.Build.0 = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|x64.ActiveCfg = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|x64.Build.0 = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|x86.ActiveCfg = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Debug|x86.Build.0 = Debug|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|Any CPU.Build.0 = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|ARM.ActiveCfg = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|ARM.Build.0 = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|x64.ActiveCfg = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|x64.Build.0 = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|x86.ActiveCfg = Release|Any CPU - {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LarkatorGUI/AddIntConverter.cs b/LarkatorGUI/AddIntConverter.cs new file mode 100644 index 0000000..76e9e95 --- /dev/null +++ b/LarkatorGUI/AddIntConverter.cs @@ -0,0 +1,22 @@ +using System; +using System.Globalization; +using System.Windows.Data; + +namespace LarkatorGUI +{ + public class AddIntConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (double.TryParse((string)parameter, out var b) && value is double a) + return a + b; + + throw new InvalidOperationException(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new InvalidOperationException(); + } + } +} diff --git a/LarkatorGUI/App.xaml b/LarkatorGUI/App.xaml index 2b8bc5f..cedcabb 100644 --- a/LarkatorGUI/App.xaml +++ b/LarkatorGUI/App.xaml @@ -8,8 +8,11 @@ + + + diff --git a/LarkatorGUI/DinoViewModel.cs b/LarkatorGUI/DinoViewModel.cs index 4cfe49b..fbfcc00 100644 --- a/LarkatorGUI/DinoViewModel.cs +++ b/LarkatorGUI/DinoViewModel.cs @@ -1,9 +1,4 @@ using Larkator.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Media; diff --git a/LarkatorGUI/DummyMainWindow.cs b/LarkatorGUI/DummyMainWindow.cs new file mode 100644 index 0000000..3cb0388 --- /dev/null +++ b/LarkatorGUI/DummyMainWindow.cs @@ -0,0 +1,55 @@ +using Larkator.Common; +using System; +using System.Collections.ObjectModel; +using System.Linq; + +namespace LarkatorGUI +{ + public class DummyMainWindow + { + public string ApplicationVersion { get => "DUMMY"; } + + public Collection ListSearches { get => searches; } + public Collection ListResults { get => results; } + + public MapCalibration MapCalibration { get => calibration; } + + private Collection searches = new Collection() + { + new SearchCriteria { Species="Zombie", MaxLevel=4, Female=true, Group="Minecraft" }, + new SearchCriteria { Species="Creeper", MinLevel=100, Group="Minecraft" }, + new SearchCriteria { Species="Slender", MinLevel=50, Group="Other" }, + new SearchCriteria { Species="Kermit", Female=false, Group="Other" }, + }; + + private Collection results = new Collection() + { + new DinoViewModel(new Dino { BaseLevel=90, Location=new Position{ Lat=40,Lon=10 }, Name="Foud" }), + new DinoViewModel(new Dino { BaseLevel=150, Location=new Position{ Lat=10,Lon=10 }, Name="One" }), + new DinoViewModel(new Dino { BaseLevel=110, Location=new Position{ Lat=30,Lon=10 }, Name="Three" }), + new DinoViewModel(new Dino { BaseLevel=130, Location=new Position{ Lat=20,Lon=10 }, Name="Two" }), + }; + + private MapCalibration calibration = new MapCalibration + { + Filename = "TheIsland", + OffsetX = 13.75, + OffsetY = 23.75, + ScaleX = 9.8875, + ScaleY = 9.625 + }; + + public DummyMainWindow() + { + foreach (var i in Enumerable.Range(0, 40)) + searches.Add(new SearchCriteria { Species = "Long thingy name", Group = "Overrun" }); + + var rnd = new Random(); + foreach (var dvm in results) + { + dvm.Dino.Id = (ulong)rnd.Next(); + dvm.Dino.WildLevels = new StatPoints() { Health = rnd.Next(50), Stamina = rnd.Next(50), Melee = rnd.Next(50), Speed = rnd.Next(50), Weight = rnd.Next(50) }; + } + } + } +} diff --git a/LarkatorGUI/FontSizeHelper.cs b/LarkatorGUI/FontSizeHelper.cs new file mode 100644 index 0000000..8810716 --- /dev/null +++ b/LarkatorGUI/FontSizeHelper.cs @@ -0,0 +1,35 @@ +using System; +using System.Windows; +using System.Windows.Controls; + +namespace LarkatorGUI +{ + public sealed class FontSizeHelper + { + public static readonly DependencyProperty RelativeFontSizeProperty = DependencyProperty.RegisterAttached( + "RelativeFontSize", typeof(double), typeof(FontSizeHelper), new PropertyMetadata(0.0, RelativeFontSizeChanged)); + + public static double GetRelativeFontSize(DependencyObject d) + { + if (d == null) throw new ArgumentNullException(nameof(d), "in GetRelativeFontSize"); + + return (double)d.GetValue(RelativeFontSizeProperty); + } + + public static void SetRelativeFontSize(DependencyObject d, double value) + { + if (d == null) throw new ArgumentNullException(nameof(d), "in SetRelativeFontSize"); + + d.SetValue(RelativeFontSizeProperty, value); + } + + private static void RelativeFontSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d == null) throw new ArgumentNullException(nameof(d), "in RelativeFontSizeChanged"); + + d.ClearValue(TextBlock.FontSizeProperty); + var old = (double)d.GetValue(TextBlock.FontSizeProperty); + d.SetValue(TextBlock.FontSizeProperty, Math.Max(old + (double)e.NewValue, 0)); + } + } +} diff --git a/LarkatorGUI/LarkatorGUI.csproj b/LarkatorGUI/LarkatorGUI.csproj index 6bb7717..45af44a 100644 --- a/LarkatorGUI/LarkatorGUI.csproj +++ b/LarkatorGUI/LarkatorGUI.csproj @@ -107,11 +107,13 @@ MSBuild:Compile Designer + CalibrationWindow.xaml + DirectoryEntryBox.xaml @@ -119,6 +121,7 @@ FileEntryBox.xaml + MainWindow.xaml @@ -208,10 +211,6 @@ {3c4c5a9e-9165-4074-ae85-df62931457eb} Common - - {916a9879-3f2d-471f-aafa-28f0c8a7ffa9} - ListViewLayout - diff --git a/LarkatorGUI/MainWindow.xaml b/LarkatorGUI/MainWindow.xaml index 80f7896..f4ddfb5 100644 --- a/LarkatorGUI/MainWindow.xaml +++ b/LarkatorGUI/MainWindow.xaml @@ -5,13 +5,12 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:LarkatorGUI" xmlns:common="clr-namespace:Larkator.Common;assembly=Larkator.Common" - xmlns:lvl="clr-namespace:Itenso.Windows.Controls.ListViewLayout;assembly=Itenso.Windows.Controls.ListViewLayout" xmlns:fa="http://schemas.fontawesome.io/icons/" xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop" - xmlns:sysCol="clr-namespace:System.Collections;assembly=mscorlib" - xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" mc:Ignorable="d" x:Name="root" + d:DataContext="{d:DesignInstance Type={x:Type local:DummyMainWindow}, IsDesignTimeCreatable=True}" SourceInitialized="Window_SourceInitialized" Loaded="Window_Loaded" Title="{Binding WindowTitle}" Background="{DynamicResource WindowBackgroundBrush}" MaxHeight="1016" MinHeight="240" @@ -20,6 +19,7 @@ Width="{Binding Source={StaticResource Settings}, Path=Default.MainWindowWidth, Mode=TwoWay}" Height="{Binding Source={StaticResource Settings}, Path=Default.MainWindowHeight, Mode=TwoWay}"> + Hidden @@ -28,63 +28,119 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -101,6 +157,24 @@ + + + + + + + + + + + + + + + @@ -111,30 +185,17 @@ - - - - - - - - - - - - - - - - - + - - + + + + + + + + @@ -144,258 +205,165 @@ - + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - + - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -