file scoped namespaces (#565)
This commit is contained in:
@@ -5,67 +5,66 @@ using Windows.UI.Xaml.Controls;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Dialogs
|
||||
namespace Wino.Dialogs;
|
||||
|
||||
public sealed partial class AccountCreationDialog : ContentDialog, IAccountCreationDialog
|
||||
{
|
||||
public sealed partial class AccountCreationDialog : ContentDialog, IAccountCreationDialog
|
||||
private TaskCompletionSource<bool> dialogOpened = new TaskCompletionSource<bool>();
|
||||
public CancellationTokenSource CancellationTokenSource { get; private set; }
|
||||
|
||||
public AccountCreationDialogState State
|
||||
{
|
||||
private TaskCompletionSource<bool> dialogOpened = new TaskCompletionSource<bool>();
|
||||
public CancellationTokenSource CancellationTokenSource { get; private set; }
|
||||
get { return (AccountCreationDialogState)GetValue(StateProperty); }
|
||||
set { SetValue(StateProperty, value); }
|
||||
}
|
||||
|
||||
public AccountCreationDialogState State
|
||||
public static readonly DependencyProperty StateProperty = DependencyProperty.Register(nameof(State), typeof(AccountCreationDialogState), typeof(AccountCreationDialog), new PropertyMetadata(AccountCreationDialogState.Idle));
|
||||
|
||||
public AccountCreationDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// Prevent users from dismissing it by ESC key.
|
||||
public void DialogClosing(ContentDialog sender, ContentDialogClosingEventArgs args)
|
||||
{
|
||||
if (args.Result == ContentDialogResult.None)
|
||||
{
|
||||
get { return (AccountCreationDialogState)GetValue(StateProperty); }
|
||||
set { SetValue(StateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty StateProperty = DependencyProperty.Register(nameof(State), typeof(AccountCreationDialogState), typeof(AccountCreationDialog), new PropertyMetadata(AccountCreationDialogState.Idle));
|
||||
|
||||
public AccountCreationDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// Prevent users from dismissing it by ESC key.
|
||||
public void DialogClosing(ContentDialog sender, ContentDialogClosingEventArgs args)
|
||||
{
|
||||
if (args.Result == ContentDialogResult.None)
|
||||
{
|
||||
args.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Complete(bool cancel)
|
||||
{
|
||||
State = cancel ? AccountCreationDialogState.Canceled : AccountCreationDialogState.Completed;
|
||||
|
||||
// Unregister from closing event.
|
||||
Closing -= DialogClosing;
|
||||
|
||||
if (cancel && !CancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
CancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void CancelClicked(object sender, System.EventArgs e) => Complete(true);
|
||||
|
||||
public async Task ShowDialogAsync(CancellationTokenSource cancellationTokenSource)
|
||||
{
|
||||
CancellationTokenSource = cancellationTokenSource;
|
||||
|
||||
Opened += DialogOpened;
|
||||
_ = ShowAsync();
|
||||
|
||||
await dialogOpened.Task;
|
||||
}
|
||||
|
||||
private void DialogOpened(ContentDialog sender, ContentDialogOpenedEventArgs args)
|
||||
{
|
||||
Opened -= DialogOpened;
|
||||
|
||||
dialogOpened?.SetResult(true);
|
||||
args.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Complete(bool cancel)
|
||||
{
|
||||
State = cancel ? AccountCreationDialogState.Canceled : AccountCreationDialogState.Completed;
|
||||
|
||||
// Unregister from closing event.
|
||||
Closing -= DialogClosing;
|
||||
|
||||
if (cancel && !CancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
CancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void CancelClicked(object sender, System.EventArgs e) => Complete(true);
|
||||
|
||||
public async Task ShowDialogAsync(CancellationTokenSource cancellationTokenSource)
|
||||
{
|
||||
CancellationTokenSource = cancellationTokenSource;
|
||||
|
||||
Opened += DialogOpened;
|
||||
_ = ShowAsync();
|
||||
|
||||
await dialogOpened.Task;
|
||||
}
|
||||
|
||||
private void DialogOpened(ContentDialog sender, ContentDialogOpenedEventArgs args)
|
||||
{
|
||||
Opened -= DialogOpened;
|
||||
|
||||
dialogOpened?.SetResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
|
||||
namespace Wino.Dialogs
|
||||
namespace Wino.Dialogs;
|
||||
|
||||
public sealed partial class AccountEditDialog : ContentDialog
|
||||
{
|
||||
public sealed partial class AccountEditDialog : ContentDialog
|
||||
public MailAccount Account { get; private set; }
|
||||
public bool IsSaved { get; set; }
|
||||
|
||||
public AccountEditDialog(MailAccount account)
|
||||
{
|
||||
public MailAccount Account { get; private set; }
|
||||
public bool IsSaved { get; set; }
|
||||
InitializeComponent();
|
||||
Account = account;
|
||||
}
|
||||
|
||||
public AccountEditDialog(MailAccount account)
|
||||
{
|
||||
InitializeComponent();
|
||||
Account = account;
|
||||
}
|
||||
|
||||
private void SaveClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
IsSaved = true;
|
||||
}
|
||||
private void SaveClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
IsSaved = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,26 +2,25 @@
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
|
||||
namespace Wino.Dialogs
|
||||
namespace Wino.Dialogs;
|
||||
|
||||
public sealed partial class AccountPickerDialog : ContentDialog
|
||||
{
|
||||
public sealed partial class AccountPickerDialog : ContentDialog
|
||||
public MailAccount PickedAccount { get; set; }
|
||||
|
||||
public List<MailAccount> AvailableAccounts { get; set; }
|
||||
|
||||
public AccountPickerDialog(List<MailAccount> availableAccounts)
|
||||
{
|
||||
public MailAccount PickedAccount { get; set; }
|
||||
AvailableAccounts = availableAccounts;
|
||||
|
||||
public List<MailAccount> AvailableAccounts { get; set; }
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public AccountPickerDialog(List<MailAccount> availableAccounts)
|
||||
{
|
||||
AvailableAccounts = availableAccounts;
|
||||
private void AccountClicked(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
PickedAccount = e.ClickedItem as MailAccount;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void AccountClicked(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
PickedAccount = e.ClickedItem as MailAccount;
|
||||
|
||||
Hide();
|
||||
}
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Wino.Core.Domain.Enums;
|
||||
|
||||
namespace Wino.Dialogs
|
||||
namespace Wino.Dialogs;
|
||||
|
||||
public partial class CustomMessageDialogInformationContainer : ObservableObject
|
||||
{
|
||||
public partial class CustomMessageDialogInformationContainer : ObservableObject
|
||||
[ObservableProperty]
|
||||
public partial bool IsDontAskChecked { get; set; }
|
||||
|
||||
public CustomMessageDialogInformationContainer(string title, string description, WinoCustomMessageDialogIcon icon, bool isDontAskAgainEnabled)
|
||||
{
|
||||
[ObservableProperty]
|
||||
public partial bool IsDontAskChecked { get; set; }
|
||||
|
||||
public CustomMessageDialogInformationContainer(string title, string description, WinoCustomMessageDialogIcon icon, bool isDontAskAgainEnabled)
|
||||
{
|
||||
Title = title;
|
||||
Description = description;
|
||||
Icon = icon;
|
||||
IsDontAskAgainEnabled = isDontAskAgainEnabled;
|
||||
}
|
||||
|
||||
public string Title { get; }
|
||||
public string Description { get; }
|
||||
public WinoCustomMessageDialogIcon Icon { get; }
|
||||
public bool IsDontAskAgainEnabled { get; }
|
||||
Title = title;
|
||||
Description = description;
|
||||
Icon = icon;
|
||||
IsDontAskAgainEnabled = isDontAskAgainEnabled;
|
||||
}
|
||||
|
||||
public string Title { get; }
|
||||
public string Description { get; }
|
||||
public WinoCustomMessageDialogIcon Icon { get; }
|
||||
public bool IsDontAskAgainEnabled { get; }
|
||||
}
|
||||
|
||||
@@ -6,60 +6,59 @@ using Windows.UI.Xaml.Media;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.UWP;
|
||||
|
||||
namespace Wino.Dialogs
|
||||
namespace Wino.Dialogs;
|
||||
|
||||
public sealed partial class CustomThemeBuilderDialog : ContentDialog
|
||||
{
|
||||
public sealed partial class CustomThemeBuilderDialog : ContentDialog
|
||||
public byte[] WallpaperData { get; private set; }
|
||||
public string AccentColor { get; private set; }
|
||||
|
||||
private IThemeService _themeService;
|
||||
|
||||
public CustomThemeBuilderDialog()
|
||||
{
|
||||
public byte[] WallpaperData { get; private set; }
|
||||
public string AccentColor { get; private set; }
|
||||
InitializeComponent();
|
||||
|
||||
private IThemeService _themeService;
|
||||
_themeService = WinoApplication.Current.Services.GetService<IThemeService>();
|
||||
}
|
||||
|
||||
public CustomThemeBuilderDialog()
|
||||
private async void ApplyClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
if (Array.Empty<byte>() == WallpaperData)
|
||||
return;
|
||||
|
||||
var deferal = args.GetDeferral();
|
||||
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_themeService = WinoApplication.Current.Services.GetService<IThemeService>();
|
||||
await _themeService.CreateNewCustomThemeAsync(ThemeNameBox.Text, AccentColor, WallpaperData);
|
||||
}
|
||||
|
||||
private async void ApplyClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (Array.Empty<byte>() == WallpaperData)
|
||||
return;
|
||||
|
||||
var deferal = args.GetDeferral();
|
||||
|
||||
try
|
||||
{
|
||||
await _themeService.CreateNewCustomThemeAsync(ThemeNameBox.Text, AccentColor, WallpaperData);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
ErrorTextBlock.Text = exception.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
deferal.Complete();
|
||||
}
|
||||
ErrorTextBlock.Text = exception.Message;
|
||||
}
|
||||
|
||||
private async void BrowseWallpaperClicked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
||||
finally
|
||||
{
|
||||
var dialogService = WinoApplication.Current.Services.GetService<IMailDialogService>();
|
||||
|
||||
var pickedFileData = await dialogService.PickWindowsFileContentAsync(".jpg", ".png");
|
||||
|
||||
if (pickedFileData == Array.Empty<byte>()) return;
|
||||
|
||||
IsPrimaryButtonEnabled = true;
|
||||
|
||||
WallpaperData = pickedFileData;
|
||||
}
|
||||
|
||||
private void PickerColorChanged(Microsoft.UI.Xaml.Controls.ColorPicker sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args)
|
||||
{
|
||||
PreviewAccentColorGrid.Background = new SolidColorBrush(args.NewColor);
|
||||
AccentColor = args.NewColor.ToHex();
|
||||
deferal.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private async void BrowseWallpaperClicked(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
var dialogService = WinoApplication.Current.Services.GetService<IMailDialogService>();
|
||||
|
||||
var pickedFileData = await dialogService.PickWindowsFileContentAsync(".jpg", ".png");
|
||||
|
||||
if (pickedFileData == Array.Empty<byte>()) return;
|
||||
|
||||
IsPrimaryButtonEnabled = true;
|
||||
|
||||
WallpaperData = pickedFileData;
|
||||
}
|
||||
|
||||
private void PickerColorChanged(Microsoft.UI.Xaml.Controls.ColorPicker sender, Microsoft.UI.Xaml.Controls.ColorChangedEventArgs args)
|
||||
{
|
||||
PreviewAccentColorGrid.Background = new SolidColorBrush(args.NewColor);
|
||||
AccentColor = args.NewColor.ToHex();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,146 +7,145 @@ using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Accounts;
|
||||
|
||||
namespace Wino.Core.UWP.Dialogs
|
||||
namespace Wino.Core.UWP.Dialogs;
|
||||
|
||||
public sealed partial class NewAccountDialog : ContentDialog
|
||||
{
|
||||
public sealed partial class NewAccountDialog : ContentDialog
|
||||
private Dictionary<SpecialImapProvider, string> helpingLinks = new Dictionary<SpecialImapProvider, string>()
|
||||
{
|
||||
private Dictionary<SpecialImapProvider, string> helpingLinks = new Dictionary<SpecialImapProvider, string>()
|
||||
{ SpecialImapProvider.iCloud, "https://support.apple.com/en-us/102654" },
|
||||
{ SpecialImapProvider.Yahoo, "http://help.yahoo.com/kb/SLN15241.html" },
|
||||
};
|
||||
|
||||
public static readonly DependencyProperty IsProviderSelectionVisibleProperty = DependencyProperty.Register(nameof(IsProviderSelectionVisible), typeof(bool), typeof(NewAccountDialog), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty IsSpecialImapServerPartVisibleProperty = DependencyProperty.Register(nameof(IsSpecialImapServerPartVisible), typeof(bool), typeof(NewAccountDialog), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty SelectedMailProviderProperty = DependencyProperty.Register(nameof(SelectedMailProvider), typeof(ProviderDetail), typeof(NewAccountDialog), new PropertyMetadata(null, new PropertyChangedCallback(OnSelectedProviderChanged)));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets current selected mail provider in the dialog.
|
||||
/// </summary>
|
||||
public ProviderDetail SelectedMailProvider
|
||||
{
|
||||
get { return (ProviderDetail)GetValue(SelectedMailProviderProperty); }
|
||||
set { SetValue(SelectedMailProviderProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public bool IsProviderSelectionVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsProviderSelectionVisibleProperty); }
|
||||
set { SetValue(IsProviderSelectionVisibleProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsSpecialImapServerPartVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsSpecialImapServerPartVisibleProperty); }
|
||||
set { SetValue(IsSpecialImapServerPartVisibleProperty, value); }
|
||||
}
|
||||
|
||||
// List of available mail providers for now.
|
||||
|
||||
public List<IProviderDetail> Providers { get; set; }
|
||||
|
||||
public AccountCreationDialogResult Result = null;
|
||||
|
||||
public NewAccountDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// AccountColorPicker.Color = Colors.Blue;
|
||||
}
|
||||
|
||||
private static void OnSelectedProviderChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
if (obj is NewAccountDialog dialog)
|
||||
dialog.Validate();
|
||||
}
|
||||
|
||||
private void CancelClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void CreateClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
if (IsSpecialImapServerPartVisible)
|
||||
{
|
||||
{ SpecialImapProvider.iCloud, "https://support.apple.com/en-us/102654" },
|
||||
{ SpecialImapProvider.Yahoo, "http://help.yahoo.com/kb/SLN15241.html" },
|
||||
};
|
||||
// Special imap detail input.
|
||||
|
||||
public static readonly DependencyProperty IsProviderSelectionVisibleProperty = DependencyProperty.Register(nameof(IsProviderSelectionVisible), typeof(bool), typeof(NewAccountDialog), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty IsSpecialImapServerPartVisibleProperty = DependencyProperty.Register(nameof(IsSpecialImapServerPartVisible), typeof(bool), typeof(NewAccountDialog), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty SelectedMailProviderProperty = DependencyProperty.Register(nameof(SelectedMailProvider), typeof(ProviderDetail), typeof(NewAccountDialog), new PropertyMetadata(null, new PropertyChangedCallback(OnSelectedProviderChanged)));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets current selected mail provider in the dialog.
|
||||
/// </summary>
|
||||
public ProviderDetail SelectedMailProvider
|
||||
{
|
||||
get { return (ProviderDetail)GetValue(SelectedMailProviderProperty); }
|
||||
set { SetValue(SelectedMailProviderProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public bool IsProviderSelectionVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsProviderSelectionVisibleProperty); }
|
||||
set { SetValue(IsProviderSelectionVisibleProperty, value); }
|
||||
}
|
||||
|
||||
public bool IsSpecialImapServerPartVisible
|
||||
{
|
||||
get { return (bool)GetValue(IsSpecialImapServerPartVisibleProperty); }
|
||||
set { SetValue(IsSpecialImapServerPartVisibleProperty, value); }
|
||||
}
|
||||
|
||||
// List of available mail providers for now.
|
||||
|
||||
public List<IProviderDetail> Providers { get; set; }
|
||||
|
||||
public AccountCreationDialogResult Result = null;
|
||||
|
||||
public NewAccountDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// AccountColorPicker.Color = Colors.Blue;
|
||||
}
|
||||
|
||||
private static void OnSelectedProviderChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
if (obj is NewAccountDialog dialog)
|
||||
dialog.Validate();
|
||||
}
|
||||
|
||||
private void CancelClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
var details = new SpecialImapProviderDetails(SpecialImapAddress.Text.Trim(), AppSpecificPassword.Password.Trim(), DisplayNameTextBox.Text.Trim(), SelectedMailProvider.SpecialImapProvider);
|
||||
Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), details);
|
||||
Hide();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void CreateClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
if (IsSpecialImapServerPartVisible)
|
||||
{
|
||||
// Special imap detail input.
|
||||
Validate();
|
||||
|
||||
var details = new SpecialImapProviderDetails(SpecialImapAddress.Text.Trim(), AppSpecificPassword.Password.Trim(), DisplayNameTextBox.Text.Trim(), SelectedMailProvider.SpecialImapProvider);
|
||||
Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), details);
|
||||
if (IsSecondaryButtonEnabled)
|
||||
{
|
||||
if (SelectedMailProvider.SpecialImapProvider != SpecialImapProvider.None)
|
||||
{
|
||||
// This step requires app-sepcific password login for some providers.
|
||||
args.Cancel = true;
|
||||
|
||||
IsProviderSelectionVisible = false;
|
||||
IsSpecialImapServerPartVisible = true;
|
||||
|
||||
Validate();
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), null);
|
||||
Hide();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Validate();
|
||||
|
||||
if (IsSecondaryButtonEnabled)
|
||||
{
|
||||
if (SelectedMailProvider.SpecialImapProvider != SpecialImapProvider.None)
|
||||
{
|
||||
// This step requires app-sepcific password login for some providers.
|
||||
args.Cancel = true;
|
||||
|
||||
IsProviderSelectionVisible = false;
|
||||
IsSpecialImapServerPartVisible = true;
|
||||
|
||||
Validate();
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = new AccountCreationDialogResult(SelectedMailProvider.Type, AccountNameTextbox.Text.Trim(), null);
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InputChanged(object sender, TextChangedEventArgs e) => Validate();
|
||||
private void SenderNameChanged(object sender, TextChangedEventArgs e) => Validate();
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
ValidateCreateButton();
|
||||
ValidateNames();
|
||||
}
|
||||
|
||||
// Returns whether we can create account or not.
|
||||
private void ValidateCreateButton()
|
||||
{
|
||||
bool shouldEnable = SelectedMailProvider != null
|
||||
&& SelectedMailProvider.IsSupported
|
||||
&& !string.IsNullOrEmpty(AccountNameTextbox.Text)
|
||||
&& (IsSpecialImapServerPartVisible ? (!string.IsNullOrEmpty(AppSpecificPassword.Password)
|
||||
&& !string.IsNullOrEmpty(DisplayNameTextBox.Text)
|
||||
&& EmailValidation.EmailValidator.Validate(SpecialImapAddress.Text)) : true);
|
||||
|
||||
IsPrimaryButtonEnabled = shouldEnable;
|
||||
}
|
||||
|
||||
private void ValidateNames()
|
||||
{
|
||||
AccountNameTextbox.IsEnabled = SelectedMailProvider != null;
|
||||
}
|
||||
|
||||
private void DialogOpened(ContentDialog sender, ContentDialogOpenedEventArgs args) => Validate();
|
||||
|
||||
private void BackClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsSpecialImapServerPartVisible = false;
|
||||
IsProviderSelectionVisible = true;
|
||||
|
||||
Validate();
|
||||
}
|
||||
|
||||
private void ImapPasswordChanged(object sender, RoutedEventArgs e) => Validate();
|
||||
|
||||
private async void AppSpecificHelpButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var helpUrl = helpingLinks[SelectedMailProvider.SpecialImapProvider];
|
||||
|
||||
await Launcher.LaunchUriAsync(new Uri(helpUrl));
|
||||
}
|
||||
}
|
||||
|
||||
private void InputChanged(object sender, TextChangedEventArgs e) => Validate();
|
||||
private void SenderNameChanged(object sender, TextChangedEventArgs e) => Validate();
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
ValidateCreateButton();
|
||||
ValidateNames();
|
||||
}
|
||||
|
||||
// Returns whether we can create account or not.
|
||||
private void ValidateCreateButton()
|
||||
{
|
||||
bool shouldEnable = SelectedMailProvider != null
|
||||
&& SelectedMailProvider.IsSupported
|
||||
&& !string.IsNullOrEmpty(AccountNameTextbox.Text)
|
||||
&& (IsSpecialImapServerPartVisible ? (!string.IsNullOrEmpty(AppSpecificPassword.Password)
|
||||
&& !string.IsNullOrEmpty(DisplayNameTextBox.Text)
|
||||
&& EmailValidation.EmailValidator.Validate(SpecialImapAddress.Text)) : true);
|
||||
|
||||
IsPrimaryButtonEnabled = shouldEnable;
|
||||
}
|
||||
|
||||
private void ValidateNames()
|
||||
{
|
||||
AccountNameTextbox.IsEnabled = SelectedMailProvider != null;
|
||||
}
|
||||
|
||||
private void DialogOpened(ContentDialog sender, ContentDialogOpenedEventArgs args) => Validate();
|
||||
|
||||
private void BackClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsSpecialImapServerPartVisible = false;
|
||||
IsProviderSelectionVisible = true;
|
||||
|
||||
Validate();
|
||||
}
|
||||
|
||||
private void ImapPasswordChanged(object sender, RoutedEventArgs e) => Validate();
|
||||
|
||||
private async void AppSpecificHelpButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var helpUrl = helpingLinks[SelectedMailProvider.SpecialImapProvider];
|
||||
|
||||
await Launcher.LaunchUriAsync(new Uri(helpUrl));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,44 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Wino.Dialogs
|
||||
namespace Wino.Dialogs;
|
||||
|
||||
public sealed partial class TextInputDialog : ContentDialog
|
||||
{
|
||||
public sealed partial class TextInputDialog : ContentDialog
|
||||
public bool? HasInput { get; set; }
|
||||
|
||||
public string CurrentInput
|
||||
{
|
||||
public bool? HasInput { get; set; }
|
||||
get { return (string)GetValue(CurrentInputProperty); }
|
||||
set { SetValue(CurrentInputProperty, value); }
|
||||
}
|
||||
|
||||
public string CurrentInput
|
||||
{
|
||||
get { return (string)GetValue(CurrentInputProperty); }
|
||||
set { SetValue(CurrentInputProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty CurrentInputProperty = DependencyProperty.Register(nameof(CurrentInput), typeof(string), typeof(TextInputDialog), new PropertyMetadata(string.Empty));
|
||||
|
||||
public static readonly DependencyProperty CurrentInputProperty = DependencyProperty.Register(nameof(CurrentInput), typeof(string), typeof(TextInputDialog), new PropertyMetadata(string.Empty));
|
||||
public TextInputDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public TextInputDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void SetDescription(string description)
|
||||
{
|
||||
DialogDescription.Text = description;
|
||||
}
|
||||
|
||||
public void SetDescription(string description)
|
||||
{
|
||||
DialogDescription.Text = description;
|
||||
}
|
||||
public void SetPrimaryButtonText(string text)
|
||||
{
|
||||
PrimaryButtonText = text;
|
||||
}
|
||||
|
||||
public void SetPrimaryButtonText(string text)
|
||||
{
|
||||
PrimaryButtonText = text;
|
||||
}
|
||||
private void CancelClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void CancelClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
private void UpdateOrCreateClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
HasInput = true;
|
||||
|
||||
private void UpdateOrCreateClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
HasInput = true;
|
||||
|
||||
Hide();
|
||||
}
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user