|
| 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 Microsoft.Toolkit.Services.MicrosoftGraph; |
| 7 | +using Windows.UI.Xaml; |
| 8 | +using Windows.UI.Xaml.Controls; |
| 9 | +using Windows.UI.Xaml.Media.Imaging; |
| 10 | + |
| 11 | +namespace Microsoft.Toolkit.Uwp.UI.Controls.Graph |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Defines the properties for the <see cref="AadLogin"/> control. |
| 15 | + /// </summary> |
| 16 | + public partial class AadLogin : Button |
| 17 | + { |
| 18 | + /// <summary> |
| 19 | + /// Gets the <see cref="MicrosoftGraphService"/> instance |
| 20 | + /// </summary> |
| 21 | + public static MicrosoftGraphService GraphService => MicrosoftGraphService.Instance; |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// Gets required delegated permissions for the <see cref="AadLogin"/> control |
| 25 | + /// </summary> |
| 26 | + public static string[] RequiredDelegatedPermissions |
| 27 | + { |
| 28 | + get |
| 29 | + { |
| 30 | + return new string[] { "User.Read" }; |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Identifies the <see cref="DefaultImage"/> dependency property. |
| 36 | + /// </summary> |
| 37 | + public static readonly DependencyProperty DefaultImageProperty = DependencyProperty.Register( |
| 38 | + nameof(DefaultImage), |
| 39 | + typeof(BitmapImage), |
| 40 | + typeof(AadLogin), |
| 41 | + new PropertyMetadata(null)); |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Identifies the <see cref="View"/> dependency property. |
| 45 | + /// </summary> |
| 46 | + public static readonly DependencyProperty ViewProperty = DependencyProperty.Register( |
| 47 | + nameof(View), |
| 48 | + typeof(ViewType), |
| 49 | + typeof(AadLogin), |
| 50 | + new PropertyMetadata(ViewType.PictureOnly)); |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Identifies the <see cref="AllowSignInAsDifferentUser"/> dependency property. |
| 54 | + /// </summary> |
| 55 | + public static readonly DependencyProperty AllowSignInAsDifferentUserProperty = DependencyProperty.Register( |
| 56 | + nameof(AllowSignInAsDifferentUser), |
| 57 | + typeof(bool), |
| 58 | + typeof(AadLogin), |
| 59 | + new PropertyMetadata(true)); |
| 60 | + |
| 61 | + /// <summary> |
| 62 | + /// Identifies the <see cref="SignInDefaultText"/> dependency property. |
| 63 | + /// </summary> |
| 64 | + public static readonly DependencyProperty SignInDefaultTextProperty = DependencyProperty.Register( |
| 65 | + nameof(SignInDefaultText), |
| 66 | + typeof(string), |
| 67 | + typeof(AadLogin), |
| 68 | + new PropertyMetadata("Sign In")); |
| 69 | + |
| 70 | + /// <summary> |
| 71 | + /// Identifies the <see cref="SignOutDefaultText"/> dependency property. |
| 72 | + /// </summary> |
| 73 | + public static readonly DependencyProperty SignOutDefaultTextProperty = DependencyProperty.Register( |
| 74 | + nameof(SignOutDefaultText), |
| 75 | + typeof(string), |
| 76 | + typeof(AadLogin), |
| 77 | + new PropertyMetadata("Sign Out")); |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// Identifies the <see cref="SignInAnotherUserDefaultText"/> dependency property. |
| 81 | + /// </summary> |
| 82 | + public static readonly DependencyProperty SignInAnotherUserDefaultTextProperty = DependencyProperty.Register( |
| 83 | + nameof(SignInAnotherUserDefaultText), |
| 84 | + typeof(string), |
| 85 | + typeof(AadLogin), |
| 86 | + new PropertyMetadata("Sign in with another account")); |
| 87 | + |
| 88 | + /// <summary> |
| 89 | + /// Identifies the <see cref="CurrentUserId"/> dependency property. |
| 90 | + /// </summary> |
| 91 | + public static readonly DependencyProperty CurrentUserIdProperty = DependencyProperty.Register( |
| 92 | + nameof(CurrentUserId), |
| 93 | + typeof(string), |
| 94 | + typeof(AadLogin), |
| 95 | + new PropertyMetadata(null)); |
| 96 | + |
| 97 | + /// <summary> |
| 98 | + /// Gets or sets the default user photo |
| 99 | + /// </summary> |
| 100 | + public BitmapImage DefaultImage |
| 101 | + { |
| 102 | + get { return (BitmapImage)GetValue(DefaultImageProperty); } |
| 103 | + set { SetValue(DefaultImageProperty, value); } |
| 104 | + } |
| 105 | + |
| 106 | + /// <summary> |
| 107 | + /// Gets or sets a value indicating which view type will be presented, the default value is PictureOnly. |
| 108 | + /// </summary> |
| 109 | + public ViewType View |
| 110 | + { |
| 111 | + get { return (ViewType)GetValue(ViewProperty); } |
| 112 | + set { SetValue(ViewProperty, value); } |
| 113 | + } |
| 114 | + |
| 115 | + /// <summary> |
| 116 | + /// Gets or sets a value indicating whether AllowSignInAsDifferentUser menu button is enabled for logged in user. |
| 117 | + /// </summary> |
| 118 | + public bool AllowSignInAsDifferentUser |
| 119 | + { |
| 120 | + get { return (bool)GetValue(AllowSignInAsDifferentUserProperty); } |
| 121 | + set { SetValue(AllowSignInAsDifferentUserProperty, value); } |
| 122 | + } |
| 123 | + |
| 124 | + /// <summary> |
| 125 | + /// Gets or sets a value for default sign-in text. |
| 126 | + /// </summary> |
| 127 | + public string SignInDefaultText |
| 128 | + { |
| 129 | + get { return (string)GetValue(SignInDefaultTextProperty); } |
| 130 | + set { SetValue(SignInDefaultTextProperty, value); } |
| 131 | + } |
| 132 | + |
| 133 | + /// <summary> |
| 134 | + /// Gets or sets a value for default sign-out text. |
| 135 | + /// </summary> |
| 136 | + public string SignOutDefaultText |
| 137 | + { |
| 138 | + get { return (string)GetValue(SignOutDefaultTextProperty); } |
| 139 | + set { SetValue(SignOutDefaultTextProperty, value); } |
| 140 | + } |
| 141 | + |
| 142 | + /// <summary> |
| 143 | + /// Gets or sets a value for default text of the Sign-in-with-another-account button. |
| 144 | + /// </summary> |
| 145 | + public string SignInAnotherUserDefaultText |
| 146 | + { |
| 147 | + get { return (string)GetValue(SignInAnotherUserDefaultTextProperty); } |
| 148 | + set { SetValue(SignInAnotherUserDefaultTextProperty, value); } |
| 149 | + } |
| 150 | + |
| 151 | + /// <summary> |
| 152 | + /// Gets the unique identifier for current signed in user. |
| 153 | + /// </summary> |
| 154 | + public string CurrentUserId |
| 155 | + { |
| 156 | + get { return (string)GetValue(CurrentUserIdProperty); } |
| 157 | + private set { SetValue(CurrentUserIdProperty, value); } |
| 158 | + } |
| 159 | + } |
| 160 | +} |
0 commit comments