Skip to content

Commit 1f01026

Browse files
committed
Moved samples into separate files
1 parent ece3af0 commit 1f01026

12 files changed

+474
-364
lines changed

SampleTest/App.xaml.cs

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using CommunityToolkit.Authentication;
65
using System;
6+
using CommunityToolkit.Authentication;
77
using Windows.ApplicationModel;
88
using Windows.ApplicationModel.Activation;
99
using Windows.UI.Xaml;
@@ -12,15 +12,8 @@
1212

1313
namespace SampleTest
1414
{
15-
/// <summary>
16-
/// Provides application-specific behavior to supplement the default Application class.
17-
/// </summary>
1815
sealed partial class App : Application
1916
{
20-
/// <summary>
21-
/// Initializes the singleton application object. This is the first line of authored code
22-
/// executed, and as such is the logical equivalent of main() or WinMain().
23-
/// </summary>
2417
public App()
2518
{
2619
this.InitializeComponent();

SampleTest/MainPage.xaml

+2-273
Large diffs are not rendered by default.

SampleTest/MainPage.xaml.cs

+1-80
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,15 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

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;
115
using Windows.UI.Xaml.Controls;
126

137
namespace SampleTest
148
{
15-
/// <summary>
16-
/// An empty page that can be used on its own or navigated to within a Frame.
17-
/// </summary>
189
public sealed partial class MainPage : Page
1910
{
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-
3111
public MainPage()
3212
{
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();
9314
}
9415
}
9516
}

SampleTest/SampleTest.csproj

+23-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,16 @@
123123
<DependentUpon>MainPage.xaml</DependentUpon>
124124
</Compile>
125125
<Compile Include="Properties\AssemblyInfo.cs" />
126-
<Compile Include="Samples\PersonView\PersonViewSample.xaml.cs">
126+
<Compile Include="Samples\GraphPresenterSample.xaml.cs">
127+
<DependentUpon>GraphPresenterSample.xaml</DependentUpon>
128+
</Compile>
129+
<Compile Include="Samples\OneDriveStorageSample.xaml.cs">
130+
<DependentUpon>OneDriveStorageSample.xaml</DependentUpon>
131+
</Compile>
132+
<Compile Include="Samples\PeoplePickerSample.xaml.cs">
133+
<DependentUpon>PeoplePickerSample.xaml</DependentUpon>
134+
</Compile>
135+
<Compile Include="Samples\PersonViewSample.xaml.cs">
127136
<DependentUpon>PersonViewSample.xaml</DependentUpon>
128137
</Compile>
129138
</ItemGroup>
@@ -153,7 +162,19 @@
153162
<Generator>MSBuild:Compile</Generator>
154163
<SubType>Designer</SubType>
155164
</Page>
156-
<Page Include="Samples\PersonView\PersonViewSample.xaml">
165+
<Page Include="Samples\GraphPresenterSample.xaml">
166+
<SubType>Designer</SubType>
167+
<Generator>MSBuild:Compile</Generator>
168+
</Page>
169+
<Page Include="Samples\OneDriveStorageSample.xaml">
170+
<SubType>Designer</SubType>
171+
<Generator>MSBuild:Compile</Generator>
172+
</Page>
173+
<Page Include="Samples\PeoplePickerSample.xaml">
174+
<SubType>Designer</SubType>
175+
<Generator>MSBuild:Compile</Generator>
176+
</Page>
177+
<Page Include="Samples\PersonViewSample.xaml">
157178
<SubType>Designer</SubType>
158179
<Generator>MSBuild:Compile</Generator>
159180
</Page>

0 commit comments

Comments
 (0)