|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | 4 |
|
5 | | -using CommunityToolkit.Authentication; |
6 | | -using CommunityToolkit.Graph.Extensions; |
7 | | -using Microsoft.Graph; |
8 | | -using Microsoft.Graph.Extensions; |
9 | | -using System; |
10 | | -using System.Text.RegularExpressions; |
11 | 5 | using Windows.UI.Xaml.Controls; |
12 | 6 |
|
13 | 7 | namespace SampleTest |
14 | 8 | { |
15 | | - /// <summary> |
16 | | - /// An empty page that can be used on its own or navigated to within a Frame. |
17 | | - /// </summary> |
18 | 9 | public sealed partial class MainPage : Page |
19 | 10 | { |
20 | | - // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 |
21 | | - public DateTime Today => DateTimeOffset.Now.Date.ToUniversalTime(); |
22 | | - |
23 | | - // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 |
24 | | - public DateTime ThreeDaysFromNow => Today.AddDays(3); |
25 | | - |
26 | | - public IBaseRequestBuilder CalendarViewBuilder; |
27 | | - public IBaseRequestBuilder MessagesBuilder; |
28 | | - public IBaseRequestBuilder PlannerTasksBuilder; |
29 | | - public IBaseRequestBuilder TeamsChannelMessagesBuilder; |
30 | | - |
31 | 11 | public MainPage() |
32 | 12 | { |
33 | | - this.InitializeComponent(); |
34 | | - |
35 | | - ProviderManager.Instance.ProviderUpdated += this.OnProviderUpdated; |
36 | | - ProviderManager.Instance.ProviderStateChanged += this.OnProviderStateChanged; |
37 | | - } |
38 | | - |
39 | | - private void OnProviderStateChanged(object sender, ProviderStateChangedEventArgs e) |
40 | | - { |
41 | | - if (e.NewState == ProviderState.SignedIn) |
42 | | - { |
43 | | - var graphClient = ProviderManager.Instance.GlobalProvider.GetClient(); |
44 | | - |
45 | | - CalendarViewBuilder = graphClient.Me.CalendarView; |
46 | | - MessagesBuilder = graphClient.Me.Messages; |
47 | | - PlannerTasksBuilder = graphClient.Me.Planner.Tasks; |
48 | | - TeamsChannelMessagesBuilder = graphClient.Teams["02bd9fd6-8f93-4758-87c3-1fb73740a315"].Channels["19:[email protected]"].Messages; |
49 | | - } |
50 | | - else |
51 | | - { |
52 | | - ClearRequestBuilders(); |
53 | | - } |
54 | | - } |
55 | | - |
56 | | - private void OnProviderUpdated(object sender, IProvider provider) |
57 | | - { |
58 | | - if (provider == null) |
59 | | - { |
60 | | - ClearRequestBuilders(); |
61 | | - } |
62 | | - } |
63 | | - |
64 | | - private void ClearRequestBuilders() |
65 | | - { |
66 | | - CalendarViewBuilder = null; |
67 | | - MessagesBuilder = null; |
68 | | - PlannerTasksBuilder = null; |
69 | | - TeamsChannelMessagesBuilder = null; |
70 | | - } |
71 | | - |
72 | | - public static string ToLocalTime(DateTimeTimeZone value) |
73 | | - { |
74 | | - // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2407 |
75 | | - return value.ToDateTimeOffset().LocalDateTime.ToString("g"); |
76 | | - } |
77 | | - |
78 | | - public static string ToLocalTime(DateTimeOffset? value) |
79 | | - { |
80 | | - // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 |
81 | | - return value?.LocalDateTime.ToString("g"); |
82 | | - } |
83 | | - |
84 | | - public static string RemoveWhitespace(string value) |
85 | | - { |
86 | | - // Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/2654 |
87 | | - return Regex.Replace(value, @"\t|\r|\n", " "); |
88 | | - } |
89 | | - |
90 | | - public static bool IsTaskCompleted(int? percentCompleted) |
91 | | - { |
92 | | - return percentCompleted == 100; |
| 13 | + InitializeComponent(); |
93 | 14 | } |
94 | 15 | } |
95 | 16 | } |
0 commit comments