Skip to content

Commit

Permalink
Some small UI changes
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
coldino committed Apr 2, 2021
1 parent 33c8f47 commit 5a65679
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 43 deletions.
16 changes: 16 additions & 0 deletions LarkatorGUI/DummyNewSearch.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
28 changes: 14 additions & 14 deletions LarkatorGUI/FontSizeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
1 change: 1 addition & 0 deletions LarkatorGUI/LarkatorGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<Compile Include="DebounceDispatcher.cs" />
<Compile Include="DinoViewModel.cs" />
<Compile Include="DummyMainWindow.cs" />
<Compile Include="DummyNewSearch.cs" />
<Compile Include="ExternalToolsException.cs" />
<Compile Include="FileEntryBox.xaml.cs">
<DependentUpon>FileEntryBox.xaml</DependentUpon>
Expand Down
43 changes: 27 additions & 16 deletions LarkatorGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<Grid x:Name="leftPanel" Grid.Column="0" Width="240" MinHeight="200" Background="{DynamicResource WindowBackgroundBrush}">
<Grid x:Name="leftPanel" Grid.Column="0" Width="270" MinHeight="200" Background="{DynamicResource WindowBackgroundBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
Expand Down Expand Up @@ -319,26 +319,37 @@
<Button Width="32" FontFamily="Arial Black" FontSize="28" FontWeight="Bold" Padding="-4" Margin="16" Content="+" Click="CreateSearch_Click"
Visibility="{Binding CreateSearchAvailable, Converter={StaticResource BoolToVisibilityConverter}}"/>
<Grid Margin="16,0,16,16" Visibility="{Binding NewSearchActive, Converter={StaticResource BoolToVisibilityConverter}}" Background="#44ffffff">
<StackPanel Margin="8" Orientation="Vertical" HorizontalAlignment="Stretch" DataContext="{Binding NewSearch}">
<StackPanel Margin="8" Orientation="Vertical" HorizontalAlignment="Stretch" DataContext="{Binding NewSearch}" d:DataContext="{d:DesignInstance Type={x:Type local:DummyNewSearch}, IsDesignTimeCreatable=True}">
<ComboBox x:Name="groupsCombo" Text="{Binding Group}" IsEditable="True" />
<ComboBox x:Name="speciesCombo" Text="{Binding Species}" IsEditable="True" StaysOpenOnEdit="True" GotFocus="ComboOpen" AllowDrop="True"/>
<Grid Margin="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Min" HorizontalAlignment="Right" Margin="8,2"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Max" HorizontalAlignment="Right" Margin="8,2"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Partial match" HorizontalAlignment="Right" Margin="8,2"
ToolTip="Match species that contain the given string" />
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding MinLevel, ConverterParameter=-, Converter={StaticResource OptionalIntConverter}}"
HorizontalAlignment="Left" VerticalAlignment="Center" Width="32" TextAlignment="Center" MouseWheel="AdjustableInteger_MouseWheel"/>
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding MaxLevel, ConverterParameter=-, Converter={StaticResource OptionalIntConverter}}"
HorizontalAlignment="Left" VerticalAlignment="Center" Width="32" TextAlignment="Center" MouseWheel="AdjustableInteger_MouseWheel"/>
<CheckBox Grid.Column="1" Grid.Row="2" ToolTip="Match species that contain the given string" HorizontalAlignment="Left" Margin="6,4,0,0"
IsChecked="{Binding GroupSearch, FallbackValue=False}"/>
</Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4">
<TextBlock Text="Min "/>
<TextBlock Text="{Binding MinLevel, ConverterParameter=-, Converter={StaticResource OptionalIntConverter}}" MinWidth="64" MouseWheel="AdjustableInteger_MouseWheel"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4">
<TextBlock Text="Max "/>
<TextBlock Text="{Binding MinLevel, ConverterParameter=-, Converter={StaticResource OptionalIntConverter}}" MinWidth="64" MouseWheel="AdjustableInteger_MouseWheel"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4">
<TextBlock Text="Grouped search "/>
<CheckBox x:Name="groupCheck" ToolTip="Keyword search for a group of dinosaurs"
IsChecked="{Binding Source={StaticResource Settings}, Path=Default.GroupSearch, Mode=TwoWay}" HorizontalAlignment="Right"
Margin="7,4"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Width="32" FontFamily="Arial Black" FontSize="28" FontWeight="Bold" Padding="-4" Margin="4,0" Content="+" Click="SaveSearch_Click" />
<TextBlock VerticalAlignment="Center" MouseDown="CloseNewSearch_Click"><Underline><Run Text="X"/></Underline></TextBlock>
<Button Width="32" FontFamily="Arial Black" FontSize="28" FontWeight="Bold" Padding="-4" Margin="4,0" Content="+" Click="SaveSearch_Click" ToolTip="Save this search" />
<Button Click="CloseNewSearch_Click" BorderBrush="{x:Null}" BorderThickness="0" Background="{x:Null}" ToolTip="Cancel">
<fa:ImageAwesome Icon="Close" Width="10" Foreground="AntiqueWhite" Opacity="0.8"/>
</Button>
</StackPanel>
</StackPanel>
</Grid>
Expand Down
22 changes: 13 additions & 9 deletions LarkatorGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FastMember;
using FastMember;

using GongSolutions.Wpf.DragDrop;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions LarkatorGUI/MapPositionConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 5a65679

Please sign in to comment.