Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save last state when selecting an entry. esc clears the input #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FluentPassFinder/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
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" >
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemesDictionary Theme="Dark" />
<ui:ControlsDictionary />
</ResourceDictionary.MergedDictionaries>
<s:Boolean x:Key="True">True</s:Boolean>
<s:Boolean x:Key="False">False</s:Boolean>
</ResourceDictionary>
</Application.Resources>
</Application>
1 change: 1 addition & 0 deletions FluentPassFinder/FluentPassFinder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<OutDir>$(SolutionDir)Build/$(Configuration)/$(TargetFramework)/bin</OutDir>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion FluentPassFinder/Views/SearchWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ui:FluentWindow.Resources>
<ui:FluentWindow.InputBindings>
<KeyBinding Gesture="Escape"
Command="{Binding HideSearchWindowCommand}" />
Command="{Binding HideSearchWindowCommand}" CommandParameter="{StaticResource True}" />
<KeyBinding Gesture="Enter"
Command="{Binding ViewModel.EnterActionCommand}" />
<KeyBinding Gesture="Shift+Enter"
Expand Down
35 changes: 28 additions & 7 deletions FluentPassFinder/Views/SearchWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows;
using System.Windows.Controls;
using WpfScreenHelper;
using System.Timers;

namespace FluentPassFinder.Views
{
Expand All @@ -28,22 +29,42 @@ protected override void OnDeactivated(EventArgs e)
}

[RelayCommand]
public void HideSearchWindow()
public void HideSearchWindow(bool clearInputDirectly=false)
{
if (!isClosing && !isOpening)
{
isClosing = true;
Hide();

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)
{
Expand Down