From 87e3eace47aa75bc6b51d6a82b4e5f1f197f0711 Mon Sep 17 00:00:00 2001
From: Andrey Nasonov <37536541+Erapchu@users.noreply.github.com>
Date: Sat, 8 Apr 2023 21:43:19 +0700
Subject: [PATCH 1/5] NuGet update and VM refactoring
---
SinglePass.WPF/SinglePass.WPF.csproj | 8 ++++----
SinglePass.WPF/ViewModels/CloudSyncViewModel.cs | 3 +--
.../ViewModels/Dialogs/CreateCredentialViewModel.cs | 5 ++---
.../ViewModels/Dialogs/MaterialInputBoxViewModel.cs | 3 +--
.../ViewModels/Dialogs/MaterialMessageBoxViewModel.cs | 3 +--
SinglePass.WPF/ViewModels/Dialogs/ProcessingViewModel.cs | 3 +--
SinglePass.WPF/ViewModels/MainWindowViewModel.cs | 3 +--
SinglePass.WPF/ViewModels/PasswordsViewModel.cs | 3 +--
SinglePass.WPF/ViewModels/PopupViewModel.cs | 3 +--
SinglePass.WPF/ViewModels/SettingsViewModel.cs | 4 +---
10 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/SinglePass.WPF/SinglePass.WPF.csproj b/SinglePass.WPF/SinglePass.WPF.csproj
index a91d8e8..aacb02a 100644
--- a/SinglePass.WPF/SinglePass.WPF.csproj
+++ b/SinglePass.WPF/SinglePass.WPF.csproj
@@ -37,14 +37,14 @@
-
+
-
+
-
-
+
+
diff --git a/SinglePass.WPF/ViewModels/CloudSyncViewModel.cs b/SinglePass.WPF/ViewModels/CloudSyncViewModel.cs
index 67ddd6d..f4010d8 100644
--- a/SinglePass.WPF/ViewModels/CloudSyncViewModel.cs
+++ b/SinglePass.WPF/ViewModels/CloudSyncViewModel.cs
@@ -16,8 +16,7 @@
namespace SinglePass.WPF.ViewModels
{
- [INotifyPropertyChanged]
- public partial class CloudSyncViewModel
+ public partial class CloudSyncViewModel : ObservableObject
{
#region Design time instance
private static readonly Lazy _lazy = new(GetDesignTimeVM);
diff --git a/SinglePass.WPF/ViewModels/Dialogs/CreateCredentialViewModel.cs b/SinglePass.WPF/ViewModels/Dialogs/CreateCredentialViewModel.cs
index cc89dad..b4d3527 100644
--- a/SinglePass.WPF/ViewModels/Dialogs/CreateCredentialViewModel.cs
+++ b/SinglePass.WPF/ViewModels/Dialogs/CreateCredentialViewModel.cs
@@ -5,8 +5,7 @@
namespace SinglePass.WPF.ViewModels.Dialogs
{
- [INotifyPropertyChanged]
- public partial class CredentialEditViewModel
+ public partial class CredentialEditViewModel : ObservableObject
{
public event Action Accept;
@@ -19,7 +18,7 @@ public partial class CredentialEditViewModel
[ObservableProperty]
private CredentialDetailsMode _mode;
- public string CaptionText => _mode switch
+ public string CaptionText => Mode switch
{
CredentialDetailsMode.Edit => SinglePass.Language.Properties.Resources.Edit,
CredentialDetailsMode.New => SinglePass.Language.Properties.Resources.NewItem,
diff --git a/SinglePass.WPF/ViewModels/Dialogs/MaterialInputBoxViewModel.cs b/SinglePass.WPF/ViewModels/Dialogs/MaterialInputBoxViewModel.cs
index 73c5b12..1109b6f 100644
--- a/SinglePass.WPF/ViewModels/Dialogs/MaterialInputBoxViewModel.cs
+++ b/SinglePass.WPF/ViewModels/Dialogs/MaterialInputBoxViewModel.cs
@@ -5,8 +5,7 @@
namespace SinglePass.WPF.ViewModels.Dialogs
{
- [INotifyPropertyChanged]
- public partial class MaterialInputBoxViewModel
+ public partial class MaterialInputBoxViewModel : ObservableObject
{
private static readonly Lazy _lazy = new(() => new MaterialInputBoxViewModel());
public static MaterialInputBoxViewModel DesignTimeInstance => _lazy.Value;
diff --git a/SinglePass.WPF/ViewModels/Dialogs/MaterialMessageBoxViewModel.cs b/SinglePass.WPF/ViewModels/Dialogs/MaterialMessageBoxViewModel.cs
index 9009538..19a14c0 100644
--- a/SinglePass.WPF/ViewModels/Dialogs/MaterialMessageBoxViewModel.cs
+++ b/SinglePass.WPF/ViewModels/Dialogs/MaterialMessageBoxViewModel.cs
@@ -5,8 +5,7 @@
namespace SinglePass.WPF.ViewModels.Dialogs
{
- [INotifyPropertyChanged]
- public partial class MaterialMessageBoxViewModel
+ public partial class MaterialMessageBoxViewModel : ObservableObject
{
#region Design time instance
private static readonly Lazy _lazyDesignTime = new(CreateDesignTime);
diff --git a/SinglePass.WPF/ViewModels/Dialogs/ProcessingViewModel.cs b/SinglePass.WPF/ViewModels/Dialogs/ProcessingViewModel.cs
index d250f6d..597059b 100644
--- a/SinglePass.WPF/ViewModels/Dialogs/ProcessingViewModel.cs
+++ b/SinglePass.WPF/ViewModels/Dialogs/ProcessingViewModel.cs
@@ -6,8 +6,7 @@
namespace SinglePass.WPF.ViewModels.Dialogs
{
- [INotifyPropertyChanged]
- public partial class ProcessingViewModel
+ public partial class ProcessingViewModel : ObservableObject
{
#region Design time instance
private static readonly Lazy _lazy = new(GetDesignTimeVM);
diff --git a/SinglePass.WPF/ViewModels/MainWindowViewModel.cs b/SinglePass.WPF/ViewModels/MainWindowViewModel.cs
index e7d50dc..cf2cd50 100644
--- a/SinglePass.WPF/ViewModels/MainWindowViewModel.cs
+++ b/SinglePass.WPF/ViewModels/MainWindowViewModel.cs
@@ -11,8 +11,7 @@
namespace SinglePass.WPF.ViewModels
{
- [INotifyPropertyChanged]
- public partial class MainWindowViewModel
+ public partial class MainWindowViewModel : ObservableObject
{
#region Design time instance
private static readonly Lazy _lazy = new(GetDesignTimeVM);
diff --git a/SinglePass.WPF/ViewModels/PasswordsViewModel.cs b/SinglePass.WPF/ViewModels/PasswordsViewModel.cs
index a38c82b..855960c 100644
--- a/SinglePass.WPF/ViewModels/PasswordsViewModel.cs
+++ b/SinglePass.WPF/ViewModels/PasswordsViewModel.cs
@@ -21,8 +21,7 @@
namespace SinglePass.WPF.ViewModels
{
- [INotifyPropertyChanged]
- public partial class PasswordsViewModel
+ public partial class PasswordsViewModel : ObservableObject
{
#region Design time instance
private static readonly Lazy _lazy = new(GetDesignTimeVM);
diff --git a/SinglePass.WPF/ViewModels/PopupViewModel.cs b/SinglePass.WPF/ViewModels/PopupViewModel.cs
index c0a311a..17b805e 100644
--- a/SinglePass.WPF/ViewModels/PopupViewModel.cs
+++ b/SinglePass.WPF/ViewModels/PopupViewModel.cs
@@ -14,8 +14,7 @@
namespace SinglePass.WPF.ViewModels
{
- [INotifyPropertyChanged]
- public partial class PopupViewModel
+ public partial class PopupViewModel : ObservableObject
{
#region Design time instance
private static readonly Lazy _lazy = new(GetDesignTimeVM);
diff --git a/SinglePass.WPF/ViewModels/SettingsViewModel.cs b/SinglePass.WPF/ViewModels/SettingsViewModel.cs
index 899e6a1..e0d0af5 100644
--- a/SinglePass.WPF/ViewModels/SettingsViewModel.cs
+++ b/SinglePass.WPF/ViewModels/SettingsViewModel.cs
@@ -2,7 +2,6 @@
using CommunityToolkit.Mvvm.Input;
using MaterialDesignThemes.Wpf;
using Microsoft.Extensions.Logging;
-using SinglePass.WPF.Helpers;
using SinglePass.WPF.Hotkeys;
using SinglePass.WPF.Services;
using SinglePass.WPF.Settings;
@@ -13,8 +12,7 @@
namespace SinglePass.WPF.ViewModels
{
- [INotifyPropertyChanged]
- public partial class SettingsViewModel
+ public partial class SettingsViewModel : ObservableObject
{
#region Design time instance
private static readonly Lazy _lazy = new(GetDesignTimeVM);
From 90e3143f89d50225fb08900ac9c645596c03e7f3 Mon Sep 17 00:00:00 2001
From: Andrey Nasonov <37536541+Erapchu@users.noreply.github.com>
Date: Sun, 11 Jun 2023 18:10:00 +0700
Subject: [PATCH 2/5] Optimized second start and show main window
---
SinglePass.WPF/App.xaml.cs | 56 ++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 29 deletions(-)
diff --git a/SinglePass.WPF/App.xaml.cs b/SinglePass.WPF/App.xaml.cs
index c4080dc..d37a531 100644
--- a/SinglePass.WPF/App.xaml.cs
+++ b/SinglePass.WPF/App.xaml.cs
@@ -52,6 +52,12 @@ public App()
_configuration = BuildConfiguration();
Services = ConfigureServices(_configuration);
}
+ else
+ {
+ // Show main window and shutdown process
+ InterprocessHelper.ShowMainWindow();
+ Environment.Exit(0);
+ }
}
private static IServiceProvider ConfigureServices(IConfiguration configuration)
@@ -138,42 +144,34 @@ private void Application_Startup(object sender, StartupEventArgs e)
// Override culture
//SinglePass.Language.Properties.Resources.Culture = new System.Globalization.CultureInfo("en-US");
- if (IsFirstInstance)
- {
- var hiw = new HiddenInterprocessWindow();
- hiw.InitWithoutShowing();
+ var hiw = new HiddenInterprocessWindow();
+ hiw.InitWithoutShowing();
+
+ Constants.EnsurePaths();
- Constants.EnsurePaths();
+ // Resolve theme
+ var themeService = Services.GetService();
+ themeService.Init();
- // Resolve theme
- var themeService = Services.GetService();
- themeService.Init();
+ // Login
+ using (var loginScope = Services.CreateScope())
+ {
+ var loginWindow = loginScope.ServiceProvider.GetService();
+ bool? dialogResult = loginWindow.ShowDialog(); // Stop here
- // Login
- using (var loginScope = Services.CreateScope())
+ if (dialogResult != true)
{
- var loginWindow = loginScope.ServiceProvider.GetService();
- bool? dialogResult = loginWindow.ShowDialog(); // Stop here
-
- if (dialogResult != true)
- {
- Shutdown();
- return;
- }
+ Shutdown();
+ return;
}
+ }
- // Create tray icon
- _trayIcon = new TrayIcon();
+ // Create tray icon
+ _trayIcon = new TrayIcon();
- // Open main window
- var mainWindow = Services.GetService();
- mainWindow.Show();
- }
- else
- {
- InterprocessHelper.ShowMainWindow();
- Shutdown();
- }
+ // Open main window
+ var mainWindow = Services.GetService();
+ mainWindow.Show();
}
private void Application_Exit(object sender, ExitEventArgs e)
From bc4f25f947239f25069fd960552a3575aa4314b8 Mon Sep 17 00:00:00 2001
From: Andrey Nasonov <37536541+Erapchu@users.noreply.github.com>
Date: Sun, 11 Jun 2023 19:04:47 +0700
Subject: [PATCH 3/5] Cleaning up .yml
---
.github/workflows/dotnet-desktop.yml | 34 +++-------------------------
1 file changed, 3 insertions(+), 31 deletions(-)
diff --git a/.github/workflows/dotnet-desktop.yml b/.github/workflows/dotnet-desktop.yml
index db1cfc1..66054ca 100644
--- a/.github/workflows/dotnet-desktop.yml
+++ b/.github/workflows/dotnet-desktop.yml
@@ -6,54 +6,30 @@ on:
- 'v*'
jobs:
-
build:
- runs-on: windows-latest # For a list of available runner types, refer to
- # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
+ runs-on: windows-latest
env:
SOLUTION_NAME: SinglePass.WPF.sln
PROJECT_PATH: .\SinglePass.WPF\SinglePass.WPF.csproj
CONFIGURATION: Release
-
steps:
- name: Checkout
uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- # Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
-
- # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- - name: Setup MSBuild.exe
+ - name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.3.1
-
- # Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore
run: |
msbuild $env:PROJECT_PATH /t:Restore /p:Configuration=$env:CONFIGURATION
-
- # Build the application to populate the bin folder
- name: Build
run: |
- msbuild $env:PROJECT_PATH /t:Publish /p:Configuration=$env:CONFIGURATION /p:RuntimeIdentifier=win-x64 /p:SelfContained=true /p:PublishReadyToRun=True /p:PublishSingleFile=true
-
- # Upload artifacts
- - name: Archive production artifacts
- uses: actions/upload-artifact@v3
- with:
- name: build_result
- path: .\SinglePass.WPF\bin\Release\net7.0-windows\win-x64\publish\
-
- # Create .zip from artifacts
+ msbuild $env:PROJECT_PATH /t:Publish /p:Configuration=$env:CONFIGURATION /p:RuntimeIdentifier=win-x64 /p:SelfContained=true /p:PublishReadyToRun=true /p:PublishSingleFile=true
- name: Create .zip artifacts
run: |
Compress-Archive -Path '.\SinglePass.WPF\bin\Release\net7.0-windows\win-x64\publish\' -DestinationPath '.\build_result.zip'
-
- # Use script because we need to automate generate_release_notes
- name: Create release
uses: "actions/github-script@v6.4.0"
env:
@@ -77,8 +53,6 @@ jobs:
} catch (error) {
core.setFailed(error.message);
}
-
- # Upload artifacts to release
- name: Upload artifact
uses: actions/upload-release-asset@v1
env:
@@ -88,8 +62,6 @@ jobs:
asset_path: .\build_result.zip
asset_name: build_result.zip
asset_content_type: application/zip
-
-
# - name: Create release
# uses: actions/create-release@v1
From fc9ebb2fba8fd884025f4522f3a97acc04ba3769 Mon Sep 17 00:00:00 2001
From: Andrey Nasonov <37536541+Erapchu@users.noreply.github.com>
Date: Sun, 11 Jun 2023 19:11:56 +0700
Subject: [PATCH 4/5] Update NuGets
---
SinglePass.WPF/SinglePass.WPF.csproj | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/SinglePass.WPF/SinglePass.WPF.csproj b/SinglePass.WPF/SinglePass.WPF.csproj
index 962dcf1..72344d6 100644
--- a/SinglePass.WPF/SinglePass.WPF.csproj
+++ b/SinglePass.WPF/SinglePass.WPF.csproj
@@ -35,16 +35,16 @@
-
+
-
-
-
+
+
+
From 4dbafbe2fc5d9e4db5eb9758eb9ae537d1c2a703 Mon Sep 17 00:00:00 2001
From: Andrey Nasonov <37536541+Erapchu@users.noreply.github.com>
Date: Sun, 11 Jun 2023 20:13:36 +0700
Subject: [PATCH 5/5] Implemented combination
---
.../Properties/Resources.Designer.cs | 12 ++--
SinglePass.Language/Properties/Resources.resx | 8 +--
.../Properties/Resources.ru.resx | 8 +--
SinglePass.WPF/Helpers/WindowsKeyboard.cs | 1 +
SinglePass.WPF/ViewModels/PopupViewModel.cs | 67 +++++++++++++++++++
.../Views/Controls/SettingsControl.xaml | 6 +-
.../Views/Windows/PopupWindow.xaml.cs | 38 +++++++----
7 files changed, 109 insertions(+), 31 deletions(-)
diff --git a/SinglePass.Language/Properties/Resources.Designer.cs b/SinglePass.Language/Properties/Resources.Designer.cs
index b729006..6eea28c 100644
--- a/SinglePass.Language/Properties/Resources.Designer.cs
+++ b/SinglePass.Language/Properties/Resources.Designer.cs
@@ -700,20 +700,20 @@ public static string Theme {
}
///
- /// Looks up a localized string similar to to paste login.
+ /// Looks up a localized string similar to to paste combination.
///
- public static string ToPasteLogin {
+ public static string ToPasteCombination {
get {
- return ResourceManager.GetString("ToPasteLogin", resourceCulture);
+ return ResourceManager.GetString("ToPasteCombination", resourceCulture);
}
}
///
- /// Looks up a localized string similar to to paste password.
+ /// Looks up a localized string similar to to paste login or password.
///
- public static string ToPastePassword {
+ public static string ToPasteLoginOrPassword {
get {
- return ResourceManager.GetString("ToPastePassword", resourceCulture);
+ return ResourceManager.GetString("ToPasteLoginOrPassword", resourceCulture);
}
}
diff --git a/SinglePass.Language/Properties/Resources.resx b/SinglePass.Language/Properties/Resources.resx
index 457f190..a1beb31 100644
--- a/SinglePass.Language/Properties/Resources.resx
+++ b/SinglePass.Language/Properties/Resources.resx
@@ -325,11 +325,11 @@
Can't merge credentials
-
- to paste login
+
+ to paste combination
-
- to paste password
+
+ to paste login or password
Theme
diff --git a/SinglePass.Language/Properties/Resources.ru.resx b/SinglePass.Language/Properties/Resources.ru.resx
index 59c2747..2912e69 100644
--- a/SinglePass.Language/Properties/Resources.ru.resx
+++ b/SinglePass.Language/Properties/Resources.ru.resx
@@ -345,11 +345,11 @@
Нет изменений
-
- для вставки логина
+
+ для вставки комбинации
-
- для вставки пароля
+
+ для вставки логина или пароля
Тема
diff --git a/SinglePass.WPF/Helpers/WindowsKeyboard.cs b/SinglePass.WPF/Helpers/WindowsKeyboard.cs
index 3ef0adc..c2f2cb4 100644
--- a/SinglePass.WPF/Helpers/WindowsKeyboard.cs
+++ b/SinglePass.WPF/Helpers/WindowsKeyboard.cs
@@ -7,6 +7,7 @@ internal static class WindowsKeyboard
{
public const byte VK_V = 0x56;
public const byte VK_CONTROL = 0x11;
+ public const byte VK_TAB = 0x09;
public const int KEYEVENTF_KEYUP = 0x0002;
public const uint WM_PASTE = 0x0302;
diff --git a/SinglePass.WPF/ViewModels/PopupViewModel.cs b/SinglePass.WPF/ViewModels/PopupViewModel.cs
index 17b805e..8fa8bde 100644
--- a/SinglePass.WPF/ViewModels/PopupViewModel.cs
+++ b/SinglePass.WPF/ViewModels/PopupViewModel.cs
@@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
using Unidecode.NET;
@@ -74,6 +75,72 @@ private void Close()
Accept?.Invoke();
}
+ [RelayCommand]
+ private void SetFullAndClose(CredentialViewModel credentialViewModel)
+ {
+ try
+ {
+ Accept?.Invoke();
+
+ WindowsClipboard.SetText(credentialViewModel.LoginFieldVM.Value);
+
+ INPUT[] inputs = new INPUT[4];
+
+ // Ctrl+V
+ inputs[0].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[0].U.ki.wVk = WindowsKeyboard.VK_CONTROL;
+
+ inputs[1].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[1].U.ki.wVk = WindowsKeyboard.VK_V;
+
+ inputs[2].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[2].U.ki.wVk = WindowsKeyboard.VK_V;
+ inputs[2].U.ki.dwFlags = WindowsKeyboard.KEYEVENTF_KEYUP;
+
+ inputs[3].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[3].U.ki.wVk = WindowsKeyboard.VK_CONTROL;
+ inputs[3].U.ki.dwFlags = WindowsKeyboard.KEYEVENTF_KEYUP;
+
+ var uSent = WindowsKeyboard.SendInput((uint)inputs.Length, inputs, INPUT.Size);
+
+ // Pause between Ctrl+V and set clipboard
+ Thread.Sleep(100);
+
+ WindowsClipboard.SetText(credentialViewModel.PasswordFieldVM.Value);
+
+ inputs = new INPUT[6];
+
+ // Tab
+ inputs[0].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[0].U.ki.wVk = WindowsKeyboard.VK_TAB;
+
+ inputs[1].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[1].U.ki.wVk = WindowsKeyboard.VK_TAB;
+ inputs[1].U.ki.dwFlags = WindowsKeyboard.KEYEVENTF_KEYUP;
+
+ // Ctrl+V
+ inputs[2].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[2].U.ki.wVk = WindowsKeyboard.VK_CONTROL;
+
+ inputs[3].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[3].U.ki.wVk = WindowsKeyboard.VK_V;
+
+ inputs[4].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[4].U.ki.wVk = WindowsKeyboard.VK_V;
+ inputs[4].U.ki.dwFlags = WindowsKeyboard.KEYEVENTF_KEYUP;
+
+ inputs[5].type = WindowsKeyboard.INPUT_KEYBOARD;
+ inputs[5].U.ki.wVk = WindowsKeyboard.VK_CONTROL;
+ inputs[5].U.ki.dwFlags = WindowsKeyboard.KEYEVENTF_KEYUP;
+
+ uSent = WindowsKeyboard.SendInput((uint)inputs.Length, inputs, INPUT.Size);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, null);
+ }
+ }
+
[RelayCommand]
private void SetAndClose(PassFieldViewModel passFieldViewModel)
{
diff --git a/SinglePass.WPF/Views/Controls/SettingsControl.xaml b/SinglePass.WPF/Views/Controls/SettingsControl.xaml
index 6ee5d5f..fa7dad1 100644
--- a/SinglePass.WPF/Views/Controls/SettingsControl.xaml
+++ b/SinglePass.WPF/Views/Controls/SettingsControl.xaml
@@ -185,10 +185,10 @@
VerticalAlignment="Center"
Opacity="0.5">
-
+
-
-
+
+
diff --git a/SinglePass.WPF/Views/Windows/PopupWindow.xaml.cs b/SinglePass.WPF/Views/Windows/PopupWindow.xaml.cs
index 02eee4c..1ccc225 100644
--- a/SinglePass.WPF/Views/Windows/PopupWindow.xaml.cs
+++ b/SinglePass.WPF/Views/Windows/PopupWindow.xaml.cs
@@ -52,32 +52,42 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
IsClosed = true;
}
- private void MaterialWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
+ private void MaterialWindow_Loaded(object sender, RoutedEventArgs e)
{
Application.Current.Dispatcher.InvokeAsync(() => SearchTextBox.Focus());
}
- private void MaterialWindow_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
+ private void MaterialWindow_PreviewKeyDown(object sender, KeyEventArgs e)
{
- var isCtrlDown = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);
- var isEnterDown = e.Key == Key.Enter;
+ if (e.Key == Key.Escape)
+ {
+ Close();
+ return;
+ }
- if (isEnterDown)
+ if (e.Key == Key.Enter)
{
- if (isCtrlDown)
+ // Enter
+ ViewModel.SetFullAndCloseCommand.Execute(ViewModel.SelectedCredentialVM);
+ return;
+ }
+
+ if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
+ {
+ // Ctrl+1
+ if (e.Key == Key.NumPad1 || e.Key == Key.D1)
{
- // This is Ctrl + Enter
- ViewModel.SetAndCloseCommand.Execute(ViewModel.SelectedCredentialVM.PasswordFieldVM);
+ ViewModel.SetAndCloseCommand.Execute(ViewModel.SelectedCredentialVM.LoginFieldVM);
+ return;
}
- else
+
+ // Ctrl+2
+ if (e.Key == Key.NumPad2 || e.Key == Key.D2)
{
- // This is Enter
- ViewModel.SetAndCloseCommand.Execute(ViewModel.SelectedCredentialVM.LoginFieldVM);
+ ViewModel.SetAndCloseCommand.Execute(ViewModel.SelectedCredentialVM.PasswordFieldVM);
+ return;
}
}
-
- if (e.Key == System.Windows.Input.Key.Escape)
- Close();
}
private void MaterialWindow_Closed(object sender, EventArgs e)