Add primitive visual property
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
@@ -10,6 +11,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
public HasStirrupsFromDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
@@ -63,7 +65,8 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
|
||||
}
|
||||
|
||||
visualUpdateStrategy = new HasVisualPropertyFromDTOUpdateStrategy(referenceDictionary, traceLogger);
|
||||
visualUpdateStrategy.Update(newItem, stirrup);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
@@ -10,6 +11,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
public HasStirrupsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
@@ -64,6 +66,8 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
|
||||
}
|
||||
visualUpdateStrategy = new HasVisualPropertyToDTOUpdateStrategy(referenceDictionary, traceLogger);
|
||||
visualUpdateStrategy.Update(newItem, stirrup);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
@@ -14,6 +15,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private IUpdateStrategy<IStirrupByInclinedRebar> updateStrategy;
|
||||
private IConvertStrategy<RebarSectionDTO, IRebarSection> rebarConvertStrategy;
|
||||
|
||||
|
||||
public StirrupByInclinedRebarToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.BeamShears.Logics;
|
||||
using System;
|
||||
@@ -15,6 +16,7 @@ namespace DataAccess.DTOs
|
||||
private IUpdateStrategy<IStirrupGroup> updateStrategy;
|
||||
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
||||
|
||||
|
||||
public StirrupGroupToDTOConvertStrategy(
|
||||
Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
||||
IShiftTraceLogger traceLogger)
|
||||
@@ -34,7 +36,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new StirrupGroupUpdateStrategy();
|
||||
updateStrategy ??= new StirrupGroupUpdateStrategy() { UpdateChildren = false};
|
||||
stirrupUpdateStrategy ??= new HasStirrupsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasVisualPropertyFromDTOUpdateStrategy : IUpdateStrategy<IHasVisualProperty>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO> convertStrategy;
|
||||
|
||||
public HasVisualPropertyFromDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasVisualProperty targetObject, IHasVisualProperty sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
convertStrategy = new DictionaryConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO>(
|
||||
referenceDictionary,
|
||||
traceLogger,
|
||||
new PrimitiveVisualPropertyFromDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
if (sourceObject.VisualProperty is not PrimitiveVisualPropertyDTO visualProperty)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(sourceObject.VisualProperty));
|
||||
}
|
||||
targetObject.VisualProperty = convertStrategy.Convert(visualProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasVisualPropertyToDTOUpdateStrategy : IUpdateStrategy<IHasVisualProperty>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty> convertStrategy;
|
||||
|
||||
public HasVisualPropertyToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasVisualProperty targetObject, IHasVisualProperty sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
convertStrategy = new DictionaryConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty>(
|
||||
referenceDictionary,
|
||||
traceLogger,
|
||||
new PrimitiveVisualPropertyToDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
targetObject.VisualProperty = convertStrategy.Convert(sourceObject.VisualProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
internal class PrimitiveVisualPropertyFromDTOConvertStrategy : ConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IPrimitiveVisualProperty> _updateStrategy;
|
||||
|
||||
public PrimitiveVisualPropertyFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override PrimitiveVisualProperty GetNewItem(PrimitiveVisualPropertyDTO source)
|
||||
{
|
||||
_updateStrategy ??= new PrimitiveVisualPropertyUpdateStrategy();
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class PrimitiveVisualPropertyToDTOConvertStrategy : ConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty>
|
||||
{
|
||||
private IUpdateStrategy<IPrimitiveVisualProperty> _updateStrategy;
|
||||
|
||||
public PrimitiveVisualPropertyToDTOConvertStrategy(
|
||||
Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
||||
IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override PrimitiveVisualPropertyDTO GetNewItem(IPrimitiveVisualProperty source)
|
||||
{
|
||||
_updateStrategy ??= new PrimitiveVisualPropertyUpdateStrategy();
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace DataAccess.DTOs
|
||||
(this, new RectangleShapeFromDTOConvertStrategy(this));
|
||||
NewItem = rectangleConvertStrategy.Convert(rectangleShapeDTO);
|
||||
}
|
||||
if (source is CircleShapeDTO circleShapeDTO)
|
||||
else if (source is CircleShapeDTO circleShapeDTO)
|
||||
{
|
||||
circleConvertStrategy ??= new DictionaryConvertStrategy<CircleShape, CircleShapeDTO>
|
||||
(this, new CircleShapeFromDTOConvertStrategy(this));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
@@ -10,13 +12,23 @@ namespace DataAccess.DTOs
|
||||
[JsonProperty("Name")]
|
||||
public string? Name { get; set; } = string.Empty;
|
||||
[JsonProperty("StirrupDensity")]
|
||||
public double StirrupDensity { get; set; }
|
||||
public double StirrupDensity { get; set; } = 30000;
|
||||
[JsonProperty("CompressedGap")]
|
||||
public double CompressedGap { get; set; }
|
||||
public double CompressedGap { get; set; } = 0;
|
||||
[JsonProperty("StartCoordinate")]
|
||||
public double StartCoordinate { get; set; } = 0;
|
||||
[JsonProperty("EndCoordinate")]
|
||||
public double EndCoordinate { get; set; } = 100;
|
||||
[JsonProperty("VisualProperty")]
|
||||
public IPrimitiveVisualProperty VisualProperty { get; set; }
|
||||
|
||||
public StirrupByDensityDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
VisualProperty = new PrimitiveVisualPropertyDTO(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("Black")
|
||||
};
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
@@ -22,11 +24,16 @@ namespace DataAccess.DTOs
|
||||
public double LegCount { get; set; }
|
||||
[JsonProperty("RebarSection")]
|
||||
public IRebarSection RebarSection { get; set; }
|
||||
|
||||
[JsonProperty("VisualProperty")]
|
||||
public IPrimitiveVisualProperty VisualProperty { get; set; }
|
||||
|
||||
public StirrupByInclinedRebarDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
VisualProperty = new PrimitiveVisualPropertyDTO(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("Black")
|
||||
};
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
@@ -9,23 +11,33 @@ namespace DataAccess.DTOs
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; }
|
||||
[JsonProperty("Name")]
|
||||
public string? Name { get; set; }
|
||||
public string? Name { get; set; } = string.Empty;
|
||||
[JsonProperty("LegCount")]
|
||||
public double LegCount { get; set; }
|
||||
public double LegCount { get; set; } = 2;
|
||||
[JsonProperty("Diameter")]
|
||||
public double Diameter { get; set; }
|
||||
public double Diameter { get; set; } = 0.008;
|
||||
[JsonProperty("Material")]
|
||||
public IReinforcementLibMaterial Material { get; set; }
|
||||
[JsonProperty("Spacing")]
|
||||
public double Spacing { get; set; }
|
||||
public double Spacing { get; set; } = 0.1;
|
||||
[JsonProperty("CompressedGap")]
|
||||
public double CompressedGap { get; set; }
|
||||
public double CompressedGap { get; set; } = 0;
|
||||
[JsonProperty("IsSpiral")]
|
||||
public bool IsSpiral { get; set; } = false;
|
||||
[JsonProperty("StartCoordinate")]
|
||||
public double StartCoordinate { get; set; } = 0;
|
||||
[JsonProperty("EndCoordinate")]
|
||||
public double EndCoordinate { get; set; } = 100;
|
||||
[JsonProperty("VisualProperty")]
|
||||
public IPrimitiveVisualProperty VisualProperty { get; set; }
|
||||
|
||||
public StirrupByRebarDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
VisualProperty = new PrimitiveVisualPropertyDTO(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("Black")
|
||||
};
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
@@ -8,20 +11,27 @@ namespace DataAccess.DTOs
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; }
|
||||
[JsonProperty("Name")]
|
||||
public string? Name { get; set; }
|
||||
public string? Name { get; set; } = string.Empty;
|
||||
[JsonProperty("CompressedGap")]
|
||||
public double CompressedGap { get; set; }
|
||||
public double CompressedGap { get; set; } = 0;
|
||||
[JsonProperty("Stirrups")]
|
||||
public List<IStirrup> Stirrups { get; } = new();
|
||||
[JsonProperty("VisualProperty")]
|
||||
public IPrimitiveVisualProperty VisualProperty { get; set; }
|
||||
|
||||
public StirrupGroupDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
VisualProperty = new PrimitiveVisualPropertyDTO(Guid.NewGuid())
|
||||
{
|
||||
Color = (Color)ColorConverter.ConvertFromString("Black")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
DataAccess/DTOs/DTOEntities/PrimitiveVisualPropertyDTO.cs
Normal file
32
DataAccess/DTOs/DTOEntities/PrimitiveVisualPropertyDTO.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class PrimitiveVisualPropertyDTO : IPrimitiveVisualProperty
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; }
|
||||
[JsonProperty("IsVisible")]
|
||||
public bool IsVisible { get; set; } = true;
|
||||
[JsonProperty("Color")]
|
||||
public Color Color { get; set; } = ColorProcessor.GetRandomColor();
|
||||
[JsonProperty("Zindex")]
|
||||
public int ZIndex { get; set; } = 0;
|
||||
[JsonProperty("Opacity")]
|
||||
public double Opacity { get; set; } = 1;
|
||||
|
||||
|
||||
public PrimitiveVisualPropertyDTO(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,7 @@ namespace DataAccess.DTOs
|
||||
{ (typeof(List<IVisualAnalysis>), "ListOfIVisualAnalysis") },
|
||||
{ (typeof(Point2DDTO), "Point2D") },
|
||||
{ (typeof(PointNdmPrimitiveDTO), "PointNdmPrimitive") },
|
||||
{ (typeof(PrimitiveVisualPropertyDTO), "PrimitiveVisualProperty") },
|
||||
{ (typeof(ProjectDTO), "Project") },
|
||||
{ (typeof(RebarNdmPrimitiveDTO), "RebarNdmPrimitive") },
|
||||
{ (typeof(RebarSectionDTO), "RebarSection") },
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
@@ -24,5 +19,9 @@ namespace DataAccess.DTOs
|
||||
[JsonProperty("Opacity")]
|
||||
public double Opacity { get; set; }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user