mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 17:46:36 +00:00
rework to have only 1 exe!
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user