Skip to content

Commit 8661fae

Browse files
authored
Merge pull request #3056 from windows-toolkit/mhawker/sample-6.0
Sample App Update 6.0
2 parents 26d32b3 + dab96bd commit 8661fae

File tree

63 files changed

+426
-2047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+426
-2047
lines changed

Microsoft.Toolkit.Services/Microsoft.Toolkit.Services.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<!-- This is a temporary workaround for https://github.com/dotnet/sdk/issues/955 -->
1515
<DebugType>Full</DebugType>
16-
<NoWarn>CS8002</NoWarn>
16+
<NoWarn>CS8002;CS0618</NoWarn>
1717
</PropertyGroup>
1818

1919
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.16299'">

Microsoft.Toolkit.Services/Services/MicrosoftGraph/MicrosoftGraphService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace Microsoft.Toolkit.Services.MicrosoftGraph
1515
/// <summary>
1616
/// Class for connecting to Office 365 Microsoft Graph
1717
/// </summary>
18+
[Obsolete("Please use the Microsoft Graph SDK or our new providers at https://aka.ms/wgt")]
1819
public class MicrosoftGraphService
1920
{
2021
private readonly SemaphoreSlim _readLock = new SemaphoreSlim(1, 1);

Microsoft.Toolkit.Services/Services/MicrosoftGraph/WinForms/GraphLoginComponent.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Microsoft.Toolkit.Services.WinForms
1616
/// It is implemented as a Windows Forms Component for a drag and drop experience from the toolbox.
1717
/// </summary>
1818
/// <seealso cref="IComponent" />
19+
[Obsolete("Please use the new LoginButton control through XAML Islands from https://aka.ms/wgt")]
1920
public partial class GraphLoginComponent : Component
2021
{
2122
/// <summary>
@@ -93,6 +94,7 @@ public async Task<bool> LoginAsync()
9394
}
9495

9596
// Initialize the MicrosoftGraphService
97+
#pragma warning disable CS0618 // Type or member is obsolete
9698
if (!MicrosoftGraphService.Instance.Initialize(ClientId, delegatedPermissionScopes: Scopes))
9799
{
98100
// error
@@ -128,6 +130,7 @@ public async Task<bool> LoginAsync()
128130

129131
// return Microsoft.Graph.GraphServiceClient from the MicrosoftGraphService.Instance.GraphProvider
130132
GraphServiceClient = MicrosoftGraphService.Instance.GraphProvider;
133+
#pragma warning restore CS0618 // Type or member is obsolete
131134
return true;
132135
}
133136
}

Microsoft.Toolkit.Services/Services/OneDrive/OneDriveService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Microsoft.Toolkit.Services.OneDrive
1212
/// <summary>
1313
/// Class using OneDrive API
1414
/// </summary>
15+
[Obsolete("Please use the Microsoft Graph SDK or our new providers at https://aka.ms/wgt")]
1516
public class OneDriveService
1617
{
1718
/// <summary>
@@ -57,6 +58,7 @@ public class OneDriveService
5758
/// <summary>
5859
/// Gets a reference to an instance of the underlying data provider.
5960
/// </summary>
61+
#pragma warning disable CS0618 // Type or member is obsolete
6062
public MicrosoftGraphService Provider
6163
{
6264
get
@@ -69,6 +71,7 @@ public MicrosoftGraphService Provider
6971
return MicrosoftGraphService.Instance;
7072
}
7173
}
74+
#pragma warning restore CS0618 // Type or member is obsolete
7275

7376
/// <summary>
7477
/// Intializes OneDrive service.
Loading
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Text.RegularExpressions;
7+
using Microsoft.Toolkit.Uwp.UI.Behaviors;
8+
using Windows.UI.Xaml;
9+
using Windows.UI.Xaml.Controls;
10+
using Windows.UI.Xaml.Documents;
11+
using Windows.UI.Xaml.Media;
12+
13+
namespace Microsoft.Toolkit.Uwp.SampleApp.Common
14+
{
15+
public class TextBlockHyperlinkBehavior : BehaviorBase<TextBlock>
16+
{
17+
//// From: http://urlregex.com/
18+
private static readonly Regex UrlRegex = new Regex(@"(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?", RegexOptions.Compiled);
19+
20+
private long? _textChangedRegistration;
21+
22+
public Brush Foreground { get; set; }
23+
24+
protected override bool Initialize()
25+
{
26+
if (_textChangedRegistration == null)
27+
{
28+
_textChangedRegistration = AssociatedObject.RegisterPropertyChangedCallback(TextBlock.TextProperty, Text_PropertyChanged);
29+
}
30+
31+
return base.Initialize();
32+
}
33+
34+
protected override void OnDetaching()
35+
{
36+
if (AssociatedObject != null && _textChangedRegistration != null && _textChangedRegistration.HasValue)
37+
{
38+
AssociatedObject.UnregisterPropertyChangedCallback(TextBlock.TextProperty, _textChangedRegistration.Value);
39+
}
40+
41+
base.OnDetaching();
42+
}
43+
44+
private void Text_PropertyChanged(DependencyObject sender, DependencyProperty dp)
45+
{
46+
if (AssociatedObject != null && !string.IsNullOrWhiteSpace(AssociatedObject.Text))
47+
{
48+
var first = true;
49+
var text = AssociatedObject.Text;
50+
var last_index = 0;
51+
52+
foreach (Match match in UrlRegex.Matches(text))
53+
{
54+
if (first)
55+
{
56+
AssociatedObject.Inlines.Clear();
57+
58+
first = false;
59+
}
60+
61+
var left_text = text.Substring(last_index, match.Index - last_index);
62+
last_index = match.Index + match.Length;
63+
64+
AssociatedObject.Inlines.Add(new Run() { Text = left_text });
65+
AssociatedObject.Inlines.Add(new Hyperlink()
66+
{
67+
Foreground = this.Foreground,
68+
NavigateUri = new Uri(match.Value),
69+
Inlines =
70+
{
71+
new Run() { Text = match.Value }
72+
}
73+
});
74+
}
75+
76+
if (!first && last_index < text.Length)
77+
{
78+
var right_text = text.Substring(last_index);
79+
80+
AssociatedObject.Inlines.Add(new Run() { Text = right_text });
81+
}
82+
}
83+
}
84+
}
85+
}

Microsoft.Toolkit.Uwp.SampleApp/Controls/AadAuthControl.xaml

Lines changed: 0 additions & 66 deletions
This file was deleted.

Microsoft.Toolkit.Uwp.SampleApp/Controls/AadAuthControl.xaml.cs

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)