refactor(Annotation): Aktualisiert, um null anstelle von Standard zu verwenden
This commit is contained in:
parent
2d7c0a292b
commit
a7b980bd28
@ -15,65 +15,41 @@ public record Annotation
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Layout
|
#region Layout
|
||||||
internal double _marginLeft = default;
|
|
||||||
|
|
||||||
internal double _marginTop = default;
|
|
||||||
|
|
||||||
internal double _width = default;
|
|
||||||
|
|
||||||
internal double _height = default;
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double MarginLeft
|
public double? MarginLeft { get; set; }
|
||||||
{
|
|
||||||
get => _marginLeft;
|
|
||||||
init => _marginLeft = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double MarginLeftRatio { get; init; } = 1;
|
public double MarginLeftRatio { get; init; } = 1;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double MarginTop
|
public double? MarginTop { get; set; }
|
||||||
{
|
|
||||||
get => _marginTop;
|
|
||||||
init => _marginTop = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double MarginTopRatio { get; init; } = 1;
|
public double MarginTopRatio { get; init; } = 1;
|
||||||
|
|
||||||
public double Width
|
public double? Width { get; set; }
|
||||||
{
|
|
||||||
get => _width;
|
|
||||||
init => _width = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double WidthRatio { get; init; } = 1;
|
public double WidthRatio { get; init; } = 1;
|
||||||
|
|
||||||
public double Height
|
public double? Height { get; set; }
|
||||||
{
|
|
||||||
get => _height;
|
|
||||||
init => _height = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double HeightRatio { get; init; } = 1;
|
public double HeightRatio { get; init; } = 1;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Position
|
#region Position
|
||||||
public double Left => MarginLeft + (HorBoundAnnot?.HorBoundary ?? 0);
|
public double Left => (MarginLeft ?? 0) + (HorBoundAnnot?.HorBoundary ?? 0);
|
||||||
|
|
||||||
public double Top => MarginTop + (VerBoundAnnot?.VerBoundary ?? 0);
|
public double Top => (MarginTop ?? 0) + (VerBoundAnnot?.VerBoundary ?? 0);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Boundary
|
#region Boundary
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double HorBoundary => Left + Width;
|
public double HorBoundary => Left + (Width ?? 0);
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public double VerBoundary => Top + Height;
|
public double VerBoundary => Top + (Height ?? 0);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region BoundAnnot
|
#region BoundAnnot
|
||||||
@ -89,18 +65,18 @@ public record Annotation
|
|||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
// To set default value, annotation must have default (0) value but default must has non-default value
|
// To set null value, annotation must have null (0) value but null must has non-null value
|
||||||
if (_marginLeft == default && value.MarginLeft != default)
|
if (MarginLeft == null && value.MarginLeft != null)
|
||||||
_marginLeft = value.MarginLeft * MarginLeftRatio;
|
MarginLeft = value.MarginLeft * MarginLeftRatio;
|
||||||
|
|
||||||
if (_marginTop == default && value.MarginTop != default)
|
if (MarginTop == null && value.MarginTop != null)
|
||||||
_marginTop = value.MarginTop * MarginTopRatio;
|
MarginTop = value.MarginTop * MarginTopRatio;
|
||||||
|
|
||||||
if (_width == default && value.Width != default)
|
if (Width == null && value.Width != null)
|
||||||
_width = value.Width * WidthRatio;
|
Width = value.Width * WidthRatio;
|
||||||
|
|
||||||
if (_height == default && value.Height != default)
|
if (Height == null && value.Height != null)
|
||||||
_height = value.Height * HeightRatio;
|
Height = value.Height * HeightRatio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -153,11 +153,13 @@
|
|||||||
"AnnotationParams": {
|
"AnnotationParams": {
|
||||||
"DefaultAnnotation": {
|
"DefaultAnnotation": {
|
||||||
"Width": 1,
|
"Width": 1,
|
||||||
"Height": 0.5
|
"Height": 0.5,
|
||||||
|
"MarginTop": 1
|
||||||
},
|
},
|
||||||
"Annotations": [
|
"Annotations": [
|
||||||
{
|
{
|
||||||
"Name": "Signature"
|
"Name": "Signature",
|
||||||
|
"MarginTop": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "City",
|
"Name": "City",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user