-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cs
87 lines (74 loc) · 2.78 KB
/
MainPage.xaml.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
/* ----------------------------
* The Logic of Page 'MainPage'
* By DaweiX
* ---------------------------*/
using DJI.WindowsSDK;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
// https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板
namespace UAV_with_AI
{
/// <summary>
/// 可用于自身或导航至 Frame 内部的空白页。
/// </summary>
public sealed partial class MainPage : Page
{
public string APIKEY = "0281645fb34b5dd61a0ce508";
public List<PaneItem> PaneListItems => new List<PaneItem>
{
new PaneItem { Title = "Home", Glyph = "ms-appx:///Assets//Icons//star.png" , Index = 0 },
new PaneItem { Title = "FPV", Glyph = "ms-appx:///Assets//Icons//play.png" , Index = 1 },
};
public MainPage()
{
this.InitializeComponent();
this.DataContext = this;
DJISDKManager.Instance.SDKRegistrationStateChanged += Instance_SDKRegistrationStateChanged;
if (DJISDKManager.Instance.appActivationState != AppActivationState.ACTIVATED)
{
// Active the APP with ApiKey
DJISDKManager.Instance.RegisterApp(APIKEY);
TB_active.Text = "Activiting...";
}
Mainframe.Navigate(typeof(Views.Home));
}
private async void Instance_SDKRegistrationStateChanged(SDKRegistrationState state, SDKError errorCode)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
TB_active.Text = state == SDKRegistrationState.Succeeded
? "Api Key Activated"
: "Api Key Not Activated";
if (errorCode == SDKError.NO_ERROR)
return;
else
Debug.WriteLine(errorCode);
});
}
private void MainList_ItemClick(object sender, ItemClickEventArgs e)
{
if (ham.DisplayMode == SplitViewDisplayMode.Overlay) ham.IsPaneOpen = false;
if (e.ClickedItem is PaneItem)
{
var item = e.ClickedItem as PaneItem;
switch (item.Index)
{
case 0: Mainframe.Navigate(typeof(Views.Home));break;
case 1: Mainframe.Navigate(typeof(Views.Camera)); break;
}
}
}
private void Mainframe_Navigated(object sender, NavigationEventArgs e)
{
}
}
public class PaneItem
{
public string Title { get; set; }
public string Glyph { get; set; }
public int Index { get; set; }
}
}