1,4 → 1,54 |
using GMap.NET; |
///============================================================================ |
/// MKLiveView |
/// Copyright © 2016 Steph |
/// |
///This file is part of MKLiveView. |
/// |
///MKLiveView is free software: you can redistribute it and/or modify |
///it under the terms of the GNU General Public License as published by |
///the Free Software Foundation, either version 3 of the License, or |
///(at your option) any later version. |
/// |
///MKLiveView is distributed in the hope that it will be useful, |
///but WITHOUT ANY WARRANTY; without even the implied warranty of |
///MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
///GNU General Public License for more details. |
/// |
///You should have received a copy of the GNU General Public License |
///along with cssRcon. If not, see <http://www.gnu.org/licenses/>. |
/// |
///============================================================================ |
///Credits: |
|
/// radioman (http://www.codeplex.com/site/users/view/radioman) |
/// for his really GreatMaps! (http://greatmaps.codeplex.com/) |
/// |
/// I made some changes to the source, so You need all files from this project here in order to compile and run |
/// |
/// JOHN C. MACDONALD at Ira A. Fulton College of Engineering and Technology |
/// for his MIKROKOPTER SERIAL CONTROL TUTORIAL (http://hdl.lib.byu.edu/1877/2747) |
/// and the sourcecode (http://hdl.lib.byu.edu/1877/2748) |
/// By his work I finally managed to get the communication with the Mikrokopter controllers to run |
/// Some of his code was used in this programm like the SimpelSerialPort class (with lots of changes) |
/// and the FilghtControllerMessage class |
/// |
///============================================================================ |
/// DISCLAIMER |
/// =========== |
/// |
/// I created this software with my best knowledge and belief. |
/// |
/// IN NO EVENT, UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, |
/// SHALL I, OR ANY PERSON BE LIABLE FOR ANY LOSS, EXPENSE OR DAMAGE, |
/// OF ANY TYPE OR NATURE ARISING OUT OF THE USE OF, |
/// OR INABILITY TO USE THIS SOFTWARE OR PROGRAM, |
/// INCLUDING, BUT NOT LIMITED TO, CLAIMS, SUITS OR CAUSES OF ACTION |
/// INVOLVING ALLEGED INFRINGEMENT OF COPYRIGHTS, |
/// PATENTS, TRADEMARKS, TRADE SECRETS, OR UNFAIR COMPETITION. |
/// |
/// This means: use it & have fun (but @ Your own risk...) |
/// =========================================================================== |
using GMap.NET; |
using GMap.NET.MapProviders; |
using GMap.NET.WindowsPresentation; |
using MKLiveView.GMapCustomMarkers; |
691,6 → 741,48 |
Application.Current.Shutdown(); |
} |
|
#region doubletap //http://stackoverflow.com/questions/9001023/capturing-double-tap-touch-on-multi-touch-screen |
private Point? _lastTapLocation; |
private readonly Stopwatch _doubleTapStopwatch = new Stopwatch(); |
|
private bool IsDoubleTap(TouchEventArgs e) |
{ |
Point currentTapPosition = e.GetTouchPoint(this).Position; |
bool tapsAreCloseInDistance = false; |
if (_lastTapLocation != null) |
{ |
tapsAreCloseInDistance = GetDistanceBetweenPoints(currentTapPosition, (Point)_lastTapLocation) < 70; |
} |
_lastTapLocation = currentTapPosition; |
|
TimeSpan elapsed = _doubleTapStopwatch.Elapsed; |
_doubleTapStopwatch.Restart(); |
bool tapsAreCloseInTime = (elapsed != TimeSpan.Zero && elapsed < TimeSpan.FromSeconds(0.4)); |
|
if (tapsAreCloseInTime && tapsAreCloseInDistance) |
{ |
_lastTapLocation = null; |
} |
return tapsAreCloseInDistance && tapsAreCloseInTime; |
} |
|
private void OnPreviewTouchDown(object sender, TouchEventArgs e) |
{ |
if (IsDoubleTap(e)) |
{ |
MainMap.CanDragMap = false; |
MessageBox.Show("Blubb!"); |
} |
} |
public static double GetDistanceBetweenPoints(Point p, Point q) |
{ |
double a = p.X - q.X; |
double b = p.Y - q.Y; |
double distance = Math.Sqrt(a * a + b * b); |
return distance; |
} |
|
#endregion doubletap |
#endregion events |
|
#region GMap |
1845,6 → 1937,8 |
switch ((int)data[0]) |
{ |
case 10: |
char[] c = Encoding.ASCII.GetChars(new byte[] { data[13] }); |
Dispatcher.Invoke((Action)(() => tbCamCtrl.Text = c[0].ToString())); |
break; |
case 11: |
OSDSTATUSFLAGS2 = osd.OSDSTATUSFLAGS2(); |
1931,6 → 2025,8 |
} |
Dispatcher.Invoke((Action)(() => tbWPMaxRange.Text = iVal.ToString() + " m")); |
} |
//--------------- LiPoCell count ------------------------ |
Dispatcher.Invoke((Action)(() => tbLiPoCells.Text = data[25].ToString())); |
|
break; |
|
2408,10 → 2504,10 |
Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = ((double)(iVal)/100).ToString("0.00 m/s"))); |
|
//--------------- Heading north ------------------------ |
i_16 = data[61]; |
i_16 = (Int16)(i_16 << 8); |
iVal = data[60] + i_16; |
Dispatcher.Invoke((Action)(() => tbHeadingNorth.Text = iVal.ToString() + " °")); |
//i_16 = data[61]; |
//i_16 = (Int16)(i_16 << 8); |
//iVal = data[60] + i_16; |
//Dispatcher.Invoke((Action)(() => tbHeadingNorth.Text = iVal.ToString() + " °")); |
|
//--------------- Heading compass ------------------------ |
i_16 = data[63]; |
5152,6 → 5248,7 |
|
} |
|
|
private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
{ |
_loadGPXLog(); |
5416,5 → 5513,4 |
IsMaximized = false; |
} |
} |
|
} |