From 262d065d2aa244b33719811ba5d6a6ab16b56810 Mon Sep 17 00:00:00 2001 From: Greg Pettyjohn Date: Thu, 11 Aug 2016 17:26:53 -0700 Subject: [PATCH 01/51] DeviceLab sample --- Samples/DeviceLab/App.config | 6 + Samples/DeviceLab/App.xaml | 9 + Samples/DeviceLab/App.xaml.cs | 17 + Samples/DeviceLab/BindablePassword.xaml | 11 + Samples/DeviceLab/BindablePassword.xaml.cs | 38 ++ Samples/DeviceLab/DeviceLab.csproj | 136 +++++++ Samples/DeviceLab/DeviceLab.sln | 31 ++ Samples/DeviceLab/DevicePortalView.xaml | 104 +++++ Samples/DeviceLab/DevicePortalView.xaml.cs | 34 ++ Samples/DeviceLab/DevicePortalViewModel.cs | 359 ++++++++++++++++++ Samples/DeviceLab/DeviceSignInViewModel.cs | 255 +++++++++++++ .../DeviceLab/DiagnosticOutputViewModel.cs | 163 ++++++++ Samples/DeviceLab/MainViewModel.cs | 67 ++++ Samples/DeviceLab/MainWindow.xaml | 74 ++++ Samples/DeviceLab/MainWindow.xaml.cs | 40 ++ Samples/DeviceLab/Properties/AssemblyInfo.cs | 55 +++ .../Properties/Resources.Designer.cs | 71 ++++ Samples/DeviceLab/Properties/Resources.resx | 117 ++++++ .../DeviceLab/Properties/Settings.Designer.cs | 30 ++ .../DeviceLab/Properties/Settings.settings | 7 + .../DeviceLab/XboxDevicePortalConnection.cs | 172 +++++++++ Samples/DeviceLab/packages.config | 4 + 22 files changed, 1800 insertions(+) create mode 100644 Samples/DeviceLab/App.config create mode 100644 Samples/DeviceLab/App.xaml create mode 100644 Samples/DeviceLab/App.xaml.cs create mode 100644 Samples/DeviceLab/BindablePassword.xaml create mode 100644 Samples/DeviceLab/BindablePassword.xaml.cs create mode 100644 Samples/DeviceLab/DeviceLab.csproj create mode 100644 Samples/DeviceLab/DeviceLab.sln create mode 100644 Samples/DeviceLab/DevicePortalView.xaml create mode 100644 Samples/DeviceLab/DevicePortalView.xaml.cs create mode 100644 Samples/DeviceLab/DevicePortalViewModel.cs create mode 100644 Samples/DeviceLab/DeviceSignInViewModel.cs create mode 100644 Samples/DeviceLab/DiagnosticOutputViewModel.cs create mode 100644 Samples/DeviceLab/MainViewModel.cs create mode 100644 Samples/DeviceLab/MainWindow.xaml create mode 100644 Samples/DeviceLab/MainWindow.xaml.cs create mode 100644 Samples/DeviceLab/Properties/AssemblyInfo.cs create mode 100644 Samples/DeviceLab/Properties/Resources.Designer.cs create mode 100644 Samples/DeviceLab/Properties/Resources.resx create mode 100644 Samples/DeviceLab/Properties/Settings.Designer.cs create mode 100644 Samples/DeviceLab/Properties/Settings.settings create mode 100644 Samples/DeviceLab/XboxDevicePortalConnection.cs create mode 100644 Samples/DeviceLab/packages.config diff --git a/Samples/DeviceLab/App.config b/Samples/DeviceLab/App.config new file mode 100644 index 00000000..88fa4027 --- /dev/null +++ b/Samples/DeviceLab/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Samples/DeviceLab/App.xaml b/Samples/DeviceLab/App.xaml new file mode 100644 index 00000000..12fbc02f --- /dev/null +++ b/Samples/DeviceLab/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Samples/DeviceLab/App.xaml.cs b/Samples/DeviceLab/App.xaml.cs new file mode 100644 index 00000000..32b134b3 --- /dev/null +++ b/Samples/DeviceLab/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace DeviceLab +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Samples/DeviceLab/BindablePassword.xaml b/Samples/DeviceLab/BindablePassword.xaml new file mode 100644 index 00000000..a31e1b81 --- /dev/null +++ b/Samples/DeviceLab/BindablePassword.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/Samples/DeviceLab/BindablePassword.xaml.cs b/Samples/DeviceLab/BindablePassword.xaml.cs new file mode 100644 index 00000000..2cf6964e --- /dev/null +++ b/Samples/DeviceLab/BindablePassword.xaml.cs @@ -0,0 +1,38 @@ +using System.Security; +using System.Windows; +using System.Windows.Controls; + +namespace DeviceLab +{ + /// + /// Interaction logic for BindablePassword.xaml + /// + public partial class BindablePassword : UserControl + { + public SecureString Password + { + get + { + return (SecureString)GetValue(PasswordProperty); + } + set + { + SetValue(PasswordProperty, value); + } + } + + public static readonly DependencyProperty PasswordProperty = + DependencyProperty.Register("Password", typeof(SecureString), typeof(BindablePassword), + new PropertyMetadata(default(SecureString))); + + public BindablePassword() + { + InitializeComponent(); + } + + private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) + { + Password = ((PasswordBox)sender).SecurePassword; + } + } +} diff --git a/Samples/DeviceLab/DeviceLab.csproj b/Samples/DeviceLab/DeviceLab.csproj new file mode 100644 index 00000000..d188e6a5 --- /dev/null +++ b/Samples/DeviceLab/DeviceLab.csproj @@ -0,0 +1,136 @@ + + + + + Debug + AnyCPU + {C0C9CBEF-E460-431B-90DD-4B1EFEBB9445} + WinExe + Properties + DeviceLab + DeviceLab + v4.5.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + packages\Prism.Core.6.1.0\lib\net45\Prism.dll + True + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + DevicePortalView.xaml + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + BindablePassword.xaml + + + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + {6a9e862e-5cda-4a8a-bbc0-56e9ea921e39} + WindowsDevicePortalWrapper + + + + + \ No newline at end of file diff --git a/Samples/DeviceLab/DeviceLab.sln b/Samples/DeviceLab/DeviceLab.sln new file mode 100644 index 00000000..0e1b1c70 --- /dev/null +++ b/Samples/DeviceLab/DeviceLab.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceLab", "DeviceLab.csproj", "{C0C9CBEF-E460-431B-90DD-4B1EFEBB9445}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsDevicePortalWrapper", "..\..\WindowsDevicePortalWrapper\WindowsDevicePortalWrapper\WindowsDevicePortalWrapper.csproj", "{6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}" +EndProject +Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\..\WindowsDevicePortalWrapper\WindowsDevicePortalWrapper.Shared\WindowsDevicePortalWrapper.Shared.projitems*{6a9e862e-5cda-4a8a-bbc0-56e9ea921e39}*SharedItemsImports = 4 + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C0C9CBEF-E460-431B-90DD-4B1EFEBB9445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0C9CBEF-E460-431B-90DD-4B1EFEBB9445}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0C9CBEF-E460-431B-90DD-4B1EFEBB9445}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0C9CBEF-E460-431B-90DD-4B1EFEBB9445}.Release|Any CPU.Build.0 = Release|Any CPU + {6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/DeviceLab/DevicePortalView.xaml b/Samples/DeviceLab/DevicePortalView.xaml new file mode 100644 index 00000000..e63cdc5d --- /dev/null +++ b/Samples/DeviceLab/DevicePortalView.xaml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + - diff --git a/Samples/DeviceLab/MainWindow.xaml.cs b/Samples/DeviceLab/MainWindow.xaml.cs index 72dadbd2..316d16ee 100644 --- a/Samples/DeviceLab/MainWindow.xaml.cs +++ b/Samples/DeviceLab/MainWindow.xaml.cs @@ -24,17 +24,5 @@ public MainWindow() { InitializeComponent(); } - - private void addressEntry_TextChanged(object sender, TextChangedEventArgs e) - { - var binding = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty); - binding.UpdateSource(); - } - - private void userNameEntry_TextChanged(object sender, TextChangedEventArgs e) - { - var binding = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty); - binding.UpdateSource(); - } } } diff --git a/Samples/DeviceLab/SelectionListBox.cs b/Samples/DeviceLab/SelectionListBox.cs new file mode 100644 index 00000000..5f84f343 --- /dev/null +++ b/Samples/DeviceLab/SelectionListBox.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace DeviceLab +{ + /// + /// Custom ListBox that exposes a SelectionList Dependency property to enable two-way binding. + /// Internally, SelectionList is kept in sink with the SelectedItems property of the base + /// class + /// + public class SelectionListBox : ListBox + { + static SelectionListBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(SelectionListBox), new FrameworkPropertyMetadata(typeof(SelectionListBox))); + } + + protected override void OnSelectionChanged(SelectionChangedEventArgs e) + { + base.OnSelectionChanged(e); + SetValue(SelectionListProperty, this.SelectedItems); + } + + public IList SelectionList + { + get { return (IList)GetValue(SelectionListProperty); } + set { SetValue(SelectionListProperty, value); } + } + + public static readonly DependencyProperty SelectionListProperty = + DependencyProperty.Register("SelectionList", typeof(IList), typeof(SelectionListBox), new PropertyMetadata(null, null, CoerceSelectionList)); + + /// + /// Coerce the value of SelectionList so that it is identical to (i.e. the same object as) the + /// value of SelectedItems + /// + /// SelectionListBox instance + /// New list of selected items + /// The list of selected items of the list + private static object CoerceSelectionList(DependencyObject d, object baseValue) + { + SelectionListBox thisDCV = d as SelectionListBox; + IList selectedItems = thisDCV.SelectedItems; + IList baseList = baseValue as IList; + if (baseList == selectedItems) + { + // Must have been called from OnSelectionChanged... + // ...implies nothing to do so early out + return selectedItems; + } + + // baseValue is not identical to SelectedItems, so fixup SelectedItems + // to have the same elements as baseValue... + // Note: This will result in multiple calls to OnSelectionChanged which + // will subsequently call this method but will early out according to + // the condition described above. + thisDCV.SelectedItems.Clear(); + if (baseList != null) + { + foreach (object itm in baseList) + { + thisDCV.SelectedItems.Add(itm); + } + } + + return selectedItems; + } + } +} diff --git a/Samples/DeviceLab/Themes/Generic.xaml b/Samples/DeviceLab/Themes/Generic.xaml new file mode 100644 index 00000000..c5a45f41 --- /dev/null +++ b/Samples/DeviceLab/Themes/Generic.xaml @@ -0,0 +1,5 @@ + + @@ -171,6 +135,10 @@ - - +