From 70e717b38085cf0bc525c95ecd527fae3b1d13af Mon Sep 17 00:00:00 2001 From: Alex Wolowiecki Date: Thu, 9 Nov 2017 13:09:28 -0800 Subject: [PATCH 1/4] Mobile center API token input --- .../Dialogs/SetAPItokenDialog.xaml | 31 ++++++++++++ .../Dialogs/SetAPItokenDialog.xaml.cs | 27 ++++++++++ .../Dialogs/SetAPItokenDialogViewModel.cs | 39 +++++++++++++++ .../SetAPItokenDialogViewModelProperties.cs | 28 +++++++++++ .../HoloLensCommander.csproj | 10 ++++ .../HoloLensCommander/MainPage.xaml | 7 +++ .../HoloLensCommander/MainWindowViewModel.cs | 7 +++ .../MainWindowViewModelCommands.cs | 21 ++++++++ .../MainWindowViewModelProperties.cs | 50 +++++++++++++++++++ .../HoloLensCommander/Utilities/UserToken.cs | 18 +++++++ 10 files changed, 238 insertions(+) create mode 100644 HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml create mode 100644 HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml.cs create mode 100644 HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModel.cs create mode 100644 HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModelProperties.cs create mode 100644 HoloLensCommander/HoloLensCommander/Utilities/UserToken.cs diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml new file mode 100644 index 00000000..93c51833 --- /dev/null +++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml.cs b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml.cs new file mode 100644 index 00000000..b28aaf39 --- /dev/null +++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialog.xaml.cs @@ -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) + { + } + } +} diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModel.cs b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModel.cs new file mode 100644 index 00000000..63b2cfa4 --- /dev/null +++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModel.cs @@ -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 + { + /// + /// Event that is notified when a property value has changed. + /// + public event PropertyChangedEventHandler PropertyChanged; + + public SetAPItokenDialogViewModel(UserToken apiToken) + { + this.APIToken= apiToken.ApiToken; + } + + /// + /// 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; + } + } +} diff --git a/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModelProperties.cs b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModelProperties.cs new file mode 100644 index 00000000..d0295fec --- /dev/null +++ b/HoloLensCommander/HoloLensCommander/Dialogs/SetAPItokenDialogViewModelProperties.cs @@ -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) + { + this.apiToken = value; + this.NotifyPropertyChanged(nameof(APIToken)); + } + } + } + } +} diff --git a/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj b/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj index f7e966a1..5a34f318 100644 --- a/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj +++ b/HoloLensCommander/HoloLensCommander/HoloLensCommander.csproj @@ -131,6 +131,11 @@ + + SetAPItokenDialog.xaml + + + @@ -174,6 +179,7 @@ + @@ -212,6 +218,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/HoloLensCommander/HoloLensCommander/MainPage.xaml b/HoloLensCommander/HoloLensCommander/MainPage.xaml index 6952a6c3..6515ef19 100644 --- a/HoloLensCommander/HoloLensCommander/MainPage.xaml +++ b/HoloLensCommander/HoloLensCommander/MainPage.xaml @@ -315,6 +315,13 @@ Command="{Binding Path=UseDesktopFilterCommand}" HorizontalAlignment="Left" Width="130" Canvas.Left="545" Canvas.Top="8"/> +