diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialog.xaml b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialog.xaml
new file mode 100644
index 00000000..8f95c19f
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialog.xaml
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialog.xaml.cs b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialog.xaml.cs
new file mode 100644
index 00000000..490da9d1
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialog.xaml.cs
@@ -0,0 +1,42 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using Windows.Web.Http;
+using Windows.Web.Http.Headers;
+using Windows.Web.Http.Filters;
+
+// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace HoloLensCommander
+{
+ public sealed partial class MobileCenterAppsDialog : ContentDialog
+ {
+ public MobileCenterAppsDialog(AppResponse[] appResponse)
+ {
+ this.DataContext = new MobileCenterAppsDialogViewModel(appResponse);
+ this.InitializeComponent();
+ }
+
+ private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
+ {
+ //close the dialog
+ }
+
+ private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
+ {
+ }
+ }
+}
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModel.cs b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModel.cs
new file mode 100644
index 00000000..b4d29d77
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModel.cs
@@ -0,0 +1,32 @@
+using Newtonsoft.Json;
+using System.ComponentModel;
+using System.Net;
+
+namespace HoloLensCommander
+{
+ public partial class MobileCenterAppsDialogViewModel : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public MobileCenterAppsDialogViewModel (AppResponse[] appResponseList)
+ {
+ for (int i = 0; i < appResponseList.Length; i++)
+ {
+ this.MobileCenterApps.Add(appResponseList[i].name);
+ }
+
+ //Register the commands for the mobile center apps dialog
+ this.DownloadInstallMobileAppsCommand = new Command(
+ async (parameter) =>
+ {
+ await this.DownloadInstallMobileAppsAsync(appResponseList);
+ });
+ }
+ private void NotifyPropertyChanged(string propertyName)
+ {
+ this.PropertyChanged?.Invoke(
+ this,
+ new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
\ No newline at end of file
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModelCommands.cs b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModelCommands.cs
new file mode 100644
index 00000000..4f298c8d
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModelCommands.cs
@@ -0,0 +1,34 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace HoloLensCommander
+{
+ public partial class MobileCenterAppsDialogViewModel
+ {
+ AppCenterWebRequest appCenterWebRequest = new AppCenterWebRequest();
+ public ICommand DownloadInstallMobileAppsCommand
+ { get; private set; }
+
+ private async Task DownloadInstallMobileAppsAsync(AppResponse[] appList)
+ {
+ string selectedApp = this.SelectedMobileCenterApp as string;
+ DownloadResponse downloadResponse;
+
+ for (int i = 0; i < appList.Length; i++)
+ {
+ if (selectedApp == appList[i].name || selectedApp == appList[i].display_name)
+ {
+ string requestResponseJson = await appCenterWebRequest.HttpReleaseRequest(appList[i].app_secret);
+ downloadResponse = JsonConvert.DeserializeObject(requestResponseJson);
+ appCenterWebRequest.HttpDownloadRequest(downloadResponse.download_url, selectedApp);
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModelProperties.cs b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModelProperties.cs
new file mode 100644
index 00000000..4f2af9ea
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/MobileCenterAppsDialogViewModelProperties.cs
@@ -0,0 +1,41 @@
+using System.Collections.Generic;
+
+namespace HoloLensCommander
+{
+ public partial class MobileCenterAppsDialogViewModel
+ {
+ private List mobileCenterApps = new List();
+ public List MobileCenterApps
+ {
+ get
+ {
+ return this.mobileCenterApps;
+ }
+ set
+ {
+ if (this.mobileCenterApps != value)
+ {
+ this.mobileCenterApps = value;
+ this.NotifyPropertyChanged(nameof(MobileCenterApps));
+ }
+ }
+ }
+
+ private string selectedMobileCenterApp = string.Empty;
+ public string SelectedMobileCenterApp
+ {
+ get
+ {
+ return this.selectedMobileCenterApp;
+ }
+ set
+ {
+ if (this.selectedMobileCenterApp!=value)
+ {
+ this.selectedMobileCenterApp = value;
+ this.NotifyPropertyChanged(nameof(SelectedMobileCenterApp));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml
new file mode 100644
index 00000000..05ba6e04
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml.cs b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml.cs
new file mode 100644
index 00000000..5c5591c2
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml.cs
@@ -0,0 +1,31 @@
+using System.Net;
+using Windows.UI.Xaml.Controls;
+
+// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace HoloLensCommander
+{
+ public sealed partial class SetAPItokenDialog : ContentDialog
+ {
+ private UserToken apiToken;
+ private NetworkCredential appCenterCredentials;
+
+ public SetAPItokenDialog(UserToken APItoken, NetworkCredential AppCenterCredentials)
+ {
+ this.apiToken = APItoken;
+ this.appCenterCredentials = AppCenterCredentials;
+ this.DataContext = new SetAPItokenDialogViewModel(APItoken, AppCenterCredentials);
+ this.InitializeComponent();
+ }
+
+ private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
+ {
+ ((SetAPItokenDialogViewModel)this.DataContext).UpdateAPItoken(this.apiToken);
+ ((SetAPItokenDialogViewModel)this.DataContext).UpdateAppCenterCredentials(this.appCenterCredentials);
+ }
+
+ private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
+ {
+ }
+ }
+}
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModel.cs b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModel.cs
new file mode 100644
index 00000000..93d49c48
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModel.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoloLensCommander
+{
+ public partial class SetAPItokenDialogViewModel : INotifyPropertyChanged
+ {
+ ///
+ /// Event that is notified when a property value has changed.
+ ///
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public SetAPItokenDialogViewModel(UserToken apiToken, NetworkCredential appCenterCredentials)
+ {
+ this.APIToken= apiToken.ApiToken;
+ this.AppCenterUserName = appCenterCredentials.UserName;
+ this.AppCenterPassword = appCenterCredentials.Password;
+ }
+
+ ///
+ /// Sends the PropertyChanged events to registered handlers.
+ ///
+ /// The name of property that has changed.
+ private void NotifyPropertyChanged(string propertyName)
+ {
+ this.PropertyChanged?.Invoke(
+ this,
+ new PropertyChangedEventArgs(propertyName));
+ }
+
+ internal void UpdateAPItoken(UserToken apiToken)
+ {
+ apiToken.ApiToken = this.APIToken;
+ }
+
+ internal void UpdateAppCenterCredentials(NetworkCredential appCenterCredentials)
+ {
+ appCenterCredentials.UserName = this.AppCenterUserName;
+ appCenterCredentials.Password = this.AppCenterPassword;
+ }
+ }
+}
diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModelProperties.cs b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModelProperties.cs
new file mode 100644
index 00000000..ac4e70d5
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModelProperties.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoloLensCommander
+{
+ public partial class SetAPItokenDialogViewModel
+ {
+ private string apiToken = string.Empty;
+ public string APIToken
+ {
+ get
+ {
+ return this.apiToken;
+ }
+ set
+ {
+ if (this.apiToken!=value)
+ {
+ this.apiToken = value;
+ this.NotifyPropertyChanged(nameof(APIToken));
+ }
+ }
+ }
+
+ private string appCenterUserName = string.Empty;
+ public string AppCenterUserName
+ {
+ get
+ {
+ return this.appCenterUserName;
+ }
+ set
+ {
+ if (this.appCenterUserName!=value)
+ {
+ this.appCenterUserName = value;
+ this.NotifyPropertyChanged(nameof(AppCenterUserName));
+ }
+ }
+ }
+ private string appCenterPassword = string.Empty;
+ public string AppCenterPassword
+ {
+ get
+ {
+ return this.appCenterPassword;
+ }
+ set
+ {
+ if (this.appCenterPassword != value)
+ {
+ this.appCenterPassword = value;
+ this.NotifyPropertyChanged(nameof(AppCenterPassword));
+ }
+ }
+ }
+ }
+}
diff --git a/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj b/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj
index 61e46466..2e17604e 100644
--- a/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj
+++ b/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj
@@ -1,256 +1,278 @@
-
-
-
-
- Debug
- x86
- {8B5388DA-FE17-430A-85C1-5EF7C9AF0F7D}
- AppContainerExe
- Properties
- HoloLensCommander
- HoloLensCommander
- en-US
- UAP
- 10.0.10586.0
- 10.0.10240.0
- 14
- 512
- {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- HoloLensCommander_TemporaryKey.pfx
- True
- Always
- x86|x64
- 45A74AE0CFE4E2E056BE059B6F77620B0309D3E2
-
-
- true
- bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- x86
- false
- prompt
- true
-
-
- bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- x86
- false
- prompt
- true
- true
-
-
- true
- bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- ARM
- false
- prompt
- true
-
-
- bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- ARM
- false
- prompt
- true
- true
-
-
- true
- bin\x64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- x64
- false
- prompt
- true
-
-
- bin\x64\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- x64
- false
- prompt
- true
- true
-
-
-
-
-
-
-
-
- App.xaml
-
-
- DeviceMonitorControl.xaml
-
-
-
-
-
-
-
-
- ConnectToDeviceDialog.xaml
-
-
-
-
-
- DeviceInformationDialog.xaml
-
-
-
-
- GetAppInstallFilesDialog.xaml
-
-
-
-
-
-
-
-
-
-
-
-
- SetIpdDialog.xaml
-
-
-
-
-
-
- TagDeviceDialog.xaml
-
-
-
-
-
- MainPage.xaml
-
-
-
-
- MixedRealityViewDialog.xaml
-
-
- ManageAppsDialog.xaml
-
-
-
- SetCredentialsDialog.xaml
-
-
- SettingsDialog.xaml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Designer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- Designer
- MSBuild:Compile
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
-
-
- 15.0
-
-
-
-
+
+
+
+
+ Debug
+ x86
+ {8B5388DA-FE17-430A-85C1-5EF7C9AF0F7D}
+ AppContainerExe
+ Properties
+ HoloLensCommander
+ HoloLensCommander
+ en-US
+ UAP
+ 10.0.10586.0
+ 10.0.10240.0
+ 14
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ HoloLensCommander_TemporaryKey.pfx
+ True
+ Always
+ x86
+ A4B49ABD7F86BC59443864123563E3BB0CCBC3A9
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\ARM\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\ARM\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+ true
+
+
+
+
+
+
+
+
+ App.xaml
+
+
+ DeviceMonitorControl.xaml
+
+
+
+
+
+
+
+
+ ConnectToDeviceDialog.xaml
+
+
+
+
+
+ DeviceInformationDialog.xaml
+
+
+
+
+ GetAppInstallFilesDialog.xaml
+
+
+
+
+
+
+
+
+
+
+ MobileCenterAppsDialog.xaml
+
+
+
+
+
+ SetAPItokenDialog.xaml
+
+
+
+
+
+
+ SetIpdDialog.xaml
+
+
+
+
+
+
+ TagDeviceDialog.xaml
+
+
+
+
+
+ MainPage.xaml
+
+
+
+
+ MixedRealityViewDialog.xaml
+
+
+ ManageAppsDialog.xaml
+
+
+
+ SetCredentialsDialog.xaml
+
+
+ SettingsDialog.xaml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+ 15.0
+
+
+
+
\ No newline at end of file
diff --git a/HoloLensCommander/HoloLensCommander/MainPage.xaml b/HoloLensCommander/HoloLensCommander/MainPage.xaml
index 6952a6c3..ce856f77 100644
--- a/HoloLensCommander/HoloLensCommander/MainPage.xaml
+++ b/HoloLensCommander/HoloLensCommander/MainPage.xaml
@@ -315,6 +315,21 @@
Command="{Binding Path=UseDesktopFilterCommand}"
HorizontalAlignment="Left" Width="130"
Canvas.Left="545" Canvas.Top="8"/>
+
+
diff --git a/HoloLensCommander/HoloLensCommander/MainWindowViewModel.cs b/HoloLensCommander/HoloLensCommander/MainWindowViewModel.cs
index 67a19c48..0db5f746 100644
--- a/HoloLensCommander/HoloLensCommander/MainWindowViewModel.cs
+++ b/HoloLensCommander/HoloLensCommander/MainWindowViewModel.cs
@@ -20,6 +20,9 @@ partial class MainWindowViewModel : INotifyPropertyChanged, IDisposable
/// Values used to store and retrieve settings data.
///
private static readonly string AutoReconnectKey = "autoReconnect";
+ private static readonly string DefaultAPItokenKey = "defaultAPItokenKey";
+ private static readonly string DefaultAppCenterUserNameKey = "defaultAppCenterUserName";
+ private static readonly string DefaultAppCenterPasswordKey = "defaultAppCenterPassword";
private static readonly string DefaultNetworkKeyKey = "defaultNetworkKey";
private static readonly string DefaultPasswordKey = "defaultPassword";
private static readonly string DefaultSsidKey = "defaultSsid";
@@ -375,6 +378,18 @@ await this.ConnectToDeviceAsync(
this.SelectAllDevices();
});
+ this.ShowMobileCenterAppsCommand = new Command(
+ async (parameter) =>
+ {
+ await this.ShowMobileCenterApps();
+ });
+
+ this.ShowSetAPItokenCommand = new Command(
+ async (parameter) =>
+ {
+ await this.ShowSetAPItoken();
+ });
+
this.ShowSetCredentialsCommand = new Command(
async (parameter) =>
{
diff --git a/HoloLensCommander/HoloLensCommander/MainWindowViewModelCommands.cs b/HoloLensCommander/HoloLensCommander/MainWindowViewModelCommands.cs
index 1cdbf170..c0633265 100644
--- a/HoloLensCommander/HoloLensCommander/MainWindowViewModelCommands.cs
+++ b/HoloLensCommander/HoloLensCommander/MainWindowViewModelCommands.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
@@ -586,6 +587,38 @@ private async Task ShowSetCredentials()
}
}
+ public ICommand ShowMobileCenterAppsCommand
+ { get; private set; }
+
+ private async Task ShowMobileCenterApps()
+ {
+ AppCenterWebRequest appCenterWebRequest = new AppCenterWebRequest();
+ string requestResponseJson = await appCenterWebRequest.HttpWebRequest();
+
+ AppResponse[] appResponse;
+ appResponse = JsonConvert.DeserializeObject(requestResponseJson);
+
+ ContentDialog mobileCenterAppsDialog = new MobileCenterAppsDialog(appResponse);
+ await mobileCenterAppsDialog.ShowAsync();
+ }
+
+ public ICommand ShowSetAPItokenCommand
+ { get; private set; }
+
+ private async Task ShowSetAPItoken()
+ {
+ UserToken apiToken = new UserToken(this.ApiToken);
+
+ SetAPItokenDialog apiTokenDialogs = new SetAPItokenDialog(apiToken);
+ ContentDialogResult dialogResult = await apiTokenDialogs.ShowAsync();
+
+ if (dialogResult==ContentDialogResult.Primary)
+ {
+ this.ApiToken = apiToken.ApiToken;
+ this.SaveApplicationSettings();
+ }
+ }
+
///
/// Command used to display the settings dialog.
///
@@ -860,6 +893,10 @@ private void LoadApplicationSettings()
this.UserName = this.appSettings.Values[DefaultUserNameKey] as string;
this.Password = this.appSettings.Values[DefaultPasswordKey] as string;
+ this.ApiToken = this.appSettings.Values[DefaultAPItokenKey] as string;
+ this.AppCenterUserName = this.appSettings.Values[DefaultAppCenterUserNameKey] as string;
+ this.AppCenterPassword = this.appSettings.Values[DefaultAppCenterPasswordKey] as string;
+
this.defaultSsid = this.appSettings.Values[DefaultSsidKey] as string;
this.defaultNetworkKey = this.appSettings.Values[DefaultNetworkKeyKey] as string;
@@ -983,6 +1020,10 @@ private void SaveApplicationSettings()
this.appSettings.Values[DefaultUserNameKey] = this.UserName;
this.appSettings.Values[DefaultPasswordKey] = this.Password;
+ this.appSettings.Values[DefaultAPItokenKey] = this.ApiToken;
+ this.appSettings.Values[DefaultAppCenterUserNameKey] = this.AppCenterUserName;
+ this.appSettings.Values[DefaultAppCenterPasswordKey] = this.AppCenterPassword;
+
this.appSettings.Values[DefaultSsidKey] = this.defaultSsid;
this.appSettings.Values[DefaultNetworkKeyKey] = this.defaultNetworkKey;
diff --git a/HoloLensCommander/HoloLensCommander/MainWindowViewModelProperties.cs b/HoloLensCommander/HoloLensCommander/MainWindowViewModelProperties.cs
index 110516e3..e12e3a25 100644
--- a/HoloLensCommander/HoloLensCommander/MainWindowViewModelProperties.cs
+++ b/HoloLensCommander/HoloLensCommander/MainWindowViewModelProperties.cs
@@ -33,6 +33,88 @@ private set
}
}
+ ///
+ /// Gets or sets the API Token to be used when connecting to mobile center.
+ ///
+ private string apiToken = string.Empty;
+ public string ApiToken
+ {
+ get
+ {
+ return this.apiToken;
+ }
+
+ set
+ {
+ if (this.apiToken != value)
+ {
+ this.apiToken = value;
+ this.UpdateAPItoken();
+ }
+ }
+ }
+
+ private bool apiTokenSet = false;
+ public bool ApiTokenSet
+ {
+ get
+ {
+ return this.apiTokenSet;
+ }
+ set
+ {
+ if (apiTokenSet!=value)
+ {
+ apiTokenSet = value;
+ this.NotifyPropertyChanged("APItokenSet");
+ }
+ }
+ }
+
+ private bool appCenterCredentialsSet = false;
+ public bool AppCenterCredentialsSet
+ {
+ get
+ {
+ return this.appCenterCredentialsSet;
+ }
+
+ private set
+ {
+ if (this.appCenterCredentialsSet != value)
+ {
+ this.appCenterCredentialsSet = value;
+ this.NotifyPropertyChanged("AppCenterCredentialsSet");
+ }
+ }
+ }
+
+ private string appCenterUserName = string.Empty;
+ public string AppCenterUserName
+ {
+ get
+ {
+ return this.appCenterUserName;
+ }
+ set
+ {
+ appCenterUserName = value;
+ }
+ }
+
+ private string appCenterPassword = string.Empty;
+ public string AppCenterPassword
+ {
+ get
+ {
+ return this.appCenterPassword;
+ }
+ set
+ {
+ appCenterPassword = value;
+ }
+ }
+
///
/// Gets a value indicating whether or not the application management controls are to be enabled.
///
@@ -238,6 +320,18 @@ private set
}
}
+ private void UpdateAPItoken()
+ {
+ bool haveAPItoken = false;
+
+ if (!string.IsNullOrWhiteSpace(this.ApiToken))
+ {
+ haveAPItoken = true;
+ }
+
+ this.ApiTokenSet = haveAPItoken;
+ }
+
///
/// Updates whether or not connections are safe to be restored.
///
@@ -260,6 +354,18 @@ private void UpdateCanReconnect()
}
}
+ private void UpdateAppCenterCredentials()
+ {
+ bool haveAppCenterCredentials = false;
+
+ if (!string.IsNullOrWhiteSpace(this.AppCenterUserName) && !string.IsNullOrWhiteSpace(this.AppCenterPassword))
+ {
+ haveAppCenterCredentials = true;
+ }
+ this.AppCenterCredentialsSet = haveAppCenterCredentials;
+ this.UpdateCanReconnect();
+ }
+
///
/// Updates whether or not credentials have been set to valid strings.
///
diff --git a/HoloLensCommander/HoloLensCommander/Utilities/AppResponse.cs b/HoloLensCommander/HoloLensCommander/Utilities/AppResponse.cs
new file mode 100644
index 00000000..973e7f2f
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Utilities/AppResponse.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoloLensCommander
+{
+ ///
+ /// Class to create an object that saves app metadata for each application returned from enumerated JSON response.
+ ///
+ public class AppResponse
+ {
+ public string display_name;
+ public string name;
+ public string app_secret;
+ public string id;
+ }
+
+ ///
+ /// Class to create an object that saves download URL for a specific application returned from enumerated JSON response.
+ ///
+ public class DownloadResponse
+ {
+ public string download_url;
+ }
+}
diff --git a/HoloLensCommander/HoloLensCommander/Utilities/UserToken.cs b/HoloLensCommander/HoloLensCommander/Utilities/UserToken.cs
new file mode 100644
index 00000000..cd286c23
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Utilities/UserToken.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HoloLensCommander
+{
+ public class UserToken
+ {
+ public UserToken(string apiToken)
+ {
+ ApiToken = apiToken;
+ }
+
+ public string ApiToken { get; set; }
+ }
+}
diff --git a/HoloLensCommander/HoloLensCommander/Utilities/WebRequest.cs b/HoloLensCommander/HoloLensCommander/Utilities/WebRequest.cs
new file mode 100644
index 00000000..0f141c57
--- /dev/null
+++ b/HoloLensCommander/HoloLensCommander/Utilities/WebRequest.cs
@@ -0,0 +1,138 @@
+using System;
+using System.IO.Compression;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using Windows.Networking.BackgroundTransfer;
+using Windows.Storage;
+using Windows.Storage.Streams;
+using Windows.Web.Http;
+using Windows.Web.Http.Headers;
+
+namespace HoloLensCommander
+{
+ public class AppCenterWebRequest
+ {
+ public async Task HttpWebRequest()
+ {
+ HttpClient httpClient = new HttpClient();
+
+ var request = new HttpRequestMessage();
+
+ request.Headers.Accept.Add(new HttpMediaTypeWithQualityHeaderValue("application/json"));
+ request.Headers.Append("X-API-Token", "9b8e356d29f80de93d88fac0252e48f8fbe22e96");
+
+ Uri uri = new Uri("https://api.appcenter.ms/v0.1/apps");
+ request.RequestUri = uri;
+
+
+ HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
+ string httpResponseBody = "";
+
+ try
+ {
+ httpResponseMessage = await httpClient.SendRequestAsync(request);
+ httpResponseMessage.EnsureSuccessStatusCode();
+ httpResponseBody = await httpResponseMessage.Content.ReadAsStringAsync();
+ }
+ catch (Exception ex)
+ {
+ httpResponseBody = "Error: " + ex.HResult.ToString("X") + " Message: " + ex.Message;
+ }
+
+ return httpResponseBody;
+ }
+
+ ///
+ /// A web request for latest App Center release of the selected app. Release information includes download URL.
+ ///
+ ///
+ ///
+ public async Task HttpReleaseRequest(string appSecret)
+ {
+ HttpClient httpClient = new HttpClient();
+
+ var request = new HttpRequestMessage();
+
+ request.Headers.Accept.Add(new HttpMediaTypeWithQualityHeaderValue("application/json"));
+ request.Headers.Append("X-API-Token", "9b8e356d29f80de93d88fac0252e48f8fbe22e96"); //TODO remove hardcoded API Token
+
+ Uri uri = new Uri("https://api.appcenter.ms/v0.1/sdk/apps/"+ appSecret+"/releases/latest"); //how do I format this?
+ request.RequestUri = uri;
+
+ HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
+ string httpResponseBody = "";
+
+ try
+ {
+ httpResponseMessage = await httpClient.SendRequestAsync(request);
+ httpResponseMessage.EnsureSuccessStatusCode();
+ httpResponseBody = await httpResponseMessage.Content.ReadAsStringAsync();
+ }
+ catch (Exception ex)
+ {
+ httpResponseBody = "Error: " + ex.HResult.ToString("X") + " Message: " + ex.Message;
+ }
+
+ return httpResponseBody;
+ }
+
+ ///
+ /// A web request to download a release of an app.
+ ///
+ ///
+ ///
+ public async void HttpDownloadRequest(string downloadUrl, string appName)
+ {
+ try
+ {
+ Uri uri = new Uri(downloadUrl);
+ HttpClient httpClient = new HttpClient();
+
+ IInputStream content = await httpClient.GetInputStreamAsync(uri);
+
+ HttpStreamContent httpStream = new HttpStreamContent(content);
+ IBuffer buffer = await httpStream.ReadAsBufferAsync();
+
+ StorageFolder cacheFolder = ApplicationData.Current.LocalCacheFolder;
+ StorageFile file = await cacheFolder.CreateFileAsync(appName+".appxbundle", CreationCollisionOption.GenerateUniqueName);
+
+ IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite);
+
+ using (var outputStream = stream.GetOutputStreamAt(0))
+ {
+ using (var dataWriter = new DataWriter(outputStream))
+ {
+ dataWriter.WriteBuffer(buffer);
+ await dataWriter.StoreAsync();
+ await outputStream.FlushAsync();
+ }
+ }
+ stream.Dispose();
+ httpStream.Dispose();
+
+ //Unzipping the download
+
+ //var archive = await cacheFolder.GetFileAsync(appName + ".zip");
+ //ZipFile.ExtractToDirectory(archive.Path, cacheFolder.Path);
+
+
+ //Background downloader
+
+ //BackgroundDownloader backgroundDownloader = new BackgroundDownloader();
+ ////DownloadOperation downloadOperation = await backgroundDownloader.CreateDownloadAsync(uri, downloadedAppx, inputStream);
+ //DownloadOperation downloadOperation = backgroundDownloader.CreateDownload(uri, downloadedAppx);
+ ////operation = await Task.Run(() => { return downloadOperation.StartAsync(); });
+
+
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ finally
+ {
+ await Windows.System.Launcher.LaunchFolderAsync(ApplicationData.Current.LocalCacheFolder);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/HoloLensCommander/HoloLensCommander/project.json b/HoloLensCommander/HoloLensCommander/project.json
index ac17492a..3d8189e6 100644
--- a/HoloLensCommander/HoloLensCommander/project.json
+++ b/HoloLensCommander/HoloLensCommander/project.json
@@ -1,7 +1,8 @@
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
- "WindowsDevicePortalWrapper": "0.9.5.1"
+ "WindowsDevicePortalWrapper": "0.9.4"
+ "Newtonsoft.Json": "10.0.3",
},
"frameworks": {
"uap10.0": {}