mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:26:31 +00:00
add MediaHash. Step1
This commit is contained in:
@@ -8,7 +8,6 @@ using System.Windows.Shapes;
|
||||
using Azaion.Common.Database;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.Extensions;
|
||||
using MediatR;
|
||||
using Color = System.Windows.Media.Color;
|
||||
using Image = System.Windows.Controls.Image;
|
||||
using Point = System.Windows.Point;
|
||||
@@ -20,7 +19,7 @@ namespace Azaion.Common.Controls;
|
||||
public class CanvasEditor : Canvas
|
||||
{
|
||||
private Point _lastPos;
|
||||
public SelectionState SelectionState { get; set; } = SelectionState.None;
|
||||
private SelectionState SelectionState { get; set; } = SelectionState.None;
|
||||
|
||||
private readonly Rectangle _newAnnotationRect;
|
||||
private Point _newAnnotationStartPos;
|
||||
@@ -30,7 +29,7 @@ public class CanvasEditor : Canvas
|
||||
private readonly TextBlock _classNameHint;
|
||||
|
||||
private Rectangle _curRec = new();
|
||||
private DetectionControl _curAnn = null!;
|
||||
private DetectionControl? _curAnn;
|
||||
|
||||
private readonly MatrixTransform _matrixTransform = new();
|
||||
private Point _panStartPoint;
|
||||
@@ -56,12 +55,12 @@ public class CanvasEditor : Canvas
|
||||
}
|
||||
|
||||
private DetectionClass _currentAnnClass = null!;
|
||||
public DetectionClass CurrentAnnClass
|
||||
public DetectionClass? CurrentAnnClass
|
||||
{
|
||||
get => _currentAnnClass;
|
||||
set
|
||||
{
|
||||
_verticalLine.Stroke = value.ColorBrush;
|
||||
_verticalLine.Stroke = value!.ColorBrush;
|
||||
_verticalLine.Fill = value.ColorBrush;
|
||||
_horizontalLine.Stroke = value.ColorBrush;
|
||||
_horizontalLine.Fill = value.ColorBrush;
|
||||
@@ -251,7 +250,7 @@ public class CanvasEditor : Canvas
|
||||
if (width >= MIN_SIZE && height >= MIN_SIZE)
|
||||
{
|
||||
var time = GetTimeFunc();
|
||||
var control = CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel
|
||||
var control = CreateDetectionControl(CurrentAnnClass!, time, new CanvasLabel
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
@@ -263,7 +262,7 @@ public class CanvasEditor : Canvas
|
||||
CheckLabelBoundaries(control);
|
||||
}
|
||||
}
|
||||
else if (SelectionState != SelectionState.PanZoomMoving)
|
||||
else if (SelectionState != SelectionState.PanZoomMoving && _curAnn != null)
|
||||
CheckLabelBoundaries(_curAnn);
|
||||
|
||||
SelectionState = SelectionState.None;
|
||||
@@ -353,7 +352,7 @@ public class CanvasEditor : Canvas
|
||||
|
||||
private void AnnotationResizeMove(Point point)
|
||||
{
|
||||
if (SelectionState != SelectionState.AnnResizing)
|
||||
if (SelectionState != SelectionState.AnnResizing || _curAnn == null)
|
||||
return;
|
||||
|
||||
var x = GetLeft(_curAnn);
|
||||
@@ -418,7 +417,7 @@ public class CanvasEditor : Canvas
|
||||
|
||||
private void AnnotationPositionMove(Point point)
|
||||
{
|
||||
if (SelectionState != SelectionState.AnnMoving)
|
||||
if (SelectionState != SelectionState.AnnMoving || _curAnn == null)
|
||||
return;
|
||||
|
||||
var offsetX = point.X - _lastPos.X;
|
||||
@@ -442,14 +441,14 @@ public class CanvasEditor : Canvas
|
||||
|
||||
#region NewAnnotation
|
||||
|
||||
private void NewAnnotationStart(object sender, MouseButtonEventArgs e)
|
||||
private void NewAnnotationStart(object _, MouseButtonEventArgs e)
|
||||
{
|
||||
_newAnnotationStartPos = e.GetPosition(this);
|
||||
SetLeft(_newAnnotationRect, _newAnnotationStartPos.X);
|
||||
SetTop(_newAnnotationRect, _newAnnotationStartPos.Y);
|
||||
_newAnnotationRect.MouseMove += (sender, e) =>
|
||||
_newAnnotationRect.MouseMove += (_, args) =>
|
||||
{
|
||||
var currentPos = e.GetPosition(this);
|
||||
var currentPos = args.GetPosition(this);
|
||||
NewAnnotationCreatingMove(currentPos);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user