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
+2 -1
View File
@@ -7,7 +7,8 @@
xmlns:controls1="clr-namespace:Azaion.Common.Controls;assembly=Azaion.Common"
xmlns:controls2="clr-namespace:Azaion.Annotator.Controls;assembly=Azaion.Common"
mc:Ignorable="d"
Title="Azaion Annotator" Height="450" Width="1100"
Title="Azaion Annotator" Height="800" Width="1100"
WindowState="Maximized"
>
<Window.Resources>
+6 -6
View File
@@ -76,21 +76,21 @@ public partial class Annotator
_vlcFrameExtractor = vlcFrameExtractor;
_aiDetector = aiDetector;
Loaded += VideoView_Loaded;
Loaded += OnLoaded;
Closed += OnFormClosed;
Editor.GetTimeFunc = () => TimeSpan.FromMilliseconds(_mediaPlayer.Time);
}
private void VideoView_Loaded(object sender, RoutedEventArgs e)
private void OnLoaded(object sender, RoutedEventArgs e)
{
Core.Initialize();
InitControls();
_suspendLayout = true;
MainGrid.ColumnDefinitions.FirstOrDefault()!.Width = new GridLength(_appConfig.WindowConfig.LeftPanelWidth);
MainGrid.ColumnDefinitions.LastOrDefault()!.Width = new GridLength(_appConfig.WindowConfig.RightPanelWidth);
MainGrid.ColumnDefinitions.FirstOrDefault()!.Width = new GridLength(_appConfig.AnnotatorWindowConfig.LeftPanelWidth);
MainGrid.ColumnDefinitions.LastOrDefault()!.Width = new GridLength(_appConfig.AnnotatorWindowConfig.RightPanelWidth);
_suspendLayout = false;
@@ -229,8 +229,8 @@ public partial class Annotator
if (_suspendLayout)
return;
_appConfig.WindowConfig.LeftPanelWidth = MainGrid.ColumnDefinitions.FirstOrDefault()!.Width.Value;
_appConfig.WindowConfig.RightPanelWidth = MainGrid.ColumnDefinitions.LastOrDefault()!.Width.Value;
_appConfig.AnnotatorWindowConfig.LeftPanelWidth = MainGrid.ColumnDefinitions.FirstOrDefault()!.Width.Value;
_appConfig.AnnotatorWindowConfig.RightPanelWidth = MainGrid.ColumnDefinitions.LastOrDefault()!.Width.Value;
await ThrottleExt.Throttle(() =>
{
@@ -1,16 +0,0 @@
using System.Windows;
using Azaion.Annotator.DTO;
using Azaion.Common.DTO.Config;
namespace Azaion.Annotator.Extensions;
public static class WindowExtensions
{
public static WindowConfig GetConfig(this Window window) =>
new()
{
WindowSize = new Size(window.Width, window.Height),
WindowLocation = new Point(window.Left, window.Top),
FullScreen = window.WindowState == WindowState.Maximized
};
}
+6 -6
View File
@@ -6,12 +6,12 @@ namespace Azaion.Annotator;
public partial class HelpWindow : Window
{
private readonly WindowConfig _windowConfig;
private readonly AnnotatorWindowConfig _annotatorWindowConfig;
public HelpWindow(IOptions<WindowConfig> windowConfig)
public HelpWindow(IOptions<AnnotatorWindowConfig> windowConfig)
{
_windowConfig = windowConfig.Value;
Loaded += (_, _) => CbShowHelp.IsChecked = _windowConfig.ShowHelpOnStart;
_annotatorWindowConfig = windowConfig.Value;
Loaded += (_, _) => CbShowHelp.IsChecked = _annotatorWindowConfig.ShowHelpOnStart;
Closing += (sender, args) =>
{
args.Cancel = true;
@@ -20,7 +20,7 @@ public partial class HelpWindow : Window
InitializeComponent();
}
private void CbShowHelp_OnChecked(object sender, RoutedEventArgs e) => _windowConfig.ShowHelpOnStart = true;
private void CbShowHelp_OnUnchecked(object sender, RoutedEventArgs e) => _windowConfig.ShowHelpOnStart = false;
private void CbShowHelp_OnChecked(object sender, RoutedEventArgs e) => _annotatorWindowConfig.ShowHelpOnStart = true;
private void CbShowHelp_OnUnchecked(object sender, RoutedEventArgs e) => _annotatorWindowConfig.ShowHelpOnStart = false;
}
+5 -4
View File
@@ -56,16 +56,17 @@ public class Constants
# endregion AIRecognitionConfig
# region WindowConfig
# region AnnotatorWindowConfig
public static readonly Size DefaultWindowSize = new(1280, 720);
public static readonly Point DefaultWindowLocation = new(100, 100);
public static readonly Size DefaultThumbnailSize = new(240, 135);
public static int DEFAULT_LEFT_PANEL_WIDTH = 250;
public static int DEFAULT_RIGHT_PANEL_WIDTH = 250;
#endregion
#region Thumbnails
public static readonly Size DefaultThumbnailSize = new(240, 135);
public const int DEFAULT_THUMBNAIL_BORDER = 10;
public const string THUMBNAIL_PREFIX = "_thumb";
@@ -0,0 +1,8 @@
namespace Azaion.Common.DTO.Config;
public class AnnotatorWindowConfig
{
public double LeftPanelWidth { get; set; }
public double RightPanelWidth { get; set; }
public bool ShowHelpOnStart { get; set; }
}
+4 -7
View File
@@ -12,7 +12,7 @@ public class AppConfig
public AnnotationConfig AnnotationConfig { get; set; } = null!;
public WindowConfig WindowConfig { get; set; } = null!;
public AnnotatorWindowConfig AnnotatorWindowConfig { get; set; } = null!;
public AIRecognitionConfig AIRecognitionConfig { get; set; } = null!;
@@ -51,13 +51,10 @@ public class ConfigUpdater : IConfigUpdater
ImageFormats = Constants.DefaultImageFormats,
},
WindowConfig = new WindowConfig
AnnotatorWindowConfig = new AnnotatorWindowConfig
{
WindowSize = Constants.DefaultWindowSize,
WindowLocation = Constants.DefaultWindowLocation,
FullScreen = true,
LeftPanelWidth = 250,
RightPanelWidth = 250,
LeftPanelWidth = Constants.DEFAULT_LEFT_PANEL_WIDTH,
RightPanelWidth = Constants.DEFAULT_RIGHT_PANEL_WIDTH
},
DirectoriesConfig = new DirectoriesConfig
-14
View File
@@ -1,14 +0,0 @@
using System.Windows;
namespace Azaion.Common.DTO.Config;
public class WindowConfig
{
public Size WindowSize { get; set; }
public Point WindowLocation { get; set; }
public bool FullScreen { get; set; }
public double LeftPanelWidth { get; set; }
public double RightPanelWidth { get; set; }
public bool ShowHelpOnStart { get; set; }
}
+2 -1
View File
@@ -9,7 +9,8 @@
xmlns:controls="clr-namespace:Azaion.Common.Controls;assembly=Azaion.Common"
xmlns:controls1="clr-namespace:Azaion.Annotator.Controls;assembly=Azaion.Common"
mc:Ignorable="d"
Title="Переглядач анотацій" Height="900" Width="1200">
Title="Переглядач анотацій" Height="900" Width="1200"
WindowState="Maximized">
<Window.Resources>
<DataTemplate x:Key="ThumbnailTemplate" DataType="{x:Type datasetExplorer:ThumbnailDto}">
+1 -1
View File
@@ -4,7 +4,7 @@ namespace Azaion.Dataset;
public class DatasetExplorerModule : IAzaionModule
{
public string Name => "Переглядач Анотацій";
public string Name => "Переглядач";
public string SvgIcon =>
@"<?xml version=""1.0"" encoding=""utf-8""?>
+3 -1
View File
@@ -12,9 +12,11 @@ public partial class Loader : Window
InitializeComponent();
}
private void RunClick(object sender, RoutedEventArgs e)
private async void RunClick(object sender, RoutedEventArgs e)
{
Process.Start("Azaion.Suite.exe", $"-e {TbEmail.Text} -p {TbPassword.Password}");
await Task.Delay(2000);
Close();
}
private void CloseClick(object sender, RoutedEventArgs e) => Close();
+15 -8
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;
}
+8 -1
View File
@@ -33,11 +33,18 @@
<ProjectReference Include="..\Azaion.Dataset\Azaion.Dataset.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="logo.png" />
<Content Include="logo.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="Build">
<MakeDir Directories="$(TargetDir)secure" />
<Move SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)secure" />
<Move SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)secure" />
<Exec Command="upload.cmd" />
<Exec Command="upload.cmd $(ConfigurationName)" />
</Target>
</Project>
+42 -3
View File
@@ -4,19 +4,58 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Title="Azaion Оператор" Height="100" Width="200"
Title="Azaion Оператор" Height="60" Width="214"
WindowStyle="None"
ResizeMode="NoResize"
Top="0"
Topmost="True"
>
<Grid>
<ListView Name="ListView" Background="Black" BorderBrush="Black">
<Grid Background="Black">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="24"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Padding="5">
<Image Source="logo.png" />
</Border>
<ListView
Grid.Column="1"
Name="ListView"
Background="Black" BorderBrush="Black">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<Border Grid.Column="2">
<Button
VerticalAlignment="Top"
Width="24"
Height="24"
ToolTip="Закрити" Background="Black" BorderBrush="Black" Cursor="Hand"
Name="CloseBtn"
Click="CloseBtn_OnClick">
<Path Stretch="Fill" Fill="LightGray" Data="M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166
4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166
19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289
17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z" />
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}" BorderThickness="1">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Border>
</Grid>
</Window>
+32 -10
View File
@@ -18,7 +18,7 @@ public partial class MainSuite
private readonly IConfigUpdater _configUpdater;
private readonly IEnumerable<IAzaionModule> _modules;
private readonly IServiceProvider _sp;
private readonly List<Window> _openedWindows = new();
private readonly Dictionary<WindowEnum, Window> _openedWindows = new();
public MainSuite(IOptions<AppConfig> appConfig, IConfigUpdater configUpdater, IEnumerable<IAzaionModule> modules, IServiceProvider sp )
{
@@ -33,7 +33,7 @@ public partial class MainSuite
SizeChanged += async (_, _) => await SaveUserSettings();
LocationChanged += async (_, _) => await SaveUserSettings();
StateChanged += async (_, _) => await SaveUserSettings();
Left = SystemParameters.WorkArea.Width - Width - 150;
Left = SystemParameters.WorkArea.Width - Width - 250;
}
private void OnLoaded(object sender, RoutedEventArgs e)
@@ -71,15 +71,35 @@ public partial class MainSuite
Cursor = Cursors.Hand,
Tag = azaionModule
};
lvItem.MouseUp += (sender, _) =>
{
var module = ((sender as ListViewItem)!.Tag as IAzaionModule)!;
var window = (_sp.GetRequiredService(module.MainWindowType) as Window)!;
_openedWindows.Add(window);
window.Show();
};
lvItem.MouseUp += (lv, _) => OpenWindow((lv as ListViewItem)!);
ListView.Items.Add(lvItem);
}
//by default show first
ListView.SelectedIndex = 0;
OpenWindow((ListView.Items[0] as ListViewItem)!);
}
private void OpenWindow(ListViewItem sender)
{
var module = (sender.Tag as IAzaionModule)!;
var window = (_sp.GetRequiredService(module.MainWindowType) as Window)!;
if (_openedWindows.ContainsKey(module.WindowEnum))
window.Activate();
else
{
_openedWindows[module.WindowEnum] = window;
window.Closed += (_, _) =>
{
_openedWindows.Remove(module.WindowEnum);
if (!_openedWindows.Any())
Close();
};
window.Show();
window.Activate();
}
}
private async Task SaveUserSettings()
@@ -95,7 +115,9 @@ public partial class MainSuite
{
_configUpdater.Save(_appConfig);
foreach (var window in _openedWindows)
window.Close();
window.Value.Close();
Application.Current.Shutdown();
}
private void CloseBtn_OnClick(object sender, RoutedEventArgs e) => Close();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

+24 -15
View File
@@ -1,14 +1,22 @@
setlocal enabledelayedexpansion
set CONFIG=%1
@echo off
set API_URL=https://api.azaion.com
set LOGIN_URL=https://api.azaion.com/login
set RESOURCE_URL=https://api.azaion.com/resources
set EMAIL=uploader@azaion.com
set PASSWORD=Az@1on_10Upl0@der
set FILE_TO_UPLOAD=bin\Release\net8.0-windows\secure\Azaion.Annotator.dll
set FILE1_TO_UPLOAD=%cd%\bin\%CONFIG%\net8.0-windows\secure\Azaion.Annotator.dll
set "FILE1_TO_UPLOAD=%FILE1_TO_UPLOAD:\=/%"
set FILE2_TO_UPLOAD=%cd%\bin\%CONFIG%\net8.0-windows\secure\Azaion.Dataset.dll
set "FILE2_TO_UPLOAD=%FILE2_TO_UPLOAD:\=/%"
echo Logging in and retrieving token...
for /f "tokens=*" %%i in ('curl -s -X POST -H "Content-Type: application/json" ^
-d "{\"email\":\"%EMAIL%\",\"password\":\"%PASSWORD%\"}" %LOGIN_URL%') do set RESPONSE=%%i
-d "{\"email\":\"%EMAIL%\",\"password\":\"%PASSWORD%\"}" %API_URL%/login') do set RESPONSE=%%i
for /f "tokens=2 delims=:" %%a in ('echo %RESPONSE% ^| findstr /i "token"') do (
set "TOKEN=%%a"
@@ -16,18 +24,19 @@ for /f "tokens=2 delims=:" %%a in ('echo %RESPONSE% ^| findstr /i "token"') do (
set "TOKEN=!TOKEN:~0,-2!"
)
echo Token retrieved: %TOKEN%
:: Step 2: Upload the DLL file
if not exist "%FILE_TO_UPLOAD%" (
echo File %FILE_TO_UPLOAD% does not exist. Exiting...
exit /b 1
)
echo Uploading file to resources...
curl -X POST -H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: application/octet-stream" ^
--data-binary @"%FILE_TO_UPLOAD%" ^
%RESOURCE_URL%
echo Uploading files to resources...
curl --location %API_URL%/resources ^
-H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: multipart/form-data" ^
--form "data=@%FILE1_TO_UPLOAD%"
curl --location %API_URL%/resources ^
-H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: multipart/form-data" ^
--form "data=@%FILE2_TO_UPLOAD%"
echo Done!