rework to have only 1 exe!

This commit is contained in:
Alex Bezdieniezhnykh
2024-12-04 20:51:26 +02:00
parent 3944df8efe
commit 60519461a1
25 changed files with 194 additions and 198 deletions
+52 -47
View File
@@ -24,6 +24,7 @@ public partial class DatasetExplorer
private int _tempSelectedClassIdx = 0;
private readonly IGalleryManager _galleryManager;
private readonly FormState _formState;
public bool ThumbnailLoading { get; set; }
@@ -33,60 +34,17 @@ public partial class DatasetExplorer
IOptions<DirectoriesConfig> directoriesConfig,
IOptions<AnnotationConfig> annotationConfig,
ILogger<DatasetExplorer> logger,
IGalleryManager galleryManager)
IGalleryManager galleryManager,
FormState formState)
{
_directoriesConfig = directoriesConfig.Value;
_annotationConfig = annotationConfig.Value;
_logger = logger;
_galleryManager = galleryManager;
_formState = formState;
InitializeComponent();
Loaded += async (_, _) =>
{
_ = Task.Run(async () => await _galleryManager.RefreshThumbnails());
AllAnnotationClasses = new ObservableCollection<AnnotationClass>(
new List<AnnotationClass> { new() {Id = -1, Name = "All", ShortName = "All"}}
.Concat(_annotationConfig.AnnotationClasses));
LvClasses.ItemsSource = AllAnnotationClasses;
LvClasses.MouseUp += async (_, _) =>
{
var selectedClass = (AnnotationClass)LvClasses.SelectedItem;
ExplorerEditor.CurrentAnnClass = selectedClass;
_annotationConfig.LastSelectedExplorerClass = selectedClass.Id;
if (Switcher.SelectedIndex == 0)
await ReloadThumbnails();
else
foreach (var ann in ExplorerEditor.CurrentAnns.Where(x => x.IsSelected))
ann.AnnotationClass = selectedClass;
};
LvClasses.SelectionChanged += (_, _) =>
{
if (Switcher.SelectedIndex != 1)
return;
var selectedClass = (AnnotationClass)LvClasses.SelectedItem;
if (selectedClass == null)
return;
ExplorerEditor.CurrentAnnClass = selectedClass;
foreach (var ann in ExplorerEditor.CurrentAnns.Where(x => x.IsSelected))
ann.AnnotationClass = selectedClass;
};
LvClasses.SelectedIndex = _annotationConfig.LastSelectedExplorerClass ?? 0;
ExplorerEditor.CurrentAnnClass = (AnnotationClass)LvClasses.SelectedItem;
await ReloadThumbnails();
LoadClassDistribution();
RefreshThumbBar.Value = galleryManager.ThumbnailsPercentage;
DataContext = this;
};
Loaded += OnLoaded;
ThumbnailsView.KeyDown += async (sender, args) =>
{
@@ -115,6 +73,53 @@ public partial class DatasetExplorer
}
private async void OnLoaded(object sender, RoutedEventArgs e)
{
_ = Task.Run(async () => await _galleryManager.RefreshThumbnails());
AllAnnotationClasses = new ObservableCollection<AnnotationClass>(
new List<AnnotationClass> { new() {Id = -1, Name = "All", ShortName = "All"}}
.Concat(_annotationConfig.AnnotationClasses));
LvClasses.ItemsSource = AllAnnotationClasses;
LvClasses.MouseUp += async (_, _) =>
{
var selectedClass = (AnnotationClass)LvClasses.SelectedItem;
ExplorerEditor.CurrentAnnClass = selectedClass;
_annotationConfig.LastSelectedExplorerClass = selectedClass.Id;
if (Switcher.SelectedIndex == 0)
await ReloadThumbnails();
else
foreach (var ann in ExplorerEditor.CurrentAnns.Where(x => x.IsSelected))
ann.AnnotationClass = selectedClass;
};
LvClasses.SelectionChanged += (_, _) =>
{
if (Switcher.SelectedIndex != 1)
return;
var selectedClass = (AnnotationClass)LvClasses.SelectedItem;
if (selectedClass == null)
return;
ExplorerEditor.CurrentAnnClass = selectedClass;
foreach (var ann in ExplorerEditor.CurrentAnns.Where(x => x.IsSelected))
ann.AnnotationClass = selectedClass;
};
Activated += (_, _) => _formState.ActiveWindow = WindowEnum.Annotator;
LvClasses.SelectedIndex = _annotationConfig.LastSelectedExplorerClass ?? 0;
ExplorerEditor.CurrentAnnClass = (AnnotationClass)LvClasses.SelectedItem;
await ReloadThumbnails();
LoadClassDistribution();
RefreshThumbBar.Value = _galleryManager.ThumbnailsPercentage;
DataContext = this;
}
private void LoadClassDistribution()
{
var data = _galleryManager.LabelsCache