From e1cb487c5e936478a488ffa30000ec55c6dfda76 Mon Sep 17 00:00:00 2001 From: Eike Thies Date: Mon, 26 Aug 2024 22:49:01 +0200 Subject: [PATCH 1/2] save last state when selecting an entry. esc clears the input --- FluentPassFinder/App.xaml | 3 +++ FluentPassFinder/FluentPassFinder.csproj | 1 + FluentPassFinder/Views/SearchWindow.xaml | 2 +- FluentPassFinder/Views/SearchWindow.xaml.cs | 13 +++++++------ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/FluentPassFinder/App.xaml b/FluentPassFinder/App.xaml index 2c172d0..045cee1 100644 --- a/FluentPassFinder/App.xaml +++ b/FluentPassFinder/App.xaml @@ -3,6 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" + xmlns:s="clr-namespace:System;assembly=mscorlib" ShutdownMode="OnExplicitShutdown" > @@ -10,6 +11,8 @@ + True + False diff --git a/FluentPassFinder/FluentPassFinder.csproj b/FluentPassFinder/FluentPassFinder.csproj index 8ff1dff..12e2021 100644 --- a/FluentPassFinder/FluentPassFinder.csproj +++ b/FluentPassFinder/FluentPassFinder.csproj @@ -5,6 +5,7 @@ enable true $(SolutionDir)Build/$(Configuration)/$(TargetFramework)/bin + net48 diff --git a/FluentPassFinder/Views/SearchWindow.xaml b/FluentPassFinder/Views/SearchWindow.xaml index be2ae87..8c7edee 100644 --- a/FluentPassFinder/Views/SearchWindow.xaml +++ b/FluentPassFinder/Views/SearchWindow.xaml @@ -34,7 +34,7 @@ + Command="{Binding HideSearchWindowCommand}" CommandParameter="{StaticResource True}" /> Date: Wed, 28 Aug 2024 14:06:39 +0200 Subject: [PATCH 2/2] use timer to clear inputs after 30 seconds --- FluentPassFinder/Views/SearchWindow.xaml.cs | 34 ++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/FluentPassFinder/Views/SearchWindow.xaml.cs b/FluentPassFinder/Views/SearchWindow.xaml.cs index f87858d..e1a5dcb 100644 --- a/FluentPassFinder/Views/SearchWindow.xaml.cs +++ b/FluentPassFinder/Views/SearchWindow.xaml.cs @@ -2,6 +2,7 @@ using System.Windows; using System.Windows.Controls; using WpfScreenHelper; +using System.Timers; namespace FluentPassFinder.Views { @@ -28,23 +29,42 @@ protected override void OnDeactivated(EventArgs e) } [RelayCommand] - public void HideSearchWindow(bool clearInput=false) + public void HideSearchWindow(bool clearInputDirectly=false) { if (!isClosing && !isOpening) { isClosing = true; Hide(); - if(clearInput){ - ViewModel.SearchText = string.Empty; - ViewModel.Entries.Clear(); - - ViewModel.IsContextMenuOpen = false; - ViewModel.SelectedEntry = null; + if(clearInputDirectly){ + ClearInputs(); + }else{ + ClearInputsAfterDelay(TimeSpan.FromSeconds(30)); } isClosing = false; } } + private void ClearInputsAfterDelay(TimeSpan delay) + { + var timer = new System.Threading.Timer(_ => + { + Dispatcher.Invoke(() => + { + ClearInputs(); + }); + }, null, delay, Timeout.InfiniteTimeSpan); + } + + private void ClearInputs() + { + ViewModel.SearchText = string.Empty; + ViewModel.Entries.Clear(); + + ViewModel.IsContextMenuOpen = false; + ViewModel.SelectedEntry = null; + } + + public void ShowSearchWindow(bool showOnPrimaryScreen) {