Rev 2429 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2429 | Rev 2431 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | ///============================================================================ |
|
- | 2 | /// MKLiveView |
|
- | 3 | /// Copyright © 2016 Steph |
|
- | 4 | /// |
|
- | 5 | ///This file is part of MKLiveView. |
|
- | 6 | /// |
|
- | 7 | ///MKLiveView is free software: you can redistribute it and/or modify |
|
- | 8 | ///it under the terms of the GNU General Public License as published by |
|
- | 9 | ///the Free Software Foundation, either version 3 of the License, or |
|
- | 10 | ///(at your option) any later version. |
|
- | 11 | /// |
|
- | 12 | ///MKLiveView is distributed in the hope that it will be useful, |
|
- | 13 | ///but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
- | 14 | ///MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
- | 15 | ///GNU General Public License for more details. |
|
- | 16 | /// |
|
- | 17 | ///You should have received a copy of the GNU General Public License |
|
- | 18 | ///along with cssRcon. If not, see <http://www.gnu.org/licenses/>. |
|
- | 19 | /// |
|
- | 20 | ///============================================================================ |
|
- | 21 | ///Credits: |
|
- | 22 | ||
- | 23 | /// radioman (http://www.codeplex.com/site/users/view/radioman) |
|
- | 24 | /// for his really GreatMaps! (http://greatmaps.codeplex.com/) |
|
- | 25 | /// |
|
- | 26 | /// I made some changes to the source, so You need all files from this project here in order to compile and run |
|
- | 27 | /// |
|
- | 28 | /// JOHN C. MACDONALD at Ira A. Fulton College of Engineering and Technology |
|
- | 29 | /// for his MIKROKOPTER SERIAL CONTROL TUTORIAL (http://hdl.lib.byu.edu/1877/2747) |
|
- | 30 | /// and the sourcecode (http://hdl.lib.byu.edu/1877/2748) |
|
- | 31 | /// By his work I finally managed to get the communication with the Mikrokopter controllers to run |
|
- | 32 | /// Some of his code was used in this programm like the SimpelSerialPort class (with lots of changes) |
|
- | 33 | /// and the FilghtControllerMessage class |
|
- | 34 | /// |
|
- | 35 | ///============================================================================ |
|
- | 36 | /// DISCLAIMER |
|
- | 37 | /// =========== |
|
- | 38 | /// |
|
- | 39 | /// I created this software with my best knowledge and belief. |
|
- | 40 | /// |
|
- | 41 | /// IN NO EVENT, UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, |
|
- | 42 | /// SHALL I, OR ANY PERSON BE LIABLE FOR ANY LOSS, EXPENSE OR DAMAGE, |
|
- | 43 | /// OF ANY TYPE OR NATURE ARISING OUT OF THE USE OF, |
|
- | 44 | /// OR INABILITY TO USE THIS SOFTWARE OR PROGRAM, |
|
- | 45 | /// INCLUDING, BUT NOT LIMITED TO, CLAIMS, SUITS OR CAUSES OF ACTION |
|
- | 46 | /// INVOLVING ALLEGED INFRINGEMENT OF COPYRIGHTS, |
|
- | 47 | /// PATENTS, TRADEMARKS, TRADE SECRETS, OR UNFAIR COMPETITION. |
|
- | 48 | /// |
|
- | 49 | /// This means: use it & have fun (but @ Your own risk...) |
|
- | 50 | /// =========================================================================== |
|
1 | using GMap.NET; |
51 | using GMap.NET; |
2 | using GMap.NET.MapProviders; |
52 | using GMap.NET.MapProviders; |
3 | using GMap.NET.WindowsPresentation; |
53 | using GMap.NET.WindowsPresentation; |
4 | using MKLiveView.GMapCustomMarkers; |
54 | using MKLiveView.GMapCustomMarkers; |
5 | using System; |
55 | using System; |
6 | using System.Collections.Generic; |
56 | using System.Collections.Generic; |
Line 689... | Line 739... | ||
689 | private void Window_Closed(object sender, EventArgs e) |
739 | private void Window_Closed(object sender, EventArgs e) |
690 | { |
740 | { |
691 | Application.Current.Shutdown(); |
741 | Application.Current.Shutdown(); |
692 | } |
742 | } |
Line -... | Line 743... | ||
- | 743 | ||
- | 744 | #region doubletap //http://stackoverflow.com/questions/9001023/capturing-double-tap-touch-on-multi-touch-screen |
|
- | 745 | private Point? _lastTapLocation; |
|
- | 746 | private readonly Stopwatch _doubleTapStopwatch = new Stopwatch(); |
|
- | 747 | ||
- | 748 | private bool IsDoubleTap(TouchEventArgs e) |
|
- | 749 | { |
|
- | 750 | Point currentTapPosition = e.GetTouchPoint(this).Position; |
|
- | 751 | bool tapsAreCloseInDistance = false; |
|
- | 752 | if (_lastTapLocation != null) |
|
- | 753 | { |
|
- | 754 | tapsAreCloseInDistance = GetDistanceBetweenPoints(currentTapPosition, (Point)_lastTapLocation) < 70; |
|
- | 755 | } |
|
- | 756 | _lastTapLocation = currentTapPosition; |
|
- | 757 | ||
- | 758 | TimeSpan elapsed = _doubleTapStopwatch.Elapsed; |
|
- | 759 | _doubleTapStopwatch.Restart(); |
|
- | 760 | bool tapsAreCloseInTime = (elapsed != TimeSpan.Zero && elapsed < TimeSpan.FromSeconds(0.4)); |
|
- | 761 | ||
- | 762 | if (tapsAreCloseInTime && tapsAreCloseInDistance) |
|
- | 763 | { |
|
- | 764 | _lastTapLocation = null; |
|
- | 765 | } |
|
- | 766 | return tapsAreCloseInDistance && tapsAreCloseInTime; |
|
- | 767 | } |
|
- | 768 | ||
- | 769 | private void OnPreviewTouchDown(object sender, TouchEventArgs e) |
|
- | 770 | { |
|
- | 771 | if (IsDoubleTap(e)) |
|
- | 772 | { |
|
- | 773 | MainMap.CanDragMap = false; |
|
- | 774 | MessageBox.Show("Blubb!"); |
|
- | 775 | } |
|
- | 776 | } |
|
- | 777 | public static double GetDistanceBetweenPoints(Point p, Point q) |
|
- | 778 | { |
|
- | 779 | double a = p.X - q.X; |
|
- | 780 | double b = p.Y - q.Y; |
|
- | 781 | double distance = Math.Sqrt(a * a + b * b); |
|
- | 782 | return distance; |
|
- | 783 | } |
|
- | 784 | ||
693 | 785 | #endregion doubletap |
|
Line 694... | Line 786... | ||
694 | #endregion events |
786 | #endregion events |
Line 695... | Line 787... | ||
695 | 787 | ||
Line 1843... | Line 1935... | ||
1843 | Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = osd.Speed().ToString("0.0 m/s"))); |
1935 | Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = osd.Speed().ToString("0.0 m/s"))); |
Line 1844... | Line 1936... | ||
1844 | 1936 | ||
1845 | switch ((int)data[0]) |
1937 | switch ((int)data[0]) |
1846 | { |
1938 | { |
- | 1939 | case 10: |
|
- | 1940 | char[] c = Encoding.ASCII.GetChars(new byte[] { data[13] }); |
|
1847 | case 10: |
1941 | Dispatcher.Invoke((Action)(() => tbCamCtrl.Text = c[0].ToString())); |
1848 | break; |
1942 | break; |
1849 | case 11: |
1943 | case 11: |
1850 | OSDSTATUSFLAGS2 = osd.OSDSTATUSFLAGS2(); |
1944 | OSDSTATUSFLAGS2 = osd.OSDSTATUSFLAGS2(); |
1851 | //---------------NC-Flags-------------------------- |
1945 | //---------------NC-Flags-------------------------- |
Line 1929... | Line 2023... | ||
1929 | } |
2023 | } |
1930 | }); |
2024 | }); |
1931 | } |
2025 | } |
1932 | Dispatcher.Invoke((Action)(() => tbWPMaxRange.Text = iVal.ToString() + " m")); |
2026 | Dispatcher.Invoke((Action)(() => tbWPMaxRange.Text = iVal.ToString() + " m")); |
1933 | } |
2027 | } |
- | 2028 | //--------------- LiPoCell count ------------------------ |
|
- | 2029 | Dispatcher.Invoke((Action)(() => tbLiPoCells.Text = data[25].ToString())); |
|
Line 1934... | Line 2030... | ||
1934 | 2030 | ||
Line 1935... | Line 2031... | ||
1935 | break; |
2031 | break; |
1936 | 2032 | ||
Line 2406... | Line 2502... | ||
2406 | Dispatcher.Invoke((Action)(() => tbNCGrSpeed.Text = ((double)(iVal)/100).ToString("0.00 m/s"))); |
2502 | Dispatcher.Invoke((Action)(() => tbNCGrSpeed.Text = ((double)(iVal)/100).ToString("0.00 m/s"))); |
2407 | if(_Simulate) |
2503 | if(_Simulate) |
2408 | Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = ((double)(iVal)/100).ToString("0.00 m/s"))); |
2504 | Dispatcher.Invoke((Action)(() => tbTopSpeed.Text = ((double)(iVal)/100).ToString("0.00 m/s"))); |
Line 2409... | Line 2505... | ||
2409 | 2505 | ||
2410 | //--------------- Heading north ------------------------ |
2506 | //--------------- Heading north ------------------------ |
2411 | i_16 = data[61]; |
2507 | //i_16 = data[61]; |
2412 | i_16 = (Int16)(i_16 << 8); |
2508 | //i_16 = (Int16)(i_16 << 8); |
2413 | iVal = data[60] + i_16; |
2509 | //iVal = data[60] + i_16; |
Line 2414... | Line 2510... | ||
2414 | Dispatcher.Invoke((Action)(() => tbHeadingNorth.Text = iVal.ToString() + " °")); |
2510 | //Dispatcher.Invoke((Action)(() => tbHeadingNorth.Text = iVal.ToString() + " °")); |
2415 | 2511 | ||
2416 | //--------------- Heading compass ------------------------ |
2512 | //--------------- Heading compass ------------------------ |
2417 | i_16 = data[63]; |
2513 | i_16 = data[63]; |
Line 5150... | Line 5246... | ||
5150 | private void Grid_TouchDown(object sender, TouchEventArgs e) |
5246 | private void Grid_TouchDown(object sender, TouchEventArgs e) |
5151 | { |
5247 | { |
Line 5152... | Line 5248... | ||
5152 | 5248 | ||
Line -... | Line 5249... | ||
- | 5249 | } |
|
5153 | } |
5250 | |
5154 | 5251 | ||
5155 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
5252 | private void btnLoadGPXLog_Click(object sender, RoutedEventArgs e) |
5156 | { |
5253 | { |
5157 | _loadGPXLog(); |
5254 | _loadGPXLog(); |
Line 5414... | Line 5511... | ||
5414 | targetForm.Height = restore.Height; |
5511 | targetForm.Height = restore.Height; |
5415 | targetForm.Width = restore.Width; |
5512 | targetForm.Width = restore.Width; |
5416 | IsMaximized = false; |
5513 | IsMaximized = false; |
5417 | } |
5514 | } |
5418 | } |
5515 | } |
5419 | - | ||
5420 | } |
5516 | } |