Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<ContentDialog
x:Class="HoloLensCommander.MobileCenterAppsDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HoloLensCommander"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Mobile Center Apps"
PrimaryButtonText="Close"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
MaxHeight="800">

<StackPanel>
<Canvas
Width="450" Height="40">
<TextBlock
x:Name="UserDisplayNameLabel"
Text="Display Name"
FontSize="16"
Canvas.Top="10"/>
<TextBlock
x:Name="UserDisplayName"
Text="{Binding Path=DeviceAddress}"
ToolTipService.ToolTip="The address of the target device"
FontSize="16"
Width="347"
Canvas.Left="103" Canvas.Top="10"/>
</Canvas>
<Canvas
Width="450" Height="440">
<TextBlock
x:Name="UserEmailLabel"
Text="Email"
FontSize="16"/>
<ListBox

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to make this multi-select?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidkline-ms Yes, we could make it multi-select to allow for multiple downloads at once. That would require some additional steps for making the download call async and queuing up concurrent downloads, correct?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are probably right. Unless the AppCenter has an endpoint for "install these". Probably something best left for the next rev :)

@awolowiecki720 wolo (awolowiecki720) Jan 25, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To my knowledge there is not. I am using the download URL and then caching that downloaded data. There is "install" api other than to install to a mobile device for testing.
imgo

x:Name="MobileCenterAppsList"
ItemsSource="{Binding MobileCenterApps}"
SelectedItem="{Binding SelectedMobileCenterApp, Mode=TwoWay}"
ToolTipService.ToolTip="Mobile Center apps from your organization"
Width="395" Height= "400"
BorderThickness="1"
ScrollViewer.HorizontalScrollMode="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
Canvas.Top="26"/>
<Button
x:Name="downloadSelectedApp"
Content="&#xE896;"
Command="{Binding RefreshInstalledAppsCommand}"
ToolTipService.ToolTip="Download selected app from the Mobile Center"
FontFamily="Segoe MDL2 Assets" FontSize="24"
Width="50" Height="40"
Canvas.Left="400" Canvas.Top="25"/>
</Canvas>
</StackPanel>
</ContentDialog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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()
{
jsonParse();
this.InitializeComponent();
}

private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
//close the dialog
}

private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no secondary button in the XAML, no need to have this method.

{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Newtonsoft.Json;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, this project's only dependency is on WindowsDevicePortalWrapper. Is the json data from the app center complex enough to warrant using the Netwtonsoft component? If not, I would prefer we not take an additional dependency.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can help with the deserialization code if we can avoid the component,.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidkline-ms Yes, there are only 2 instances of deserializing the JSON response data, and it’s a relatively simple object (~15 fields total, but I only use 4). Help with this would be awesome so that we do not add more dependencies.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Since you only use the four, we should be able to only define the subset when configuring the object for the built in json serializer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidkline-ms what's the easiest way to write our own json parser for these objects? Are you thinking we parse the strings ourselves? Or are there built in functions I am not aware of?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is a sample class definition from the WindowsDevicePortalWrapper project:

     using System.Runtime.Serialization;

    [DataContract]
    public class BatteryState
    {
        [DataMember(Name = "AcOnline")]
        public bool IsOnAcPower { get; private set; }

        [DataMember(Name = "BatteryPresent")]
        public bool IsBatteryPresent { get; private set; }

        [DataMember(Name = "Charging")]
        public bool IsCharging { get; private set; }

        [DataMember(Name = "DefaultAlert1")]
        public int DefaultAlert1 { get; private set; }

        [DataMember(Name = "DefaultAlert2")]
        public int DefaultAlert2 { get; private set; }

        [DataMember(Name = "EstimatedTime")]
        public uint EstimatedTimeRaw { get; private set; }

        [DataMember(Name = "MaximumCapacity")]
        public int MaximumCapacity { get; private set; }

        [DataMember(Name = "RemainingCapacity")]
        public int RemainingCapacity { get; private set; }
    }

@david-c-kline David Kline (david-c-kline) Jan 25, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the BatteryState example, if all you cared about was whether or not a battery existed and if the system was plugged in, you could include only the first two members of the class.

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);
}

}
private void NotifyPropertyChanged(string propertyName)
{
this.PropertyChanged?.Invoke(
this,
new PropertyChangedEventArgs(propertyName));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections.Generic;

namespace HoloLensCommander
{
public partial class MobileCenterAppsDialogViewModel
{
private List<string> mobileCenterApps = new List<string>();
public List<string> MobileCenterApps
{
get
{
return this.mobileCenterApps;
}
set
{
if (this.mobileCenterApps != value)
{
this.mobileCenterApps = value;
this.NotifyPropertyChanged(nameof(MobileCenterApps));
}
}
}
}
}
31 changes: 31 additions & 0 deletions HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<ContentDialog
x:Class="HoloLensCommander.SetAPItokenDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HoloLensCommander"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Set API Token"
PrimaryButtonText="Ok"
SecondaryButtonText="Cancel"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
SecondaryButtonClick="ContentDialog_SecondaryButtonClick">

<StackPanel>
<Canvas
Width="350" Height="50">
<TextBlock
x:Name="TokenLabel"
Text="Token"
FontSize="16"
Canvas.Top="16" Canvas.Left="5"/>
<TextBox
x:Name="token"
Text="{Binding Path= APIToken, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ToolTipService.ToolTip="Mobile Center API Token"
Width="200"
Canvas.Top="10" Canvas.Left="85"/>
</Canvas>
</StackPanel>
</ContentDialog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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;

public SetAPItokenDialog(UserToken APItoken)
{
this.apiToken = APItoken;
this.DataContext = new SetAPItokenDialogViewModel(APItoken);
this.InitializeComponent();
}

private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
((SetAPItokenDialogViewModel)this.DataContext).UpdateAPItoken(this.apiToken);
}

private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to get rid of this method by not specifying a click event for the secondary button. This is what the Connect to Device dialog does.

{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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
{
/// <summary>
/// Event that is notified when a property value has changed.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;

public SetAPItokenDialogViewModel(UserToken apiToken)
{
this.APIToken= apiToken.ApiToken;
}

/// <summary>
/// Sends the PropertyChanged events to registered handlers.
/// </summary>
/// <param name="propertyName">The name of property that has changed.</param>
private void NotifyPropertyChanged(string propertyName)
{
this.PropertyChanged?.Invoke(
this,
new PropertyChangedEventArgs(propertyName));
}

internal void UpdateAPItoken(UserToken apiToken)
{
apiToken.ApiToken = this.APIToken;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this.apiToken != value

{
this.apiToken = value;
this.NotifyPropertyChanged(nameof(APIToken));
}
}
}
}
}
21 changes: 21 additions & 0 deletions HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@
<Compile Include="Dialogs\ManageAppsDialogViewModelProperties.cs" />
<Compile Include="Dialogs\MixedRealityViewDialogViewModel.cs" />
<Compile Include="Dialogs\MixedRealityViewDialogViewModelProperties.cs" />
<Compile Include="Dialogs\MobileCenterAppsDialog.xaml.cs">
<DependentUpon>MobileCenterAppsDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\MobileCenterAppsDialogViewModel.cs" />
<Compile Include="Dialogs\MobileCenterAppsDialogViewModelProperties.cs" />
<Compile Include="Dialogs\SetAPItokenDialog.xaml.cs">
<DependentUpon>SetAPItokenDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Dialogs\SetAPItokenDialogViewModel.cs" />
<Compile Include="Dialogs\SetAPItokenDialogViewModelProperties.cs" />
<Compile Include="Dialogs\SetCredentialsDialogViewModel.cs" />
<Compile Include="Dialogs\SetCredentialsDialogViewModelProperties.cs" />
<Compile Include="Dialogs\SetIpdDialog.xaml.cs">
Expand Down Expand Up @@ -165,6 +175,7 @@
<DependentUpon>SettingsDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Utilities\AppInstallFiles.cs" />
<Compile Include="Utilities\AppResponse.cs" />
<Compile Include="Utilities\ConnectionInformation.cs" />
<Compile Include="Utilities\ConnectOptions.cs" />
<Compile Include="Utilities\DeviceMonitorControlComparer.cs" />
Expand All @@ -174,7 +185,9 @@
<Compile Include="Utilities\Settings.cs" />
<Compile Include="Utilities\TagInformation.cs" />
<Compile Include="Utilities\UserInformation.cs" />
<Compile Include="Utilities\UserToken.cs" />
<Compile Include="Utilities\Utilities.cs" />
<Compile Include="Utilities\WebRequest.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down Expand Up @@ -212,6 +225,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialogs\MobileCenterAppsDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialogs\SetAPItokenDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialogs\SetIpdDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
14 changes: 14 additions & 0 deletions HoloLensCommander/HoloLensCommander/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@
Command="{Binding Path=UseDesktopFilterCommand}"
HorizontalAlignment="Left" Width="130"
Canvas.Left="545" Canvas.Top="8"/>
<Button
Content="&#xEE57;"
ToolTipService.ToolTip="Enter API token"
Command="{Binding Path=ShowSetAPItokenCommand}"
FontFamily="Segoe MDL2 Assets"
Width="50" Height="40"
Canvas.Top="5" Canvas.Left="675"/>
<Button
Content="&#xE71D;"
ToolTipService.ToolTip="Display Mobile Center app list"
Command="{Binding Path=ShowMobileCenterAppsCommand}"
FontFamily="Segoe MDL2 Assets"
Width="50" Height="40"
Canvas.Top="5" Canvas.Left="730"/>
</Canvas>
<ScrollViewer Grid.Column="1" Grid.Row="1"
VerticalScrollBarVisibility="Auto" VerticalScrollMode="Auto">
Expand Down
13 changes: 13 additions & 0 deletions HoloLensCommander/HoloLensCommander/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ partial class MainWindowViewModel : INotifyPropertyChanged, IDisposable
/// Values used to store and retrieve settings data.
/// </summary>
private static readonly string AutoReconnectKey = "autoReconnect";
private static readonly string DefaultAPItokenKey = "defaultAPItokenKey";
private static readonly string DefaultNetworkKeyKey = "defaultNetworkKey";
private static readonly string DefaultPasswordKey = "defaultPassword";
private static readonly string DefaultSsidKey = "defaultSsid";
Expand Down Expand Up @@ -375,6 +376,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) =>
{
Expand Down
Loading