add badge with window switch on the top right

This commit is contained in:
Alex Bezdieniezhnykh
2024-11-28 18:04:34 +02:00
parent 7430b33b8e
commit 0290d8f5db
17 changed files with 160 additions and 96 deletions
+16 -9
View File
@@ -1,7 +1,6 @@
using System.IO;
using System.Net.Http;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using Azaion.Annotator;
@@ -104,7 +103,7 @@ public partial class App
services.ConfigureSection<ApiConfig>(context.Configuration);
services.ConfigureSection<DirectoriesConfig>(context.Configuration);
services.ConfigureSection<AnnotationConfig>(context.Configuration);
services.ConfigureSection<WindowConfig>(context.Configuration);
services.ConfigureSection<AnnotatorWindowConfig>(context.Configuration);
services.ConfigureSection<AIRecognitionConfig>(context.Configuration);
services.ConfigureSection<ThumbnailConfig>(context.Configuration);
@@ -171,18 +170,26 @@ public partial class App
_ = ThrottleExt.Throttle(() => _mediator.Publish(keyEvent), TimeSpan.FromMilliseconds(50));
}
private readonly Dictionary<string, WindowEnum> _uiElementToWindowEnum = new()
{
{ "LibVLCSharp.WPF.ForegroundWindow", WindowEnum.Annotator },
{ "Azaion.Annotator.Annotator", WindowEnum.Annotator },
{ "Azaion.Annotator.DatasetExplorer", WindowEnum.DatasetExplorer }
};
private WindowEnum GetParentWindow(FrameworkElement? element)
{
if (element?.GetType().Name == "LibVLCSharp.WPF.ForegroundWindow")
return WindowEnum.Annotator;
while (element != null)
{
var windowEnum = _uiElementToWindowEnum!.GetValueOrDefault(element.GetType().FullName);
if (windowEnum != WindowEnum.None)
return windowEnum;
while (element != null && element is not TabItem)
element = element.Parent as FrameworkElement;
}
if (element is not TabItem || element.Tag == null)
return WindowEnum.None;
return (WindowEnum)element.Tag;
return WindowEnum.None;
}