-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added each of the standard maps. Added coordinate calibrations for each map that should be good, but are mostly untested. When a development version is run there are now additional buttons for map calibration and dummy map points. Loading species in the background is now more visible, with status bar text and showing the loading cog.
- Loading branch information
Showing
16 changed files
with
652 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<Window x:Class="LarkatorGUI.CalibrationWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:LarkatorGUI" | ||
mc:Ignorable="d" | ||
d:DataContext="{d:DesignInstance local:Calibration, IsDesignTimeCreatable=True}" | ||
Title="CalibrationWindow" SizeToContent="WidthAndHeight"> | ||
<Grid x:Name="grid"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
<Canvas Grid.Row="0" Panel.ZIndex="100"> | ||
<Line StrokeThickness="2" Stroke="HotPink" X1="0" X2="1000" Y1="{Binding Bounds.Y1}" Y2="{Binding Bounds.Y1}"/> | ||
<Line StrokeThickness="2" Stroke="HotPink" X1="0" X2="1000" Y1="{Binding Bounds.Y2}" Y2="{Binding Bounds.Y2}"/> | ||
<Line StrokeThickness="2" Stroke="HotPink" Y1="0" Y2="1000" X1="{Binding Bounds.X1}" X2="{Binding Bounds.X1}"/> | ||
<Line StrokeThickness="2" Stroke="HotPink" Y1="0" Y2="1000" X1="{Binding Bounds.X2}" X2="{Binding Bounds.X2}"/> | ||
</Canvas> | ||
<Image x:Name="img" Grid.Row="0" Source="{Binding Image}" Height="1000" Width="1000" Stretch="Uniform" MouseDown="Image_MouseDown" MouseUp="Image_MouseUp" MouseMove="Image_MouseMove"/> | ||
<Grid Grid.Row="1" HorizontalAlignment="Center"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto"/> | ||
<ColumnDefinition Width="Auto"/> | ||
</Grid.ColumnDefinitions> | ||
<StackPanel Orientation="Vertical" Margin="8"> | ||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4"> | ||
<TextBlock Text="X1" Margin="8,2"/> | ||
<TextBox Text="{Binding Bounds.X1, Mode=TwoWay}" Width="64"/> | ||
<TextBlock Text="X2" Margin="8,2"/> | ||
<TextBox Text="{Binding Bounds.X2, Mode=TwoWay}" Width="64"/> | ||
<TextBlock Text="Y1" Margin="8,2"/> | ||
<TextBox Text="{Binding Bounds.Y1, Mode=TwoWay}" Width="64"/> | ||
<TextBlock Text="Y1" Margin="8,2"/> | ||
<TextBox Text="{Binding Bounds.Y2, Mode=TwoWay}" Width="64"/> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4"> | ||
<TextBlock Text="ARK filename" Margin="8,2"/> | ||
<TextBox Text="{Binding Filename, Mode=TwoWay}" Width="100"/> | ||
<TextBlock Text="Image" Margin="8,2"/> | ||
<TextBox Text="{Binding Image, Mode=TwoWay}" Width="100"/> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="4"> | ||
<TextBlock Text="+X" Margin="8,2"/> | ||
<TextBox Text="{Binding OffsetX}" Width="32"/> | ||
<TextBlock Text="+Y" Margin="8,2"/> | ||
<TextBox Text="{Binding OffsetY}" Width="32"/> | ||
<TextBlock Text="*X" Margin="8,2"/> | ||
<TextBox Text="{Binding ScaleX}" Width="64"/> | ||
<TextBlock Text="*Y" Margin="8,2"/> | ||
<TextBox Text="{Binding ScaleY}" Width="64"/> | ||
</StackPanel> | ||
</StackPanel> | ||
<TextBox Grid.Column="1" Text="{Binding Output}" Margin="8" MinWidth="300" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" IsReadOnly="True"/> | ||
</Grid> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.Serialization; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
|
||
namespace LarkatorGUI | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CalibrationWindow.xaml | ||
/// </summary> | ||
public partial class CalibrationWindow : Window | ||
{ | ||
private bool dragging; | ||
private Bounds boundsMult; | ||
private Calibration calibration; | ||
|
||
public CalibrationWindow(Calibration calibration) | ||
{ | ||
DataContext = calibration; | ||
this.calibration = calibration; | ||
|
||
InitializeComponent(); | ||
} | ||
|
||
private void Image_MouseDown(object sender, MouseButtonEventArgs e) | ||
{ | ||
var img = (Image)sender; | ||
var pos = Mouse.GetPosition(img); | ||
pos.X /= img.ActualWidth; | ||
pos.Y /= img.ActualHeight; | ||
|
||
dragging = true; | ||
boundsMult = new Bounds | ||
{ | ||
X1 = pos.X < 0.5 ? 1 : 0, | ||
X2 = pos.X > 0.5 ? 1 : 0, | ||
Y1 = pos.Y < 0.5 ? 1 : 0, | ||
Y2 = pos.Y > 0.5 ? 1 : 0 | ||
}; | ||
|
||
img.CaptureMouse(); | ||
} | ||
|
||
private void Image_MouseUp(object sender, MouseButtonEventArgs e) | ||
{ | ||
if (!dragging) return; | ||
var img = (Image)sender; | ||
img.ReleaseMouseCapture(); | ||
dragging = false; | ||
} | ||
|
||
private void Image_MouseMove(object sender, MouseEventArgs e) | ||
{ | ||
if (!dragging) return; | ||
|
||
var img = (Image)sender; | ||
var pos = Mouse.GetPosition(img); | ||
|
||
calibration.Bounds.X1 = UpdateBound(calibration.Bounds.X1, boundsMult.X1, pos.X); | ||
calibration.Bounds.X2 = UpdateBound(calibration.Bounds.X2, boundsMult.X2, pos.X); | ||
calibration.Bounds.Y1 = UpdateBound(calibration.Bounds.Y1, boundsMult.Y1, pos.Y); | ||
calibration.Bounds.Y2 = UpdateBound(calibration.Bounds.Y2, boundsMult.Y2, pos.Y); | ||
|
||
calibration.Recalculate(); | ||
} | ||
|
||
private double UpdateBound(double cal, double mult, double x) | ||
{ | ||
return cal * (1 - mult) + x * mult; | ||
} | ||
} | ||
|
||
public class ExampleCalibration : Calibration | ||
{ | ||
public ExampleCalibration() | ||
{ | ||
Bounds = new Bounds { X1 = 100, X2 = 800, Y1 = 150, Y2 = 750 }; | ||
} | ||
} | ||
|
||
[DataContract] | ||
public class Calibration : DependencyObject | ||
{ | ||
[JsonIgnore] | ||
public Bounds Bounds | ||
{ | ||
get { return (Bounds)GetValue(BoundsProperty); } | ||
set { SetValue(BoundsProperty, value); } | ||
} | ||
|
||
[DataMember] | ||
public string Filename | ||
{ | ||
get { return (string)GetValue(FilenameProperty); } | ||
set { SetValue(FilenameProperty, value); } | ||
} | ||
|
||
[DataMember] | ||
public double OffsetX | ||
{ | ||
get { return (double)GetValue(OffsetXProperty); } | ||
set { SetValue(OffsetXProperty, value); } | ||
} | ||
|
||
[DataMember] | ||
public double OffsetY | ||
{ | ||
get { return (double)GetValue(OffsetYProperty); } | ||
set { SetValue(OffsetYProperty, value); } | ||
} | ||
|
||
[DataMember] | ||
public double ScaleX | ||
{ | ||
get { return (double)GetValue(ScaleXProperty); } | ||
set { SetValue(ScaleXProperty, value); } | ||
} | ||
|
||
[DataMember] | ||
public double ScaleY | ||
{ | ||
get { return (double)GetValue(ScaleYProperty); } | ||
set { SetValue(ScaleYProperty, value); } | ||
} | ||
|
||
[JsonIgnore] | ||
public string Output | ||
{ | ||
get { return (string)GetValue(OutputProperty); } | ||
set { SetValue(OutputProperty, value); } | ||
} | ||
|
||
public static readonly DependencyProperty OutputProperty = | ||
DependencyProperty.Register("Output", typeof(string), typeof(Calibration), new PropertyMetadata("")); | ||
|
||
public static readonly DependencyProperty ScaleYProperty = | ||
DependencyProperty.Register("ScaleY", typeof(double), typeof(Calibration), new PropertyMetadata(0.0)); | ||
|
||
public static readonly DependencyProperty ScaleXProperty = | ||
DependencyProperty.Register("ScaleX", typeof(double), typeof(Calibration), new PropertyMetadata(0.0)); | ||
|
||
public static readonly DependencyProperty OffsetYProperty = | ||
DependencyProperty.Register("OffsetY", typeof(double), typeof(Calibration), new PropertyMetadata(0.0)); | ||
|
||
public static readonly DependencyProperty OffsetXProperty = | ||
DependencyProperty.Register("OffsetX", typeof(double), typeof(Calibration), new PropertyMetadata(0.0)); | ||
|
||
public static readonly DependencyProperty ImageProperty = | ||
DependencyProperty.Register("Image", typeof(string), typeof(Calibration), new PropertyMetadata("")); | ||
|
||
public static readonly DependencyProperty FilenameProperty = | ||
DependencyProperty.Register("Filename", typeof(string), typeof(Calibration), new PropertyMetadata("")); | ||
|
||
public static readonly DependencyProperty BoundsProperty = | ||
DependencyProperty.Register("Bounds", typeof(Bounds), typeof(Calibration), new PropertyMetadata(null)); | ||
|
||
public void Recalculate() | ||
{ | ||
if (Bounds == null) return; | ||
|
||
var minX = Math.Min(Bounds.X1, Bounds.X2); | ||
var minY = Math.Min(Bounds.Y1, Bounds.Y2); | ||
var maxX = Math.Max(Bounds.X1, Bounds.X2); | ||
var maxY = Math.Max(Bounds.Y1, Bounds.Y2); | ||
|
||
ScaleX = (maxX - minX) / 80.0; | ||
ScaleY = (maxY - minY) / 80.0; | ||
|
||
OffsetX = minX - ScaleX * 10; | ||
OffsetY = minY - ScaleY * 10; | ||
|
||
Output = JsonConvert.SerializeObject(this, Formatting.Indented); | ||
} | ||
} | ||
|
||
[DebuggerDisplay("X={X1}-{X2}, Y={Y1}-{Y2}")] | ||
public class Bounds : DependencyObject | ||
{ | ||
public double X1 | ||
{ | ||
get { return (double)GetValue(X1Property); } | ||
set { SetValue(X1Property, value); } | ||
} | ||
|
||
public double X2 | ||
{ | ||
get { return (double)GetValue(X2Property); } | ||
set { SetValue(X2Property, value); } | ||
} | ||
|
||
public double Y1 | ||
{ | ||
get { return (double)GetValue(Y1Property); } | ||
set { SetValue(Y1Property, value); } | ||
} | ||
|
||
public double Y2 | ||
{ | ||
get { return (double)GetValue(Y2Property); } | ||
set { SetValue(Y2Property, value); } | ||
} | ||
|
||
public static readonly DependencyProperty Y2Property = | ||
DependencyProperty.Register("Y2", typeof(double), typeof(Bounds), new PropertyMetadata(0.0)); | ||
|
||
public static readonly DependencyProperty Y1Property = | ||
DependencyProperty.Register("Y1", typeof(double), typeof(Bounds), new PropertyMetadata(0.0)); | ||
|
||
public static readonly DependencyProperty X2Property = | ||
DependencyProperty.Register("X2", typeof(double), typeof(Bounds), new PropertyMetadata(0.0)); | ||
|
||
public static readonly DependencyProperty X1Property = | ||
DependencyProperty.Register("X1", typeof(double), typeof(Bounds), new PropertyMetadata(0.0)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.