mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 02:06:30 +00:00
add left menu with icons
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user