fix keyboard event retrieving for dataset explorer

This commit is contained in:
Alex Bezdieniezhnykh
2024-12-05 00:34:00 +02:00
parent 60519461a1
commit 626767469a
3 changed files with 4 additions and 6 deletions
+1 -3
View File
@@ -24,7 +24,6 @@ public partial class DatasetExplorer
private int _tempSelectedClassIdx = 0; private int _tempSelectedClassIdx = 0;
private readonly IGalleryManager _galleryManager; private readonly IGalleryManager _galleryManager;
private readonly FormState _formState;
public bool ThumbnailLoading { get; set; } public bool ThumbnailLoading { get; set; }
@@ -41,10 +40,10 @@ public partial class DatasetExplorer
_annotationConfig = annotationConfig.Value; _annotationConfig = annotationConfig.Value;
_logger = logger; _logger = logger;
_galleryManager = galleryManager; _galleryManager = galleryManager;
_formState = formState;
InitializeComponent(); InitializeComponent();
Loaded += OnLoaded; Loaded += OnLoaded;
Activated += (_, _) => formState.ActiveWindow = WindowEnum.DatasetExplorer;
ThumbnailsView.KeyDown += async (sender, args) => ThumbnailsView.KeyDown += async (sender, args) =>
{ {
@@ -109,7 +108,6 @@ public partial class DatasetExplorer
foreach (var ann in ExplorerEditor.CurrentAnns.Where(x => x.IsSelected)) foreach (var ann in ExplorerEditor.CurrentAnns.Where(x => x.IsSelected))
ann.AnnotationClass = selectedClass; ann.AnnotationClass = selectedClass;
}; };
Activated += (_, _) => _formState.ActiveWindow = WindowEnum.Annotator;
LvClasses.SelectedIndex = _annotationConfig.LastSelectedExplorerClass ?? 0; LvClasses.SelectedIndex = _annotationConfig.LastSelectedExplorerClass ?? 0;
ExplorerEditor.CurrentAnnClass = (AnnotationClass)LvClasses.SelectedItem; ExplorerEditor.CurrentAnnClass = (AnnotationClass)LvClasses.SelectedItem;
+1 -3
View File
@@ -88,9 +88,8 @@ public partial class App
AppDomain.CurrentDomain.AssemblyResolve += (_, a) => _resourceLoader.LoadAssembly(a.Name); AppDomain.CurrentDomain.AssemblyResolve += (_, a) => _resourceLoader.LoadAssembly(a.Name);
StartMain(); StartMain();
EventManager.RegisterClassHandler(typeof(UIElement), UIElement.KeyDownEvent, new RoutedEventHandler(GlobalClick));
await _host.StartAsync(); await _host.StartAsync();
EventManager.RegisterClassHandler(typeof(UIElement), UIElement.KeyDownEvent, new RoutedEventHandler(GlobalClick));
_host.Services.GetRequiredService<MainSuite>().Show(); _host.Services.GetRequiredService<MainSuite>().Show();
}; };
@@ -169,7 +168,6 @@ public partial class App
private void GlobalClick(object sender, RoutedEventArgs e) private void GlobalClick(object sender, RoutedEventArgs e)
{ {
var args = (KeyEventArgs)e; var args = (KeyEventArgs)e;
var keyEvent = new KeyEvent(sender, args, _formState.ActiveWindow); var keyEvent = new KeyEvent(sender, args, _formState.ActiveWindow);
_ = ThrottleExt.Throttle(() => _mediator.Publish(keyEvent), TimeSpan.FromMilliseconds(50)); _ = ThrottleExt.Throttle(() => _mediator.Publish(keyEvent), TimeSpan.FromMilliseconds(50));
} }
+2
View File
@@ -16,6 +16,8 @@ public partial class Login
private void LoginClick(object sender, RoutedEventArgs e) private void LoginClick(object sender, RoutedEventArgs e)
{ {
LoginBtn.Cursor = Cursors.Wait;
Cursor = Cursors.Wait;
CredentialsEntered?.Invoke(this, new ApiCredentials(TbEmail.Text, TbPassword.Password)); CredentialsEntered?.Invoke(this, new ApiCredentials(TbEmail.Text, TbPassword.Password));
Close(); Close();
} }