From 5722ddffedaccd6c466ddf186779da354afc2c31 Mon Sep 17 00:00:00 2001 From: michael-hawker Date: Tue, 17 Sep 2019 08:33:14 -0700 Subject: [PATCH 01/69] Copy over POC PeoplePicker code for transfer --- .../Controls/PeoplePicker/PeoplePicker.cs | 108 ++++++++++++++++++ .../Controls/PeoplePicker/PeoplePicker.xaml | 37 ++++++ 2 files changed, 145 insertions(+) create mode 100644 Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs create mode 100644 Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs new file mode 100644 index 0000000..6b83d95 --- /dev/null +++ b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs @@ -0,0 +1,108 @@ +using Microsoft.Graph; +using Microsoft.Toolkit.Graph; +using Microsoft.Toolkit.Graph.Helpers; +using Microsoft.Toolkit.Uwp.UI.Controls.Graph.Helpers; +using System; +using System.Collections.ObjectModel; +using TokenListBoxSample.Controls; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235 + +namespace Microsoft.Toolkit.Uwp.UI.Controls.Graph +{ + [TemplatePart(Name = PeoplePickerTokenListBoxName, Type = typeof(TokenListBox))] + public partial class PeoplePicker : Control + { + private const string PeoplePickerTokenListBoxName = "PART_TokenListBox"; + + private TokenListBox _tokenBox; + + private DispatcherTimer _typeTimer = new DispatcherTimer(); + + public ObservableCollection SuggestedPeople + { + get { return (ObservableCollection)GetValue(SuggestedPeopleProperty); } + set { SetValue(SuggestedPeopleProperty, value); } + } + + // Using a DependencyProperty as the backing store for SuggestedPeople. This enables animation, styling, binding, etc... + public static readonly DependencyProperty SuggestedPeopleProperty = + DependencyProperty.Register(nameof(SuggestedPeople), typeof(ObservableCollection), typeof(PeoplePicker), new PropertyMetadata(new ObservableCollection())); + + public PeoplePicker() + { + this.DefaultStyleKey = typeof(PeoplePicker); + } + + protected override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (_tokenBox != null) + { + _tokenBox.QueryTextChanged -= _tokenBox_QueryTextChanged; + } + + _tokenBox = GetTemplateChild(PeoplePickerTokenListBoxName) as TokenListBox; + + if (_tokenBox != null) + { + _tokenBox.QueryTextChanged += _tokenBox_QueryTextChanged; + } + } + + private string _previousQuery; + + private void _tokenBox_QueryTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) + { + if (!args.CheckCurrent()) + { + return; + } + + if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) + { + var text = sender.Text; + _typeTimer.Debounce(async () => + { + var graph = GlobalProvider.Instance.Graph; + if (graph != null) + { + // If empty, clear out + if (string.IsNullOrWhiteSpace(text)) + { + SuggestedPeople.Clear(); + } + // If we are typing, continue to reduce the set from current list + //else if (!string.IsNullOrWhiteSpace(_previousQuery) && text.StartsWith(_previousQuery)) + //{ + // int count = SuggestedPeople.Count; + // for (var i = count - 1; i >= 0; i--) + // { + // var contact = SuggestedPeople[i]; + // if (!contact.DisplayName.Contains(text, StringComparison.InvariantCultureIgnoreCase)) + // { + // SuggestedPeople.Remove(contact); + // } + // } + //} + // Else, filter all contacts + else + { + SuggestedPeople.Clear(); + + foreach (var contact in (await graph.FindPersonAsync(text)).CurrentPage) + { + SuggestedPeople.Add(contact); + } + } + + _previousQuery = text; + } + }, TimeSpan.FromSeconds(0.3)); + } + } + } +} diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml new file mode 100644 index 0000000..42a70e5 --- /dev/null +++ b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml @@ -0,0 +1,37 @@ + + + + From cbd395c348eacf42264df338cfdf97b736001699 Mon Sep 17 00:00:00 2001 From: michael-hawker Date: Tue, 17 Sep 2019 18:23:05 -0500 Subject: [PATCH 02/69] Update PeoplePicker on top of all other dependencies --- .../PeoplePicker/PeoplePicker.Properties.cs | 36 +++++++++++ .../Controls/PeoplePicker/PeoplePicker.cs | 62 +++++++------------ .../Controls/PeoplePicker/PeoplePicker.xaml | 18 +++--- .../Microsoft.Toolkit.Graph.Controls.csproj | 5 +- .../Themes/Generic.xaml | 1 + .../VisualStudioToolsManifest.xml | 1 + .../Microsoft.Toolkit.Graph.csproj | 2 +- SampleTest/MainPage.xaml | 5 +- 8 files changed, 78 insertions(+), 52 deletions(-) create mode 100644 Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.Properties.cs diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.Properties.cs b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.Properties.cs new file mode 100644 index 0000000..4666127 --- /dev/null +++ b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.Properties.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.ObjectModel; +using Microsoft.Graph; +using Microsoft.Toolkit.Uwp.UI.Controls; +using Windows.UI.Xaml; + +namespace Microsoft.Toolkit.Graph.Controls +{ + /// + /// Control which allows user to search for a person or contact within Microsoft Graph. Built on top of . + /// + public partial class PeoplePicker + { + /// + /// Gets or sets collection of people suggested by the graph from the user's query. + /// + public ObservableCollection SuggestedPeople + { + get { return (ObservableCollection)GetValue(SuggestedPeopleProperty); } + set { SetValue(SuggestedPeopleProperty, value); } + } + + /// + /// Identifies the dependency property. + /// + /// + /// The identifier for the dependency property. + /// + public static readonly DependencyProperty SuggestedPeopleProperty = + DependencyProperty.Register(nameof(SuggestedPeople), typeof(ObservableCollection), typeof(PeoplePicker), new PropertyMetadata(new ObservableCollection())); + + } +} diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs index 6b83d95..2dedbbf 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs @@ -1,41 +1,38 @@ -using Microsoft.Graph; -using Microsoft.Toolkit.Graph; -using Microsoft.Toolkit.Graph.Helpers; -using Microsoft.Toolkit.Uwp.UI.Controls.Graph.Helpers; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + using System; -using System.Collections.ObjectModel; -using TokenListBoxSample.Controls; +using Microsoft.Toolkit.Graph.Extensions; +using Microsoft.Toolkit.Graph.Providers; +using Microsoft.Toolkit.Uwp.UI.Controls; +using Microsoft.Toolkit.Uwp.UI.Extensions; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235 - -namespace Microsoft.Toolkit.Uwp.UI.Controls.Graph +namespace Microsoft.Toolkit.Graph.Controls { - [TemplatePart(Name = PeoplePickerTokenListBoxName, Type = typeof(TokenListBox))] + /// + /// Control which allows user to search for a person or contact within Microsoft Graph. Built on top of . + /// + [TemplatePart(Name = PeoplePickerTokenizingTextBoxName, Type = typeof(TokenizingTextBox))] public partial class PeoplePicker : Control { - private const string PeoplePickerTokenListBoxName = "PART_TokenListBox"; + private const string PeoplePickerTokenizingTextBoxName = "PART_TokenizingTextBox"; - private TokenListBox _tokenBox; + private TokenizingTextBox _tokenBox; private DispatcherTimer _typeTimer = new DispatcherTimer(); - public ObservableCollection SuggestedPeople - { - get { return (ObservableCollection)GetValue(SuggestedPeopleProperty); } - set { SetValue(SuggestedPeopleProperty, value); } - } - - // Using a DependencyProperty as the backing store for SuggestedPeople. This enables animation, styling, binding, etc... - public static readonly DependencyProperty SuggestedPeopleProperty = - DependencyProperty.Register(nameof(SuggestedPeople), typeof(ObservableCollection), typeof(PeoplePicker), new PropertyMetadata(new ObservableCollection())); - + /// + /// Initializes a new instance of the class. + /// public PeoplePicker() { this.DefaultStyleKey = typeof(PeoplePicker); } + /// protected override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -45,7 +42,7 @@ protected override void OnApplyTemplate() _tokenBox.QueryTextChanged -= _tokenBox_QueryTextChanged; } - _tokenBox = GetTemplateChild(PeoplePickerTokenListBoxName) as TokenListBox; + _tokenBox = GetTemplateChild(PeoplePickerTokenizingTextBoxName) as TokenizingTextBox; if (_tokenBox != null) { @@ -65,9 +62,10 @@ private void _tokenBox_QueryTextChanged(AutoSuggestBox sender, AutoSuggestBoxTex if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) { var text = sender.Text; - _typeTimer.Debounce(async () => + _typeTimer.Debounce( + async () => { - var graph = GlobalProvider.Instance.Graph; + var graph = ProviderManager.Instance.GlobalProvider.Graph; if (graph != null) { // If empty, clear out @@ -75,20 +73,6 @@ private void _tokenBox_QueryTextChanged(AutoSuggestBox sender, AutoSuggestBoxTex { SuggestedPeople.Clear(); } - // If we are typing, continue to reduce the set from current list - //else if (!string.IsNullOrWhiteSpace(_previousQuery) && text.StartsWith(_previousQuery)) - //{ - // int count = SuggestedPeople.Count; - // for (var i = count - 1; i >= 0; i--) - // { - // var contact = SuggestedPeople[i]; - // if (!contact.DisplayName.Contains(text, StringComparison.InvariantCultureIgnoreCase)) - // { - // SuggestedPeople.Remove(contact); - // } - // } - //} - // Else, filter all contacts else { SuggestedPeople.Clear(); diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml index 42a70e5..80f2225 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml +++ b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.xaml @@ -1,8 +1,8 @@  + xmlns:local="using:Microsoft.Toolkit.Graph.Controls" + xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"> diff --git a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj index 64d82d4..f531fbc 100644 --- a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj +++ b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj @@ -24,8 +24,8 @@ - - + + diff --git a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj index 46b39d6..1a5d98b 100644 --- a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj +++ b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj @@ -23,6 +23,6 @@ - + From eb7423a25087d518a47eb7aabee6b36ec1971c6d Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 11 Jun 2020 18:29:48 -0700 Subject: [PATCH 42/69] Fix showing Users in People Picker --- .../Controls/PeoplePicker/PeoplePicker.cs | 16 +++++++++++- .../Extensions/GraphExtensions.cs | 26 ++++++++++++++++++- SampleTest/MainPage.xaml | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs index 869b502..c5850e2 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/PeoplePicker/PeoplePicker.cs @@ -82,10 +82,24 @@ private void TokenBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChang if (!string.IsNullOrWhiteSpace(text)) { + foreach (var user in (await graph.FindUserAsync(text)).CurrentPage) + { + // Exclude people in suggested list that we already have picked + if (!Items.Any(person => (person as Person)?.Id == user.Id)) + { + list.Add(user.ToPerson()); + } + } + + // Grab ids of current suggestions + var ids = list.Cast().Select(person => (person as Person).Id); + foreach (var contact in (await graph.FindPersonAsync(text)).CurrentPage) { // Exclude people in suggested list that we already have picked - if (!Items.Any(person => (person as Person)?.Id == contact.Id)) + // Or already suggested + if (!Items.Any(person => (person as Person)?.Id == contact.Id) && + !ids.Any(id => id == contact.Id)) { list.Add(contact); } diff --git a/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs b/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs index 0f4a064..8e8a433 100644 --- a/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs +++ b/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs @@ -52,7 +52,7 @@ public static Person ToPerson(this User user) /// /// Instance of the . /// User to search for. - /// collection of . + /// collection of . public static async Task FindPersonAsync(this GraphServiceClient graph, string query) { try @@ -72,6 +72,30 @@ public static async Task FindPersonAsync(this GraphSe return new UserPeopleCollectionPage(); } + /// + /// Shortcut to perform a user query. + /// + /// Instance of the . + /// User to search for. + /// collection of . + public static async Task FindUserAsync(this GraphServiceClient graph, string query) + { + try + { + return await graph + .Users + .Request() + .Filter($"startswith(displayName, '{query}') or startswith(givenName, '{query}') or startswith(surname, '{query}') or startswith(mail, '{query}') or startswith(userPrincipalName, '{query}')") + .WithScopes(new string[] { "user.readbasic.all" }) + .GetAsync(); + } + catch + { + } + + return new GraphServiceUsersCollectionPage(); + } + /// /// Helper to get the photo of a particular user. /// diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index c329c45..e7cb92e 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -29,7 +29,7 @@ Picked People: - + diff --git a/Samples/XAML Islands/UWP-XamlApplication/SamplePage.xaml b/Samples/XAML Islands/UWP-XamlApplication/SamplePage.xaml index f0c7f48..929d714 100644 --- a/Samples/XAML Islands/UWP-XamlApplication/SamplePage.xaml +++ b/Samples/XAML Islands/UWP-XamlApplication/SamplePage.xaml @@ -15,14 +15,14 @@ Picked People: - + From 07652fb8f9ebfb123d709da0e7635e3c628790fe Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Fri, 12 Jun 2020 14:35:48 -0700 Subject: [PATCH 44/69] Update XML comment of Quick Create --- Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs b/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs index 72443f7..b9fdfe7 100644 --- a/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs +++ b/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs @@ -18,7 +18,7 @@ namespace Microsoft.Toolkit.Graph.Providers //// TODO: Need to set up XAML Islands sample to test in the new repo and make sure this works from this context. /// - /// Helper class for XAML Islands to easily initialize provider from just ClientId from within WPF context. + /// Helper class to easily initialize provider from just ClientId. /// public static class QuickCreate { From 67c6527c2f2e5f86f0f7249d05e7773fc67f0206 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Sun, 14 Jun 2020 23:05:30 -0700 Subject: [PATCH 45/69] Update to 6.1.0 release build --- .../Microsoft.Toolkit.Graph.Controls.csproj | 4 ++-- Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj | 2 +- .../UWP-XamlApplication/UWP-XamlApplication.csproj | 2 +- .../XAML Islands/WPF-Core-GraphApp/WPF-Core-GraphApp.csproj | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj index f531fbc..6cd7fde 100644 --- a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj +++ b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj @@ -24,8 +24,8 @@ - - + + diff --git a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj index 1a5d98b..8e49be7 100644 --- a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj +++ b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj @@ -23,6 +23,6 @@ - + diff --git a/Samples/XAML Islands/UWP-XamlApplication/UWP-XamlApplication.csproj b/Samples/XAML Islands/UWP-XamlApplication/UWP-XamlApplication.csproj index 04a2f28..d8663fd 100644 --- a/Samples/XAML Islands/UWP-XamlApplication/UWP-XamlApplication.csproj +++ b/Samples/XAML Islands/UWP-XamlApplication/UWP-XamlApplication.csproj @@ -154,7 +154,7 @@ 6.2.10 - 6.1.0-preview1 + 6.1.0 diff --git a/Samples/XAML Islands/WPF-Core-GraphApp/WPF-Core-GraphApp.csproj b/Samples/XAML Islands/WPF-Core-GraphApp/WPF-Core-GraphApp.csproj index 35e9bc8..1ce0e96 100644 --- a/Samples/XAML Islands/WPF-Core-GraphApp/WPF-Core-GraphApp.csproj +++ b/Samples/XAML Islands/WPF-Core-GraphApp/WPF-Core-GraphApp.csproj @@ -9,7 +9,7 @@ - + From f6b6a0db9fb1bcc3709cd7261a77ed48dab09809 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 25 Jun 2020 11:56:49 -0700 Subject: [PATCH 46/69] Update Example to use ImageEx to show something for files with no images --- SampleTest/Assets/FileIcon.png | Bin 0 -> 2838 bytes SampleTest/MainPage.xaml | 5 +++-- SampleTest/SampleTest.csproj | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 SampleTest/Assets/FileIcon.png diff --git a/SampleTest/Assets/FileIcon.png b/SampleTest/Assets/FileIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..0435822f88e9f95066aa532bc10bbee46fea6a13 GIT binary patch literal 2838 zcmV+x3+eQUP)a7g%!WWFWI+Y>5zCWZ1Hh5QxVJX;UX-67R~v2FnCUmT=#02T+&l)Acx~9z7lG zky@>&_1z-l?i{sSy7ldi8#h`ms6L5;ojaf!Al1;> zHp}G_TI>F^ySw|v;o;#o$`~d}54PP2mz*XLHK-y6yaBpt8fdMtx3~9`qobpLO2DPE z0(R3hy>kluHi0AsPU;gtkAwZ0&1PS|e*OA|80AmWgKhForBr`Mo2KbI5Xw|G4N?iJ z2-TxBVgo;$&Axj1^5tK%z;=lp?X*01Ks7)r*&YSieA>3f!NI}LpFe;82M)lttmWCR zrL0m4ZQFXOWs^W`LPsN;0^c+Z&YwU3o2O5o{x%tGTU>hwHmw+mMP3OYQhlb@)A}PU z6mS~h7cN}*{gWq8e(6P*$QszL4ILX;3OMaFmkuN#)u5P=jR6~QPn4!?Fc{$C#fyJ> z{P^)tqez31XH)PE;8edUkZR~?U$oXM<91Pr`HV&*b?MTjzdw5PD7ug01Us}nYC1+I zO**L41~5lw#%2dnh{MO@vA%NU%GVDbJh&LZdNuV63Ehr#<>E$a@@Wm9w9Jld3b>C} zrqgMA?b@~Dd-v|0^TNI_fdiqq)%w$ zE}@+-#iyH~5m#i}V-8K4ySux)hlhv%R*uI$$l0OjHa~sQy={Br5}hxAToLX9es6E@ zylWptlxO>FLUck0#Tl%vqh;KBC3K;n3q`lq8vFbEUmhJDt?Z)&Q$OFqDCPFhWNAxH z9xi#qLNsFk3`KX-G?>k1U%h(u>Mv&eto>|GrosW+HCR_!F7PGl+2i&d7B3bH0Pse) z)*9!|o%_X$7cc$@0IluV1)3?NI(n_O?i-JZ%U`IiP3z|KIl8XHVzEHib^XTx?2B?U zHpA%#_=AIkUq5^H>_4rmai7HWT5EJ&7mae86H9?a%W~?yfB)Y5%7f3R2{hj;5=yDx zu~I)@{!MMo-Q_NjO7d_jx7U~xs67D8=X1Tbg7i&_6fB<&7jPprczBcCF6oQ+#5l&$ zzH*zpX#|I4Tlu@BPQ0jb+1WxLAC4cpF7;6|s&jND`oh{`je*bEGvNTf2|i7&m)jRW zu!4*MO=ey%<%A@4iBH=s0aEHy;Oh%O^6Z$zIGFAobY17P@zuA*w%G)qhSI?j?E#(x zU;COPuBRZhgy;GNHpi!>bfLbmPHL!*`xN+g&m?|;`g~flUdTRrco5?1*i*ovi_#Nk z3ZK@hM|II%zgT$;tWb1weWXsD+ooGv)VLNic10f;O1UQnd!pp{hzaeRuib6bC2z5E zQ$ql2r`3{nd{UE#YjL~tblnGT>Yj<6ndI!dP$|X35^!_4-8(_LK%h3<6(s=Yi#;Jp z1-u4GrF7n1KMwFA9ko$v^&qtr;F|!6tD|MKp6I|=k{Y^n^gY26fQK>_^K(<&9(#I% z6J+d|D~yo4u@-CNkQe< zcxi+KW{Diw=O;uN(sp7uq-|SFCKC*YLs6u2fTv|e{-(xdZ-A20khC4UEY&}Np3?_| z0f0LE%|2cCMZ5H-xO63GhueP0k5USw(Fo)5c;zTh0xm7HbwzglB$-MqV@YX;U zGMTJ_mz|ApfS`L0DPVF2%AtkSTwCG;_(&^f&YW4}aS8AM^D8h?I#_CQP4(@&miV^I zlv0>Zrz?ln(up%E^^0+9YNnFvCpXvT_R|1vAL&UZ&ZHMBZGFj1MbejCf0DMS(3NKv zjc^){&F<3Kzr;=9@_SBn8!`JU0Du34{bFTl9_L)geALLdC4CtVhZv8?0C>yztkf^% zx>Wj@BGTyQ*qCKL5T7vFFIIAFQqn#SO@;J1(Ov3^ZQB;p=`^~;&-&UTpS?YZocy^o z&vN{vM*OG$mCyt3q7!ePoqETm6I!gT)Tf|icES~{bsyot`ox)?`o-*0IhYGpN-kb2 zx`EGtyN=$HQ$Jf@I?D*@xlciAKXPTc{P-@T*);?rG~#j)6Y1;4oJ@raRtja*jBem_ zgqv6ERwBD}9_<6OM!qiX2Ul`aOtZWByF*VY;2%QO|D$9N>N6sn@lCR#ag1#*kMB{k@i*Ej}p;cB=wUv zN_F(crerFdwsUiFPWvG#_KlS>J!c>#+KEYsb~tsVHukmn#mbOgny0$TIhjfftZn7) zwSNkf>zq4r#;B!4JDmEtTrZ)~A}?0@d`JLI;c3oIOQ8(ulfey+;;COqpAsc0BAra7 z<4sKpioICr({m#)q?cwYDgDivbGZ7fEmm#^B!kGwRAM(JRL*TjVn=O?zF3*!!c{nwOD(DG_-<_K4U$H8^%pB?-4YWgCsW}F=ccC69xL@L0XWB| z1U1EMq#T{|G$p5gHG!ZJA;~g0AeBlTef{<6IM+Z%>Q{T> z+zE}7g_N3HIoHy$XK%4`8%>!wQ`(7@l}I0@H`F;nrZ`Wr2?3wWjWwvL)a2QJQNX)* z@BXKhihfH&OziiOV>Uip`d%}~zpFf_9j>0!r>^U8a&q!t1>gX{j{r=(UVo4rSpql# o@SOtiV?@3R;|Ix>1%U7W54M%U2yAYW`Tzg`07*qoM6N<$f|~($b^rhX literal 0 HcmV?d00001 diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index c9e1684..00090c8 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -58,8 +58,9 @@ - + diff --git a/SampleTest/SampleTest.csproj b/SampleTest/SampleTest.csproj index e98c1d1..4a1c7d9 100644 --- a/SampleTest/SampleTest.csproj +++ b/SampleTest/SampleTest.csproj @@ -130,6 +130,7 @@ + From eedfc147563ed0bb44cdef2c8fe1974d410df5e6 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 25 Jun 2020 13:06:02 -0700 Subject: [PATCH 47/69] Update link to issue filed in Graph for the API we're trying to use --- .../Controls/GraphPresenter/GraphPresenter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs index ad37c23..4133823 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs @@ -45,7 +45,7 @@ private static async void OnDataChanged(DependencyObject d, DependencyPropertyCh { if (d is GraphPresenter presenter) { - // TODO: Should this be a Graph SDK bug? The interfaces don't match the similar class hierarchy? + // Use BaseRequestBuilder as some interfaces from the Graph SDK don't implement IBaseRequestBuilder properly, see https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/722 if (e.NewValue is BaseRequestBuilder builder) { var request = new BaseRequest(builder.RequestUrl, builder.Client, null); From 7d43dd841f830e8acc73dc0f7c9b5e03d2d8f3a8 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Mon, 29 Jun 2020 14:15:47 -0700 Subject: [PATCH 48/69] Update Missing Headers --- .../Controls/GraphPresenter/GraphPresenter.cs | 6 +++++- .../Converters/FileSizeConverter.cs | 6 +++++- .../Converters/OneDriveThumbnailConverter.cs | 6 +++++- .../Providers/NotifyTaskCompletion.cs | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs index 4133823..762377a 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs @@ -1,4 +1,8 @@ -using Microsoft.Graph; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Graph; using Microsoft.Toolkit.Graph.Providers; using Microsoft.Toolkit.Uwp.Helpers; using Newtonsoft.Json; diff --git a/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs b/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs index bff2d95..d02275d 100644 --- a/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs +++ b/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs @@ -1,4 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; using Microsoft.Toolkit.Graph.Extensions; using Windows.UI.Xaml.Data; diff --git a/Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs b/Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs index 68b3c85..8c2d929 100644 --- a/Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs +++ b/Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs @@ -1,4 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; using Microsoft.Graph; using Microsoft.Toolkit.Graph.Providers; using Windows.UI.Xaml.Data; diff --git a/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs b/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs index 09091b0..554d76c 100644 --- a/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs +++ b/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs @@ -1,4 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; using System.ComponentModel; using System.Threading.Tasks; From d5c051726a088c4b3f462f814d571ce5a31a15a3 Mon Sep 17 00:00:00 2001 From: Herrick Spencer Date: Fri, 10 Jul 2020 11:24:17 -0700 Subject: [PATCH 49/69] Changes from master to main for WCT-Graph-Controls; there are still more changes to make for links to Azure Devops and MGT --- .github/PULL_REQUEST_TEMPLATE.md | 17 +++--- azure-pipelines.yml | 102 +++++++++++++++---------------- version.json | 4 +- 3 files changed, 61 insertions(+), 62 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6562aab..571b740 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,11 @@ Fixes # + ## PR Type + What kind of change does this PR introduce? + @@ -14,28 +17,24 @@ What kind of change does this PR introduce? - ## What is the current behavior? - + ## What is the new behavior? - ## PR Checklist Please check if your PR fulfills the following requirements: -- [ ] Tested code with current [supported SDKs](https://github.com/windows-toolkit/Graph-Controls/blob/master/README.md) +- [ ] Tested code with current [supported SDKs](https://github.com/windows-toolkit/Graph-Controls/blob/main/README.md) - [ ] Sample in sample app has been added / updated (for bug fixes / features) - - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets) + - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets) - [ ] Tests for the changes have been added (for bug fixes / features) (if applicable) -- [ ] Header has been added to all new source files (run *build/UpdateHeaders.bat*) +- [ ] Header has been added to all new source files (run _build/UpdateHeaders.bat_) - [ ] Contains **NO** breaking changes - - - ## Other information diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f45fa4e..4c3da40 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,71 +1,71 @@ # Control which branches get CI triggers (defaults to all branches if this parameter is not set) trigger: -- master -- rel/* + - main + - rel/* # Specify the target branches for pull request builds pr: -- master -- rel/* + - main + - rel/* # Microsoft-hosted agent pool for Visual Studio 2019 pool: vmImage: windows-2019 -variables: +variables: BuildConfiguration: CI steps: -# Setup Environment Variables -- task: BatchScript@1 - inputs: - filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\Tools\\VsDevCmd.bat" - arguments: -no_logo - modifyEnvironment: true - displayName: Setup Environment Variables + # Setup Environment Variables + - task: BatchScript@1 + inputs: + filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\Tools\\VsDevCmd.bat" + arguments: -no_logo + modifyEnvironment: true + displayName: Setup Environment Variables -# Install Nuget Tool Installer -- task: NuGetToolInstaller@0 - displayName: Use NuGet 5.0.0 - inputs: - versionSpec: 5.0.0 + # Install Nuget Tool Installer + - task: NuGetToolInstaller@0 + displayName: Use NuGet 5.0.0 + inputs: + versionSpec: 5.0.0 -# Install NBGV Tool -- task: DotNetCoreCLI@2 - inputs: - command: custom - custom: tool - arguments: install --tool-path . nbgv - displayName: Install NBGV tool + # Install NBGV Tool + - task: DotNetCoreCLI@2 + inputs: + command: custom + custom: tool + arguments: install --tool-path . nbgv + displayName: Install NBGV tool -# Set cloud build variables -- script: nbgv cloud - displayName: Set Version + # Set cloud build variables + - script: nbgv cloud + displayName: Set Version -# Install Windows SDK 18362 (minimum compatible sdk) -- powershell: .\build\Install-WindowsSdkISO.ps1 18362 - displayName: Insider SDK + # Install Windows SDK 18362 (minimum compatible sdk) + - powershell: .\build\Install-WindowsSdkISO.ps1 18362 + displayName: Insider SDK -# Run cake build -- powershell: .\build.ps1 -target=Package - displayName: Build - workingDirectory: .\build + # Run cake build + - powershell: .\build.ps1 -target=Package + displayName: Build + workingDirectory: .\build -# Sign Nuget package -- task: PowerShell@2 - displayName: Authenticode Sign Packages - inputs: - filePath: build/Sign-Package.ps1 - env: - SignClientUser: $(SignClientUser) - SignClientSecret: $(SignClientSecret) - ArtifactDirectory: bin\nupkg - condition: and(succeeded(), not(eq(variables['build.reason'], 'PullRequest')), not(eq(variables['SignClientSecret'], '')), not(eq(variables['SignClientUser'], ''))) + # Sign Nuget package + - task: PowerShell@2 + displayName: Authenticode Sign Packages + inputs: + filePath: build/Sign-Package.ps1 + env: + SignClientUser: $(SignClientUser) + SignClientSecret: $(SignClientSecret) + ArtifactDirectory: bin\nupkg + condition: and(succeeded(), not(eq(variables['build.reason'], 'PullRequest')), not(eq(variables['SignClientSecret'], '')), not(eq(variables['SignClientUser'], ''))) -# Publish nuget package -- task: PublishBuildArtifacts@1 - displayName: Publish Package Artifacts - inputs: - pathToPublish: .\bin\nupkg - artifactType: container - artifactName: Packages \ No newline at end of file + # Publish nuget package + - task: PublishBuildArtifacts@1 + displayName: Publish Package Artifacts + inputs: + pathToPublish: .\bin\nupkg + artifactType: container + artifactName: Packages diff --git a/version.json b/version.json index 585f60b..6f05a7c 100644 --- a/version.json +++ b/version.json @@ -1,11 +1,11 @@ { "version": "6.1.0-build.{height}", "publicReleaseRefSpec": [ - "^refs/heads/master$", // we release out of master + "^refs/heads/main$", // we release out of main "^refs/heads/dev$", // we release out of dev "^refs/heads/rel/\\d+\\.\\d+\\.\\d+" // we also release branches starting with rel/N.N.N ], - "nugetPackageVersion":{ + "nugetPackageVersion": { "semVer": 2 }, "cloudBuild": { From 0c04921a684ae457da138f95f765d1472ed3e999 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 16 Jul 2020 12:50:48 -0700 Subject: [PATCH 50/69] [Broken] CalendarView Example Not fully tested as hit error with payload response see https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/740 --- .../Controls/GraphPresenter/GraphPresenter.cs | 76 ++++++++++++------- .../Controls/GraphPresenter/QueryOption.cs | 30 ++++++++ .../Extensions/GraphExtensions.cs | 27 ++----- SampleTest/MainPage.xaml | 37 +++++---- SampleTest/MainPage.xaml.cs | 12 +++ 5 files changed, 119 insertions(+), 63 deletions(-) create mode 100644 Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs index 762377a..2b9ca3c 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs @@ -26,9 +26,9 @@ public class GraphPresenter : ContentPresenter /// /// Gets or sets a to be used to make a request to the graph. The results will be automatically populated to the property. Use a to change the presentation of the data. /// - public object RequestBuilder + public IBaseRequestBuilder RequestBuilder { - get { return (object)GetValue(RequestBuilderProperty); } + get { return (IBaseRequestBuilder)GetValue(RequestBuilderProperty); } set { SetValue(RequestBuilderProperty, value); } } @@ -39,43 +39,65 @@ public object RequestBuilder /// The identifier for the dependency property. /// public static readonly DependencyProperty RequestBuilderProperty = - DependencyProperty.Register(nameof(RequestBuilder), typeof(object), typeof(GraphPresenter), new PropertyMetadata(null, OnDataChanged)); + DependencyProperty.Register(nameof(RequestBuilder), typeof(IBaseRequestBuilder), typeof(GraphPresenter), new PropertyMetadata(null)); + /// + /// Gets or sets the of item returned by the . + /// Set to the base item type and use the property to indicate if a collection is expected back. + /// public Type ResponseType { get; set; } + /// + /// Gets or sets a value indicating whether the returned data from the is a collection. + /// public bool IsCollection { get; set; } - private static async void OnDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + /// + /// Gets or sets list of representing values to pass into the request built by . + /// + public List QueryOptions { get; set; } = new List(); + + /// + /// Initializes a new instance of the class. + /// + public GraphPresenter() { - if (d is GraphPresenter presenter) - { - // Use BaseRequestBuilder as some interfaces from the Graph SDK don't implement IBaseRequestBuilder properly, see https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/722 - if (e.NewValue is BaseRequestBuilder builder) - { - var request = new BaseRequest(builder.RequestUrl, builder.Client, null); - request.Method = "GET"; + Loaded += GraphPresenter_Loaded; + } - var response = await request.SendAsync(null, CancellationToken.None).ConfigureAwait(false) as JObject; + private async void GraphPresenter_Loaded(object sender, RoutedEventArgs e) + { + // Note: some interfaces from the Graph SDK don't implement IBaseRequestBuilder properly, see https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/722 + if (RequestBuilder != null) + { + var request = new BaseRequest( + RequestBuilder.RequestUrl, + RequestBuilder.Client); // TODO: Do we need separate Options here? + request.Method = "GET"; + request.QueryOptions = QueryOptions?.Select(option => option.ToQueryOption())?.ToList(); - //// TODO: Deal with paging? + // TODO: Add Exception Handling + // Note: CalendarView not supported https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/740 + var response = await request.SendAsync(null, CancellationToken.None).ConfigureAwait(false) as JObject; - var values = response["value"]; - object data = null; + //// TODO: Deal with paging? - if (presenter.IsCollection) - { - data = values.ToObject(Array.CreateInstance(presenter.ResponseType, 0).GetType()); - } - else - { - data = values.ToObject(presenter.ResponseType); - } + var values = response["value"]; + object data = null; - await DispatcherHelper.ExecuteOnUIThreadAsync(() => - { - presenter.Content = data; - }); + if (IsCollection) + { + data = values.ToObject(Array.CreateInstance(ResponseType, 0).GetType()); } + else + { + data = values.ToObject(ResponseType); + } + + await DispatcherHelper.ExecuteOnUIThreadAsync(() => + { + Content = data; + }); } } } diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs new file mode 100644 index 0000000..9da4526 --- /dev/null +++ b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Windows.UI.Xaml; + +namespace Microsoft.Toolkit.Graph.Controls +{ + /// + /// XAML Proxy for . + /// + public class QueryOption + { + /// + public string Name { get; set; } + + /// + public string Value { get; set; } + + /// + /// Constructs a value representing this proxy. + /// + /// result. + public Microsoft.Graph.QueryOption ToQueryOption() + { + return new Microsoft.Graph.QueryOption(Name, Value); + } + } +} diff --git a/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs b/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs index afd9d02..c042189 100644 --- a/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs +++ b/Microsoft.Toolkit.Graph/Extensions/GraphExtensions.cs @@ -151,43 +151,28 @@ public static string ToFileSizeString(this long size) // TODO: Move this to Micr } else if ((size >> 10) < 1024) { - return (size / (float)1024).ToString("F1") + " KB"; + return (size / 1024F).ToString("F1") + " KB"; } else if ((size >> 20) < 1024) { - return ((size >> 10) / (float)1024).ToString("F1") + " MB"; + return ((size >> 10) / 1024F).ToString("F1") + " MB"; } else if ((size >> 30) < 1024) { - return ((size >> 20) / (float)1024).ToString("F1") + " GB"; + return ((size >> 20) / 1024F).ToString("F1") + " GB"; } else if ((size >> 40) < 1024) { - return ((size >> 30) / (float)1024).ToString("F1") + " TB"; + return ((size >> 30) / 1024F).ToString("F1") + " TB"; } else if ((size >> 50) < 1024) { - return ((size >> 40) / (float)1024).ToString("F1") + " PB"; + return ((size >> 40) / 1024F).ToString("F1") + " PB"; } else { - return ((size >> 50) / (float)1024).ToString("F0") + " EB"; + return ((size >> 50) / 1024F).ToString("F0") + " EB"; } } - - /// - /// Extension Helper to help convert timestamp results from the Graph to . - /// - /// Graph Timestamp - /// System Timestamp - public static DateTimeOffset ToDateTimeOffset(this DateTimeTimeZone dttz) - { - // https://docs.microsoft.com/en-us/dotnet/standard/datetime/choosing-between-datetime - var datetime = DateTime.Parse(dttz.DateTime); - var timezone = TimeZoneInfo.FindSystemTimeZoneById(dttz.TimeZone); - var dto = new DateTimeOffset(datetime, timezone.GetUtcOffset(datetime)); - - return dto; - } } } diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index 00090c8..2499c3f 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -2,11 +2,12 @@ x:Class="SampleTest.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:SampleTest" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:local="using:SampleTest" xmlns:wgt="using:Microsoft.Toolkit.Graph.Controls" xmlns:graph="using:Microsoft.Graph" + xmlns:global="using:System.Globalization" xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:providers="using:Microsoft.Toolkit.Graph.Providers" xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" @@ -47,30 +48,36 @@ Recent Files: - + + + + + - + - + - - - + + + - + + + + + + + + - - - - - diff --git a/SampleTest/MainPage.xaml.cs b/SampleTest/MainPage.xaml.cs index 2689205..60231dc 100644 --- a/SampleTest/MainPage.xaml.cs +++ b/SampleTest/MainPage.xaml.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Graph; +using Microsoft.Graph.Extensions; +using System; using Windows.UI.Xaml.Controls; namespace SampleTest @@ -11,9 +14,18 @@ namespace SampleTest /// public sealed partial class MainPage : Page { + public DateTime Today => DateTimeOffset.Now.Date.ToUniversalTime(); + + public DateTime ThreeDaysFromNow => Today.AddDays(3); + public MainPage() { this.InitializeComponent(); } + + public static string ToLocalTime(DateTimeTimeZone value) + { + return value.ToDateTimeOffset().LocalDateTime.ToString("g"); + } } } From e5b3013d7787fa78c55e106576379bc7902cce2a Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 16 Jul 2020 12:52:16 -0700 Subject: [PATCH 51/69] Add forgotten .NET Foundation Header --- .../Controls/GraphPresenter/QueryOption.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs index 9da4526..7cce86a 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs @@ -1,4 +1,8 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; using System.Collections.Generic; using System.Linq; using System.Text; From 2a9e157a619d88e054f88253b0d0a95e73170683 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 16 Jul 2020 13:05:40 -0700 Subject: [PATCH 52/69] Add OrderBy property to GraphPresenter --- .../Controls/GraphPresenter/GraphPresenter.cs | 26 ++++++++++++++----- SampleTest/MainPage.xaml | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs index 2b9ca3c..de0c006 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/GraphPresenter.cs @@ -2,17 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Graph; -using Microsoft.Toolkit.Graph.Providers; -using Microsoft.Toolkit.Uwp.Helpers; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; +using Microsoft.Graph; +using Microsoft.Toolkit.Uwp.Helpers; +using Newtonsoft.Json.Linq; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -57,6 +53,11 @@ public IBaseRequestBuilder RequestBuilder /// public List QueryOptions { get; set; } = new List(); + /// + /// Gets or sets a string to indicate a sorting order for the . This is a helper to add this specific request option to the . + /// + public string OrderBy { get; set; } + /// /// Initializes a new instance of the class. /// @@ -76,6 +77,17 @@ private async void GraphPresenter_Loaded(object sender, RoutedEventArgs e) request.Method = "GET"; request.QueryOptions = QueryOptions?.Select(option => option.ToQueryOption())?.ToList(); + if (request.QueryOptions == null) + { + request.QueryOptions = new List(); + } + + // Handle Special QueryOptions + if (!string.IsNullOrWhiteSpace(OrderBy)) + { + request.QueryOptions.Add(new Microsoft.Graph.QueryOption("$orderby", OrderBy)); + } + // TODO: Add Exception Handling // Note: CalendarView not supported https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/740 var response = await request.SendAsync(null, CancellationToken.None).ConfigureAwait(false) as JObject; diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index 2499c3f..da167aa 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -49,6 +49,7 @@ Recent Files: From 6556c2d7d337a5abe4b25864306cb87ce65d0e8e Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 23 Jul 2020 15:43:19 -0700 Subject: [PATCH 53/69] Try updating dependencies --- .../Microsoft.Toolkit.Graph.Controls.csproj | 4 ++-- Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj index 6cd7fde..5dbc42e 100644 --- a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj +++ b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj @@ -34,8 +34,8 @@ - - + + diff --git a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj index 8e49be7..5164e15 100644 --- a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj +++ b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj @@ -21,8 +21,8 @@ - - + + From ff9ee756fce2d870415cd344f914c980ab6cd476 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Sun, 26 Jul 2020 16:16:25 -0700 Subject: [PATCH 54/69] Fix Stylecop Issues --- .../Converters/FileSizeConverter.cs | 5 +++++ .../Providers/NotifyTaskCompletion.cs | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs b/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs index d02275d..0a86246 100644 --- a/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs +++ b/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs @@ -8,8 +8,12 @@ namespace Microsoft.Toolkit.Graph.Controls.Converters { + /// + /// The takes a long value in and converts it to a human readible string using the method. + /// public class FileSizeConverter : IValueConverter { + /// public object Convert(object value, Type targetType, object parameter, string language) { if (value is long size) @@ -20,6 +24,7 @@ public object Convert(object value, Type targetType, object parameter, string la return null; } + /// public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); diff --git a/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs b/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs index 554d76c..a3422fb 100644 --- a/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs +++ b/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs @@ -6,7 +6,7 @@ using System.ComponentModel; using System.Threading.Tasks; -namespace Microsoft.Toolkit.Graph.Providers // TODO: Move to base-toolkit +namespace Microsoft.Toolkit.Graph.Providers // TODO: Remove { /// /// Helper class to wrap around a Task to provide more information usable for UI databinding scenarios. As discussed in MSDN Magazine: https://msdn.microsoft.com/magazine/dn605875. @@ -106,7 +106,10 @@ public bool IsCompleted /// /// Gets a value indicating whether the task is not completed. /// - public bool IsNotCompleted { get { return !Task.IsCompleted; } } + public bool IsNotCompleted + { + get { return !Task.IsCompleted; } + } /// /// Gets a value indicating whether the task was successfully completed. @@ -138,7 +141,10 @@ public bool IsFaulted /// /// Gets the exception which occured on the task (if one occurred). /// - public AggregateException Exception { get { return Task.Exception; } } + public AggregateException Exception + { + get { return Task.Exception; } + } /// /// Gets the inner exception of the task. From dc8a6417d6f68d0b7f8a9ab5d3095077946d229b Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Sun, 26 Jul 2020 17:36:07 -0700 Subject: [PATCH 55/69] Reconfigure Proxy to work in all cases and more effectively Update Calendar Example Test --- .../Providers/MockProvider.cs | 27 ++++++++----------- SampleTest/MainPage.xaml | 4 +-- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Microsoft.Toolkit.Graph/Providers/MockProvider.cs b/Microsoft.Toolkit.Graph/Providers/MockProvider.cs index 863c3dd..d0f40d2 100644 --- a/Microsoft.Toolkit.Graph/Providers/MockProvider.cs +++ b/Microsoft.Toolkit.Graph/Providers/MockProvider.cs @@ -21,6 +21,8 @@ namespace Microsoft.Toolkit.Graph.Providers /// public class MockProvider : IProvider { + private static readonly string GRAPH_PROXY_URL = "https://proxy.apisandbox.msdn.microsoft.com/svc?url="; + private ProviderState _state = ProviderState.Loading; /// @@ -42,22 +44,15 @@ private set /// public GraphServiceClient Graph => new GraphServiceClient( - "https://proxy.apisandbox.msdn.microsoft.com/svc?url=" + HttpUtility.HtmlEncode("https://graph.microsoft.com/beta/"), - new DelegateAuthenticationProvider((requestMessage) => - { - //// Temporary Workaround for https://github.com/microsoftgraph/msgraph-sdk-dotnet-core/issues/59 - //// ------------------------ - var requestUri = requestMessage.RequestUri.ToString(); - var index = requestUri.IndexOf("&"); - if (index >= 0) - { - requestMessage.RequestUri = new Uri(requestUri.Remove(index, 1).Insert(index, "?")); - } - - //// End Workaround - - return this.AuthenticateRequestAsync(requestMessage); - })); + new DelegateAuthenticationProvider((requestMessage) => + { + var requestUri = requestMessage.RequestUri.ToString(); + + // Prepend Proxy Service URI to our request + requestMessage.RequestUri = new Uri(GRAPH_PROXY_URL + HttpUtility.UrlEncode(requestUri)); + + return this.AuthenticateRequestAsync(requestMessage); + })); /// public event EventHandler StateChanged; diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index da167aa..7876f20 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -65,14 +65,14 @@ + - - - + From b70e6b70c11aafdf209fe58406cf0686fd0c2f6b Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Sun, 26 Jul 2020 18:18:31 -0700 Subject: [PATCH 56/69] Better separate out Samples in UWP app --- SampleTest/MainPage.xaml | 112 +++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 34 deletions(-) diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index 7876f20..01f7976 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -32,10 +32,25 @@ - - - + + + + + + + + The `LoginButton` above allows your user and application to easily connect to the Microsoft Graph. They can then also easily logout from the drop-down menu. + + + + + + + The `PeoplePicker` lets a logged in user easily search for familiar people they interact with or contacts. Great for emails or messages. + Picked People: - - Recent Files: - + + + + + + + + + The `GraphPresenter` is a unique control in the library which makes it easier for a developer to make any graph call and configure a nice display template in XAML. This opens up a world of possibilities for many uses outside of any other control available within this library. You can see a few examples of what's possible below. + + + + + + + + + The following example shows the `Me.CalendarView` API. + My Upcoming Calendar Events: + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + - - + + + + + + + + + - - - - - - - - - + + + + + + + + + From f028d3fe4956c73a81ba2649b9c3478685892a05 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Sun, 26 Jul 2020 19:00:03 -0700 Subject: [PATCH 57/69] Add (Mail) Messages GraphPresenter sample --- SampleTest/MainPage.xaml | 34 ++++++++++++++++++++++++++++++++++ SampleTest/MainPage.xaml.cs | 7 +++++++ 2 files changed, 41 insertions(+) diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index 01f7976..8ee7c8e 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -127,6 +127,40 @@ + + + + The following example shows the `Me.Messages` API for getting a user's inbox mail messages. + My Messages: + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleTest/MainPage.xaml.cs b/SampleTest/MainPage.xaml.cs index 60231dc..9b524f6 100644 --- a/SampleTest/MainPage.xaml.cs +++ b/SampleTest/MainPage.xaml.cs @@ -5,6 +5,7 @@ using Microsoft.Graph; using Microsoft.Graph.Extensions; using System; +using System.Text.RegularExpressions; using Windows.UI.Xaml.Controls; namespace SampleTest @@ -27,5 +28,11 @@ public static string ToLocalTime(DateTimeTimeZone value) { return value.ToDateTimeOffset().LocalDateTime.ToString("g"); } + + public static string RemoveWhitespace(string value) + { + //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 + return Regex.Replace(value, @"\t|\r|\n", " "); + } } } From a4919fb3d2f3bbe949b87b895905b4b90db9333e Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 6 Aug 2020 11:13:51 -0700 Subject: [PATCH 58/69] Add Task sample to GraphPresenter --- SampleTest/MainPage.xaml | 62 +++++++++++++++++++++++++++++++++++++ SampleTest/MainPage.xaml.cs | 10 ++++++ 2 files changed, 72 insertions(+) diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index 8ee7c8e..c6ca60e 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -161,6 +161,68 @@ + + + + The following example shows the `Me.Planner.Tasks` API for getting a user's tasks. + My Tasks: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Due + + + + + + + + + + + + + + + + + diff --git a/SampleTest/MainPage.xaml.cs b/SampleTest/MainPage.xaml.cs index 9b524f6..38fe405 100644 --- a/SampleTest/MainPage.xaml.cs +++ b/SampleTest/MainPage.xaml.cs @@ -29,10 +29,20 @@ public static string ToLocalTime(DateTimeTimeZone value) return value.ToDateTimeOffset().LocalDateTime.ToString("g"); } + public static string ToLocalTime(DateTimeOffset? value) + { + return value?.LocalDateTime.ToString("g"); + } + public static string RemoveWhitespace(string value) { //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 return Regex.Replace(value, @"\t|\r|\n", " "); } + + public static bool IsTaskCompleted(int? percentCompleted) + { + return percentCompleted == 100; + } } } From 7cdd34f786cf3b81ec0be7d00824f4179f8231a4 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Thu, 6 Aug 2020 12:30:23 -0700 Subject: [PATCH 59/69] Add in Teams Messages example to GraphPresenter TODO: Display HTML better or strip out tags. --- SampleTest/MainPage.xaml | 37 +++++++++++++++++++++++++++++++++++++ SampleTest/MainPage.xaml.cs | 11 +++++++++++ 2 files changed, 48 insertions(+) diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index c6ca60e..8e4845c 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -223,6 +223,43 @@ + + + + The following example shows the beta `Teams/id/Channels/id/messages` API for getting a list of messages (without replies) from a Channel in Teams. + My Chat Messages: + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SampleTest/MainPage.xaml.cs b/SampleTest/MainPage.xaml.cs index 38fe405..174e225 100644 --- a/SampleTest/MainPage.xaml.cs +++ b/SampleTest/MainPage.xaml.cs @@ -4,6 +4,7 @@ using Microsoft.Graph; using Microsoft.Graph.Extensions; +using Microsoft.Toolkit.Graph.Providers; using System; using System.Text.RegularExpressions; using Windows.UI.Xaml.Controls; @@ -15,8 +16,10 @@ namespace SampleTest /// public sealed partial class MainPage : Page { + //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 public DateTime Today => DateTimeOffset.Now.Date.ToUniversalTime(); + //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 public DateTime ThreeDaysFromNow => Today.AddDays(3); public MainPage() @@ -26,11 +29,13 @@ public MainPage() public static string ToLocalTime(DateTimeTimeZone value) { + //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 return value.ToDateTimeOffset().LocalDateTime.ToString("g"); } public static string ToLocalTime(DateTimeOffset? value) { + //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 return value?.LocalDateTime.ToString("g"); } @@ -44,5 +49,11 @@ public static bool IsTaskCompleted(int? percentCompleted) { return percentCompleted == 100; } + + public static IBaseRequestBuilder GetTeamsChannelMessagesBuilder(string team, string channel) + { + //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/3064 + return ProviderManager.Instance.GlobalProvider.Graph.Teams[team].Channels[channel].Messages; + } } } From b93e18c5119e5ca5b45ef5d950a5ba07ea8c997a Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Fri, 7 Aug 2020 17:32:45 -0700 Subject: [PATCH 60/69] Remove unused OneDrive sample Converters (they need re-work see #55) Also updated Teams sample messages to remove HTML tags for now. --- .../Converters/FileSizeConverter.cs | 33 ---- .../Converters/OneDriveThumbnailConverter.cs | 39 ---- .../Providers/NotifyTaskCompletion.cs | 180 ------------------ SampleTest/MainPage.xaml | 8 +- 4 files changed, 2 insertions(+), 258 deletions(-) delete mode 100644 Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs delete mode 100644 Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs delete mode 100644 Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs diff --git a/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs b/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs deleted file mode 100644 index 0a86246..0000000 --- a/Microsoft.Toolkit.Graph.Controls/Converters/FileSizeConverter.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Toolkit.Graph.Extensions; -using Windows.UI.Xaml.Data; - -namespace Microsoft.Toolkit.Graph.Controls.Converters -{ - /// - /// The takes a long value in and converts it to a human readible string using the method. - /// - public class FileSizeConverter : IValueConverter - { - /// - public object Convert(object value, Type targetType, object parameter, string language) - { - if (value is long size) - { - return size.ToFileSizeString(); - } - - return null; - } - - /// - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs b/Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs deleted file mode 100644 index 8c2d929..0000000 --- a/Microsoft.Toolkit.Graph.Controls/Converters/OneDriveThumbnailConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Microsoft.Graph; -using Microsoft.Toolkit.Graph.Providers; -using Windows.UI.Xaml.Data; - -namespace Microsoft.Toolkit.Graph.Controls.Converters -{ - /// - /// Helper to return a . - /// - public class OneDriveThumbnailConverter : IValueConverter - { - /// - public object Convert(object value, Type targetType, object parameter, string language) - { - if (value is RemoteItem ri) - { - // drives/${file.remoteItem.parentReference.driveId}/items/${file.remoteItem.id}/thumbnails/0/medium - var provider = ProviderManager.Instance.GlobalProvider; - if (provider != null && provider.Graph != null) - { - return new NotifyTaskCompletion(provider.Graph.Drives[ri.ParentReference.DriveId].Items[ri.Id].Thumbnails["0"].Request().GetAsync()); - } - } - - return null; - } - - /// - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs b/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs deleted file mode 100644 index a3422fb..0000000 --- a/Microsoft.Toolkit.Graph.Controls/Providers/NotifyTaskCompletion.cs +++ /dev/null @@ -1,180 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.ComponentModel; -using System.Threading.Tasks; - -namespace Microsoft.Toolkit.Graph.Providers // TODO: Remove -{ - /// - /// Helper class to wrap around a Task to provide more information usable for UI databinding scenarios. As discussed in MSDN Magazine: https://msdn.microsoft.com/magazine/dn605875. - /// - /// Type of result returned by task. - public sealed class NotifyTaskCompletion : INotifyPropertyChanged - { - /// - /// Initializes a new instance of the class. - /// - /// Task to wait on. - public NotifyTaskCompletion(Task task) - { - Task = task; - if (!task.IsCompleted) - { - TaskCompletion = WatchTaskAsync(task); - } - } - - private async Task WatchTaskAsync(Task task) - { - try - { - await task; - } - catch - { - } - - if (PropertyChanged == null) - { - return; - } - - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Status))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCompleted))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsNotCompleted))); - - if (task.IsCanceled) - { - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCanceled))); - } - else if (task.IsFaulted) - { - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsFaulted))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Exception))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(InnerException))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(ErrorMessage))); - } - else - { - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsSuccessfullyCompleted))); - PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Result))); - } - } - - /// - /// Gets the task that is being waited on. - /// - public Task Task { get; private set; } - - /// - /// Gets the task wrapper task. - /// - public Task TaskCompletion { get; private set; } - - /// - /// Gets the result of the given task. - /// - public TResult Result - { - get - { - return (Task.Status == TaskStatus.RanToCompletion) ? - Task.Result : - default(TResult); - } - } - - /// - /// Gets the status of the task. - /// - public TaskStatus Status - { - get { return Task.Status; } - } - - /// - /// Gets a value indicating whether the task is completed. - /// - public bool IsCompleted - { - get { return Task.IsCompleted; } - } - - /// - /// Gets a value indicating whether the task is not completed. - /// - public bool IsNotCompleted - { - get { return !Task.IsCompleted; } - } - - /// - /// Gets a value indicating whether the task was successfully completed. - /// - public bool IsSuccessfullyCompleted - { - get - { - return Task.Status == TaskStatus.RanToCompletion; - } - } - - /// - /// Gets a value indicating whether the task was cancelled. - /// - public bool IsCanceled - { - get { return Task.IsCanceled; } - } - - /// - /// Gets a value indicating whether there was an error with the task. - /// - public bool IsFaulted - { - get { return Task.IsFaulted; } - } - - /// - /// Gets the exception which occured on the task (if one occurred). - /// - public AggregateException Exception - { - get { return Task.Exception; } - } - - /// - /// Gets the inner exception of the task. - /// - public Exception InnerException - { - get - { - return (Exception == null) ? - null : - Exception.InnerException; - } - } - - /// - /// Gets the error message of the task. - /// - public string ErrorMessage - { - get - { - return (InnerException == null) ? - null : - InnerException.Message; - } - } - - /// - /// PropertyChanged event. - /// - public event PropertyChangedEventHandler PropertyChanged; - } -} \ No newline at end of file diff --git a/SampleTest/MainPage.xaml b/SampleTest/MainPage.xaml index 8e4845c..ad16332 100644 --- a/SampleTest/MainPage.xaml +++ b/SampleTest/MainPage.xaml @@ -11,14 +11,10 @@ xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:providers="using:Microsoft.Toolkit.Graph.Providers" xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" - xmlns:converters="using:Microsoft.Toolkit.Graph.Controls.Converters" + xmlns:ex="using:Microsoft.Toolkit.Extensions" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" xmlns:controlsKeepThis="using:Microsoft.Toolkit.Uwp.UI.Controls"> - - - - - + From 8e58409ccd62d0d9414f0de210eadb9215edda32 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Mon, 10 Aug 2020 13:39:38 -0700 Subject: [PATCH 65/69] Update Project to Build with latest Uno package --- Directory.Build.props | 6 +++--- .../Microsoft.Toolkit.Graph.Controls.csproj | 17 ++++++++++------- .../Providers/QuickCreate.cs | 5 ++--- .../Microsoft.Toolkit.Graph.csproj | 12 +++++++----- SampleGraphApp/SampleGraphApp.Droid/Main.cs | 2 +- .../Properties/AndroidManifest.xml | 6 +++--- .../SampleGraphApp.Droid.csproj | 4 +++- .../SampleGraphApp.UWP.csproj | 4 ++-- .../SampleGraphApp.Wasm.csproj | 6 +++--- .../SampleGraphApp.iOS.csproj | 2 +- build/build.cake | 4 ++-- global.json | 6 +++++- 12 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 227593e..c9c8221 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,14 +13,14 @@ en-US - uap10.0.16299;MonoAndroid80;xamarinios10;netstandard2.0 + uap10.0.17763;MonoAndroid90;xamarinios10;netstandard2.0 $(MSBuildProjectName.Contains('.Design')) $(MSBuildProjectName.Contains('Test')) $(MSBuildProjectName.Contains('Uwp')) $(MSBuildProjectName.Contains('Sample')) 17763 - 16299 + 17763 $(MSBuildThisFileDirectory)bin\nupkg @@ -82,7 +82,7 @@ $(DefineConstants);__WASM__ - + $(NoWarn);CS0649;CS0067;CS1998 diff --git a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj index d1bad7c..c3155a1 100644 --- a/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj +++ b/Microsoft.Toolkit.Graph.Controls/Microsoft.Toolkit.Graph.Controls.csproj @@ -15,6 +15,8 @@ UWP Toolkit Windows Controls MSAL Microsoft Graph AadLogin ProfileCard Person PeoplePicker Login false true + Debug;Release;CI + AnyCPU;ARM;ARM64;x64;x86 CS1701;1702;Uno0001;NU1701 @@ -31,12 +33,12 @@ - - + + - - + + @@ -44,8 +46,9 @@ - - + + + @@ -56,7 +59,7 @@ - + diff --git a/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs b/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs index 3c8337b..5c4afec 100644 --- a/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs +++ b/Microsoft.Toolkit.Graph.Controls/Providers/QuickCreate.cs @@ -7,6 +7,7 @@ using Microsoft.Toolkit.Graph.Providers; using System.Reflection; using System.Threading.Tasks; +using Uno.UI.MSAL; namespace Microsoft.Toolkit.Graph.Providers { @@ -19,9 +20,7 @@ public static async Task CreateMsalProviderAsync(string clientid, .WithRedirectUri(redirectUri) .WithClientName(ProviderManager.ClientName) .WithClientVersion(Assembly.GetExecutingAssembly().GetName().Version.ToString()) -#if __ANDROID__ - .WithParentActivityOrWindow(() => Uno.UI.ContextHelper.Current as Android.App.Activity) -#endif + .WithUnoHelpers() .Build(); if (scopes == null) diff --git a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj index 7267057..de6bc8e 100644 --- a/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj +++ b/Microsoft.Toolkit.Graph/Microsoft.Toolkit.Graph.csproj @@ -12,20 +12,22 @@ Full - CS1701;1702;CS8002;Uno0001;NU1701 + Debug;Release;CI + AnyCPU;ARM;ARM64;x64;x86 + CS1701;1702;CS8002;Uno0001;NU1701;CS0618 $(DefineConstants);WINRT - + $(DefineConstants);WINRT - - - + + + diff --git a/SampleGraphApp/SampleGraphApp.Droid/Main.cs b/SampleGraphApp/SampleGraphApp.Droid/Main.cs index 8f6b5a4..b066943 100644 --- a/SampleGraphApp/SampleGraphApp.Droid/Main.cs +++ b/SampleGraphApp/SampleGraphApp.Droid/Main.cs @@ -27,7 +27,7 @@ namespace SampleGraphApp.Droid public class Application : Windows.UI.Xaml.NativeApplication { public Application(IntPtr javaReference, JniHandleOwnership transfer) - : base(new App(), javaReference, transfer) + : base(() => new App(), javaReference, transfer) { ConfigureUniversalImageLoader(); } diff --git a/SampleGraphApp/SampleGraphApp.Droid/Properties/AndroidManifest.xml b/SampleGraphApp/SampleGraphApp.Droid/Properties/AndroidManifest.xml index 730b910..bcae63f 100644 --- a/SampleGraphApp/SampleGraphApp.Droid/Properties/AndroidManifest.xml +++ b/SampleGraphApp/SampleGraphApp.Droid/Properties/AndroidManifest.xml @@ -1,6 +1,6 @@  - - + + @@ -12,4 +12,4 @@ - + \ No newline at end of file diff --git a/SampleGraphApp/SampleGraphApp.Droid/SampleGraphApp.Droid.csproj b/SampleGraphApp/SampleGraphApp.Droid/SampleGraphApp.Droid.csproj index 7e0b2ab..9ecf8ba 100644 --- a/SampleGraphApp/SampleGraphApp.Droid/SampleGraphApp.Droid.csproj +++ b/SampleGraphApp/SampleGraphApp.Droid/SampleGraphApp.Droid.csproj @@ -71,10 +71,12 @@ - + + + diff --git a/SampleGraphApp/SampleGraphApp.UWP/SampleGraphApp.UWP.csproj b/SampleGraphApp/SampleGraphApp.UWP/SampleGraphApp.UWP.csproj index 262fdf5..ae17778 100644 --- a/SampleGraphApp/SampleGraphApp.UWP/SampleGraphApp.UWP.csproj +++ b/SampleGraphApp/SampleGraphApp.UWP/SampleGraphApp.UWP.csproj @@ -12,7 +12,7 @@ en-US UAP 10.0.18362.0 - 10.0.16299.0 + 10.0.17763.0 14 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -96,7 +96,7 @@ - + - - - + + + \ No newline at end of file diff --git a/SampleGraphApp/SampleGraphApp.iOS/SampleGraphApp.iOS.csproj b/SampleGraphApp/SampleGraphApp.iOS/SampleGraphApp.iOS.csproj index 893a995..4782d42 100644 --- a/SampleGraphApp/SampleGraphApp.iOS/SampleGraphApp.iOS.csproj +++ b/SampleGraphApp/SampleGraphApp.iOS/SampleGraphApp.iOS.csproj @@ -127,7 +127,7 @@ - + diff --git a/build/build.cake b/build/build.cake index 0c4e6a6..bd4fd78 100644 --- a/build/build.cake +++ b/build/build.cake @@ -17,8 +17,8 @@ var target = Argument("target", "Default"); // VERSIONS ////////////////////////////////////////////////////////////////////// -var gitVersioningVersion = "2.1.65"; -var inheritDocVersion = "1.1.1.1"; +var gitVersioningVersion = "3.1.91"; +var inheritDocVersion = "2.5.2"; ////////////////////////////////////////////////////////////////////// // VARIABLES diff --git a/global.json b/global.json index e6e7cdb..e8ff583 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,9 @@ { "msbuild-sdks": { - "MSBuild.Sdk.Extras": "2.0.43" + "MSBuild.Sdk.Extras": "2.0.54" + }, + "sdk": { + "version": "3.1.200", + "rollForward": "latestPatch" } } \ No newline at end of file From 13b062be075724c1533456e6cfc3f568eec268a9 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Mon, 10 Aug 2020 21:37:49 -0700 Subject: [PATCH 66/69] Apply Work-Arounds for x:Bind in Uno TODO: Investigate PeoplePicker and GraphPresenter display (only Teams displaying) --- .../Controls/GraphPresenter/QueryOption.cs | 2 +- .../SampleGraphApp.Shared/MainPage.xaml | 12 +++---- .../SampleGraphApp.Shared/MainPage.xaml.cs | 31 +++++++++++++++---- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs index ff05eb3..9f17a46 100644 --- a/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs +++ b/Microsoft.Toolkit.Graph.Controls/Controls/GraphPresenter/QueryOption.cs @@ -14,7 +14,7 @@ namespace Microsoft.Toolkit.Graph.Controls /// /// XAML Proxy for . /// - public sealed class QueryOption + public partial class QueryOption : DependencyObject { /// public string Name { get; set; } diff --git a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml index cd25a26..89afde8 100644 --- a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml +++ b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wgt="using:Microsoft.Toolkit.Graph.Controls" xmlns:graph="using:Microsoft.Graph" - xmlns:global="using:System.Globalization" + xmlns:glob="using:System.Globalization" xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:providers="using:Microsoft.Toolkit.Graph.Providers" xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" @@ -79,14 +79,14 @@ The following example shows the `Me.CalendarView` API. My Upcoming Calendar Events: - - - + + @@ -128,7 +128,7 @@ The following example shows the `Me.Messages` API for getting a user's inbox mail messages. My Messages: - @@ -162,7 +162,7 @@ The following example shows the `Me.Planner.Tasks` API for getting a user's tasks. My Tasks: - diff --git a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs index b320d75..6165aa9 100644 --- a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs +++ b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs @@ -7,6 +7,7 @@ using Microsoft.Toolkit.Graph.Providers; using System; using System.Text.RegularExpressions; +using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; namespace SampleGraphApp @@ -16,32 +17,50 @@ namespace SampleGraphApp /// public sealed partial class MainPage : Page { - //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 + // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 public DateTime Today => DateTimeOffset.Now.Date.ToUniversalTime(); - //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 + // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 public DateTime ThreeDaysFromNow => Today.AddDays(3); + // Workaround for https://github.com/unoplatform/uno/issues/3261 + public GraphServiceClient Graph + { + get { return (GraphServiceClient)GetValue(GraphProperty); } + set { SetValue(GraphProperty, value); } + } + + // Using a DependencyProperty as the backing store for Graph. This enables animation, styling, binding, etc... + public static readonly DependencyProperty GraphProperty = + DependencyProperty.Register(nameof(Graph), typeof(GraphServiceClient), typeof(MainPage), new PropertyMetadata(null)); + public MainPage() { this.InitializeComponent(); + + ProviderManager.Instance.ProviderUpdated += MainPage_ProviderUpdated; + } + + private void MainPage_ProviderUpdated(object sender, ProviderUpdatedEventArgs e) + { + Graph = ProviderManager.Instance.GlobalProvider.Graph; } public static string ToLocalTime(DateTimeTimeZone value) { - //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 + // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 return value.ToDateTimeOffset().LocalDateTime.ToString("g"); } public static string ToLocalTime(DateTimeOffset? value) { - //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 + // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 return value?.LocalDateTime.ToString("g"); } public static string RemoveWhitespace(string value) { - //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 + // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 return Regex.Replace(value, @"\t|\r|\n", " "); } @@ -52,7 +71,7 @@ public static bool IsTaskCompleted(int? percentCompleted) public static IBaseRequestBuilder GetTeamsChannelMessagesBuilder(string team, string channel) { - //// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/3064 + // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/3064 return ProviderManager.Instance.GlobalProvider.Graph.Teams[team].Channels[channel].Messages; } } From 1864faf3ba62d835dd8ddb1ed7c8b659aa15087d Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Mon, 10 Aug 2020 22:12:27 -0700 Subject: [PATCH 67/69] Fix Provider Timing TODO: QueryOption Value timing is not set, so CalendarView isn't working --- SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs index 6165aa9..50f0cbe 100644 --- a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs +++ b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml.cs @@ -38,7 +38,9 @@ public MainPage() { this.InitializeComponent(); - ProviderManager.Instance.ProviderUpdated += MainPage_ProviderUpdated; + ProviderManager.Instance.ProviderUpdated += MainPage_ProviderUpdated; + + MainPage_ProviderUpdated(null, null); } private void MainPage_ProviderUpdated(object sender, ProviderUpdatedEventArgs e) From 3e3816d2056375a83250e2a852051a3d10bc74cc Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Tue, 11 Aug 2020 20:34:00 -0700 Subject: [PATCH 68/69] Remove Nested ScrollViewers in Sample App # Conflicts: # SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml --- .../SampleGraphApp.Shared/MainPage.xaml | 310 ++++++++++-------- 1 file changed, 165 insertions(+), 145 deletions(-) diff --git a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml index 89afde8..7b87c9f 100644 --- a/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml +++ b/SampleGraphApp/SampleGraphApp.Shared/MainPage.xaml @@ -75,186 +75,206 @@ - + + + + + The following example shows the `Me.CalendarView` API. My Upcoming Calendar Events: - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - + + + + + The following example shows the `Me.Messages` API for getting a user's inbox mail messages. My Messages: - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + + + + + The following example shows the `Me.Planner.Tasks` API for getting a user's tasks. My Tasks: - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Due - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + + + + The following example shows the beta `Teams/id/Channels/id/messages` API for getting a list of messages (without replies) from a Channel in Teams. My Chat Messages: - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + From 53689078e465f1c65ef1052867bee287a99a1b54 Mon Sep 17 00:00:00 2001 From: michael-hawker <24302614+michael-hawker@users.noreply.github.com> Date: Tue, 11 Aug 2020 20:39:11 -0700 Subject: [PATCH 69/69] Remove duplicate line in pipeline yml file --- azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 366c209..7f34579 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,4 +10,3 @@ pr: jobs: - template: azure-windows-pipeline.yml -- template: azure-windows-pipeline.yml