diff --git a/Azaion.Annotator/Annotator.xaml b/Azaion.Annotator/Annotator.xaml index b2f7911..24161c8 100644 --- a/Azaion.Annotator/Annotator.xaml +++ b/Azaion.Annotator/Annotator.xaml @@ -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" > diff --git a/Azaion.Annotator/Annotator.xaml.cs b/Azaion.Annotator/Annotator.xaml.cs index 7a96d2a..1c52a90 100644 --- a/Azaion.Annotator/Annotator.xaml.cs +++ b/Azaion.Annotator/Annotator.xaml.cs @@ -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(() => { diff --git a/Azaion.Annotator/Extensions/WindowExtensions.cs b/Azaion.Annotator/Extensions/WindowExtensions.cs deleted file mode 100644 index fe72f66..0000000 --- a/Azaion.Annotator/Extensions/WindowExtensions.cs +++ /dev/null @@ -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 - }; -} \ No newline at end of file diff --git a/Azaion.Annotator/HelpWindow.xaml.cs b/Azaion.Annotator/HelpWindow.xaml.cs index b9e3518..f5e7cc3 100644 --- a/Azaion.Annotator/HelpWindow.xaml.cs +++ b/Azaion.Annotator/HelpWindow.xaml.cs @@ -6,12 +6,12 @@ namespace Azaion.Annotator; public partial class HelpWindow : Window { - private readonly WindowConfig _windowConfig; + private readonly AnnotatorWindowConfig _annotatorWindowConfig; - public HelpWindow(IOptions windowConfig) + public HelpWindow(IOptions 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; } \ No newline at end of file diff --git a/Azaion.Common/Constants.cs b/Azaion.Common/Constants.cs index f5295ec..8464329 100644 --- a/Azaion.Common/Constants.cs +++ b/Azaion.Common/Constants.cs @@ -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"; diff --git a/Azaion.Common/DTO/Config/AnnotatorWindowConfig.cs b/Azaion.Common/DTO/Config/AnnotatorWindowConfig.cs new file mode 100644 index 0000000..6c7d8aa --- /dev/null +++ b/Azaion.Common/DTO/Config/AnnotatorWindowConfig.cs @@ -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; } +} \ No newline at end of file diff --git a/Azaion.Common/DTO/Config/AppConfig.cs b/Azaion.Common/DTO/Config/AppConfig.cs index 84528cb..60cdb37 100644 --- a/Azaion.Common/DTO/Config/AppConfig.cs +++ b/Azaion.Common/DTO/Config/AppConfig.cs @@ -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 diff --git a/Azaion.Common/DTO/Config/WindowConfig.cs b/Azaion.Common/DTO/Config/WindowConfig.cs deleted file mode 100644 index 98a5097..0000000 --- a/Azaion.Common/DTO/Config/WindowConfig.cs +++ /dev/null @@ -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; } -} \ No newline at end of file diff --git a/Azaion.Dataset/DatasetExplorer.xaml b/Azaion.Dataset/DatasetExplorer.xaml index f267355..87aeff0 100644 --- a/Azaion.Dataset/DatasetExplorer.xaml +++ b/Azaion.Dataset/DatasetExplorer.xaml @@ -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"> diff --git a/Azaion.Dataset/DatasetExplorerModule.cs b/Azaion.Dataset/DatasetExplorerModule.cs index 37a2922..c907ec5 100644 --- a/Azaion.Dataset/DatasetExplorerModule.cs +++ b/Azaion.Dataset/DatasetExplorerModule.cs @@ -4,7 +4,7 @@ namespace Azaion.Dataset; public class DatasetExplorerModule : IAzaionModule { - public string Name => "Переглядач Анотацій"; + public string Name => "Переглядач"; public string SvgIcon => @" diff --git a/Azaion.Launcher/Loader.xaml.cs b/Azaion.Launcher/Loader.xaml.cs index 13a66c4..299aa78 100644 --- a/Azaion.Launcher/Loader.xaml.cs +++ b/Azaion.Launcher/Loader.xaml.cs @@ -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(); diff --git a/Azaion.Suite/App.xaml.cs b/Azaion.Suite/App.xaml.cs index a8bcd56..f7ee763 100644 --- a/Azaion.Suite/App.xaml.cs +++ b/Azaion.Suite/App.xaml.cs @@ -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(context.Configuration); services.ConfigureSection(context.Configuration); services.ConfigureSection(context.Configuration); - services.ConfigureSection(context.Configuration); + services.ConfigureSection(context.Configuration); services.ConfigureSection(context.Configuration); services.ConfigureSection(context.Configuration); @@ -171,18 +170,26 @@ public partial class App _ = ThrottleExt.Throttle(() => _mediator.Publish(keyEvent), TimeSpan.FromMilliseconds(50)); } + private readonly Dictionary _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; } diff --git a/Azaion.Suite/Azaion.Suite.csproj b/Azaion.Suite/Azaion.Suite.csproj index cb5a641..6d11ed8 100644 --- a/Azaion.Suite/Azaion.Suite.csproj +++ b/Azaion.Suite/Azaion.Suite.csproj @@ -33,11 +33,18 @@ + + + + PreserveNewest + + + - + diff --git a/Azaion.Suite/MainSuite.xaml b/Azaion.Suite/MainSuite.xaml index 6ebe207..1589da7 100644 --- a/Azaion.Suite/MainSuite.xaml +++ b/Azaion.Suite/MainSuite.xaml @@ -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" > - - + + + + + + + + + + + + + + diff --git a/Azaion.Suite/MainSuite.xaml.cs b/Azaion.Suite/MainSuite.xaml.cs index bc9ec5f..8c8e790 100644 --- a/Azaion.Suite/MainSuite.xaml.cs +++ b/Azaion.Suite/MainSuite.xaml.cs @@ -18,7 +18,7 @@ public partial class MainSuite private readonly IConfigUpdater _configUpdater; private readonly IEnumerable _modules; private readonly IServiceProvider _sp; - private readonly List _openedWindows = new(); + private readonly Dictionary _openedWindows = new(); public MainSuite(IOptions appConfig, IConfigUpdater configUpdater, IEnumerable 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(); } \ No newline at end of file diff --git a/Azaion.Suite/logo.png b/Azaion.Suite/logo.png new file mode 100644 index 0000000..094e3c1 Binary files /dev/null and b/Azaion.Suite/logo.png differ diff --git a/Azaion.Suite/upload.cmd b/Azaion.Suite/upload.cmd index b013bc4..a0291f7 100644 --- a/Azaion.Suite/upload.cmd +++ b/Azaion.Suite/upload.cmd @@ -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... -echo Done! \ No newline at end of file +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!