/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/Dialogs/CredentialDialog.xaml.cs
70 строк
2 KB
yair100
Fix: Fixed issue where the permanently delete checkbox was not shown in the delete dialog (#18792)
04 авг 2026, 01:51
Не верифицирован
04 авг 2026, 01:51
8bfed61
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using System.Text; namespace Files.App.Dialogs { public sealed partial class CredentialDialog : ContentDialog, IDialog<CredentialDialogViewModel> { private FrameworkElement RootAppElement => (FrameworkElement)MainWindow.Instance.Content; public CredentialDialogViewModel ViewModel { get => (CredentialDialogViewModel)DataContext; set => DataContext = value; } public CredentialDialog() { InitializeComponent(); } public new async Task<DialogResult> ShowAsync() { return (DialogResult)await base.ShowAsync(); } private void ContentDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args) { // Focus the first editable input so the user can type without clicking first var target = UserName is { Visibility: Visibility.Visible, IsEnabled: true } ? UserName : (Control)Password; target.Focus(FocusState.Programmatic); } private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var password = new DisposableArray(Encoding.UTF8.GetBytes(Password.Password)); if (ViewModel.PasswordValidator is null) { ViewModel.PrimaryButtonClickCommand.Execute(password); return; } var deferral = args.GetDeferral(); try { IsPrimaryButtonEnabled = false; if (await ViewModel.PasswordValidator(password)) { ViewModel.PrimaryButtonClickCommand.Execute(password); } else { args.Cancel = true; ViewModel.IsWrongPassword = true; password.Dispose(); } } finally { IsPrimaryButtonEnabled = true; deferral.Complete(); } } } }