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 @@
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
-
+
diff --git a/LarkatorGUI/MainWindow.xaml.cs b/LarkatorGUI/MainWindow.xaml.cs
index e51811c..258ca98 100644
--- a/LarkatorGUI/MainWindow.xaml.cs
+++ b/LarkatorGUI/MainWindow.xaml.cs
@@ -19,713 +19,753 @@
namespace LarkatorGUI
{
- ///
- /// Interaction logic for MainWindow.xaml
- ///
- public partial class MainWindow : Window, IDropTarget
- {
- public ObservableCollection ListSearches { get; } = new ObservableCollection();
- public Collection ListResults { get; } = new Collection();
- public List AllSpecies { get { return arkReaderWild.AllSpecies; } }
-
- public string ApplicationVersion
- {
- get
- {
- try
- {
- return ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
- }
- catch (InvalidDeploymentException)
- {
- return "DEVELOPMENT";
- }
- }
- }
-
- public string WindowTitle { get { return $"{Properties.Resources.ProgramName} {ApplicationVersion}"; } }
- public MapCalibration MapCalibration { get; private set; }
- public ImageSource MapImage { get; private set; }
-
- public bool IsLoading
- {
- get { return (bool)GetValue(IsLoadingProperty); }
- set { SetValue(IsLoadingProperty, value); }
- }
-
- public string StatusText
- {
- get { return (string)GetValue(StatusTextProperty); }
- set { SetValue(StatusTextProperty, value); }
- }
-
- public string StatusDetailText
- {
- get { return (string)GetValue(StatusDetailTextProperty); }
- set { SetValue(StatusDetailTextProperty, value); }
- }
-
- public SearchCriteria NewSearch
- {
- get { return (SearchCriteria)GetValue(NewSearchProperty); }
- set { SetValue(NewSearchProperty, value); }
- }
-
- public bool CreateSearchAvailable
- {
- get { return (bool)GetValue(CreateSearchAvailableProperty); }
- set { SetValue(CreateSearchAvailableProperty, value); }
- }
-
- public bool NewSearchActive
- {
- get { return (bool)GetValue(NewSearchActiveProperty); }
- set { SetValue(NewSearchActiveProperty, value); }
- }
-
- public bool ShowHunt
- {
- get { return (bool)GetValue(ShowHuntProperty); }
- set { SetValue(ShowHuntProperty, value); }
- }
-
- public bool ShowTames
- {
- get { return (bool)GetValue(ShowTamesProperty); }
- set { SetValue(ShowTamesProperty, value); }
- }
-
- public ImageSource ImageSource
- {
- get { return (ImageSource)GetValue(ImageSourceProperty); }
- set { SetValue(ImageSourceProperty, value); }
- }
-
- public static readonly DependencyProperty ImageSourceProperty =
- DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(MainWindow), new PropertyMetadata(null));
-
- public static readonly DependencyProperty ShowTamesProperty =
- DependencyProperty.Register("ShowTames", typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
-
- public static readonly DependencyProperty ShowHuntProperty =
- DependencyProperty.Register("ShowHunt", typeof(bool), typeof(MainWindow), new PropertyMetadata(true));
-
- public static readonly DependencyProperty NewSearchActiveProperty =
- DependencyProperty.Register("NewSearchActive", typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
-
- public static readonly DependencyProperty CreateSearchAvailableProperty =
- DependencyProperty.Register("CreateSearchAvailable", typeof(bool), typeof(MainWindow), new PropertyMetadata(true));
-
- public static readonly DependencyProperty NewSearchProperty =
- DependencyProperty.Register("NewSearch", typeof(SearchCriteria), typeof(MainWindow), new PropertyMetadata(null));
-
- public static readonly DependencyProperty IsLoadingProperty =
- DependencyProperty.Register("IsLoading", typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
-
- public static readonly DependencyProperty StatusTextProperty =
- DependencyProperty.Register("StatusText", typeof(string), typeof(MainWindow), new PropertyMetadata(""));
-
- public static readonly DependencyProperty StatusDetailTextProperty =
- DependencyProperty.Register("StatusDetailText", typeof(string), typeof(MainWindow), new PropertyMetadata(""));
-
-
- ArkReader arkReaderWild;
- ArkReader arkReaderTamed;
- FileSystemWatcher fileWatcher;
- DispatcherTimer reloadTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
- private List mapCalibrations;
- readonly List nullableBoolValues = new List { null, false, true };
-
- public MainWindow()
- {
- ValidateWindowPositionAndSize();
-
- arkReaderWild = new ArkReader(true);
- arkReaderTamed = new ArkReader(false);
-
- LoadCalibrations();
- DiscoverCalibration();
-
- DataContext = this;
-
- InitializeComponent();
-
- devButtons.Visibility = (ApplicationVersion == "DEVELOPMENT") ? Visibility.Visible : Visibility.Collapsed;
-
- LoadSavedSearches();
- EnsureOutputDirectory();
- SetupFileWatcher();
- CheckIfArkChanged(false);
-
- // Sort the results
- resultsList.Items.SortDescriptions.Add(new SortDescription("Dino.BaseLevel", ListSortDirection.Descending));
-
- // Sort the searches
- searchesList.Items.SortDescriptions.Add(new SortDescription("Group", ListSortDirection.Ascending));
- searchesList.Items.SortDescriptions.Add(new SortDescription("Order", ListSortDirection.Ascending));
-
- // Add grouping to the searches list
- CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(searchesList.ItemsSource);
- view.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
- }
-
- private void SetupFileWatcher()
- {
- if (fileWatcher != null) fileWatcher.EnableRaisingEvents = false;
- fileWatcher = new FileSystemWatcher(Path.GetDirectoryName(Properties.Settings.Default.SaveFile));
- fileWatcher.Renamed += FileWatcher_Changed;
- fileWatcher.EnableRaisingEvents = true;
- reloadTimer.Interval = TimeSpan.FromMilliseconds(Properties.Settings.Default.ConvertDelay);
- reloadTimer.Tick += ReloadTimer_Tick;
- }
-
- private void LoadCalibrations()
- {
- mapCalibrations = JsonConvert.DeserializeObject>(Properties.Resources.calibrationsJson);
- }
-
- private void DiscoverCalibration()
- {
- var filename = Properties.Settings.Default.SaveFile;
- filename = Path.GetFileNameWithoutExtension(filename);
- var best = mapCalibrations.FirstOrDefault(cal => filename.StartsWith(cal.Filename));
- if (best == null)
- {
- StatusText = "Warning: Unable to determine map from filename - defaulting to The Island";
- MapCalibration = mapCalibrations.Single(cal => cal.Filename == "TheIsland");
- }
- else
- {
- MapCalibration = best;
- }
-
- var imgFilename = $"pack://application:,,,/imgs/map_{MapCalibration.Filename}.jpg";
- MapImage = (new ImageSourceConverter()).ConvertFromString(imgFilename) as ImageSource;
- if (image != null) image.Source = MapImage;
- }
-
- private void ValidateWindowPositionAndSize()
- {
- var settings = Properties.Settings.Default;
-
- if (settings.MainWindowLeft <= -10000 || settings.MainWindowTop <= -10000)
- {
- WindowStartupLocation = WindowStartupLocation.CenterScreen;
- }
-
- if (settings.MainWindowWidth < 0 || settings.MainWindowHeight < 0)
- {
- settings.MainWindowWidth = (double)settings.Properties["MainWindowWidth"].DefaultValue;
- settings.MainWindowHeight = (double)settings.Properties["MainWindowHeight"].DefaultValue;
- settings.Save();
- }
- }
-
- private void EnsureOutputDirectory()
- {
- if (String.IsNullOrWhiteSpace(Properties.Settings.Default.OutputDir))
- {
- Properties.Settings.Default.OutputDir = Path.Combine(Path.GetTempPath(), Properties.Resources.ProgramName);
- if (!Directory.Exists(Properties.Settings.Default.OutputDir))
- {
- Directory.CreateDirectory(Properties.Settings.Default.OutputDir);
- Properties.Settings.Default.Save();
- }
- }
- }
-
- private void CheckIfArkChanged(bool reconvert = true)
- {
- var arkChanged = false;
- try
- {
- var lastArk = File.ReadAllText(Path.Combine(Properties.Settings.Default.OutputDir, Properties.Resources.LastArkFile));
- if (lastArk != Properties.Settings.Default.SaveFile) arkChanged = true;
- }
- catch
- {
- arkChanged = true;
- }
-
- if (arkChanged)
- {
- arkReaderTamed.ForceNextConversion = true;
- arkReaderWild.ForceNextConversion = true;
-
- if (reconvert)
- {
- NotifyArkChanged();
- }
- }
- }
-
- private void NotifyArkChanged()
- {
- // Cause a fresh conversion of the new ark
- Dispatcher.Invoke(() => ReReadArk(force: true), DispatcherPriority.Background);
-
- // Ensure the file watcher is watching the right directory
- fileWatcher.Path = Path.GetDirectoryName(Properties.Settings.Default.SaveFile);
- }
-
- private void FileWatcher_Changed(object sender, FileSystemEventArgs e)
- {
- if (!String.Equals(e.FullPath, Properties.Settings.Default.SaveFile)) return;
-
- Dispatcher.Invoke(() =>
- {
- StatusText = "Detected change to saved ARK...";
- StatusDetailText = "...waiting";
- });
-
- // Cancel any existing timer to ensure we're not called multiple times
- if (reloadTimer.IsEnabled) reloadTimer.Stop();
-
- reloadTimer.Start();
- }
-
- private async void ReloadTimer_Tick(object sender, EventArgs e)
- {
- reloadTimer.Stop();
- await Dispatcher.InvokeAsync(() => ReReadArk(), DispatcherPriority.Background);
- }
-
- private async void Window_Loaded(object sender, RoutedEventArgs e)
- {
- await UpdateArkToolsData();
- await ReReadArk();
- }
-
- private void Searches_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- UpdateCurrentSearch();
- }
-
- private void RemoveSearch_Click(object sender, RoutedEventArgs e)
- {
- if (ShowTames) return;
-
- var button = sender as Button;
- if (button?.DataContext is SearchCriteria search) ListSearches.Remove(search);
- UpdateCurrentSearch();
-
- MarkSearchesChanged();
- }
-
- private void Window_SourceInitialized(object sender, EventArgs e)
- {
- // Handler to maintain window aspect ratio
- WindowAspectRatio.Register((Window)sender, height => (int)Math.Round(
- height - statusPanel.ActualHeight - 2 * SystemParameters.ResizeFrameHorizontalBorderHeight - SystemParameters.WindowCaptionHeight
- + leftPanel.ActualWidth + rightPanel.ActualWidth + 2 * SystemParameters.ResizeFrameVerticalBorderWidth));
- }
-
- private void CreateSearch_Click(object sender, RoutedEventArgs e)
- {
- NewSearch = new SearchCriteria();
- NewSearchActive = true;
- CreateSearchAvailable = false;
-
- speciesCombo.ItemsSource = arkReaderWild.AllSpecies;
- groupsCombo.ItemsSource = ListSearches.Select(sc => sc.Group).Distinct().OrderBy(g => g).ToArray();
- }
-
- private void Calibration_Click(object sender, MouseButtonEventArgs e)
- {
- var win = new CalibrationWindow(new Calibration { Bounds = new Bounds() });
- win.ShowDialog();
- }
-
- private void DummyData_Click(object sender, MouseButtonEventArgs e)
- {
- ListResults.Clear();
-
- var dummyData = new Dino[] {
- new Dino { Location=new Position{ Lat=10,Lon=10 }, Type="Testificate", Name="10,10" },
- new Dino { Location=new Position{ Lat=90,Lon=10 }, Type="Testificate", Name="90,10" },
- new Dino { Location=new Position{ Lat=10,Lon=90 }, Type="Testificate", Name="10,90" },
- new Dino { Location=new Position{ Lat=90,Lon=90 }, Type="Testificate", Name="90,90" },
- new Dino { Location=new Position{ Lat=50,Lon=50 }, Type="Testificate", Name="50,50" },
- };
-
- var rnd = new Random();
- foreach (var result in dummyData)
- {
- result.Id = (ulong)rnd.Next();
- DinoViewModel vm = new DinoViewModel(result) { Color = Colors.Green };
- ListResults.Add(vm);
- }
-
- var cv = (CollectionView)CollectionViewSource.GetDefaultView(ListResults);
- cv.Refresh();
- }
-
- private async void SaveSearch_Click(object sender, RoutedEventArgs e)
- {
- if (String.IsNullOrWhiteSpace(NewSearch.Species)) return;
-
- try
- {
- NewSearch.Order = ListSearches.Where(sc => sc.Group == NewSearch.Group).Max(sc => sc.Order) + 100;
- }
- catch (InvalidOperationException) // no entries for .Max - ignore
- { }
-
- IsLoading = true;
- try
- {
- StatusText = $"Loading {NewSearch.Species}...";
- await arkReaderWild.EnsureSpeciesIsLoaded(NewSearch.Species);
- StatusText = $"Ready";
- }
- finally
- {
- IsLoading = false;
- }
-
- ListSearches.Add(NewSearch);
- NewSearch = null;
- NewSearchActive = false;
- CreateSearchAvailable = true;
-
- MarkSearchesChanged();
- }
-
- private void AdjustableInteger_MouseWheel(object sender, MouseWheelEventArgs e)
- {
- var tb = (TextBlock)sender;
- var diff = Math.Sign(e.Delta) * Properties.Settings.Default.LevelStep;
- var bexpr = tb.GetBindingExpression(TextBlock.TextProperty);
- var accessor = TypeAccessor.Create(typeof(SearchCriteria));
- var value = (int?)accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName];
- if (value.HasValue)
- {
- value = value + diff;
- if (value < 0 || value > Properties.Settings.Default.MaxLevel) value = null;
- }
- else
- {
- value = (diff > 0) ? 0 : Properties.Settings.Default.MaxLevel;
- }
-
- accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName] = value;
- bexpr.UpdateTarget();
-
- if (null != searchesList.SelectedItem)
- UpdateCurrentSearch();
-
- MarkSearchesChanged();
- }
-
- private void AdjustableGender_MouseWheel(object sender, MouseWheelEventArgs e)
- {
- var im = (Image)sender;
- var diff = Math.Sign(e.Delta);
- var nOptions = nullableBoolValues.Count;
- var bexpr = im.GetBindingExpression(Image.SourceProperty);
- var accessor = TypeAccessor.Create(typeof(SearchCriteria));
- var value = (bool?)accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName];
- var index = nullableBoolValues.IndexOf(value);
- index = (index + diff + nOptions) % nOptions;
- value = nullableBoolValues[index];
- accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName] = value;
- bexpr.UpdateTarget();
-
- if (null != searchesList.SelectedItem)
- UpdateCurrentSearch();
-
- MarkSearchesChanged();
- }
-
- private void Result_MouseEnter(object sender, MouseEventArgs e)
- {
- var fe = sender as FrameworkElement;
- if (fe == null) return;
- var dino = fe.DataContext as DinoViewModel;
- if (dino == null) return;
- dino.Highlight = true;
- }
-
- private void Result_MouseLeave(object sender, MouseEventArgs e)
- {
- var fe = sender as FrameworkElement;
- if (fe == null) return;
- var dino = fe.DataContext as DinoViewModel;
- if (dino == null) return;
- dino.Highlight = false;
- }
-
- private void MarkSearchesChanged()
- {
- SaveSearches();
- }
-
- private void SaveSearches()
- {
- Properties.Settings.Default.SavedSearches = JsonConvert.SerializeObject(ListSearches);
- Properties.Settings.Default.Save();
- }
-
- private void LoadSavedSearches()
- {
- if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedSearches))
- {
- Collection searches;
- try
- {
- searches = JsonConvert.DeserializeObject>(Properties.Settings.Default.SavedSearches);
- }
- catch (Exception e)
- {
- Console.WriteLine("Exception reading saved searches: " + e.ToString());
- return;
- }
-
- ListSearches.Clear();
- foreach (var search in searches)
- ListSearches.Add(search);
- }
- }
-
- private async Task UpdateArkToolsData()
- {
- StatusText = "Updating ark-tools database";
- try
- {
- await ArkReader.ExecuteArkTools("update-data");
- StatusText = "Updated ark-tools database";
- }
- catch (Exception e)
- {
- StatusText = "Failed to update ark-tools database: " + e.Message;
- }
- }
-
- private async Task ReReadArk(bool force = false)
- {
- if (IsLoading) return;
-
- await PerformConversion(force);
- await LoadSearchSpecies();
-
- var currentSearch = searchesList.SelectedItems.Cast().ToList();
- UpdateSearchResults(currentSearch);
- }
-
- private async Task LoadSearchSpecies()
- {
- IsLoading = true;
- try
- {
- var species = arkReaderWild.AllSpecies.Distinct();
- foreach (var speciesName in species)
- {
- StatusText = $"Loading {speciesName}...";
- await arkReaderWild.EnsureSpeciesIsLoaded(speciesName);
- }
-
- species = arkReaderTamed.AllSpecies.Distinct();
- foreach (var speciesName in species)
- {
- StatusText = $"Loading {speciesName}...";
- await arkReaderTamed.EnsureSpeciesIsLoaded(speciesName);
- }
-
- StatusText = "Ready";
- }
- finally
- {
- IsLoading = false;
- }
- }
-
- private void UpdateSearchResults(IList searches)
- {
- if (searches == null || searches.Count == 0)
- {
- ListResults.Clear();
- }
- else
- {
- // Find dinos that match the given searches
- var found = new List();
- var reader = ShowTames ? arkReaderTamed : arkReaderWild;
- foreach (var search in searches)
- {
- if (String.IsNullOrWhiteSpace(search.Species))
- {
- foreach (var speciesDinos in reader.FoundDinos.Values)
- found.AddRange(speciesDinos);
- }
- else
- {
- if (reader.FoundDinos.ContainsKey(search.Species))
- {
- var dinoList = reader.FoundDinos[search.Species];
- found.AddRange(dinoList.Where(d => search.Matches(d)));
- }
- }
- }
-
- ListResults.Clear();
- foreach (var result in found)
- ListResults.Add(result);
- }
-
- var cv = (CollectionView)CollectionViewSource.GetDefaultView(ListResults);
- cv.Refresh();
- }
-
- private async Task PerformConversion(bool force)
- {
- string arkDirName = Path.GetFileNameWithoutExtension(Properties.Settings.Default.SaveFile);
-
- IsLoading = true;
- try
- {
- StatusDetailText = "...converting";
- StatusText = "Processing saved ARK : Wild";
- await arkReaderWild.PerformConversion(force, arkDirName);
- StatusText = "Processing saved ARK : Tamed";
- await arkReaderTamed.PerformConversion(force, arkDirName);
- StatusText = "ARK processing completed";
- StatusDetailText = $"{arkReaderWild.NumberOfSpecies} wild and {arkReaderTamed.NumberOfSpecies} species located";
-
- // Write path to last ark into the output folder so we can check when we change ARKs
- File.WriteAllText(Path.Combine(Properties.Settings.Default.OutputDir, Properties.Resources.LastArkFile), Properties.Settings.Default.SaveFile);
- }
- catch (Exception ex)
- {
- StatusText = "ARK processing failed";
- StatusDetailText = "";
- MessageBox.Show(ex.Message, "ARK Tools Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
- }
- finally
- {
- IsLoading = false;
- }
- }
-
- private void UpdateCurrentSearch()
- {
- var search = (SearchCriteria)searchesList.SelectedItem;
- var searches = new List();
- if (search != null) searches.Add(search);
- UpdateSearchResults(searches);
- }
-
- void IDropTarget.DragOver(IDropInfo dropInfo)
- {
- if (dropInfo.TargetItem is SearchCriteria targetItem && dropInfo.Data is SearchCriteria sourceItem)
- {
- dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
- dropInfo.Effects = DragDropEffects.Move;
- }
- }
-
- void IDropTarget.Drop(IDropInfo dropInfo)
- {
- var sourceItem = (SearchCriteria)dropInfo.Data;
- var targetItem = (SearchCriteria)dropInfo.TargetItem;
-
- var ii = dropInfo.InsertIndex;
- var ip = dropInfo.InsertPosition;
-
- // Change source item's group
- sourceItem.Group = targetItem.Group;
-
- // Try to figure out the other item to insert between, or pick a boundary
- var options = ListSearches
- .Where(sc => sc != sourceItem)
- .Where(sc => sc.Group == targetItem.Group)
- .OrderBy(sc => sc.Order)
- .ToArray();
-
- var above = options.Where(sc => sc.Order < targetItem.Order).OrderByDescending(sc => sc.Order).FirstOrDefault();
- var below = options.Where(sc => sc.Order > targetItem.Order).OrderBy(sc => sc.Order).FirstOrDefault();
-
- var aboveOrder = (above == null) ? options.Min(sc => sc.Order) - 1 : above.Order;
- var belowOrder = (below == null) ? options.Max(sc => sc.Order) + 1 : below.Order;
-
- // Update the order to be mid-way between either above or below, based on drag insert position
- sourceItem.Order = (targetItem.Order + (ip.HasFlag(RelativeInsertPosition.AfterTargetItem) ? belowOrder : aboveOrder)) / 2;
-
- // Renumber the results
- var orderedSearches = ListSearches
- .OrderBy(sc => sc.Group)
- .ThenBy(sc => sc.Order)
- .ToArray();
-
- for (var i = 0; i < orderedSearches.Length; i++)
- {
- orderedSearches[i].Order = i;
- }
-
- // Force binding update
- CollectionViewSource.GetDefaultView(searchesList.ItemsSource).Refresh();
-
- // Save list
- MarkSearchesChanged();
- }
-
- private void ShowTames_Click(object sender, MouseButtonEventArgs e)
- {
- ShowTames = true;
- ShowHunt = false;
- NewSearchActive = false;
- CreateSearchAvailable = false;
-
- ShowTameSearches();
- }
-
- private void ShowTheHunt_Click(object sender, MouseButtonEventArgs e)
- {
- ShowTames = false;
- ShowHunt = true;
- NewSearchActive = false;
- CreateSearchAvailable = true;
-
- ShowWildSearches();
- }
-
- private void ShowTameSearches()
- {
- SetupTamedSearches();
- }
-
- private void SetupTamedSearches()
- {
- var wildcard = new string[] { null };
- var speciesList = wildcard.Concat(arkReaderTamed.AllSpecies).ToList();
- var orderList = Enumerable.Range(0, speciesList.Count);
- var searches = speciesList.Zip(orderList, (species, order) => new SearchCriteria { Species = species, Order = order });
-
- ListSearches.Clear();
- foreach (var search in searches)
- ListSearches.Add(search);
- }
-
- private void ShowWildSearches()
- {
- LoadSavedSearches();
- }
-
- private void Settings_Click(object sender, MouseButtonEventArgs e)
- {
- var settings = new SettingsWindow();
- settings.ShowDialog();
-
- OnSettingsChanged();
- }
-
- private void OnSettingsChanged()
- {
- DiscoverCalibration();
- EnsureOutputDirectory();
- CheckIfArkChanged();
- UpdateCurrentSearch();
-
- reloadTimer.Interval = TimeSpan.FromMilliseconds(Properties.Settings.Default.ConvertDelay);
- }
- }
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window, IDropTarget
+ {
+ public ObservableCollection ListSearches { get; } = new ObservableCollection();
+ public Collection ListResults { get; } = new Collection();
+ public List AllSpecies { get { return arkReaderWild.AllSpecies; } }
+
+ public string ApplicationVersion
+ {
+ get
+ {
+ return appVersion;
+ }
+ }
+
+ public string WindowTitle { get { return $"{Properties.Resources.ProgramName} {ApplicationVersion}"; } }
+ public MapCalibration MapCalibration { get; private set; }
+ public ImageSource MapImage { get; private set; }
+
+ public bool IsLoading
+ {
+ get { return (bool)GetValue(IsLoadingProperty); }
+ set { SetValue(IsLoadingProperty, value); }
+ }
+
+ public string StatusText
+ {
+ get { return (string)GetValue(StatusTextProperty); }
+ set { SetValue(StatusTextProperty, value); }
+ }
+
+ public string StatusDetailText
+ {
+ get { return (string)GetValue(StatusDetailTextProperty); }
+ set { SetValue(StatusDetailTextProperty, value); }
+ }
+
+ public SearchCriteria NewSearch
+ {
+ get { return (SearchCriteria)GetValue(NewSearchProperty); }
+ set { SetValue(NewSearchProperty, value); }
+ }
+
+ public bool CreateSearchAvailable
+ {
+ get { return (bool)GetValue(CreateSearchAvailableProperty); }
+ set { SetValue(CreateSearchAvailableProperty, value); }
+ }
+
+ public bool NewSearchActive
+ {
+ get { return (bool)GetValue(NewSearchActiveProperty); }
+ set { SetValue(NewSearchActiveProperty, value); }
+ }
+
+ public bool ShowHunt
+ {
+ get { return (bool)GetValue(ShowHuntProperty); }
+ set { SetValue(ShowHuntProperty, value); }
+ }
+
+ public bool ShowTames
+ {
+ get { return (bool)GetValue(ShowTamesProperty); }
+ set { SetValue(ShowTamesProperty, value); }
+ }
+
+ public ImageSource ImageSource
+ {
+ get { return (ImageSource)GetValue(ImageSourceProperty); }
+ set { SetValue(ImageSourceProperty, value); }
+ }
+
+ public static readonly DependencyProperty ImageSourceProperty =
+ DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(MainWindow), new PropertyMetadata(null));
+
+ public static readonly DependencyProperty ShowTamesProperty =
+ DependencyProperty.Register("ShowTames", typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
+
+ public static readonly DependencyProperty ShowHuntProperty =
+ DependencyProperty.Register("ShowHunt", typeof(bool), typeof(MainWindow), new PropertyMetadata(true));
+
+ public static readonly DependencyProperty NewSearchActiveProperty =
+ DependencyProperty.Register("NewSearchActive", typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
+
+ public static readonly DependencyProperty CreateSearchAvailableProperty =
+ DependencyProperty.Register("CreateSearchAvailable", typeof(bool), typeof(MainWindow), new PropertyMetadata(true));
+
+ public static readonly DependencyProperty NewSearchProperty =
+ DependencyProperty.Register("NewSearch", typeof(SearchCriteria), typeof(MainWindow), new PropertyMetadata(null));
+
+ public static readonly DependencyProperty IsLoadingProperty =
+ DependencyProperty.Register("IsLoading", typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
+
+ public static readonly DependencyProperty StatusTextProperty =
+ DependencyProperty.Register("StatusText", typeof(string), typeof(MainWindow), new PropertyMetadata(""));
+
+ public static readonly DependencyProperty StatusDetailTextProperty =
+ DependencyProperty.Register("StatusDetailText", typeof(string), typeof(MainWindow), new PropertyMetadata(""));
+
+
+ ArkReader arkReaderWild;
+ ArkReader arkReaderTamed;
+ FileSystemWatcher fileWatcher;
+ DispatcherTimer reloadTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
+ private List mapCalibrations;
+ private readonly string appVersion;
+ readonly List nullableBoolValues = new List { null, false, true };
+
+ public MainWindow()
+ {
+ ValidateWindowPositionAndSize();
+
+ arkReaderWild = new ArkReader(true);
+ arkReaderTamed = new ArkReader(false);
+
+ appVersion = CalculateApplicationVersion();
+
+ LoadCalibrations();
+ DiscoverCalibration();
+
+ DataContext = this;
+
+ InitializeComponent();
+
+ devButtons.Visibility = (ApplicationVersion == "DEVELOPMENT") ? Visibility.Visible : Visibility.Collapsed;
+
+ LoadSavedSearches();
+ EnsureOutputDirectory();
+ SetupFileWatcher();
+ CheckIfArkChanged(false);
+ }
+
+ private static string CalculateApplicationVersion()
+ {
+ try
+ {
+ return ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
+ }
+ catch (InvalidDeploymentException)
+ {
+ return "DEVELOPMENT";
+ }
+ }
+
+ private void SetupFileWatcher()
+ {
+ if (fileWatcher != null) fileWatcher.EnableRaisingEvents = false;
+ fileWatcher = new FileSystemWatcher(Path.GetDirectoryName(Properties.Settings.Default.SaveFile));
+ fileWatcher.Renamed += FileWatcher_Changed;
+ fileWatcher.EnableRaisingEvents = true;
+ reloadTimer.Interval = TimeSpan.FromMilliseconds(Properties.Settings.Default.ConvertDelay);
+ reloadTimer.Tick += ReloadTimer_Tick;
+ }
+
+ private void LoadCalibrations()
+ {
+ mapCalibrations = JsonConvert.DeserializeObject>(Properties.Resources.calibrationsJson);
+ }
+
+ private void DiscoverCalibration()
+ {
+ var filename = Properties.Settings.Default.SaveFile;
+ filename = Path.GetFileNameWithoutExtension(filename);
+ var best = mapCalibrations.FirstOrDefault(cal => filename.StartsWith(cal.Filename));
+ if (best == null)
+ {
+ StatusText = "Warning: Unable to determine map from filename - defaulting to The Island";
+ MapCalibration = mapCalibrations.Single(cal => cal.Filename == "TheIsland");
+ }
+ else
+ {
+ MapCalibration = best;
+ }
+
+ var imgFilename = $"pack://application:,,,/imgs/map_{MapCalibration.Filename}.jpg";
+ MapImage = (new ImageSourceConverter()).ConvertFromString(imgFilename) as ImageSource;
+ if (image != null) image.Source = MapImage;
+ }
+
+ private void ValidateWindowPositionAndSize()
+ {
+ var settings = Properties.Settings.Default;
+
+ if (settings.MainWindowLeft <= -10000 || settings.MainWindowTop <= -10000)
+ {
+ WindowStartupLocation = WindowStartupLocation.CenterScreen;
+ }
+
+ if (settings.MainWindowWidth < 0 || settings.MainWindowHeight < 0)
+ {
+ settings.MainWindowWidth = (double)settings.Properties["MainWindowWidth"].DefaultValue;
+ settings.MainWindowHeight = (double)settings.Properties["MainWindowHeight"].DefaultValue;
+ settings.Save();
+ }
+ }
+
+ private void EnsureOutputDirectory()
+ {
+ if (String.IsNullOrWhiteSpace(Properties.Settings.Default.OutputDir))
+ {
+ Properties.Settings.Default.OutputDir = Path.Combine(Path.GetTempPath(), Properties.Resources.ProgramName);
+ if (!Directory.Exists(Properties.Settings.Default.OutputDir))
+ {
+ Directory.CreateDirectory(Properties.Settings.Default.OutputDir);
+ Properties.Settings.Default.Save();
+ }
+ }
+ }
+
+ private void CheckIfArkChanged(bool reconvert = true)
+ {
+ var arkChanged = false;
+ try
+ {
+ var lastArk = File.ReadAllText(Path.Combine(Properties.Settings.Default.OutputDir, Properties.Resources.LastArkFile));
+ if (lastArk != Properties.Settings.Default.SaveFile) arkChanged = true;
+ }
+ catch
+ {
+ arkChanged = true;
+ }
+
+ if (arkChanged)
+ {
+ arkReaderTamed.ForceNextConversion = true;
+ arkReaderWild.ForceNextConversion = true;
+
+ if (reconvert)
+ {
+ NotifyArkChanged();
+ }
+ }
+ }
+
+ private void NotifyArkChanged()
+ {
+ // Cause a fresh conversion of the new ark
+ Dispatcher.Invoke(() => ReReadArk(force: true), DispatcherPriority.Background);
+
+ // Ensure the file watcher is watching the right directory
+ fileWatcher.Path = Path.GetDirectoryName(Properties.Settings.Default.SaveFile);
+ }
+
+ private void FileWatcher_Changed(object sender, FileSystemEventArgs e)
+ {
+ if (!String.Equals(e.FullPath, Properties.Settings.Default.SaveFile)) return;
+
+ Dispatcher.Invoke(() =>
+ {
+ StatusText = "Detected change to saved ARK...";
+ StatusDetailText = "...waiting";
+ });
+
+ // Cancel any existing timer to ensure we're not called multiple times
+ if (reloadTimer.IsEnabled) reloadTimer.Stop();
+
+ reloadTimer.Start();
+ }
+
+ private async void ReloadTimer_Tick(object sender, EventArgs e)
+ {
+ reloadTimer.Stop();
+ await Dispatcher.InvokeAsync(() => ReReadArk(), DispatcherPriority.Background);
+ }
+
+ private async void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ await UpdateArkToolsData();
+ await ReReadArk();
+ }
+
+ private void Searches_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ UpdateCurrentSearch();
+ }
+
+ private void RemoveSearch_Click(object sender, RoutedEventArgs e)
+ {
+ if (ShowTames) return;
+
+ var button = sender as Button;
+ if (button?.DataContext is SearchCriteria search) ListSearches.Remove(search);
+ UpdateCurrentSearch();
+
+ MarkSearchesChanged();
+ }
+
+ private void MapPin_Click(object sender, MouseButtonEventArgs ev)
+ {
+ if (sender is FrameworkElement e && e.DataContext is DinoViewModel dvm)
+ {
+ dvm.Highlight = !dvm.Highlight;
+ if (dvm.Highlight) resultsList.ScrollIntoView(dvm);
+ }
+ }
+
+ private void Window_SourceInitialized(object sender, EventArgs e)
+ {
+ // Handler to maintain window aspect ratio
+ WindowAspectRatio.Register((Window)sender, height => (int)Math.Round(
+ height - statusPanel.ActualHeight - 2 * SystemParameters.ResizeFrameHorizontalBorderHeight - SystemParameters.WindowCaptionHeight
+ + leftPanel.ActualWidth + rightPanel.ActualWidth + 2 * SystemParameters.ResizeFrameVerticalBorderWidth));
+ }
+
+ private void CreateSearch_Click(object sender, RoutedEventArgs e)
+ {
+ NewSearch = new SearchCriteria();
+ NewSearchActive = true;
+ CreateSearchAvailable = false;
+
+ speciesCombo.ItemsSource = arkReaderWild.AllSpecies;
+ groupsCombo.ItemsSource = ListSearches.Select(sc => sc.Group).Distinct().OrderBy(g => g).ToArray();
+ }
+
+ private void Calibration_Click(object sender, MouseButtonEventArgs e)
+ {
+ var win = new CalibrationWindow(new Calibration { Bounds = new Bounds() });
+ win.ShowDialog();
+ }
+
+ private void DummyData_Click(object sender, MouseButtonEventArgs e)
+ {
+ ListResults.Clear();
+
+ var dummyData = new Dino[] {
+ new Dino { Location=new Position{ Lat=10,Lon=10 }, Type="Testificate", Name="10,10" },
+ new Dino { Location=new Position{ Lat=90,Lon=10 }, Type="Testificate", Name="90,10" },
+ new Dino { Location=new Position{ Lat=10,Lon=90 }, Type="Testificate", Name="10,90" },
+ new Dino { Location=new Position{ Lat=90,Lon=90 }, Type="Testificate", Name="90,90" },
+ new Dino { Location=new Position{ Lat=50,Lon=50 }, Type="Testificate", Name="50,50" },
+ };
+
+ var rnd = new Random();
+ foreach (var result in dummyData)
+ {
+ result.Id = (ulong)rnd.Next();
+ DinoViewModel vm = new DinoViewModel(result) { Color = Colors.Green };
+ ListResults.Add(vm);
+ }
+
+ var cv = (CollectionView)CollectionViewSource.GetDefaultView(ListResults);
+ cv.Refresh();
+ }
+
+ private async void SaveSearch_Click(object sender, RoutedEventArgs e)
+ {
+ if (String.IsNullOrWhiteSpace(NewSearch.Species)) return;
+
+ try
+ {
+ NewSearch.Order = ListSearches.Where(sc => sc.Group == NewSearch.Group).Max(sc => sc.Order) + 100;
+ }
+ catch (InvalidOperationException) // no entries for .Max - ignore
+ { }
+
+ IsLoading = true;
+ try
+ {
+ StatusText = $"Loading {NewSearch.Species}...";
+ await arkReaderWild.EnsureSpeciesIsLoaded(NewSearch.Species);
+ StatusText = $"Ready";
+ }
+ finally
+ {
+ IsLoading = false;
+ }
+
+ ListSearches.Add(NewSearch);
+ NewSearch = null;
+ NewSearchActive = false;
+ CreateSearchAvailable = true;
+
+ MarkSearchesChanged();
+ }
+
+ private void CloseNewSearch_Click(object sender, MouseButtonEventArgs e)
+ {
+ NewSearchActive = false;
+ CreateSearchAvailable = true;
+ }
+
+ private void ShowTames_Click(object sender, MouseButtonEventArgs e)
+ {
+ ShowTames = true;
+ ShowHunt = false;
+ NewSearchActive = false;
+ CreateSearchAvailable = false;
+
+ ShowTameSearches();
+ }
+
+ private void ShowTheHunt_Click(object sender, MouseButtonEventArgs e)
+ {
+ ShowTames = false;
+ ShowHunt = true;
+ NewSearchActive = false;
+ CreateSearchAvailable = true;
+
+ ShowWildSearches();
+ }
+
+ private void Settings_Click(object sender, MouseButtonEventArgs e)
+ {
+ var settings = new SettingsWindow();
+ settings.ShowDialog();
+
+ OnSettingsChanged();
+ }
+
+ private void AdjustableInteger_MouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ var tb = (TextBlock)sender;
+ var diff = Math.Sign(e.Delta) * Properties.Settings.Default.LevelStep;
+ var bexpr = tb.GetBindingExpression(TextBlock.TextProperty);
+ var accessor = TypeAccessor.Create(typeof(SearchCriteria));
+ var value = (int?)accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName];
+ if (value.HasValue)
+ {
+ value = value + diff;
+ if (value < 0 || value > Properties.Settings.Default.MaxLevel) value = null;
+ }
+ else
+ {
+ value = (diff > 0) ? 0 : Properties.Settings.Default.MaxLevel;
+ }
+
+ accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName] = value;
+ bexpr.UpdateTarget();
+
+ if (null != searchesList.SelectedItem)
+ UpdateCurrentSearch();
+
+ MarkSearchesChanged();
+ }
+
+ private void AdjustableGender_MouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ var im = (Image)sender;
+ var diff = Math.Sign(e.Delta);
+ var nOptions = nullableBoolValues.Count;
+ var bexpr = im.GetBindingExpression(Image.SourceProperty);
+ var accessor = TypeAccessor.Create(typeof(SearchCriteria));
+ var value = (bool?)accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName];
+ var index = nullableBoolValues.IndexOf(value);
+ index = (index + diff + nOptions) % nOptions;
+ value = nullableBoolValues[index];
+ accessor[bexpr.ResolvedSource, bexpr.ResolvedSourcePropertyName] = value;
+ bexpr.UpdateTarget();
+
+ if (null != searchesList.SelectedItem)
+ UpdateCurrentSearch();
+
+ MarkSearchesChanged();
+ }
+
+ private void Result_MouseEnter(object sender, MouseEventArgs e)
+ {
+ var fe = sender as FrameworkElement;
+ if (fe == null) return;
+ var dino = fe.DataContext as DinoViewModel;
+ if (dino == null) return;
+ dino.Highlight = true;
+ }
+
+ private void Result_MouseLeave(object sender, MouseEventArgs e)
+ {
+ var fe = sender as FrameworkElement;
+ if (fe == null) return;
+ var dino = fe.DataContext as DinoViewModel;
+ if (dino == null) return;
+ dino.ClearValue(DinoViewModel.HighlightProperty);
+ }
+
+ private void ResultList_Sorting(object sender, DataGridSortingEventArgs e)
+ {
+ if (e.Column.SortDirection == null)
+ e.Column.SortDirection = ListSortDirection.Ascending;
+
+ e.Handled = false;
+ }
+
+ private void MarkSearchesChanged()
+ {
+ SaveSearches();
+ }
+
+ private void SaveSearches()
+ {
+ Properties.Settings.Default.SavedSearches = JsonConvert.SerializeObject(ListSearches);
+ Properties.Settings.Default.Save();
+ }
+
+ private void LoadSavedSearches()
+ {
+ if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedSearches))
+ {
+ Collection searches;
+ try
+ {
+ searches = JsonConvert.DeserializeObject>(Properties.Settings.Default.SavedSearches);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Exception reading saved searches: " + e.ToString());
+ return;
+ }
+
+ ListSearches.Clear();
+ foreach (var search in searches)
+ ListSearches.Add(search);
+ }
+ }
+
+ private async Task UpdateArkToolsData()
+ {
+ StatusText = "Updating ark-tools database";
+ try
+ {
+ await ArkReader.ExecuteArkTools("update-data");
+ StatusText = "Updated ark-tools database";
+ }
+ catch (Exception e)
+ {
+ StatusText = "Failed to update ark-tools database: " + e.Message;
+ }
+ }
+
+ private async Task ReReadArk(bool force = false)
+ {
+ if (IsLoading) return;
+
+ await PerformConversion(force);
+ await LoadSearchSpecies();
+
+ var currentSearch = searchesList.SelectedItems.Cast().ToList();
+ UpdateSearchResults(currentSearch);
+ }
+
+ private async Task LoadSearchSpecies()
+ {
+ IsLoading = true;
+ try
+ {
+ var species = arkReaderWild.AllSpecies.Distinct();
+ foreach (var speciesName in species)
+ {
+ StatusText = $"Loading {speciesName}...";
+ await arkReaderWild.EnsureSpeciesIsLoaded(speciesName);
+ }
+
+ species = arkReaderTamed.AllSpecies.Distinct();
+ foreach (var speciesName in species)
+ {
+ StatusText = $"Loading {speciesName}...";
+ await arkReaderTamed.EnsureSpeciesIsLoaded(speciesName);
+ }
+
+ StatusText = "Ready";
+ }
+ finally
+ {
+ IsLoading = false;
+ }
+ }
+
+ private void UpdateSearchResults(IList searches)
+ {
+ if (searches == null || searches.Count == 0)
+ {
+ ListResults.Clear();
+ }
+ else
+ {
+ // Find dinos that match the given searches
+ var found = new List();
+ var reader = ShowTames ? arkReaderTamed : arkReaderWild;
+ foreach (var search in searches)
+ {
+ if (String.IsNullOrWhiteSpace(search.Species))
+ {
+ foreach (var speciesDinos in reader.FoundDinos.Values)
+ found.AddRange(speciesDinos);
+ }
+ else
+ {
+ if (reader.FoundDinos.ContainsKey(search.Species))
+ {
+ var dinoList = reader.FoundDinos[search.Species];
+ found.AddRange(dinoList.Where(d => search.Matches(d)));
+ }
+ }
+ }
+
+ ListResults.Clear();
+ foreach (var result in found)
+ ListResults.Add(result);
+ }
+
+ ((CollectionViewSource)Resources["OrderedResults"]).View.Refresh();
+ }
+
+ private async Task PerformConversion(bool force)
+ {
+ string arkDirName = Path.GetFileNameWithoutExtension(Properties.Settings.Default.SaveFile);
+
+ IsLoading = true;
+ try
+ {
+ StatusDetailText = "...converting";
+ StatusText = "Processing saved ARK : Wild";
+ await arkReaderWild.PerformConversion(force, arkDirName);
+ StatusText = "Processing saved ARK : Tamed";
+ await arkReaderTamed.PerformConversion(force, arkDirName);
+ StatusText = "ARK processing completed";
+ StatusDetailText = $"{arkReaderWild.NumberOfSpecies} wild and {arkReaderTamed.NumberOfSpecies} tame species located";
+
+ // Write path to last ark into the output folder so we can check when we change ARKs
+ File.WriteAllText(Path.Combine(Properties.Settings.Default.OutputDir, Properties.Resources.LastArkFile), Properties.Settings.Default.SaveFile);
+ }
+ catch (Exception ex)
+ {
+ StatusText = "ARK processing failed";
+ StatusDetailText = "";
+ MessageBox.Show(ex.Message, "ARK Tools Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ }
+ finally
+ {
+ IsLoading = false;
+ }
+ }
+
+ private void UpdateCurrentSearch()
+ {
+ var search = (SearchCriteria)searchesList.SelectedItem;
+ var searches = new List();
+ if (search != null) searches.Add(search);
+ UpdateSearchResults(searches);
+ }
+
+ void IDropTarget.DragOver(IDropInfo dropInfo)
+ {
+ if (dropInfo.TargetItem is SearchCriteria targetItem && dropInfo.Data is SearchCriteria sourceItem)
+ {
+ dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
+ dropInfo.Effects = DragDropEffects.Move;
+ }
+ }
+
+ void IDropTarget.Drop(IDropInfo dropInfo)
+ {
+ var sourceItem = (SearchCriteria)dropInfo.Data;
+ var targetItem = (SearchCriteria)dropInfo.TargetItem;
+
+ var ii = dropInfo.InsertIndex;
+ var ip = dropInfo.InsertPosition;
+
+ // Change source item's group
+ sourceItem.Group = targetItem.Group;
+
+ // Try to figure out the other item to insert between, or pick a boundary
+ var options = ListSearches
+ .Where(sc => sc != sourceItem)
+ .Where(sc => sc.Group == targetItem.Group)
+ .OrderBy(sc => sc.Order)
+ .ToArray();
+
+ var above = options.Where(sc => sc.Order < targetItem.Order).OrderByDescending(sc => sc.Order).FirstOrDefault();
+ var below = options.Where(sc => sc.Order > targetItem.Order).OrderBy(sc => sc.Order).FirstOrDefault();
+
+ var aboveOrder = (above == null) ? options.Min(sc => sc.Order) - 1 : above.Order;
+ var belowOrder = (below == null) ? options.Max(sc => sc.Order) + 1 : below.Order;
+
+ // Update the order to be mid-way between either above or below, based on drag insert position
+ sourceItem.Order = (targetItem.Order + (ip.HasFlag(RelativeInsertPosition.AfterTargetItem) ? belowOrder : aboveOrder)) / 2;
+
+ // Renumber the results
+ var orderedSearches = ListSearches
+ .OrderBy(sc => sc.Group)
+ .ThenBy(sc => sc.Order)
+ .ToArray();
+
+ for (var i = 0; i < orderedSearches.Length; i++)
+ {
+ orderedSearches[i].Order = i;
+ }
+
+ // Force binding update
+ CollectionViewSource.GetDefaultView(searchesList.ItemsSource).Refresh();
+
+ // Save list
+ MarkSearchesChanged();
+ }
+
+ private void ShowTameSearches()
+ {
+ SetupTamedSearches();
+ }
+
+ private void SetupTamedSearches()
+ {
+ var wildcard = new string[] { null };
+ var speciesList = wildcard.Concat(arkReaderTamed.AllSpecies).ToList();
+ var orderList = Enumerable.Range(0, speciesList.Count);
+ var searches = speciesList.Zip(orderList, (species, order) => new SearchCriteria { Species = species, Order = order });
+
+ ListSearches.Clear();
+ foreach (var search in searches)
+ ListSearches.Add(search);
+ }
+
+ private void ShowWildSearches()
+ {
+ LoadSavedSearches();
+ }
+
+ private void OnSettingsChanged()
+ {
+ DiscoverCalibration();
+ EnsureOutputDirectory();
+ CheckIfArkChanged();
+ UpdateCurrentSearch();
+
+ ForceFontSizeUpdate();
+
+ reloadTimer.Interval = TimeSpan.FromMilliseconds(Properties.Settings.Default.ConvertDelay);
+ }
+
+ private void ForceFontSizeUpdate()
+ {
+ Dispatcher.Invoke(() => RefreshDataGridColumnWidths("GroupedSearchCriteria", searchesList), DispatcherPriority.ContextIdle);
+ Dispatcher.Invoke(() => RefreshDataGridColumnWidths("OrderedResults", resultsList), DispatcherPriority.ContextIdle);
+ }
+
+ private void RefreshDataGridColumnWidths(string resourceName, DataGrid dataGrid)
+ {
+ var widths = dataGrid.Columns.Select(col => col.Width).ToArray();
+ foreach (var col in dataGrid.Columns)
+ col.Width = 0;
+
+ ((CollectionViewSource)Resources[resourceName]).View.Refresh();
+ dataGrid.UpdateLayout();
+
+ foreach (var o in dataGrid.Columns.Zip(widths, (col, width) => new { col, width }))
+ o.col.Width = o.width;
+ }
+ }
}
diff --git a/LarkatorGUI/Properties/Settings.Designer.cs b/LarkatorGUI/Properties/Settings.Designer.cs
index 5e9a65c..fb3d4d3 100644
--- a/LarkatorGUI/Properties/Settings.Designer.cs
+++ b/LarkatorGUI/Properties/Settings.Designer.cs
@@ -176,5 +176,29 @@ public int ConvertDelay {
this["ConvertDelay"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("15")]
+ public int ListFontSize {
+ get {
+ return ((int)(this["ListFontSize"]));
+ }
+ set {
+ this["ListFontSize"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0.9")]
+ public double PinScale {
+ get {
+ return ((double)(this["PinScale"]));
+ }
+ set {
+ this["PinScale"] = value;
+ }
+ }
}
}
diff --git a/LarkatorGUI/Properties/Settings.settings b/LarkatorGUI/Properties/Settings.settings
index 1bbcfa2..7b2bcc5 100644
--- a/LarkatorGUI/Properties/Settings.settings
+++ b/LarkatorGUI/Properties/Settings.settings
@@ -35,5 +35,11 @@
2000
+
+ 15
+
+
+ 0.9
+
\ No newline at end of file
diff --git a/LarkatorGUI/SettingsWindow.xaml b/LarkatorGUI/SettingsWindow.xaml
index 3ed1d88..e18a7be 100644
--- a/LarkatorGUI/SettingsWindow.xaml
+++ b/LarkatorGUI/SettingsWindow.xaml
@@ -27,13 +27,13 @@
- ARK Tools (.exe)
+ ARK Tools (ark-tools.exe)
- Save File (.ark)
+ Save file (.ark)
- Output Directory
+ Output directory
- Max Level
+ Max level
- Level Step
+ Level step
- Conversion Delay (ms)
- List font size
+
+ Conversion delay (ms)
+
diff --git a/LarkatorGUI/app.config b/LarkatorGUI/app.config
index 679dbaa..3f29b91 100644
--- a/LarkatorGUI/app.config
+++ b/LarkatorGUI/app.config
@@ -40,6 +40,12 @@
2000
+
+ 15
+
+
+ 0.9
+
\ No newline at end of file
diff --git a/ListViewLayout/ConverterGridViewColumn.cs b/ListViewLayout/ConverterGridViewColumn.cs
deleted file mode 100644
index 6c852af..0000000
--- a/ListViewLayout/ConverterGridViewColumn.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : ConverterGridViewColumn.cs
-// created : Jani Giannoudis - 2008.03.27
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System;
-using System.Windows.Data;
-using System.Windows.Controls;
-using System.Globalization;
-
-namespace Itenso.Windows.Controls.ListViewLayout
-{
-
- // ------------------------------------------------------------------------
- public abstract class ConverterGridViewColumn : GridViewColumn, IValueConverter
- {
-
- // ----------------------------------------------------------------------
- protected ConverterGridViewColumn( Type bindingType )
- {
- if ( bindingType == null )
- {
- throw new ArgumentNullException( "bindingType" );
- }
-
- this.bindingType = bindingType;
-
- // binding
- Binding binding = new Binding();
- binding.Mode = BindingMode.OneWay;
- binding.Converter = this;
- DisplayMemberBinding = binding;
- } // ConverterGridViewColumn
-
- // ----------------------------------------------------------------------
- public Type BindingType
- {
- get { return bindingType; }
- } // BindingType
-
- // ----------------------------------------------------------------------
- protected abstract object ConvertValue( object value );
-
- // ----------------------------------------------------------------------
- object IValueConverter.Convert( object value, Type targetType, object parameter, CultureInfo culture )
- {
- if ( !bindingType.IsInstanceOfType( value ) )
- {
- throw new InvalidOperationException();
- }
- return ConvertValue( value );
- } // IValueConverter.Convert
-
- // ----------------------------------------------------------------------
- object IValueConverter.ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
- {
- throw new NotImplementedException();
- } // IValueConverter.ConvertBack
-
- // ----------------------------------------------------------------------
- // members
- private readonly Type bindingType;
-
- } // class ConverterGridViewColumn
-
-} // namespace Itenso.Windows.Controls.ListViewLayout
-// -- EOF -------------------------------------------------------------------
diff --git a/ListViewLayout/FixedColumn.cs b/ListViewLayout/FixedColumn.cs
deleted file mode 100644
index 56fbbf0..0000000
--- a/ListViewLayout/FixedColumn.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : FixedColumn.cs
-// created : Jani Giannoudis - 2008.03.27
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System.Windows;
-using System.Windows.Controls;
-
-namespace Itenso.Windows.Controls.ListViewLayout
-{
-
- // ------------------------------------------------------------------------
- public sealed class FixedColumn : LayoutColumn
- {
-
- // ----------------------------------------------------------------------
- public static readonly DependencyProperty WidthProperty =
- DependencyProperty.RegisterAttached(
- "Width",
- typeof( double ),
- typeof( FixedColumn ) );
-
- // ----------------------------------------------------------------------
- private FixedColumn()
- {
- } // FixedColumn
-
- // ----------------------------------------------------------------------
- public static double GetWidth( DependencyObject obj )
- {
- return (double)obj.GetValue( WidthProperty );
- } // GetWidth
-
- // ----------------------------------------------------------------------
- public static void SetWidth( DependencyObject obj, double width )
- {
- obj.SetValue( WidthProperty, width );
- } // SetWidth
-
- // ----------------------------------------------------------------------
- public static bool IsFixedColumn( GridViewColumn column )
- {
- if ( column == null )
- {
- return false;
- }
- return HasPropertyValue( column, WidthProperty );
- } // IsFixedColumn
-
- // ----------------------------------------------------------------------
- public static double? GetFixedWidth( GridViewColumn column )
- {
- return GetColumnWidth( column, WidthProperty );
- } // GetFixedWidth
-
- // ----------------------------------------------------------------------
- public static GridViewColumn ApplyWidth( GridViewColumn gridViewColumn, double width )
- {
- SetWidth( gridViewColumn, width );
- return gridViewColumn;
- } // ApplyWidth
-
- } // class FixedColumn
-
-} // namespace Itenso.Windows.Controls.ListViewLayout
-// -- EOF -------------------------------------------------------------------
diff --git a/ListViewLayout/ImageGridViewColumn.cs b/ListViewLayout/ImageGridViewColumn.cs
deleted file mode 100644
index 4159c16..0000000
--- a/ListViewLayout/ImageGridViewColumn.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : ImageGridViewColumn.cs
-// created : Jani Giannoudis - 2008.03.27
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System;
-using System.Globalization;
-using System.Windows;
-using System.Windows.Data;
-using System.Windows.Media;
-using System.Windows.Controls;
-
-namespace Itenso.Windows.Controls.ListViewLayout
-{
-
- // ------------------------------------------------------------------------
- public abstract class ImageGridViewColumn : GridViewColumn, IValueConverter
- {
-
- // ----------------------------------------------------------------------
- protected ImageGridViewColumn() :
- this( Stretch.None )
- {
- } // ImageGridViewColumn
-
- // ----------------------------------------------------------------------
- protected ImageGridViewColumn( Stretch imageStretch )
- {
- FrameworkElementFactory imageElement = new FrameworkElementFactory( typeof( Image ) );
-
- // image source
- Binding imageSourceBinding = new Binding();
- imageSourceBinding.Converter = this;
- imageSourceBinding.Mode = BindingMode.OneWay;
- imageElement.SetBinding( Image.SourceProperty, imageSourceBinding );
-
- // image stretching
- Binding imageStretchBinding = new Binding();
- imageStretchBinding.Source = imageStretch;
- imageElement.SetBinding( Image.StretchProperty, imageStretchBinding );
-
- DataTemplate template = new DataTemplate();
- template.VisualTree = imageElement;
- CellTemplate = template;
- } // ImageGridViewColumn
-
- // ----------------------------------------------------------------------
- protected abstract ImageSource GetImageSource( object value );
-
- // ----------------------------------------------------------------------
- object IValueConverter.Convert( object value, Type targetType, object parameter, CultureInfo culture )
- {
- return GetImageSource( value );
- } // Convert
-
- // ----------------------------------------------------------------------
- object IValueConverter.ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
- {
- throw new NotImplementedException();
- } // ConvertBack
-
- } // class ImageGridViewColumn
-
-} // namespace Itenso.Windows.Controls.ListViewLayout
-// -- EOF -------------------------------------------------------------------
diff --git a/ListViewLayout/LayoutColumn.cs b/ListViewLayout/LayoutColumn.cs
deleted file mode 100644
index 2fc7d88..0000000
--- a/ListViewLayout/LayoutColumn.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : LayoutColumn.cs
-// created : Jani Giannoudis - 2008.03.27
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace Itenso.Windows.Controls.ListViewLayout
-{
-
- // ------------------------------------------------------------------------
- public abstract class LayoutColumn
- {
-
- // ----------------------------------------------------------------------
- protected static bool HasPropertyValue( GridViewColumn column, DependencyProperty dp )
- {
- if ( column == null )
- {
- throw new ArgumentNullException( "column" );
- }
- object value = column.ReadLocalValue( dp );
- if ( value != null && value.GetType() == dp.PropertyType )
- {
- return true;
- }
-
- return false;
- } // HasPropertyValue
-
- // ----------------------------------------------------------------------
- protected static double? GetColumnWidth( GridViewColumn column, DependencyProperty dp )
- {
- if ( column == null )
- {
- throw new ArgumentNullException( "column" );
- }
- object value = column.ReadLocalValue( dp );
- if ( value != null && value.GetType() == dp.PropertyType )
- {
- return (double)value;
- }
-
- return null;
- } // GetColumnWidth
-
- } // class LayoutColumn
-
-} // namespace Itenso.Windows.Controls.ListViewLayout
-// -- EOF -------------------------------------------------------------------
diff --git a/ListViewLayout/ListViewLayout.csproj b/ListViewLayout/ListViewLayout.csproj
deleted file mode 100644
index 29e1942..0000000
--- a/ListViewLayout/ListViewLayout.csproj
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 9.0.21022
- 2.0
- {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}
- Library
- Properties
- Itenso.Windows.Controls.ListViewLayout
- Itenso.Windows.Controls.ListViewLayout
- v3.0
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
-
-
-
-
- 3.5
-
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- AllRules.ruleset
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- AllRules.ruleset
-
-
-
-
-
- 3.0
-
-
- 3.0
-
-
- 3.0
-
-
-
-
-
-
-
-
-
-
- Code
-
-
-
-
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 3.5 SP1
- true
-
-
- False
- Windows Installer 3.1
- true
-
-
-
-
-
\ No newline at end of file
diff --git a/ListViewLayout/ListViewLayout2008.csproj b/ListViewLayout/ListViewLayout2008.csproj
deleted file mode 100644
index 25b96fc..0000000
--- a/ListViewLayout/ListViewLayout2008.csproj
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 9.0.21022
- 2.0
- {916A9879-3F2D-471F-AAFA-28F0C8A7FFA9}
- Library
- Properties
- Itenso.Windows.Controls.ListViewLayout
- Itenso.Windows.Controls.ListViewLayout
- v3.0
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
-
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
- 3.0
-
-
- 3.0
-
-
- 3.0
-
-
-
-
-
-
-
-
-
-
- Code
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ListViewLayout/ListViewLayoutManager.cs b/ListViewLayout/ListViewLayoutManager.cs
deleted file mode 100644
index fa43031..0000000
--- a/ListViewLayout/ListViewLayoutManager.cs
+++ /dev/null
@@ -1,609 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : ListViewLayoutManager.cs
-// created : Jani Giannoudis - 2008.03.27
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Input;
-using System.Windows.Controls;
-using System.Windows.Controls.Primitives;
-using System.ComponentModel;
-
-namespace Itenso.Windows.Controls.ListViewLayout
-{
-
- // ------------------------------------------------------------------------
- public class ListViewLayoutManager
- {
-
- // ----------------------------------------------------------------------
- public static readonly DependencyProperty EnabledProperty = DependencyProperty.RegisterAttached(
- "Enabled",
- typeof( bool ),
- typeof( ListViewLayoutManager ),
- new FrameworkPropertyMetadata( new PropertyChangedCallback( OnLayoutManagerEnabledChanged ) ) );
-
- // ----------------------------------------------------------------------
- public ListViewLayoutManager( ListView listView )
- {
- if ( listView == null )
- {
- throw new ArgumentNullException( "listView" );
- }
-
- this.listView = listView;
- this.listView.Loaded += new RoutedEventHandler( ListViewLoaded );
- this.listView.Unloaded += new RoutedEventHandler( ListViewUnloaded );
- } // ListViewLayoutManager
-
- // ----------------------------------------------------------------------
- public ListView ListView
- {
- get { return listView; }
- } // ListView
-
- // ----------------------------------------------------------------------
- public ScrollBarVisibility VerticalScrollBarVisibility
- {
- get { return verticalScrollBarVisibility; }
- set { verticalScrollBarVisibility = value; }
- } // VerticalScrollBarVisibility
-
- // ----------------------------------------------------------------------
- public static void SetEnabled( DependencyObject dependencyObject, bool enabled )
- {
- dependencyObject.SetValue( EnabledProperty, enabled );
- } // SetEnabled
-
- // ----------------------------------------------------------------------
- public void Refresh()
- {
- InitColumns();
- DoResizeColumns();
- } // Refresh
-
- // ----------------------------------------------------------------------
- private void RegisterEvents( DependencyObject start )
- {
- for ( int i = 0; i < VisualTreeHelper.GetChildrenCount( start ); i++ )
- {
- Visual childVisual = VisualTreeHelper.GetChild( start, i ) as Visual;
- if ( childVisual is Thumb )
- {
- GridViewColumn gridViewColumn = FindParentColumn( childVisual );
- if ( gridViewColumn != null )
- {
- Thumb thumb = childVisual as Thumb;
- if ( ProportionalColumn.IsProportionalColumn( gridViewColumn ) ||
- FixedColumn.IsFixedColumn( gridViewColumn ) || IsFillColumn( gridViewColumn ) )
- {
- thumb.IsHitTestVisible = false;
- }
- else
- {
- thumb.PreviewMouseMove += new MouseEventHandler( ThumbPreviewMouseMove );
- thumb.PreviewMouseLeftButtonDown += new MouseButtonEventHandler( ThumbPreviewMouseLeftButtonDown );
- DependencyPropertyDescriptor.FromProperty(
- GridViewColumn.WidthProperty,
- typeof( GridViewColumn ) ).AddValueChanged( gridViewColumn, GridColumnWidthChanged );
- }
- }
- }
- else if ( childVisual is GridViewColumnHeader )
- {
- GridViewColumnHeader columnHeader = childVisual as GridViewColumnHeader;
- columnHeader.SizeChanged += new SizeChangedEventHandler( GridColumnHeaderSizeChanged );
- }
- else if ( scrollViewer == null && childVisual is ScrollViewer )
- {
- scrollViewer = childVisual as ScrollViewer;
- scrollViewer.ScrollChanged += new ScrollChangedEventHandler( ScrollViewerScrollChanged );
- // assume we do the regulation of the horizontal scrollbar
- scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
- scrollViewer.VerticalScrollBarVisibility = verticalScrollBarVisibility;
- }
-
- RegisterEvents( childVisual ); // recursive
- }
- } // RegisterEvents
-
- // ----------------------------------------------------------------------
- private void UnregisterEvents( DependencyObject start )
- {
- for ( int i = 0; i < VisualTreeHelper.GetChildrenCount( start ); i++ )
- {
- Visual childVisual = VisualTreeHelper.GetChild( start, i ) as Visual;
- if ( childVisual is Thumb )
- {
- GridViewColumn gridViewColumn = FindParentColumn( childVisual );
- if ( gridViewColumn != null )
- {
- Thumb thumb = childVisual as Thumb;
- if ( ProportionalColumn.IsProportionalColumn( gridViewColumn ) ||
- FixedColumn.IsFixedColumn( gridViewColumn ) || IsFillColumn( gridViewColumn ) )
- {
- thumb.IsHitTestVisible = true;
- }
- else
- {
- thumb.PreviewMouseMove -= new MouseEventHandler( ThumbPreviewMouseMove );
- thumb.PreviewMouseLeftButtonDown -= new MouseButtonEventHandler( ThumbPreviewMouseLeftButtonDown );
- DependencyPropertyDescriptor.FromProperty(
- GridViewColumn.WidthProperty,
- typeof( GridViewColumn ) ).RemoveValueChanged( gridViewColumn, GridColumnWidthChanged );
- }
- }
- }
- else if ( childVisual is GridViewColumnHeader )
- {
- GridViewColumnHeader columnHeader = childVisual as GridViewColumnHeader;
- columnHeader.SizeChanged -= new SizeChangedEventHandler( GridColumnHeaderSizeChanged );
- }
- else if ( scrollViewer == null && childVisual is ScrollViewer )
- {
- scrollViewer = childVisual as ScrollViewer;
- scrollViewer.ScrollChanged -= new ScrollChangedEventHandler( ScrollViewerScrollChanged );
- }
-
- UnregisterEvents( childVisual ); // recursive
- }
- } // UnregisterEvents
-
- // ----------------------------------------------------------------------
- private GridViewColumn FindParentColumn( DependencyObject element )
- {
- if ( element == null )
- {
- return null;
- }
-
- while ( element != null )
- {
- GridViewColumnHeader gridViewColumnHeader = element as GridViewColumnHeader;
- if ( gridViewColumnHeader != null )
- {
- return ( gridViewColumnHeader ).Column;
- }
- element = VisualTreeHelper.GetParent( element );
- }
-
- return null;
- } // FindParentColumn
-
- // ----------------------------------------------------------------------
- private GridViewColumnHeader FindColumnHeader( DependencyObject start, GridViewColumn gridViewColumn )
- {
- for ( int i = 0; i < VisualTreeHelper.GetChildrenCount( start ); i++ )
- {
- Visual childVisual = VisualTreeHelper.GetChild( start, i ) as Visual;
- if ( childVisual is GridViewColumnHeader )
- {
- GridViewColumnHeader gridViewHeader = childVisual as GridViewColumnHeader;
- if ( gridViewHeader.Column == gridViewColumn )
- {
- return gridViewHeader;
- }
- }
- GridViewColumnHeader childGridViewHeader = FindColumnHeader( childVisual, gridViewColumn ); // recursive
- if ( childGridViewHeader != null )
- {
- return childGridViewHeader;
- }
- }
- return null;
- } // FindColumnHeader
-
- // ----------------------------------------------------------------------
- private void InitColumns()
- {
- GridView view = listView.View as GridView;
- if ( view == null )
- {
- return;
- }
-
- foreach ( GridViewColumn gridViewColumn in view.Columns )
- {
- if ( !RangeColumn.IsRangeColumn( gridViewColumn ) )
- {
- continue;
- }
-
- double? minWidth = RangeColumn.GetRangeMinWidth( gridViewColumn );
- double? maxWidth = RangeColumn.GetRangeMaxWidth( gridViewColumn );
- if ( !minWidth.HasValue && !maxWidth.HasValue )
- {
- continue;
- }
-
- GridViewColumnHeader columnHeader = FindColumnHeader( listView, gridViewColumn );
- if ( columnHeader == null )
- {
- continue;
- }
-
- double actualWidth = columnHeader.ActualWidth;
- if ( minWidth.HasValue )
- {
- columnHeader.MinWidth = minWidth.Value;
- if ( !double.IsInfinity( actualWidth ) && actualWidth < columnHeader.MinWidth )
- {
- gridViewColumn.Width = columnHeader.MinWidth;
- }
- }
- if ( maxWidth.HasValue )
- {
- columnHeader.MaxWidth = maxWidth.Value;
- if ( !double.IsInfinity( actualWidth ) && actualWidth > columnHeader.MaxWidth )
- {
- gridViewColumn.Width = columnHeader.MaxWidth;
- }
- }
- }
- } // InitColumns
-
- // ----------------------------------------------------------------------
- protected virtual void ResizeColumns()
- {
- GridView view = listView.View as GridView;
- if ( view == null || view.Columns.Count == 0 )
- {
- return;
- }
-
- // listview width
- double actualWidth = double.PositiveInfinity;
- if ( scrollViewer != null )
- {
- actualWidth = scrollViewer.ViewportWidth;
- }
- if ( double.IsInfinity( actualWidth ) )
- {
- actualWidth = listView.ActualWidth;
- }
- if ( double.IsInfinity( actualWidth ) || actualWidth <= 0 )
- {
- return;
- }
-
- double resizeableRegionCount = 0;
- double otherColumnsWidth = 0;
- // determine column sizes
- foreach ( GridViewColumn gridViewColumn in view.Columns )
- {
- if ( ProportionalColumn.IsProportionalColumn( gridViewColumn ) )
- {
- double? proportionalWidth = ProportionalColumn.GetProportionalWidth( gridViewColumn );
- if ( proportionalWidth != null )
- {
- resizeableRegionCount += proportionalWidth.Value;
- }
- }
- else
- {
- otherColumnsWidth += gridViewColumn.ActualWidth;
- }
- }
-
- if ( resizeableRegionCount <= 0 )
- {
- // no proportional columns present: commit the regulation to the scroll viewer
- if ( scrollViewer != null )
- {
- scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
- }
-
- // search the first fill column
- GridViewColumn fillColumn = null;
- for ( int i = 0; i < view.Columns.Count; i++ )
- {
- GridViewColumn gridViewColumn = view.Columns[ i ];
- if ( IsFillColumn( gridViewColumn ) )
- {
- fillColumn = gridViewColumn;
- break;
- }
- }
-
- if ( fillColumn != null )
- {
- double otherColumnsWithoutFillWidth = otherColumnsWidth - fillColumn.ActualWidth;
- double fillWidth = actualWidth - otherColumnsWithoutFillWidth;
- if ( fillWidth > 0 )
- {
- double? minWidth = RangeColumn.GetRangeMinWidth( fillColumn );
- double? maxWidth = RangeColumn.GetRangeMaxWidth( fillColumn );
-
- bool setWidth = !( minWidth.HasValue && fillWidth < minWidth.Value );
- if ( maxWidth.HasValue && fillWidth > maxWidth.Value )
- {
- setWidth = false;
- }
- if ( setWidth )
- {
- if ( scrollViewer != null )
- {
- scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
- }
- fillColumn.Width = fillWidth;
- }
- }
- }
- return;
- }
-
- double resizeableColumnsWidth = actualWidth - otherColumnsWidth;
- if ( resizeableColumnsWidth <= 0 )
- {
- return; // missing space
- }
-
- // resize columns
- double resizeableRegionWidth = resizeableColumnsWidth / resizeableRegionCount;
- foreach ( GridViewColumn gridViewColumn in view.Columns )
- {
- if ( ProportionalColumn.IsProportionalColumn( gridViewColumn ) )
- {
- double? proportionalWidth = ProportionalColumn.GetProportionalWidth( gridViewColumn );
- if ( proportionalWidth != null )
- {
- gridViewColumn.Width = proportionalWidth.Value * resizeableRegionWidth;
- }
- }
- }
- } // ResizeColumns
-
- // ----------------------------------------------------------------------
- // returns the delta
- private double SetRangeColumnToBounds( GridViewColumn gridViewColumn )
- {
- double startWidth = gridViewColumn.Width;
-
- double? minWidth = RangeColumn.GetRangeMinWidth( gridViewColumn );
- double? maxWidth = RangeColumn.GetRangeMaxWidth( gridViewColumn );
-
- if ( ( minWidth.HasValue && maxWidth.HasValue ) && ( minWidth > maxWidth ) )
- {
- return 0; // invalid case
- }
-
- if ( minWidth.HasValue && gridViewColumn.Width < minWidth.Value )
- {
- gridViewColumn.Width = minWidth.Value;
- }
- else if ( maxWidth.HasValue && gridViewColumn.Width > maxWidth.Value )
- {
- gridViewColumn.Width = maxWidth.Value;
- }
-
- return gridViewColumn.Width - startWidth;
- } // SetRangeColumnToBounds
-
- // ----------------------------------------------------------------------
- private bool IsFillColumn( GridViewColumn gridViewColumn )
- {
- if ( gridViewColumn == null )
- {
- return false;
- }
-
- GridView view = listView.View as GridView;
- if ( view == null || view.Columns.Count == 0 )
- {
- return false;
- }
-
- bool? isFillColumn = RangeColumn.GetRangeIsFillColumn( gridViewColumn );
- return isFillColumn.HasValue && isFillColumn.Value;
- } // IsFillColumn
-
- // ----------------------------------------------------------------------
- private void DoResizeColumns()
- {
- if ( resizing )
- {
- return;
- }
-
- resizing = true;
- try
- {
- ResizeColumns();
- }
- finally
- {
- resizing = false;
- }
- } // DoResizeColumns
-
- // ----------------------------------------------------------------------
- private void ListViewLoaded( object sender, RoutedEventArgs e )
- {
- RegisterEvents( listView );
- InitColumns();
- DoResizeColumns();
- loaded = true;
- } // ListViewLoaded
-
- // ----------------------------------------------------------------------
- private void ListViewUnloaded( object sender, RoutedEventArgs e )
- {
- if ( !loaded )
- {
- return;
- }
- UnregisterEvents( listView );
- loaded = false;
- } // ListViewUnloaded
-
- // ----------------------------------------------------------------------
- private void ThumbPreviewMouseMove( object sender, MouseEventArgs e )
- {
- Thumb thumb = sender as Thumb;
- if ( thumb == null )
- {
- return;
- }
- GridViewColumn gridViewColumn = FindParentColumn( thumb );
- if ( gridViewColumn == null )
- {
- return;
- }
-
- // suppress column resizing for proportional, fixed and range fill columns
- if ( ProportionalColumn.IsProportionalColumn( gridViewColumn ) ||
- FixedColumn.IsFixedColumn( gridViewColumn ) ||
- IsFillColumn( gridViewColumn ) )
- {
- thumb.Cursor = null;
- return;
- }
-
- // check range column bounds
- if ( thumb.IsMouseCaptured && RangeColumn.IsRangeColumn( gridViewColumn ) )
- {
- double? minWidth = RangeColumn.GetRangeMinWidth( gridViewColumn );
- double? maxWidth = RangeColumn.GetRangeMaxWidth( gridViewColumn );
-
- if ( ( minWidth.HasValue && maxWidth.HasValue ) && ( minWidth > maxWidth ) )
- {
- return; // invalid case
- }
-
- if ( resizeCursor == null )
- {
- resizeCursor = thumb.Cursor; // save the resize cursor
- }
-
- if ( minWidth.HasValue && gridViewColumn.Width <= minWidth.Value )
- {
- thumb.Cursor = Cursors.No;
- }
- else if ( maxWidth.HasValue && gridViewColumn.Width >= maxWidth.Value )
- {
- thumb.Cursor = Cursors.No;
- }
- else
- {
- thumb.Cursor = resizeCursor; // between valid min/max
- }
- }
- } // ThumbPreviewMouseMove
-
- // ----------------------------------------------------------------------
- private void ThumbPreviewMouseLeftButtonDown( object sender, MouseButtonEventArgs e )
- {
- Thumb thumb = sender as Thumb;
- GridViewColumn gridViewColumn = FindParentColumn( thumb );
-
- // suppress column resizing for proportional, fixed and range fill columns
- if ( ProportionalColumn.IsProportionalColumn( gridViewColumn ) ||
- FixedColumn.IsFixedColumn( gridViewColumn ) ||
- IsFillColumn( gridViewColumn ) )
- {
- e.Handled = true;
- }
- } // ThumbPreviewMouseLeftButtonDown
-
- // ----------------------------------------------------------------------
- private void GridColumnWidthChanged( object sender, EventArgs e )
- {
- if ( !loaded )
- {
- return;
- }
-
- GridViewColumn gridViewColumn = sender as GridViewColumn;
-
- // suppress column resizing for proportional and fixed columns
- if ( ProportionalColumn.IsProportionalColumn( gridViewColumn ) || FixedColumn.IsFixedColumn( gridViewColumn ) )
- {
- return;
- }
-
- // ensure range column within the bounds
- if ( RangeColumn.IsRangeColumn( gridViewColumn ) )
- {
- // special case: auto column width - maybe conflicts with min/max range
- if ( gridViewColumn != null && gridViewColumn.Width.Equals( double.NaN ) )
- {
- autoSizedColumn = gridViewColumn;
- return; // handled by the change header size event
- }
-
- // ensure column bounds
- if ( Math.Abs( SetRangeColumnToBounds( gridViewColumn ) - 0 ) > zeroWidthRange )
- {
- return;
- }
- }
-
- DoResizeColumns();
- } // GridColumnWidthChanged
-
- // ----------------------------------------------------------------------
- // handle autosized column
- private void GridColumnHeaderSizeChanged( object sender, SizeChangedEventArgs e )
- {
- if ( autoSizedColumn == null )
- {
- return;
- }
-
- GridViewColumnHeader gridViewColumnHeader = sender as GridViewColumnHeader;
- if ( gridViewColumnHeader != null && gridViewColumnHeader.Column == autoSizedColumn )
- {
- if ( gridViewColumnHeader.Width.Equals( double.NaN ) )
- {
- // sync column with
- gridViewColumnHeader.Column.Width = gridViewColumnHeader.ActualWidth;
- DoResizeColumns();
- }
-
- autoSizedColumn = null;
- }
- } // GridColumnHeaderSizeChanged
-
- // ----------------------------------------------------------------------
- private void ScrollViewerScrollChanged( object sender, ScrollChangedEventArgs e )
- {
- if ( loaded && Math.Abs( e.ViewportWidthChange - 0 ) > zeroWidthRange )
- {
- DoResizeColumns();
- }
- } // ScrollViewerScrollChanged
-
- // ----------------------------------------------------------------------
- private static void OnLayoutManagerEnabledChanged( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e )
- {
- ListView listView = dependencyObject as ListView;
- if ( listView != null )
- {
- bool enabled = (bool)e.NewValue;
- if ( enabled )
- {
- new ListViewLayoutManager( listView );
- }
- }
- } // OnLayoutManagerEnabledChanged
-
- // ----------------------------------------------------------------------
- // members
- private readonly ListView listView;
- private ScrollViewer scrollViewer;
- private bool loaded;
- private bool resizing;
- private Cursor resizeCursor;
- private ScrollBarVisibility verticalScrollBarVisibility = ScrollBarVisibility.Auto;
- private GridViewColumn autoSizedColumn;
-
- private const double zeroWidthRange = 0.1;
-
- } // class ListViewLayoutManager
-
-} // namespace Itenso.Windows.Controls.ListViewLayout
-// -- EOF -------------------------------------------------------------------
diff --git a/ListViewLayout/Properties/AssemblyInfo.cs b/ListViewLayout/Properties/AssemblyInfo.cs
deleted file mode 100644
index 9dcce7b..0000000
--- a/ListViewLayout/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : AssemblyInfo.cs
-// created : Jani Giannoudis - 2008.04.03
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-[assembly: AssemblyTitle( "ListViewLayout" )]
-[assembly: AssemblyDescription( "" )]
-[assembly: AssemblyConfiguration( "" )]
-[assembly: AssemblyCompany( "Itenso GmbH" )]
-[assembly: AssemblyProduct( "ListViewLayout" )]
-[assembly: AssemblyCopyright( "Copyright © Itenso GmbH 2008-2012" )]
-[assembly: AssemblyTrademark( "" )]
-[assembly: AssemblyCulture( "" )]
-[assembly: ComVisible( false )]
-[assembly: CLSCompliant( true )]
-[assembly: ThemeInfo(
- ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
- ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
-)]
-[assembly: AssemblyVersion( "1.3.0.0" )]
-[assembly: AssemblyFileVersion( "1.3.0.0" )]
-
-// -- EOF -------------------------------------------------------------------
diff --git a/ListViewLayout/ProportionalColumn.cs b/ListViewLayout/ProportionalColumn.cs
deleted file mode 100644
index 3023c97..0000000
--- a/ListViewLayout/ProportionalColumn.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : ProportionalColumn.cs
-// created : Jani Giannoudis - 2008.03.27
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System.Windows;
-using System.Windows.Controls;
-
-namespace Itenso.Windows.Controls.ListViewLayout
-{
-
- // ------------------------------------------------------------------------
- public sealed class ProportionalColumn : LayoutColumn
- {
-
- // ----------------------------------------------------------------------
- public static readonly DependencyProperty WidthProperty =
- DependencyProperty.RegisterAttached(
- "Width",
- typeof( double ),
- typeof( ProportionalColumn ) );
-
- // ----------------------------------------------------------------------
- private ProportionalColumn()
- {
- } // ProportionalColumn
-
- // ----------------------------------------------------------------------
- public static double GetWidth( DependencyObject obj )
- {
- return (double)obj.GetValue( WidthProperty );
- } // GetWidth
-
- // ----------------------------------------------------------------------
- public static void SetWidth( DependencyObject obj, double width )
- {
- obj.SetValue( WidthProperty, width );
- } // SetWidth
-
- // ----------------------------------------------------------------------
- public static bool IsProportionalColumn( GridViewColumn column )
- {
- if ( column == null )
- {
- return false;
- }
- return HasPropertyValue( column, WidthProperty );
- } // IsProportionalColumn
-
- // ----------------------------------------------------------------------
- public static double? GetProportionalWidth( GridViewColumn column )
- {
- return GetColumnWidth( column, WidthProperty );
- } // GetProportionalWidth
-
- // ----------------------------------------------------------------------
- public static GridViewColumn ApplyWidth( GridViewColumn gridViewColumn, double width )
- {
- SetWidth( gridViewColumn, width );
- return gridViewColumn;
- } // ApplyWidth
-
- } // class ProportionalColumn
-
-} // namespace Itenso.Windows.Controls.ListViewLayout
-// -- EOF -------------------------------------------------------------------
diff --git a/ListViewLayout/RangeColumn.cs b/ListViewLayout/RangeColumn.cs
deleted file mode 100644
index 331f6d1..0000000
--- a/ListViewLayout/RangeColumn.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-// -- FILE ------------------------------------------------------------------
-// name : RangeColumn.cs
-// created : Jani Giannoudis - 2008.03.27
-// language : c#
-// environment: .NET 3.0
-// copyright : (c) 2008-2012 by Itenso GmbH, Switzerland
-// --------------------------------------------------------------------------
-using System;
-using System.Windows;
-using System.Windows.Controls;
-
-namespace Itenso.Windows.Controls.ListViewLayout
-{
-
- // ------------------------------------------------------------------------
- public sealed class RangeColumn : LayoutColumn
- {
-
- // ----------------------------------------------------------------------
- public static readonly DependencyProperty MinWidthProperty =
- DependencyProperty.RegisterAttached(
- "MinWidth",
- typeof( double ),
- typeof( RangeColumn ) );
-
- // ----------------------------------------------------------------------
- public static readonly DependencyProperty MaxWidthProperty =
- DependencyProperty.RegisterAttached(
- "MaxWidth",
- typeof( double ),
- typeof( RangeColumn ) );
-
- // ----------------------------------------------------------------------
- public static readonly DependencyProperty IsFillColumnProperty =
- DependencyProperty.RegisterAttached(
- "IsFillColumn",
- typeof( bool ),
- typeof( RangeColumn ) );
-
- // ----------------------------------------------------------------------
- private RangeColumn()
- {
- } // RangeColumn
-
- // ----------------------------------------------------------------------
- public static double GetMinWidth( DependencyObject obj )
- {
- return (double)obj.GetValue( MinWidthProperty );
- } // GetMinWidth
-
- // ----------------------------------------------------------------------
- public static void SetMinWidth( DependencyObject obj, double minWidth )
- {
- obj.SetValue( MinWidthProperty, minWidth );
- } // SetMinWidth
-
- // ----------------------------------------------------------------------
- public static double GetMaxWidth( DependencyObject obj )
- {
- return (double)obj.GetValue( MaxWidthProperty );
- } // GetMaxWidth
-
- // ----------------------------------------------------------------------
- public static void SetMaxWidth( DependencyObject obj, double maxWidth )
- {
- obj.SetValue( MaxWidthProperty, maxWidth );
- } // SetMaxWidth
-
- // ----------------------------------------------------------------------
- public static bool GetIsFillColumn( DependencyObject obj )
- {
- return (bool)obj.GetValue( IsFillColumnProperty );
- } // GetIsFillColumn
-
- // ----------------------------------------------------------------------
- public static void SetIsFillColumn( DependencyObject obj, bool isFillColumn )
- {
- obj.SetValue( IsFillColumnProperty, isFillColumn );
- } // SetIsFillColumn
-
- // ----------------------------------------------------------------------
- public static bool IsRangeColumn( GridViewColumn column )
- {
- if ( column == null )
- {
- return false;
- }
- return
- HasPropertyValue( column, MinWidthProperty ) ||
- HasPropertyValue( column, MaxWidthProperty ) ||
- HasPropertyValue( column, IsFillColumnProperty );
- } // IsRangeColumn
-
- // ----------------------------------------------------------------------
- public static double? GetRangeMinWidth( GridViewColumn column )
- {
- return GetColumnWidth( column, MinWidthProperty );
- } // GetRangeMinWidth
-
- // ----------------------------------------------------------------------
- public static double? GetRangeMaxWidth( GridViewColumn column )
- {
- return GetColumnWidth( column, MaxWidthProperty );
- } // GetRangeMaxWidth
-
- // ----------------------------------------------------------------------
- public static bool? GetRangeIsFillColumn( GridViewColumn column )
- {
- if ( column == null )
- {
- throw new ArgumentNullException( "column" );
- }
- object value = column.ReadLocalValue( IsFillColumnProperty );
- if ( value != null && value.GetType() == IsFillColumnProperty.PropertyType )
- {
- return (bool)value;
- }
-
- return null;
- } // GetRangeIsFillColumn
-
- // ----------------------------------------------------------------------
- public static GridViewColumn ApplyWidth( GridViewColumn gridViewColumn, double minWidth,
- double width, double maxWidth )
- {
- return ApplyWidth( gridViewColumn, minWidth, width, maxWidth, false );
- } // ApplyWidth
-
- // ----------------------------------------------------------------------
- public static GridViewColumn ApplyWidth( GridViewColumn gridViewColumn, double minWidth,
- double width, double maxWidth, bool isFillColumn )
- {
- SetMinWidth( gridViewColumn, minWidth );
- gridViewColumn.Width = width;
- SetMaxWidth( gridViewColumn, maxWidth );
- SetIsFillColumn( gridViewColumn, isFillColumn );
- return gridViewColumn;
- } // ApplyWidth
-
- } // class RangeColumn
-
-} // namespace Itenso.Windows.Controls.ListViewLayout
-// -- EOF -------------------------------------------------------------------