add left menu with icons

This commit is contained in:
Alex Bezdieniezhnykh
2024-11-24 02:09:04 +02:00
parent c1b74cdc00
commit b61bed3b51
9 changed files with 177 additions and 16 deletions
+4 -1
View File
@@ -142,6 +142,9 @@ public partial class App
services.AddSingleton<DatasetExplorer>();
services.AddSingleton<IGalleryManager, GalleryManager>();
services.AddSingleton<IAzaionModule, AnnotatorModule>();
services.AddSingleton<IAzaionModule, DatasetExplorerModule>();
})
.Build();
_mediator = _host.Services.GetRequiredService<IMediator>();
@@ -176,6 +179,6 @@ public partial class App
base.OnExit(e);
await _host.StopAsync();
_host.Dispose();
//_host.Dispose();
}
}
+2
View File
@@ -22,6 +22,8 @@
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="SharpVectors" Version="1.8.4.2" />
<PackageReference Include="SharpVectors.Wpf" Version="1.8.4.2" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.21" />
</ItemGroup>
+1 -1
View File
@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Title="MainSuite" Height="450" Width="800">
<Grid>
<Grid Background="Black">
<TabControl Name="MainTabControl"
TabStripPlacement="Left"
Margin="0, 0, 0, 10"
+41 -14
View File
@@ -1,10 +1,15 @@
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Azaion.Annotator.Extensions;
using Azaion.Common.DTO;
using Azaion.Common.DTO.Config;
using Azaion.Dataset;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using SharpVectors.Converters;
namespace Azaion.Suite;
@@ -12,14 +17,15 @@ public partial class MainSuite
{
private readonly AppConfig _appConfig;
private readonly IConfigUpdater _configUpdater;
private readonly Annotator.Annotator _annotator;
private readonly DatasetExplorer _datasetExplorer;
private readonly IEnumerable<IAzaionModule> _modules;
private readonly IServiceProvider _sp;
private readonly List<Window> _openedWindows = new();
public MainSuite(IOptions<AppConfig> appConfig, IConfigUpdater configUpdater, Annotator.Annotator annotator, DatasetExplorer datasetExplorer)
public MainSuite(IOptions<AppConfig> appConfig, IConfigUpdater configUpdater, IEnumerable<IAzaionModule> modules, IServiceProvider sp )
{
_configUpdater = configUpdater;
_annotator = annotator;
_datasetExplorer = datasetExplorer;
_modules = modules;
_sp = sp;
_appConfig = appConfig.Value;
InitializeComponent();
Loaded += OnLoaded;
@@ -48,16 +54,34 @@ public partial class MainSuite
if (_appConfig.WindowConfig.FullScreen)
WindowState = WindowState.Maximized;
MainTabControl.Items.Add(new TabItem
foreach (var azaionModule in _modules)
{
Header = "Annotator",
Content = _annotator.Content
});
MainTabControl.Items.Add(new TabItem
{
Header = "Dataset Explorer",
Content = _datasetExplorer.Content
});
var window = (_sp.GetRequiredService(azaionModule.MainWindowType) as Window)!;
_openedWindows.Add(window);
var icon = new SvgViewbox
{
SvgSource = azaionModule.SvgIcon,
Width = 32,
Height = 32,
Margin = new Thickness(0, 0, 10, 0)
};
var text = new TextBlock
{
Text = azaionModule.Name,
Foreground = Brushes.White,
HorizontalAlignment = HorizontalAlignment.Center,
Background = Brushes.Black
};
var tabItem = new TabItem
{
Header = new StackPanel { Children = { icon, text } },
Content = window.Content,
Background = Brushes.Black,
Foreground = Brushes.White,
Cursor = Cursors.Hand
};
MainTabControl.Items.Add(tabItem);
}
}
private async Task SaveUserSettings()
@@ -72,5 +96,8 @@ public partial class MainSuite
private void OnFormClosed(object? sender, EventArgs e)
{
_configUpdater.Save(_appConfig);
foreach (var window in _openedWindows)
window.Close();
Application.Current.Shutdown();
}
}