private void SecureArea_Unloaded(object sender, RoutedEventArgs e) { ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = true; CoreWindow.GetForCurrentThread().KeyDown -= SecureArea_KeyDown; SelectionExtention?.Dispose(); EmptyTips.Visibility = Visibility.Collapsed; SecureCollection.Clear(); SecureGridView.RemoveHandler(PointerPressedEvent, PointerPressedHandler); }
private void SecureArea_KeyDown(CoreWindow sender, KeyEventArgs args) { CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control); switch (args.VirtualKey) { case VirtualKey.A when CtrlState.HasFlag(CoreVirtualKeyStates.Down): { SecureGridView.SelectAll(); break; } case VirtualKey.Delete when SecureGridView.SelectedItems.Count > 0: case VirtualKey.D when CtrlState.HasFlag(CoreVirtualKeyStates.Down) && SecureGridView.SelectedItems.Count > 0: { DeleteFile_Click(null, null); break; } } }
private async void SecureArea_Loaded(object sender, RoutedEventArgs e) { WholeArea.Visibility = Visibility.Collapsed; SecureGridView.AddHandler(PointerPressedEvent, PointerPressedHandler, true); ApplicationView.GetForCurrentView().IsScreenCaptureEnabled = false; if (ApplicationData.Current.LocalSettings.Values.ContainsKey("IsFirstEnterSecureArea")) { AESKeySize = Convert.ToInt32(ApplicationData.Current.LocalSettings.Values["SecureAreaAESKeySize"]); if (ApplicationData.Current.LocalSettings.Values["SecureAreaLockMode"] is not string LockMode || LockMode != nameof(CloseLockMode) || IsNewStart) { if (Convert.ToBoolean(ApplicationData.Current.LocalSettings.Values["SecureAreaEnableWindowsHello"])) { RETRY: switch (await WindowsHelloAuthenticator.VerifyUserAsync()) { case AuthenticatorState.VerifyPassed: { break; } case AuthenticatorState.UnknownError: case AuthenticatorState.VerifyFailed: { QueueContentDialog Dialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_ErrorTitle"), Content = Globalization.GetString("QueueDialog_WinHelloAuthFail_Content"), PrimaryButtonText = Globalization.GetString("Common_Dialog_TryAgain"), SecondaryButtonText = Globalization.GetString("Common_Dialog_UsePassword"), CloseButtonText = Globalization.GetString("Common_Dialog_GoBack") }; ContentDialogResult Result = await Dialog.ShowAsync(); if (Result == ContentDialogResult.Primary) { goto RETRY; } else if (Result == ContentDialogResult.Secondary) { if (!await EnterByPassword()) { return; } } else { Frame.GoBack(); return; } break; } case AuthenticatorState.UserNotRegistered: case AuthenticatorState.CredentialNotFound: { QueueContentDialog Dialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_ErrorTitle"), Content = Globalization.GetString("QueueDialog_WinHelloCredentialLost_Content"), CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton") }; _ = await Dialog.ShowAsync(); ApplicationData.Current.LocalSettings.Values["SecureAreaEnableWindowsHello"] = false; if (!await EnterByPassword()) { return; } break; } case AuthenticatorState.WindowsHelloUnsupport: { QueueContentDialog Dialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_WarningTitle"), Content = Globalization.GetString("QueueDialog_WinHelloDisable_Content"), PrimaryButtonText = Globalization.GetString("Common_Dialog_UsePassword"), CloseButtonText = Globalization.GetString("Common_Dialog_GoBack") }; ApplicationData.Current.LocalSettings.Values["SecureAreaEnableWindowsHello"] = false; if ((await Dialog.ShowAsync()) == ContentDialogResult.Primary) { if (!await EnterByPassword()) { return; } } else { Frame.GoBack(); return; } break; } } } else { if (!await EnterByPassword()) { return; } } } } else { try { await ActivateLoading(true, false, Globalization.GetString("Progress_Tip_CheckingLicense")); if (await MSStoreHelper.Current.CheckPurchaseStatusAsync()) { await Task.Delay(500); } else { SecureAreaIntroDialog IntroDialog = new SecureAreaIntroDialog(); if ((await IntroDialog.ShowAsync()) == ContentDialogResult.Primary) { StorePurchaseStatus Status = await MSStoreHelper.Current.PurchaseAsync(); if (Status == StorePurchaseStatus.AlreadyPurchased || Status == StorePurchaseStatus.Succeeded) { QueueContentDialog SuccessDialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_WarningTitle"), Content = Globalization.GetString("QueueDialog_SecureAreaUnlock_Content"), CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton") }; await SuccessDialog.ShowAsync(); } else { Frame.GoBack(); return; } } else { Frame.GoBack(); return; } } } finally { await ActivateLoading(false); } SecureAreaWelcomeDialog Dialog = new SecureAreaWelcomeDialog(); if ((await Dialog.ShowAsync()) == ContentDialogResult.Primary) { AESKeySize = Dialog.AESKeySize; UnlockPassword = Dialog.Password; ApplicationData.Current.LocalSettings.Values["SecureAreaAESKeySize"] = Dialog.AESKeySize; ApplicationData.Current.LocalSettings.Values["SecureAreaEnableWindowsHello"] = Dialog.IsEnableWindowsHello; ApplicationData.Current.LocalSettings.Values["IsFirstEnterSecureArea"] = false; } else { if (Dialog.IsEnableWindowsHello) { await WindowsHelloAuthenticator.DeleteUserAsync(); } Frame.GoBack(); return; } } CoreWindow.GetForCurrentThread().KeyDown += SecureArea_KeyDown; WholeArea.Visibility = Visibility.Visible; SelectionExtention = new ListViewBaseSelectionExtention(SecureGridView, DrawRectangle); await LoadSecureFile(); }