mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 23:26:30 +00:00
add badge with window switch on the top right
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user