From c9c631530eb0ddd78b2a1e7f75b92ce8fc15a5ab Mon Sep 17 00:00:00 2001 From: Morten Nielsen <1378165+dotMorten@users.noreply.github.com> Date: Tue, 28 Jan 2020 20:44:16 -0800 Subject: [PATCH] Add custom ArcGIS location provider to desktop sample (#69) * Location provider sample for ArcGIS Runtime --- src/SampleApp.WinDesktop/AltitudeGraph.xaml | 27 + .../AltitudeGraph.xaml.cs | 91 ++++ src/SampleApp.WinDesktop/App.config | 2 +- src/SampleApp.WinDesktop/MainWindow.xaml | 227 ++++++--- src/SampleApp.WinDesktop/MainWindow.xaml.cs | 478 +++++++++--------- src/SampleApp.WinDesktop/NmeaProvider.cs | 100 ++++ .../Properties/Resources.Designer.cs | 63 --- .../Properties/Resources.resx | 117 ----- .../Properties/Settings.Designer.cs | 26 - .../Properties/Settings.settings | 7 - .../RestoreAutoPanMode.cs | 148 ++++++ .../SampleApp.NetCore.csproj | 3 + src/SampleApp.WinDesktop/SatelliteSnr.xaml | 2 +- src/SampleApp.WinDesktop/SatelliteView.xaml | 2 +- 14 files changed, 766 insertions(+), 527 deletions(-) create mode 100644 src/SampleApp.WinDesktop/AltitudeGraph.xaml create mode 100644 src/SampleApp.WinDesktop/AltitudeGraph.xaml.cs create mode 100644 src/SampleApp.WinDesktop/NmeaProvider.cs delete mode 100644 src/SampleApp.WinDesktop/Properties/Resources.Designer.cs delete mode 100644 src/SampleApp.WinDesktop/Properties/Resources.resx delete mode 100644 src/SampleApp.WinDesktop/Properties/Settings.Designer.cs delete mode 100644 src/SampleApp.WinDesktop/Properties/Settings.settings create mode 100644 src/SampleApp.WinDesktop/RestoreAutoPanMode.cs diff --git a/src/SampleApp.WinDesktop/AltitudeGraph.xaml b/src/SampleApp.WinDesktop/AltitudeGraph.xaml new file mode 100644 index 0000000..d5b9d23 --- /dev/null +++ b/src/SampleApp.WinDesktop/AltitudeGraph.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + diff --git a/src/SampleApp.WinDesktop/AltitudeGraph.xaml.cs b/src/SampleApp.WinDesktop/AltitudeGraph.xaml.cs new file mode 100644 index 0000000..5d35869 --- /dev/null +++ b/src/SampleApp.WinDesktop/AltitudeGraph.xaml.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SampleApp.WinDesktop +{ + /// + /// Interaction logic for AltitudeGraph.xaml + /// + public partial class AltitudeGraph : UserControl + { + Queue datapoints = new Queue(); + double min = double.MaxValue; + double max = double.MinValue; + public AltitudeGraph() + { + InitializeComponent(); + MaxDatapoints = 150; + } + + public void AddDataPoint(double value) + { + if (double.IsNaN(value)) + return; + datapoints.Enqueue(value); + min = Math.Min(value, double.IsNaN(min) ? value : min); + max = Math.Max(value, double.IsNaN(max) ? value : max); + if (datapoints.Count > MaxDatapoints) + { + double val = datapoints.Dequeue(); + //If this is the limiting value, recalculate min/max + if (val == min) + min = datapoints.Min(); + if (val == max) + max = datapoints.Max(); + } + UpdatePath(); + mintb.Text = min.ToString("0"); + maxtb.Text = max.ToString("0"); + } + + private void UpdatePath() + { + if(!datapoints.Any()) + { + path.Data = null; + return; + } + var data = datapoints.ToArray(); + List segments = new List(); + for(int i=1;i - + diff --git a/src/SampleApp.WinDesktop/MainWindow.xaml b/src/SampleApp.WinDesktop/MainWindow.xaml index 7e5f61d..7611dd2 100644 --- a/src/SampleApp.WinDesktop/MainWindow.xaml +++ b/src/SampleApp.WinDesktop/MainWindow.xaml @@ -1,7 +1,8 @@  @@ -12,89 +13,153 @@ + BlurRadius="20" Opacity=".5" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -