-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorldDockPane.cs
2025 lines (1808 loc) · 89.7 KB
/
HelloWorldDockPane.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.ComponentModel.Composition;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Input;
using Microsoft.Toolkit.Uwp.Notifications;
using MapEngine.Interop.Util;
using WinTak.Display;
using WinTak.Common.Coords;
using WinTak.Common.CoT;
using WinTak.Common.Messaging;
using WinTak.Common.Preferences;
using WinTak.Common.Services;
using WinTak.CursorOnTarget.Services;
using WinTak.Framework;
using WinTak.Framework.Docking;
using WinTak.Framework.Docking.Attributes;
using WinTak.Framework.Messaging;
using WinTak.Framework.Notifications;
using WinTak.Location.Services;
using Hello_World_Sample.Notifications;
using Hello_World_Sample.Common;
using System.ComponentModel;
using System.Collections.Generic;
using WinTak.UI;
using WinTak.CursorOnTarget;
using WinTak.Common.Utils;
using TAKEngine.Core;
using WinTak.Mapping;
using WinTak.Graphics.Map;
using WinTak.Graphics;
using WinTak.Overlays.ViewModels;
using atakmap.cpp_cli.core;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using WinTak.Overlays.Services;
using Hello_World_Sample.Properties;
using WinTak.Common.Geofence;
using WinTak.Alerts;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using WinTak.Alerts.Notifications;
using Prism.Events;
using WinTak.Display.Controls;
using WinTak.Mapping.Services;
using WinTak.UI.Themes;
using System.Windows;
using WinTak.CursorOnTarget.Placement.DockPanes;
using Windows.ApplicationModel.Contacts;
using WinTak.Net.Contacts;
using WinTak.MissionPackages;
using WinTak.Common.Time;
using WinTak.Common.Location;
using WinTak.Common.Editors;
using WinTak.Location.Views;
using WinTak.Location.Providers;
using System.Threading;
namespace Hello_World_Sample
{
[DockPane(ID, "HelloWorld", Content = typeof(HelloWorldView), DockLocation = DockLocation.Left, PreferredWidth = 300)]
/* The DockPane class provides the ability to Hide/Show your dockable window
* and serves as the ViewModel for your view.
* */
internal class HelloWorldDockPane : DockPane
{
internal const string ID = "HelloWorld_HelloWorldDockPane";
internal const string TAG = "HelloWorldDockPane";
private readonly ICotMessageSender _cotMessageSender;
private readonly IContactService _contactList;
private readonly IImageStore _imageStore;
private IMissionPackageService _missionPackageService;
/* Common */
// public ILogger _logger; // Or use the Log.x like ATAK
private readonly IMessageHub _messageHub;
private IUnitDisplayPreferences _unitDisplayPreferences;
private IStatusIndicator _statusIndicator;
private ILocationPreferences _locationPreferences;
private IHelloWorldLocationPreferences _helloWorldLocationPreferences;
private ILocationProvider _locationProvider;
public IDevicePreferences _devicePreferences;
public ILocationService _locationService;
/* ***** Layout Examples ***** */
public ICommand LargerBtn { get; private set; }
public ICommand SmallerBtn { get; private set; }
public ICommand ShowSearchIconBtn { get; private set; }
public ICommand RecyclerViewBtn { get; private set; }
public ICommand TabViewBtn { get; private set; }
public ICommand OverlayViewBtn { get; private set; }
public ICommand DropdownBtn { get; private set; }
public IDockingManager _dockingManager;
public ICoTManager _coTManager;
public IElevationManager _elevationManager;
public IMapGroupManager _mapGroupManager;
public IMapObjectRenderer _mapObjectRenderer;
private readonly ImageSource _customMarkerHWImageSource;
private CompositeMapItem _customMarkerCompositeMapItem;
private MapObjectItem _customMarker;
private MapGroup _mapGroup;
private WheelMenuItem _wheelMenuItem;
private readonly IPrecisionMoveService _precisionMoveService;
public DockPaneAttribute DockPaneAttribute { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
private readonly IMapViewController _mapViewController;
public IAlertProvider _alertProvider { get; private set; }
public IAlert _alert { get; private set; }
public IGeofenceManager _geofenceManager { get; private set; }
public IMapObjectItemManager _mapObjectItemManager { get; private set; }
private string cotGuidGenerate;
public string callsignName;
public string inputTextMsg;
public string CallSignName
{
get
{
return this.callsignName;
}
//set => SetAndSubscribeProperty(ref testInputMesg, value);
//base.SetProperty(ref testInput)
set
{
if (base.SetProperty(ref callsignName, value, nameof(CallSignName)))
{
Log.d(TAG, "Save/Update the value inside : " + callsignName + "'");
}
}
}
public string InputTextMsg
{
get
{
return this.inputTextMsg;
}
//set => SetAndSubscribeProperty(ref testInputMesg, value);
//base.SetProperty(ref testInput)
set
{
if (base.SetProperty(ref inputTextMsg, value, nameof(InputTextMsg)))
{
Log.d(TAG, "Save/Update the value inside : " + inputTextMsg + "'");
}
}
}
/****** CoT Manager ***** */
ICotMessageReceiver _cotMessageReceiver;
/* ***** Map Movement ***** */
public ICommand FlyBtn { get; private set; }
/* ***** Marker Manipulation ***** */
public ICommand SpecialMarkerBtn { get; private set; }
public ICommand AddAnAircraftBtn { get; private set; }
public ICommand SvgMarkerBtn { get; private set; }
public ICommand AddLayerBtn { get; private set; }
public ICommand AddMultiLayerBtn { get; private set; }
public ICommand AddHeatMapBtn { get; private set; }
public ICommand StaleOutMarkerBtn { get; private set; }
public ICommand AddStreamBtn { get; private set; }
public ICommand RemoveStreamBtn { get; private set; }
public ICommand CoordinateEntryBtn { get; private set; }
public ICommand ItemInspectBtn { get; private set; }
public ICommand CustomTypeBtn { get; private set; }
public ICommand CustomMenuFactoryBtn { get; private set; }
public ICommand ISSLocationBtn { get; private set; }
public ICommand SensorFOVBtn { get; private set; }
/* ***** Route Examples ***** */
public ICommand ListRoutesBtn { get; private set; }
public ICommand AddXRouteBtn { get; private set; }
public ICommand ReXRouteBtn { get; private set; }
public ICommand DropRouteBtn { get; private set; }
/* ***** Emergency Examples ***** */
public ICommand EmergencyBtn { get; private set; }
public ICommand NoEmergencyBtn { get; private set; }
/* ***** Drawing Examples ***** */
public ICommand RbcircleBtn { get; private set; }
public ICommand AddRectangleBtn { get; private set; }
public ICommand DrawShapesBtn { get; private set; }
public ICommand GroupAddBtn { get; private set; }
public ICommand AssociationsBtn { get; private set; }
/* ***** GPS Examples ***** */
public ICommand ExternalGpsBtn { get; private set; }
/* ***** Elevation Examples ***** */
public ICommand SurfaceAtCenterBtn { get; private set; }
/* ***** Notification Examples ***** */
public ICommand GetCurrentNotificationsBtn { get; private set; }
public ICommand FakeContentProviderBtn { get; private set; }
public ICommand NotificationSpammerBtn { get; private set; }
public ICommand NotificationWithOptionsBtn { get; private set; }
public ICommand NotificationToWinTakToastBtn { get; private set; }
public ICommand NotificationToWindowsBtn { get; private set; }
public ICommand VideoLauncherBtn { get; private set; }
public ICommand AddToolbarItemBtn { get; private set; }
public ICommand AddCountToIconBtn { get; private set; }
public INotificationLog _notificationLog;
/* ***** Images and Camera */
public ICommand CameraLauncherBtn { get; private set; }
public ICommand ImageAttachBtn { get; private set; }
public ICommand WebViewBtn { get; private set; }
public ICommand MapScreenshotBtn { get; private set; }
/* ***** Speach To Text ***** */
public ICommand SpeechToTextBtn { get; private set; }
public ICommand SpeechToActivityBtn { get; private set; }
/* ***** Sensors ***** */
public ICommand BumpControlBtn { get; private set; }
/* ***** Navigation ***** */
public ICommand HookNavigationEventsNameBtn { get; private set; }
/* ***** Lower Level Examples ***** */
public ICommand GetImagesBtn { get; private set; }
/* ***** Map Layers ***** */
public ICommand DownloadMapLayerBtn { get; private set; }
/* ***** Spinner Examples ***** */
public ICommand Spinner1Btn { get; private set; }
/* ***** Plugin Template Duplicate (From WinTAK-Documentation) ***** */
public ICommand IncreaseCounterBtn { get; private set; }
public ICommand WhiteHouseCoTBtn { get; private set; }
private int _counter;
private double _mapFunctionLat;
private double _mapFunctionLon;
private bool _mapFunctionIsActivate;
// -- ----- ----- ----- ----- CONSTRUCTOR ----- ----- ----- ----- -- //
[ImportingConstructor] // this import provide the capability to get WinTAK exposed Interfaces
public HelloWorldDockPane(
ICommunicationService communicationService,
ICoTManager coTManager,
ICotMessageReceiver cotMessageReceiver,
ICotMessageSender cotMessageSender,
IDevicePreferences devicePreferences,
IDockingManager dockingManager,
IElevationManager elevationManager,
IGeocoderService geocoderService,
ILogger logger,
ILocationService locationService,
/* IMapObjectFinderService mapObjectFinderService, */
IMapGroupManager mapGroupManager,
IMapObjectItemManager mapObjectItemManager,
IMapObjectRenderer mapObjectRenderer,
IMessageHub messageHub,
INotificationLog notificationLog,
IMapViewController mapViewController,
// test the video
//IMediaElement mediaElement,
//IVideoOverlay videoOverlay,
//IVideoOverlayProvider videoOverlayProvider
Gv2FPlayer.IVideoPane videoPane,
Gv2FPlayer.IVideoControlsExtender videoControlsExtender,
Gv2FPlayer.IVideoControlsExtension videoControlsExtension,
IGeofenceManager geofenceManager,
IPrecisionMoveService precisionMoveMarking,
IContactService contactService,
IImageStore imageStore,
IMissionPackageService missionPackageService,
IUnitDisplayPreferences unitDisplayPreferences,
IStatusIndicator statusIndicator,
ILocationPreferences locationPreferences
//IHelloWorldLocationPreferences helloWorldLocationPreferences
)
{
// test video
//try { Log.d(TAG, "MediaElement : " + mediaElement); }
//catch (Exception ex) { Log.e(TAG, "MediaElement : " + ex.ToString()); }
//try { Log.d(TAG, "VideoOverlay : " + videoOverlay); }
//catch (Exception ex) { Log.e(TAG, "VideoOverlay : " + ex.ToString()); }
//try { Log.d(TAG, "VideoOverlayProvider : " + videoOverlayProvider); }
//catch (Exception ex) { Log.e(TAG, "VideoOverlayProvider : " + ex.ToString()); }
//WinTak.Video.IMediaElement mediaElement = null;
//WinTak.Video.IVideoOverlay videoOverlay = null;
//WinTak.Video.IVideoOverlayProvider videoOverlayProvider = null;
//WinTak.Video.MediaFrameEventArgs mediaFrameEventArgs = null;
//WinTak.Video.MetaDataEventArgs metaDataEventArgs = null;
Log.d(TAG, MethodBase.GetCurrentMethod() + " - " + videoPane.ToString());
Log.d(TAG, MethodBase.GetCurrentMethod() + " - " + videoControlsExtender.ToString());
Log.d(TAG, MethodBase.GetCurrentMethod() + " - " + videoControlsExtension.ToString());
Log.d(TAG, "We successfully read the videoPane");
WinTak.Video.IMediaElement mediaElement = videoPane.MediaElement;
Gv2FPlayer.Views.SelectVideoAliasView selectVideoAliasView;
Gv2FPlayer.ConnectionEntry connectionEntry = new Gv2FPlayer.ConnectionEntry();
connectionEntry.Alias = "test";
connectionEntry.Address = "http://";
connectionEntry.RtspReliable = true;
connectionEntry.Active = true;
// Test
_cotMessageSender = cotMessageSender;
_contactList = contactService;
_imageStore = imageStore;
_missionPackageService = missionPackageService;
_communicationService = communicationService;
/* Interface link */
//_logger = logger;
_messageHub = messageHub;
_dockingManager = dockingManager;
_locationService = locationService;
_locationService.PositionChanged += OnPositionChanged;
Log.i(TAG, "_locationService.GetGpsHeading() : " + _locationService.GetGpsHeading());
Log.i(TAG, "_locationService.GetGpsMarker() : " + _locationService.GetGpsMarker());
Log.i(TAG, "_locationService.GetGpsObject() : " + _locationService.GetGpsObject());
Log.i(TAG, "_locationService.GetGpsPosition() : " + _locationService.GetGpsPosition());
Log.i(TAG, "_locationService.GetGpsSpeed() : " + _locationService.GetGpsSpeed());
Log.i(TAG, "_locationService.GetHashCode() : " + _locationService.GetHashCode());
Log.i(TAG, "_locationService.GetPositionDocument() : " + _locationService.GetPositionDocument());
Log.i(TAG, "_locationService.GetSelfCotEvent() : " + _locationService.GetSelfCotEvent());
Log.i(TAG, "_locationService.GetType() : " + _locationService.GetType());
//Log.i(TAG, "_locationService.ConnectionStatus : " + _locationService.ConnectionStatus);
//Log.i(TAG, "_locationService.HasConnections : " + _locationService.HasConnections);
//Log.i(TAG, "_locationService.IsSimulatedGps : " + _locationService.IsSimulatedGps);
_unitDisplayPreferences = unitDisplayPreferences;
_statusIndicator = statusIndicator;
_locationPreferences = locationPreferences;
//_locationProvider = locationProvider;
//_helloWorldLocationPreferences = helloWorldLocationPreferences;
_devicePreferences = devicePreferences;
_notificationLog = notificationLog;
_coTManager = coTManager;
_elevationManager = elevationManager;
_mapGroupManager = mapGroupManager;
_mapObjectRenderer = mapObjectRenderer;
_precisionMoveService = precisionMoveMarking;
_customMarkerHWImageSource = new BitmapImage(new Uri("pack://application:,,,/Hello World Sample;component/assets/brand_cthulhu.png"));
_customMarkerCompositeMapItem = new CompositeMapItem();
Log.d(TAG, "The customMarkerCompositeMapItem : " + this._customMarkerCompositeMapItem.GetUid());
_mapObjectItemManager = mapObjectItemManager;
ICollection<MapObjectItem> rootItems = mapObjectItemManager.RootItems;
if (rootItems != null)
{
_customMarker = new LegacyMapObjectItem(Resources.btnRecyclerViewName, new BitmapImage(new Uri("pack://application:,,,/Hello World Sample;component/assets/brand_cthulhu.png")))
{
Visible = true,
Selectable = false,
Id = "HelloWorld CustomMarker"
};
rootItems.Add(_customMarker);
}
_mapGroup = mapGroupManager.GetOrCreateMapGroup("HelloWorldMapGroup");
_customMarkerCompositeMapItem.Disposing += CustomHWOnDisposing;
this.CallSignName = _devicePreferences.Callsign;
this.InputTextMsg = "A default text message from constructor.";
Log.d(TAG, "" + locationService.GetGpsPosition());
foreach(MapObjectItem mapObjectItem in rootItems)
{
if (mapObjectItem.Text == "Geo Fences")
{
Log.d(TAG, "MapObjectItem : " + mapObjectItem.ToString());
Log.d(TAG, "Text : " + mapObjectItem.Text);
Log.d(TAG, "We have the Geo Fences Overlay");
int itemCount = mapObjectItem.GetSubItemCount(); // put 0 becasue does not point to the Geo Fences icons but to the sub items.
// We nee to list the items inside of it/
Log.d(TAG, "Number of items : " + itemCount.ToString());
Log.d(TAG, "Id : " + mapObjectItem.Id);
int childCount = mapObjectItem.ChildCount;
Log.d(TAG, "ChildCount : " + childCount.ToString());
//MapItem mapItems = mapObjectItem.MapItem;
//Log.d(TAG, "mapItems : " + mapItems.ToString());
ObservableCollection<MapObjectItem> childMapObjectItems = mapObjectItem.Children;
foreach (MapObjectItem moi in childMapObjectItems)
{
Log.d(TAG, "Text : " + moi.Text);
Log.d(TAG, "Show Settings : " + moi.ShowSettings);
Log.d(TAG, "Id : " + moi.Id);
Log.d(TAG, "InViewChildCount : " + moi.InViewChildCount);
Log.d(TAG, "Location : " + moi.Location);
Log.d(TAG, "Properties : " + moi.Properties);
Log.d(TAG, "Position : " + moi.Position);
Log.d(TAG, "ShowDetailsCommand : " + moi.ShowDetailsCommand);
Log.d(TAG, "SubText : " + moi.SubText);
Log.d(TAG, "ToolTip : " + moi.ToolTip);
Log.d(TAG, "MapItem : " + moi.MapItem);
Log.d(TAG, "ChildCount : " + moi.ChildCount);
Log.d(TAG, "Children : " + moi.Children);
//Log.d(TAG, " : " + moi.PropertyChanged());
}
}
}
foreach (var item in _mapGroupManager.MapItems)
{
Log.d(TAG, "MapGroup : " + item.ToString());
Log.d(TAG, "Text : " + item.Uid);
Log.d(TAG, "MapItems : " + item.MapItems);
Log.d(TAG, "ParentMapGroup : " + item.ParentMapGroup);
Log.d(TAG, "GetCallsign : " + item.GetCallsign());
Log.d(TAG, "GetUid : " + item.GetUid());
Log.d(TAG, "Name : " + item.Name);
}
_mapViewController = mapViewController;
this._mapViewController.WheelMenuOpening += MapViewController_WheelMenuOpening;
// Layout Examples
LayoutExamples_Configuration();
// Marker Manipulation - Special Marker
var specialMarkerCommand = new ExecutedCommand();
specialMarkerCommand.Executed += OnDemandExecuted_SpecialMarkerButton;
SpecialMarkerBtn = specialMarkerCommand;
// Marker Manipulation - Add Streams
_cotMessageReceiver = cotMessageReceiver;
var addStreamCommand = new ExecutedCommand();
addStreamCommand.Executed += OnDemandExecuted_AddStreamBtn;
AddStreamBtn = addStreamCommand;
// Notification Examples
NotificationExamples_Configuration();
// Plugin Template Duplicate (From WinTAK-Documentation)
var counterButtonCommand = new ExecutedCommand();
counterButtonCommand.Executed += OnDemandExecuted_IncreaseCounterBtn;
IncreaseCounterBtn = counterButtonCommand;
// Plugin Template Duplicate (From WinTAK Reference Documentation)
var whiteHouseCoTCommand = new ExecutedCommand();
whiteHouseCoTCommand.Executed += OnDemandExecuted_WhiteHouseCoTBtn;
WhiteHouseCoTBtn = whiteHouseCoTCommand;
// Test Geofence - moved to a services
//_geofenceManager = geofenceManager;
//geofenceManager.GetGeofences();
//foreach(GeofenceData geofenceData in geofenceManager.GetGeofences())
//{
// // Get the information of all geofence in the wintak instance.
// Log.d(TAG, "MapItemUid : " + geofenceData.MapItemUid.ToString());
// Log.d(TAG, "MonitorType : " + geofenceData.MonitoredType.ToString());
// Log.d(TAG, "Trigger : " + geofenceData.Trigger.ToString());
// MonitoredTypes monitored = geofenceData.MonitoredType;
// Trigger trigger = geofenceData.Trigger;
// //public enum MonitoredTypes
// //{
// // TAKUsers,
// // Friendly,
// // Hostile,
// // Custom,
// // All
// //}
// //public enum Trigger
// //{
// // Entry,
// // Exit,
// // Both
// //}
// //GeofenceAlertMessage geofenceAlertMessage = new GeofenceAlertMessage(geofenceData.MapItemUid, );
//}
//string geofenceBreached = WinTak.Common.Properties.Resource_Civilian.GeofenceBreached;
//geofenceManager.GeofenceChanged += GeofenceManager_GeofenceChanged;
//Log.d(TAG, "Geofence Breached test ?" + geofenceBreached); // seens that is only a string and not something that we can manage
//GeofenceAlertMessage geofenceAlertMessage = new GeofenceAlertMessage();
// How to monitor them when something entering into it ?
//IEnumerable<IAlert> alerts = _alertProvider.Alerts; // Currently alertProvier.Alerts return a null
//foreach (IAlert alert in alerts)
//{
//Log.d(TAG, "Alert : " + alert.ToString());
//}
}
//private void OnPositionChanged(object sender, WinTak.Common.Location.PositionChangedEventArgs e)
//{
// throw new NotImplementedException();
//}
// This method is raised only when a geofence is modified. In any case, this method is raised when the geofence is breached.
private void GeofenceManager_GeofenceChanged(object sender, GeofenceData e)
{
Log.d(TAG, MethodBase.GetCurrentMethod() + " - " + e.ToString());
}
// --------------------------------------------------------------------
// Common Method
// --------------------------------------------------------------------
private class ExecutedCommand : ICommand
{
public event EventHandler CanExecuteChanged;
public event EventHandler Executed;
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
Executed?.Invoke(this, EventArgs.Empty);
}
}
private void GetMEFActiveInterface()
{
//Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies()
.Where(assembly => !assembly.IsDynamic)
.ToArray();
Log.d(TAG, "Under test to check information");
foreach (Assembly assembly in assemblies)
{
try
{
var exportedInterfaces = assembly.GetExportedTypes().Where(type => type.IsInterface && type.IsDefined(typeof(InheritedExportAttribute)));
var importedInterfaces = assembly.GetExportedTypes().SelectMany(type => type.GetProperties().Where(prop => prop.PropertyType.IsInterface && prop.IsDefined(typeof(ImportAttribute)))).Select(prop => prop.PropertyType).Distinct();
foreach (var exportedInterface in exportedInterfaces)
{
Log.d(TAG, MethodBase.GetCurrentMethod() + " Exported Interface : " + exportedInterface.FullName);
}
foreach (var importedInterface in importedInterfaces)
{
Log.d(TAG, MethodBase.GetCurrentMethod() + " Imported Interface : " + importedInterface.FullName);
}
}
catch (ReflectionTypeLoadException ex)
{
foreach (Exception innerEx in ex.LoaderExceptions)
{
Log.e(TAG, MethodBase.GetCurrentMethod() + " Error loading assembly: {innerEx.Message}");
}
}
catch (Exception ex)
{
Log.e(TAG, MethodBase.GetCurrentMethod() + ex.ToString());
}
}
}
private string ImageToBase64(System.Drawing.Image image, ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
// Convert byte[] to base64 string
string base64String = Convert.ToBase64String(imageBytes);
return $"data:image/png;base64,{base64String}";
}
}
private Bitmap ResizeImage(Bitmap image, int width, int height)
{
Bitmap resizedImage = new Bitmap(width, height);
using (Graphics graphics = Graphics.FromImage(resizedImage))
{
graphics.DrawImage(image, 0, 0, width, height);
}
return resizedImage;
}
private string SaveImageToFile(Bitmap image, string imgName)
{
string tempFilePath = Path.Combine(Path.GetTempPath(), imgName);
image.Save(tempFilePath, System.Drawing.Imaging.ImageFormat.Png);
return tempFilePath;
}
private void SetAndSubscribeProperty<T>(ref T backingField, T newValue) where T : INotifyPropertyChanged
{
Log.d(TAG, MethodBase.GetCurrentMethod() + " - " + backingField + " - " + newValue);
if (!EqualityComparer<T>.Default.Equals(backingField, newValue))
{
backingField.PropertyChanged -= HandlePropertyChanged;
}
else
{
backingField.PropertyChanged += HandlePropertyChanged;
}
base.SetProperty(ref backingField, newValue);
}
protected void OnPropertyChanged(string propertyname)
{
Log.d(TAG, MethodBase.GetCurrentMethod() + propertyname);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyname));
}
private void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(CallSignName))
{
OnPropertyChanged(e.PropertyName); // Notify property change
}
}
// --------------------------------------------------------------------
// Layout Examples
// --------------------------------------------------------------------
private void LayoutExamples_Configuration()
{
// Layout Example - Larger
var largerCommand = new ExecutedCommand();
largerCommand.Executed += OnDemandExecuted_LargerButton;
LargerBtn = largerCommand;
// Layout Example - Smaller
var smallerCommand = new ExecutedCommand();
smallerCommand.Executed += OnDemandExecuted_SmallerButton;
SmallerBtn = smallerCommand;
// Layout Example - Show Search Icon
var showSearchIconCommand = new ExecutedCommand();
showSearchIconCommand.Executed += OnDemandExecuted_ShowSearchIcon;
ShowSearchIconBtn = showSearchIconCommand;
// Layer Example - Recycler View
var recyclerViewCommand = new ExecutedCommand();
recyclerViewCommand.Executed += OnDemandExecuted_RecyclerViewBtn;
RecyclerViewBtn = recyclerViewCommand;
}
/* Layout Example - Larger Button
* --------------------------------------------------------------------
* Desc. : Larger button is to Float the Dockpane.
* */
private void OnDemandExecuted_LargerButton(object sender, EventArgs e)
{
Log.d(TAG, MethodBase.GetCurrentMethod() + "");
Log.d(TAG, MethodBase.GetCurrentMethod() +" : " +_locationService.GetGpsPosition());
Log.d(TAG, MethodBase.GetCurrentMethod() + " : " + _locationService);
}
/* Layout Example - Smaller Button
* --------------------------------------------------------------------
* Desc. :
* */
CotDockPane dockPane;
private ICommunicationService _communicationService;
private void OnDemandExecuted_SmallerButton(object sender, EventArgs e)
{
Log.i(TAG, MethodBase.GetCurrentMethod() + "");
TAKEngine.Core.GeoPoint test = new TAKEngine.Core.GeoPoint(44.238366, 9.6912326, 200.01, TAKEngine.Core.AltitudeReference.HAE);
dockPane = new CotDockPane(_cotMessageSender, _cotMessageReceiver,
_contactList, _messageHub, _imageStore, _missionPackageService,
_locationService, _communicationService, _dockingManager);
Log.d(TAG, "" + dockPane);
Log.d(TAG, "selfPosition : before : " + dockPane.SelfPosition);
dockPane.SelfPosition = test;
Log.d(TAG, "selfPosition : after : " + dockPane.SelfPosition);
CotEvent cotEvent = _locationService.GetSelfCotEvent();
Log.d(TAG, "Last Position with CotEvent : " + cotEvent);
Log.d(TAG, "" + cotEvent.GetSchema());
CotPoint cotPoint = new CotPoint(test);
cotEvent.Time = CoordinatedTime.FromCot(CoordinatedTime.CurrentDate().ToString());
cotEvent.Start = CoordinatedTime.FromCot(CoordinatedTime.CurrentDate().ToString());
//CotDetail cotDetail = new CotDetail();
Log.d(TAG, "cotEvent.Detail : " + cotEvent.Detail);
CotDetail cotDetail = cotEvent.Detail;
cotEvent.Point = cotPoint;
if (cotEvent.IsValid())
{
// dockPane.Send(cotEvent); // send is calling the send function.
// Opening the dockpane send not updating / sending the cot itself
Log.d(TAG, "New Position with CotEvent : " + cotEvent);
}
else
{
Log.e(TAG, "CotEvent is not valid !!! Here is the value of it : " + cotEvent);
}
// // Marker Manipulation - Special Marker
double testSpeed = 0.0;
double testHeading = 0.0;
PositionChangedEventArgs positionArgs = new PositionChangedEventArgs(test, testSpeed, testHeading);
//OnPositionChanged(this, positionArgs);
MapItem mapItem = _locationService.GetGpsObject();
MapMarker mapMarker = _locationService.GetGpsMarker();
mapItem.SetMarkerPosition(test);
Log.d(TAG, "mapMarker : " + mapMarker);
Log.d(TAG, "mapItem : " + mapItem);
// we create a new and not get the one which is currently existing
LocationPanel locationPanel = new LocationPanel(_messageHub, _unitDisplayPreferences);
locationPanel.ManualPositionRequested += LocationPanel_ManualPositionRequested;
LocationPanel_ManualPositionRequested(this, EventArgs.Empty);
Log.d(TAG, "Test LocationPanel.Callsign : " + locationPanel.Callsign);
Log.d(TAG, "Test LocationPanel.Position : " + locationPanel.Position);
//_locationService.StartSimulatedGps();
ManualResetEvent manualResetEvent;
ConnectionStatus ConnectionStatus = ConnectionStatus.Connecting;
ThreadPool.QueueUserWorkItem(delegate (object o)
{
TAKEngine.Core.GeoPoint position = (TAKEngine.Core.GeoPoint)o;
mapItem.SetMarkerPosition(position);
//ILocationProvider iprovider = new global::atakmap.i(mapItem);
//ManualResetEvent.WaitOne();
}, new TAKEngine.Core.GeoPoint(test));
WinTak.Location.Providers.PositionUpdatedEventArgs positionUpdatedEventArgs = new WinTak.Location.Providers.PositionUpdatedEventArgs(test, (FixQuality)testSpeed, testHeading);
//if (System.Windows.Application.Current.Dispatcher.CheckAccess())
//{
// if (_locationProvider != null)
// {
// _locationProvider.StartAsync();
// }
// else
// {
// System.Windowa.Application.Current.Dispatcher.Invoke(() =>
// {
// if (_locationProvider != null)
// {
// _locationProvider.StartAsync();
// }
// });
// }
//}
_statusIndicator.SetSelfMarkerRequested += StatusIndicator_SetSelfMarkerRequest;
//mapMarker = new MapMarker();
//mapMarker.ClampToSurface = true;
//mapMarker.Visible = true;
//mapMarker.Position = test;
//mapMarker.Orientation = MapMarkerBase.OrientationMode.Absolute;
_locationPreferences.GpsTypeChanged += LocationPreferences_GpsTypeChanged;
Log.d(TAG, "FollowTargetUpdateSpeed : " + _locationPreferences.FollowTargetUpdateSpeed);
Log.d(TAG, "GpsProvider : " + _locationPreferences.GpsProvider);
Log.d(TAG, "GpsType : " + _locationPreferences.GpsType);
Log.d(TAG, "BaudRate : " + _locationPreferences.BaudRate);
Log.d(TAG, "ListenPort : " + _locationPreferences.ListenPort);
Log.d(TAG, "UseGpsTime : " + _locationPreferences.UseGpsTime);
Log.d(TAG, "RequestTimeout : " + _locationPreferences.RequestTimeout);
Log.d(TAG, "StationaryLocation : " + _locationPreferences.StationaryLocation);
}
private void LocationPreferences_GpsTypeChanged(object sender, GpsType e)
{
Log.d(TAG, MethodBase.GetCurrentMethod() + " : " + e);
}
private void StatusIndicator_SetSelfMarkerRequest(object sender, EventArgs e)
{
Log.d(TAG, "StatusIndicator_SetSelfMarkerRequest : " + sender);
Log.d(TAG, "StatusIndicator_SetSelfMarkerRequest : " + e);
}
private void LocationPanel_ManualPositionRequested(object sender, EventArgs e)
{
Log.d(TAG, MethodBase.GetCurrentMethod() + "");
}
private void OnPositionChanged(object sender, PositionChangedEventArgs e)
{
var newPosition = e.Position;
var newSpeed = e.Speed;
var newHeading = e.Heading;
Log.d(TAG, "OnPositionChanged : newPosition : " + newPosition);
UpdateSelfPosition(newPosition);
}
private void UpdateSelfPosition(TAKEngine.Core.GeoPoint newPosition)
{
Log.d(TAG, "UpdateSelfPosition ?");
}
private void MoveMarker(IEditable marker, TAKEngine.Core.GeoPoint point, bool keepAltitude, PreciseCoordDetails precise)
{
if (!(marker.Geometry is IPoint point2))
{
Log.e(TAG, "Marker is not a Ipoint");
return;
}
_ = point2.Location;
TAKEngine.Core.GeoPoint geoPoint = new TAKEngine.Core.GeoPoint(point);
if (keepAltitude)
{
geoPoint.Altitude = this._elevationManager.GetElevation(geoPoint);
geoPoint.AltitudeRef = global::TAKEngine.Core.AltitudeReference.HAE;
}
point2.Location = geoPoint;
if (marker.Subject != null)
{
if (precise != null)
{
} // else if ()
//{
//}
}
}
/* Layout Example - Show Search Icon
* --------------------------------------------------------------------
* Desc. :
* */
private void OnDemandExecuted_ShowSearchIcon(object sender, EventArgs e)
{
/* ATAK implementation :
* // The button bellow shows how one might go about
* // setting up a custom map widget.
* final Button showSearchIcon = helloView.findViewById(R.id.showSearchIcon);
* showSearchIcon.setOnClickListener(new OnClickListener() {
* @Override
* public void onClick(View v) {
* Log.d(TAG, "sending broadcast SHOW_MY_WACKY_SEARCH");
* Intent intent = new Intent("SHOW_MY_WACKY_SEARCH");
* AtakBroadcast.getInstance().sendBroadcast(intent);
* }
* }); // the image shown when we click on it is the sync_search.png -> AndroidTacticalAssaultKit-CIV-master\atak\ATAK\app\src\main\res\drawable-hdpi
*/
Log.i(TAG, MethodBase.GetCurrentMethod() + "");
Prompt.Show("Place the marker on the map.");
_mapGroupManager.ItemAdded += MapObjectAdded;
MapViewControl.PushMapEvents(MapMouseEvents.MapMouseDown
| MapMouseEvents.MapMouseMove
| MapMouseEvents.MapMouseUp
| MapMouseEvents.ItemDrag
| MapMouseEvents.ItemDragCompleted
| MapMouseEvents.ItemLongPress
| MapMouseEvents.MapDrag
| MapMouseEvents.MapLongPress
| MapMouseEvents.MapDoubleClick
| MapMouseEvents.ItemDoubleClick);
MapViewControl.MapClick += PlaceHelloWorld_MapClick;
}
private void PlaceHelloWorld_MapClick(object sender, MapMouseEventArgs e)
{
Log.i(TAG, MethodBase.GetCurrentMethod() + "");
/* Variables declaration */
string cotUid;
string cotType = "a-f-A";
string cotName = "HWM"; // HelloWorldMarker
string cotDetail;
/* Implementation */
cotUid = Guid.NewGuid().ToString();
cotName = _coTManager.CreateCallsign(cotName, CallsignCreationMethod.BasedOnTypeAndDate);
cotDetail = "<archive /> <_helloworld_ title=\"" + cotName + "\" /><precisionlocation altsrc=\"DTED0\" />"; ;
TAKEngine.Core.GeoPoint geoPoint;
geoPoint = new TAKEngine.Core.GeoPoint(e.WorldLocation)
{
Altitude = _elevationManager.GetElevation(e.WorldLocation),
AltitudeRef = global::TAKEngine.Core.AltitudeReference.HAE
};
if (double.IsNaN(geoPoint.Altitude))
{
geoPoint.Altitude = Altitude.UNKNOWN_VALUE;
}
cotGuidGenerate = cotUid;
_coTManager.AddItem(cotUid, cotType, geoPoint, cotName, cotDetail);
MapViewControl.PopMapEvents();
Prompt.Clear();
}
private void MapObjectAdded(object sender, MapItemEventArgs args)
{
Log.i(TAG, MethodBase.GetCurrentMethod() + "");
MapItem mapItem;
mapItem = args?.MapItem;
if (mapItem == null || cotGuidGenerate == null || cotGuidGenerate == mapItem.GetUid())
{
return;
}
base.DispatchAsync(delegate
{
if (_dockingManager.GetDockPane(ID) is HelloWorldDockPane helloWorldDockPane)
{
MapMarker mapMarker;
mapMarker = mapItem.GetMapMarker();
if (mapMarker != null)
{
// helloWorldDockPane.SetMarker(mapMarker);
mapItem.Properties.TryGetValue("helloworldMapItem", out var value);
if (value != null)
{
((MapObjectItem)value).Text = mapItem.Properties["akey?"].ToString();
}
cotGuidGenerate = null;
}
}
});
}
public void MapViewController_WheelMenuOpening(object sender, MenuPopupEventArgs e)
{
Log.d(TAG, "MapViewController_WheelMenuOpening() - Starting");
// Log the type of 'sender'
Log.d(TAG, "Sender Type: " + (sender?.GetType().ToString() ?? "null"));
// Check if sender is WheelMenu
if (sender is WheelMenu wheelMenu)
{
Log.d(TAG, "Sender is WheelMenu");
// Attempt to get the clickedParentObject
if (e.GetSingleClickedItem(out var clickedParentObject) != null)
{
Log.d(TAG, "Clicked parent object is: " + clickedParentObject?.GetType().ToString());
// Check if clickedParentObject is MapItem
if (clickedParentObject is MapItem mapItem)
{
Log.d(TAG, "Clicked object is MapItem with Type : " + mapItem.GetType() + " _customMarkerCompositeMapItem : " + this._customMarkerCompositeMapItem.GetType());
Log.d(TAG, "Clicked object is MapItem with Name: " + mapItem.Name + " _customMarkerCompositeMapItem: " + this._customMarkerCompositeMapItem.Name);
Log.d(TAG, "Clicked object is MapItem with Text: " + mapItem.Properties + " _customMarkerCompositeMapItem: " + this._customMarkerCompositeMapItem.Properties);
Log.d(TAG, "Clicked object is MapItem with UID: " + mapItem.GetUid() + " _customMarkerCompositeMapItem: " + this._customMarkerCompositeMapItem.GetUid());
IDictionary<string, object> dictionaries = _customMarkerCompositeMapItem.Properties;
foreach(var dictionary in dictionaries)
{
Log.d(TAG, $"_customMarkerCompositeMapItem : Key: {dictionary.Key}, Value: {dictionary.Value}");
}
IDictionary<string, object> dictionaries2 = mapItem.Properties;
foreach (var dictionary in dictionaries2)
{
Log.d(TAG, $"mapItem : Key: {dictionary.Key}, Value: {dictionary.Value}");
}
//if (dictionary != null)
//{
// // Iterate through all key-value pairs
// foreach (var keyValuePair in dictionary)
// {
// Log.d(TAG, $"Key: {keyValuePair.Key}, Value: {keyValuePair.Value}");
// }
// // To access a specific key's value, for example
//}
// Check if the UIDs match
if (mapItem.GetUid().Equals(this._customMarkerCompositeMapItem.GetUid()))
{
Log.d(TAG, "MapItem UIDs match. Passed the first if statement.");
// Proceed with the rest of the logic
StandardActions.AddDelete(mapItem, wheelMenu, disabled: false);
MapMarker mapMarker = mapItem.GetMapMarker();
// Log if MapMarker is not null
if (mapMarker != null)
{
Log.d(TAG, "MapMarker is not null");
this._precisionMoveService.AddPrecisionMove(mapMarker, wheelMenu);
}
else
{
Log.d(TAG, "MapMarker is null");
}
// Remove the delete menu item
wheelMenu.Items.Remove(wheelMenu.Items.FirstOrDefault((WheelMenuItem x) => x.Id == "delete"));