mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:56:29 +00:00
76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
using System.IO;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using Azaion.Annotator.Extensions;
|
|
using Azaion.Common.DTO.Config;
|
|
using Azaion.Dataset;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace Azaion.Suite;
|
|
|
|
public partial class MainSuite
|
|
{
|
|
private readonly AppConfig _appConfig;
|
|
private readonly IConfigUpdater _configUpdater;
|
|
private readonly Annotator.Annotator _annotator;
|
|
private readonly DatasetExplorer _datasetExplorer;
|
|
|
|
public MainSuite(IOptions<AppConfig> appConfig, IConfigUpdater configUpdater, Annotator.Annotator annotator, DatasetExplorer datasetExplorer)
|
|
{
|
|
_configUpdater = configUpdater;
|
|
_annotator = annotator;
|
|
_datasetExplorer = datasetExplorer;
|
|
_appConfig = appConfig.Value;
|
|
InitializeComponent();
|
|
Loaded += OnLoaded;
|
|
Closed += OnFormClosed;
|
|
|
|
SizeChanged += async (_, _) => await SaveUserSettings();
|
|
LocationChanged += async (_, _) => await SaveUserSettings();
|
|
StateChanged += async (_, _) => await SaveUserSettings();
|
|
}
|
|
|
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!Directory.Exists(_appConfig.DirectoriesConfig.LabelsDirectory))
|
|
Directory.CreateDirectory(_appConfig.DirectoriesConfig.LabelsDirectory);
|
|
if (!Directory.Exists(_appConfig.DirectoriesConfig.ImagesDirectory))
|
|
Directory.CreateDirectory(_appConfig.DirectoriesConfig.ImagesDirectory);
|
|
if (!Directory.Exists(_appConfig.DirectoriesConfig.ResultsDirectory))
|
|
Directory.CreateDirectory(_appConfig.DirectoriesConfig.ResultsDirectory);
|
|
|
|
|
|
Left = _appConfig.WindowConfig.WindowLocation.X;
|
|
Top = _appConfig.WindowConfig.WindowLocation.Y;
|
|
Width = _appConfig.WindowConfig.WindowSize.Width;
|
|
Height = _appConfig.WindowConfig.WindowSize.Height;
|
|
|
|
if (_appConfig.WindowConfig.FullScreen)
|
|
WindowState = WindowState.Maximized;
|
|
|
|
MainTabControl.Items.Add(new TabItem
|
|
{
|
|
Header = "Annotator",
|
|
Content = _annotator.Content
|
|
});
|
|
MainTabControl.Items.Add(new TabItem
|
|
{
|
|
Header = "Dataset Explorer",
|
|
Content = _datasetExplorer.Content
|
|
});
|
|
}
|
|
|
|
private async Task SaveUserSettings()
|
|
{
|
|
await ThrottleExt.Throttle(() =>
|
|
{
|
|
_configUpdater.Save(_appConfig);
|
|
return Task.CompletedTask;
|
|
}, TimeSpan.FromSeconds(5));
|
|
}
|
|
|
|
private void OnFormClosed(object? sender, EventArgs e)
|
|
{
|
|
_configUpdater.Save(_appConfig);
|
|
}
|
|
} |