From 5a656797cf41edc8d587fe8d8eef51f0e1ee3f87 Mon Sep 17 00:00:00 2001 From: coldino <28345893+coldino@users.noreply.github.com> Date: Fri, 2 Apr 2021 19:38:59 +0100 Subject: [PATCH] Some small UI changes * Rename "Group search" to "Partial match" * Increase width of left panel - a better solution will come later (for #43) * Improve savegame watcher cleanup * Change "New Search" layout as well as how partial matches are bound * Replace scuffed search cancel button with a proper one * Replaces `d` param in all converters to help debug a VS designer crash --- LarkatorGUI/DummyNewSearch.cs | 16 +++++++++++ LarkatorGUI/FontSizeHelper.cs | 28 +++++++++---------- LarkatorGUI/LarkatorGUI.csproj | 1 + LarkatorGUI/MainWindow.xaml | 43 ++++++++++++++++++----------- LarkatorGUI/MainWindow.xaml.cs | 22 +++++++++------ LarkatorGUI/MapPositionConverter.cs | 8 +++--- 6 files changed, 75 insertions(+), 43 deletions(-) create mode 100644 LarkatorGUI/DummyNewSearch.cs diff --git a/LarkatorGUI/DummyNewSearch.cs b/LarkatorGUI/DummyNewSearch.cs new file mode 100644 index 0000000..9397628 --- /dev/null +++ b/LarkatorGUI/DummyNewSearch.cs @@ -0,0 +1,16 @@ +using Larkator.Common; + +namespace LarkatorGUI +{ + public class DummyNewSearch : SearchCriteria + { + public DummyNewSearch() + { + this.Species = "Alpha "; + this.Group = "Shopping List"; + this.MinLevel = 100; + this.MaxLevel = 150; + this.GroupSearch = true; + } + } +} diff --git a/LarkatorGUI/FontSizeHelper.cs b/LarkatorGUI/FontSizeHelper.cs index 010208a..281231f 100644 --- a/LarkatorGUI/FontSizeHelper.cs +++ b/LarkatorGUI/FontSizeHelper.cs @@ -9,30 +9,30 @@ 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) + public static double GetRelativeFontSize(DependencyObject do_grfs) { - if (d == null) - throw new ArgumentNullException(nameof(d), "in GetRelativeFontSize"); + if (do_grfs == null) + throw new ArgumentNullException(nameof(do_grfs), "in GetRelativeFontSize"); - return (double)d.GetValue(RelativeFontSizeProperty); + return (double)do_grfs.GetValue(RelativeFontSizeProperty); } - public static void SetRelativeFontSize(DependencyObject d, double value) + public static void SetRelativeFontSize(DependencyObject do_srfs, double value) { - if (d == null) - throw new ArgumentNullException(nameof(d), "in SetRelativeFontSize"); + if (do_srfs == null) + throw new ArgumentNullException(nameof(do_srfs), "in SetRelativeFontSize"); - d.SetValue(RelativeFontSizeProperty, value); + do_srfs.SetValue(RelativeFontSizeProperty, value); } - private static void RelativeFontSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + private static void RelativeFontSizeChanged(DependencyObject do_rsfc, DependencyPropertyChangedEventArgs e) { - if (d == null) - throw new ArgumentNullException(nameof(d), "in RelativeFontSizeChanged"); + if (do_rsfc == null) + throw new ArgumentNullException(nameof(do_rsfc), "in RelativeFontSizeChanged"); - d.ClearValue(TextBlock.FontSizeProperty); - var old = (double)d.GetValue(TextBlock.FontSizeProperty); - d.SetValue(TextBlock.FontSizeProperty, Math.Max(old + (double)e.NewValue, 0)); + do_rsfc.ClearValue(TextBlock.FontSizeProperty); + var old = (double)do_rsfc.GetValue(TextBlock.FontSizeProperty); + do_rsfc.SetValue(TextBlock.FontSizeProperty, Math.Max(old + (double)e.NewValue, 0)); } } } diff --git a/LarkatorGUI/LarkatorGUI.csproj b/LarkatorGUI/LarkatorGUI.csproj index 05e5c1f..48dab04 100644 --- a/LarkatorGUI/LarkatorGUI.csproj +++ b/LarkatorGUI/LarkatorGUI.csproj @@ -118,6 +118,7 @@ + FileEntryBox.xaml diff --git a/LarkatorGUI/MainWindow.xaml b/LarkatorGUI/MainWindow.xaml index c7d9774..ea6ed19 100644 --- a/LarkatorGUI/MainWindow.xaml +++ b/LarkatorGUI/MainWindow.xaml @@ -232,7 +232,7 @@ - + @@ -319,26 +319,37 @@ diff --git a/LarkatorGUI/MainWindow.xaml.cs b/LarkatorGUI/MainWindow.xaml.cs index 34f15df..6523e3b 100644 --- a/LarkatorGUI/MainWindow.xaml.cs +++ b/LarkatorGUI/MainWindow.xaml.cs @@ -1,4 +1,4 @@ -using FastMember; +using FastMember; using GongSolutions.Wpf.DragDrop; @@ -238,7 +238,11 @@ private static string CalculateApplicationVersion() private void SetupFileWatcher() { if (fileWatcher != null) + { fileWatcher.EnableRaisingEvents = false; + fileWatcher.Dispose(); + } + fileWatcher = new FileSystemWatcher(Path.GetDirectoryName(Properties.Settings.Default.SaveFile)); fileWatcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.CreationTime; fileWatcher.Renamed += FileWatcher_Changed; @@ -500,6 +504,7 @@ private void CreateSearch_Click(object sender, RoutedEventArgs e) speciesCombo.ItemsSource = arkReader.AllSpecies; groupsCombo.ItemsSource = ListSearches.Select(sc => sc.Group).Distinct().OrderBy(g => g).ToArray(); groupsCombo.SelectedItem = Properties.Settings.Default.LastGroup; + NewSearch.GroupSearch = Properties.Settings.Default.GroupSearch; } private void Dev_Calibration_Click(object sender, MouseButtonEventArgs e) @@ -656,11 +661,10 @@ private void SaveSearch_Click(object sender, RoutedEventArgs e) Properties.Settings.Default.LastGroup = "Shopping List"; } //Set and save property - Properties.Settings.Default.GroupSearch = (bool)groupCheck.IsChecked; + Properties.Settings.Default.GroupSearch = NewSearch.GroupSearch; Properties.Settings.Default.Save(); - - if (NewSearchList.Count == 0) // No matches + if (NewSearchList.Count == 0 && !NewSearch.GroupSearch) // No matches { //Trigger default values so the user knows we did search to match NewSearch = null; tempSearch = null; @@ -673,13 +677,13 @@ private void SaveSearch_Click(object sender, RoutedEventArgs e) { order = (int)ListSearches.Where(sc => sc.Group == NewSearch.Group).Max(sc => sc.Order) + 100; } - //check for group based search - if (Properties.Settings.Default.GroupSearch) + //Check for group based search + if (NewSearch.GroupSearch) { tempSearch = new SearchCriteria(NewSearch); tempSearch.Species = NewSearch.Species; tempSearch.Order = order; //Sort order - tempSearch.GroupSearch = Properties.Settings.Default.GroupSearch; + tempSearch.GroupSearch = NewSearch.GroupSearch; ListSearches.Add(tempSearch); } else @@ -693,7 +697,7 @@ private void SaveSearch_Click(object sender, RoutedEventArgs e) tempSearch = new SearchCriteria(NewSearch); tempSearch.Species = newDino; tempSearch.Order = order; - tempSearch.GroupSearch = Properties.Settings.Default.GroupSearch; + tempSearch.GroupSearch = NewSearch.GroupSearch; ListSearches.Add(tempSearch); order += 100; } @@ -712,7 +716,7 @@ private void SaveSearch_Click(object sender, RoutedEventArgs e) MarkSearchesChanged(); } - private void CloseNewSearch_Click(object sender, MouseButtonEventArgs e) + private void CloseNewSearch_Click(object sender, RoutedEventArgs e) { NewSearchActive = false; CreateSearchAvailable = true; diff --git a/LarkatorGUI/MapPositionConverter.cs b/LarkatorGUI/MapPositionConverter.cs index 250f4e3..708acac 100644 --- a/LarkatorGUI/MapPositionConverter.cs +++ b/LarkatorGUI/MapPositionConverter.cs @@ -36,12 +36,12 @@ public static void SetPosition(DependencyObject obj, Position value) DependencyProperty.RegisterAttached("Calibration", typeof(MapCalibration), typeof(MapPositionConverter), new PropertyMetadata(null, OnChanged)); - public static void OnChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + public static void OnChanged(DependencyObject do_mpoc, DependencyPropertyChangedEventArgs e) { - if (d is TranslateTransform tx) + if (do_mpoc is TranslateTransform tx) { - var cal = GetCalibration(d); - var pos = GetPosition(d); + var cal = GetCalibration(do_mpoc); + var pos = GetPosition(do_mpoc); if (cal == null || pos == null) return;