mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:36:30 +00:00
big refactoring. get rid of static properties and coupled architecture. prepare system for integration tests
This commit is contained in:
@@ -35,6 +35,7 @@ public partial class DatasetExplorer
|
||||
|
||||
private readonly IAzaionApi _azaionApi;
|
||||
private readonly IConfigUpdater _configUpdater;
|
||||
private readonly IAnnotationPathResolver _pathResolver;
|
||||
|
||||
public bool ThumbnailLoading { get; set; }
|
||||
public string CurrentFilter { get; set; } = "";
|
||||
@@ -51,7 +52,8 @@ public partial class DatasetExplorer
|
||||
IDbFactory dbFactory,
|
||||
IMediator mediator,
|
||||
IAzaionApi azaionApi,
|
||||
IConfigUpdater configUpdater)
|
||||
IConfigUpdater configUpdater,
|
||||
IAnnotationPathResolver pathResolver)
|
||||
{
|
||||
InitializeComponent();
|
||||
_appConfig = appConfig.Value;
|
||||
@@ -61,6 +63,7 @@ public partial class DatasetExplorer
|
||||
_mediator = mediator;
|
||||
_azaionApi = azaionApi;
|
||||
_configUpdater = configUpdater;
|
||||
_pathResolver = pathResolver;
|
||||
|
||||
ShowWithObjectsOnlyChBox.IsChecked = _appConfig.UIConfig.ShowDatasetWithDetectionsOnly;
|
||||
var photoModes = Enum.GetValues(typeof(PhotoMode)).Cast<PhotoMode>().ToList();
|
||||
@@ -196,7 +199,7 @@ public partial class DatasetExplorer
|
||||
ThumbnailsView.SelectedIndex = index;
|
||||
|
||||
var ann = CurrentAnnotation.Annotation;
|
||||
var image = await ann.ImagePath.OpenImage();
|
||||
var image = await _pathResolver.GetImagePath(ann).OpenImage();
|
||||
ExplorerEditor.SetBackground(image);
|
||||
SelectedAnnotationName.Text = ann.Name;
|
||||
SwitchTab(toEditor: true);
|
||||
@@ -264,7 +267,11 @@ public partial class DatasetExplorer
|
||||
var annThumbnails = _annotationsDict[ExplorerEditor.CurrentAnnClass!.YoloId]
|
||||
.WhereIf(withDetectionsOnly, x => x.Value.Detections.Any())
|
||||
.WhereIf(!string.IsNullOrEmpty(CurrentFilter), x => x.Key.Contains(CurrentFilter, StringComparison.CurrentCultureIgnoreCase))
|
||||
.Select(x => new AnnotationThumbnail(x.Value, currentUser.Role.IsValidator()))
|
||||
.Select(x => new AnnotationThumbnail(
|
||||
x.Value,
|
||||
currentUser.Role.IsValidator(),
|
||||
_pathResolver.GetImagePath(x.Value),
|
||||
_pathResolver.GetThumbPath(x.Value)))
|
||||
.OrderBy(x => !x.IsSeed)
|
||||
.ThenByDescending(x =>x.Annotation.CreatedDate);
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@ public class DatasetExplorerEventHandler(
|
||||
ILogger<DatasetExplorerEventHandler> logger,
|
||||
DatasetExplorer datasetExplorer,
|
||||
IAnnotationService annotationService,
|
||||
IAzaionApi azaionApi) :
|
||||
IAzaionApi azaionApi,
|
||||
IUICommandDispatcher uiDispatcher,
|
||||
IAnnotationPathResolver pathResolver) :
|
||||
INotificationHandler<KeyEvent>,
|
||||
INotificationHandler<DatasetExplorerControlEvent>,
|
||||
INotificationHandler<AnnotationCreatedEvent>,
|
||||
@@ -121,7 +123,7 @@ public class DatasetExplorerEventHandler(
|
||||
|
||||
public async Task Handle(AnnotationCreatedEvent notification, CancellationToken token)
|
||||
{
|
||||
await datasetExplorer.Dispatcher.Invoke(async () =>
|
||||
await uiDispatcher.ExecuteAsync(async () =>
|
||||
{
|
||||
var annotation = notification.Annotation;
|
||||
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
|
||||
@@ -132,7 +134,11 @@ public class DatasetExplorerEventHandler(
|
||||
|
||||
var index = 0;
|
||||
var currentUser = await azaionApi.GetCurrentUserAsync();
|
||||
var annThumb = new AnnotationThumbnail(annotation, currentUser.Role.IsValidator());
|
||||
var annThumb = new AnnotationThumbnail(
|
||||
annotation,
|
||||
currentUser.Role.IsValidator(),
|
||||
pathResolver.GetImagePath(annotation),
|
||||
pathResolver.GetThumbPath(annotation));
|
||||
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
|
||||
{
|
||||
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
|
||||
@@ -153,7 +159,7 @@ public class DatasetExplorerEventHandler(
|
||||
{
|
||||
try
|
||||
{
|
||||
datasetExplorer.Dispatcher.Invoke(() =>
|
||||
uiDispatcher.Execute(() =>
|
||||
{
|
||||
var annThumbs = datasetExplorer.SelectedAnnotationDict
|
||||
.Where(x => notification.AnnotationNames.Contains(x.Key))
|
||||
|
||||
Reference in New Issue
Block a user