Skip to content

Commit

Permalink
Replaced search criteria and results lists with DataGrids
Browse files Browse the repository at this point in the history
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
  • Loading branch information
coldino committed Jan 30, 2018
1 parent 6e1c3e6 commit 20ad39a
Show file tree
Hide file tree
Showing 24 changed files with 1,193 additions and 2,346 deletions.
4 changes: 0 additions & 4 deletions Common/SearchCriteria.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Larkator.Common
{
Expand Down
18 changes: 0 additions & 18 deletions Larkator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions LarkatorGUI/AddIntConverter.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
3 changes: 3 additions & 0 deletions LarkatorGUI/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
<Application.Resources>

<SolidColorBrush x:Key="WindowBackgroundBrush" Color="#FF2D6BA8"/>
<SolidColorBrush x:Key="SelectionBackgroundBrush" Color="#22FAEBD7"/>

<local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<local:OptionalIntConverter x:Key="OptionalIntConverter"/>

<prop:Settings x:Key="Settings"/>

</Application.Resources>
Expand Down
5 changes: 0 additions & 5 deletions LarkatorGUI/DinoViewModel.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
55 changes: 55 additions & 0 deletions LarkatorGUI/DummyMainWindow.cs
Original file line number Diff line number Diff line change
@@ -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<SearchCriteria> ListSearches { get => searches; }
public Collection<DinoViewModel> ListResults { get => results; }

public MapCalibration MapCalibration { get => calibration; }

private Collection<SearchCriteria> searches = new Collection<SearchCriteria>()
{
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<DinoViewModel> results = new Collection<DinoViewModel>()
{
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) };
}
}
}
}
35 changes: 35 additions & 0 deletions LarkatorGUI/FontSizeHelper.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
}
7 changes: 3 additions & 4 deletions LarkatorGUI/LarkatorGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,21 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AddIntConverter.cs" />
<Compile Include="ArkReader.cs" />
<Compile Include="CalibrationWindow.xaml.cs">
<DependentUpon>CalibrationWindow.xaml</DependentUpon>
</Compile>
<Compile Include="DinoViewModel.cs" />
<Compile Include="DummyMainWindow.cs" />
<Compile Include="ExternalToolsException.cs" />
<Compile Include="DirectoryEntryBox.xaml.cs">
<DependentUpon>DirectoryEntryBox.xaml</DependentUpon>
</Compile>
<Compile Include="FileEntryBox.xaml.cs">
<DependentUpon>FileEntryBox.xaml</DependentUpon>
</Compile>
<Compile Include="FontSizeHelper.cs" />
<Compile Include="ListViewHackyCell.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
Expand Down Expand Up @@ -208,10 +211,6 @@
<Project>{3c4c5a9e-9165-4074-ae85-df62931457eb}</Project>
<Name>Common</Name>
</ProjectReference>
<ProjectReference Include="..\ListViewLayout\ListViewLayout.csproj">
<Project>{916a9879-3f2d-471f-aafa-28f0c8a7ffa9}</Project>
<Name>ListViewLayout</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="imgs\nogender.png" />
Expand Down
Loading

0 comments on commit 20ad39a

Please sign in to comment.