Compare commits
3 Commits
MainGraph
...
Localizati
| Author | SHA1 | Date | |
|---|---|---|---|
| d8d20745e7 | |||
|
|
9562e56ffc | ||
| 971b5d6204 |
@@ -1,13 +0,0 @@
|
|||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class CirclePrimitiveDTO
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
|
||||||
using StructureHelperCommon.Models.Materials;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class ConcreteLibMaterialDTO : IConcreteLibMaterial
|
|
||||||
{
|
|
||||||
const MaterialTypes materialType = MaterialTypes.Concrete;
|
|
||||||
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("RelativeHumidity")]
|
|
||||||
public double RelativeHumidity { get; set; }
|
|
||||||
[JsonProperty("MinAge")]
|
|
||||||
public double MinAge { get; set; }
|
|
||||||
[JsonProperty("MaxAge")]
|
|
||||||
public double MaxAge { get; set; }
|
|
||||||
[JsonProperty("MaterialEntityId")]
|
|
||||||
public Guid MaterialEntityId
|
|
||||||
{
|
|
||||||
get => MaterialEntity.Id;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
MaterialEntity = ProgramSetting.MaterialRepository.Repository.Single(x => x.Id == value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[JsonIgnore]
|
|
||||||
public ILibMaterialEntity MaterialEntity { get; set; }
|
|
||||||
[JsonProperty("SafetyFactors")]
|
|
||||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
|
|
||||||
[JsonProperty("TensionForULS")]
|
|
||||||
public bool TensionForULS { get; set; }
|
|
||||||
[JsonProperty("TensionForSLS")]
|
|
||||||
public bool TensionForSLS { get; set; }
|
|
||||||
[JsonProperty("MaterialLogicId")]
|
|
||||||
public Guid MaterialLogicId
|
|
||||||
{
|
|
||||||
get => MaterialLogic.Id;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
MaterialLogic = MaterialLogics.Single(x => x.Id == value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[JsonIgnore]
|
|
||||||
public IMaterialLogic MaterialLogic { get; set; }
|
|
||||||
[JsonIgnore]
|
|
||||||
public List<IMaterialLogic> MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperLogic.Models.Analyses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
|
||||||
{
|
|
||||||
public class AnalysisToDTOConvertStrategy : IConvertStrategy<IAnalysis, IAnalysis>
|
|
||||||
{
|
|
||||||
private const string Message = "Analysis type is";
|
|
||||||
private IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis> convertCrossSectionNdmAnalysisStrategy = new CrossSectionNdmAnalysisToDTOConvertStrategy();
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public IAnalysis Convert(IAnalysis source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
IAnalysis analysis;
|
|
||||||
if (source is ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
|
||||||
{
|
|
||||||
analysis = GetCrossSectionNdmAnalysisDTO(crossSectionNdmAnalysis);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
|
||||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
|
||||||
throw new StructureHelperException(errorString);
|
|
||||||
}
|
|
||||||
foreach (var item in source.VersionProcessor.Versions)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
return analysis;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CrossSectionNdmAnalysisDTO GetCrossSectionNdmAnalysisDTO(ICrossSectionNdmAnalysis crossSectionNdmAnalysis)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
|
||||||
convertCrossSectionNdmAnalysisStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertCrossSectionNdmAnalysisStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertCrossSectionNdmAnalysisStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
CrossSectionNdmAnalysisDTO crossSectionNdmAnalysisDTO = convertLogic.Convert(crossSectionNdmAnalysis);
|
|
||||||
return crossSectionNdmAnalysisDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<IAnalysis, IAnalysis>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class ConcreteLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>
|
|
||||||
{
|
|
||||||
public override IUpdateStrategy<IConcreteLibMaterial> UpdateStrategy { get; } = new ConcreteLibUpdateStrategy();
|
|
||||||
|
|
||||||
public override ConcreteLibMaterialDTO GetMaterialDTO(IConcreteLibMaterial source)
|
|
||||||
{
|
|
||||||
ConcreteLibMaterialDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperLogic.Models.Analyses;
|
|
||||||
using StructureHelperLogics.Models.Analyses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
|
||||||
{
|
|
||||||
internal class CrossSectionNdmAnalysisToDTOConvertStrategy : IConvertStrategy<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy;
|
|
||||||
private IConvertStrategy<VersionProcessorDTO, IVersionProcessor> convertStrategy;
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public CrossSectionNdmAnalysisToDTOConvertStrategy(
|
|
||||||
IUpdateStrategy<ICrossSectionNdmAnalysis> updateStrategy,
|
|
||||||
IConvertStrategy<VersionProcessorDTO, IVersionProcessor> convertStrategy,
|
|
||||||
IShiftTraceLogger traceLogger)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
this.convertStrategy = convertStrategy;
|
|
||||||
this.TraceLogger = traceLogger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CrossSectionNdmAnalysisToDTOConvertStrategy() : this(new CrossSectionNdmAnalysisUpdateStrategy(),
|
|
||||||
new VersionProcessorToDTOConvertStrategy(),
|
|
||||||
null)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public CrossSectionNdmAnalysisDTO Convert(ICrossSectionNdmAnalysis source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
CrossSectionNdmAnalysisDTO newItem = new();
|
|
||||||
newItem.Id = source.Id;
|
|
||||||
updateStrategy.Update(newItem, source);
|
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<VersionProcessorDTO, IVersionProcessor>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
newItem.VersionProcessor = convertLogic.Convert(source.VersionProcessor);
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<CrossSectionNdmAnalysisDTO, ICrossSectionNdmAnalysis>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
using DataAccess.DTOs.Converters;
|
|
||||||
using StructureHelper.Models.Materials;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class CrossSectionRepositoryToDTOConvertStrategy : IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>
|
|
||||||
{
|
|
||||||
private IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy;
|
|
||||||
|
|
||||||
public CrossSectionRepositoryToDTOConvertStrategy(IConvertStrategy<HeadMaterialDTO, IHeadMaterial> materialConvertStrategy)
|
|
||||||
{
|
|
||||||
this.materialConvertStrategy = materialConvertStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CrossSectionRepositoryToDTOConvertStrategy() : this(
|
|
||||||
new HeadMaterialToDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
CrossSectionRepositoryDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
List<HeadMaterialDTO> materials = ProcessMaterials(source);
|
|
||||||
newItem.HeadMaterials.AddRange(materials);
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<HeadMaterialDTO> ProcessMaterials(ICrossSectionRepository source)
|
|
||||||
{
|
|
||||||
materialConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
materialConvertStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<HeadMaterialDTO, IHeadMaterial>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = materialConvertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
List<HeadMaterialDTO> materials = new();
|
|
||||||
foreach (var item in source.HeadMaterials)
|
|
||||||
{
|
|
||||||
materials.Add(convertLogic.Convert(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<CrossSectionRepositoryDTO, ICrossSectionRepository>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
|
||||||
{
|
|
||||||
public class CrossSectionToDTOConvertStrategy : IConvertStrategy<CrossSectionDTO, ICrossSection>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<ICrossSection> updateStrategy;
|
|
||||||
private IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertStrategy;
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public CrossSectionToDTOConvertStrategy(IUpdateStrategy<ICrossSection> updateStrategy,
|
|
||||||
IConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository> convertStrategy)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
this.convertStrategy = convertStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CrossSectionToDTOConvertStrategy() : this(
|
|
||||||
new CrossSectionUpdateStrategy(),
|
|
||||||
new CrossSectionRepositoryToDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public CrossSectionDTO Convert(ICrossSection source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
CrossSectionDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<CrossSectionRepositoryDTO, ICrossSectionRepository>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
newItem.SectionRepository = convertLogic.Convert(source.SectionRepository);
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<CrossSectionDTO, ICrossSection>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperLogic.Models.Analyses;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
|
||||||
{
|
|
||||||
public class DateVersionToDTOConvertStrategy : IConvertStrategy<DateVersionDTO, IDateVersion>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<IDateVersion> updateStrategy;
|
|
||||||
private IConvertStrategy<ISaveable, ISaveable> convertStrategy;
|
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public DateVersionToDTOConvertStrategy(
|
|
||||||
IUpdateStrategy<IDateVersion> updateStrategy,
|
|
||||||
IConvertStrategy<ISaveable, ISaveable> convertStrategy)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
this.convertStrategy = convertStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateVersionToDTOConvertStrategy() : this (
|
|
||||||
new DateVersionUpdateStrategy(),
|
|
||||||
new VersionItemToDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateVersionDTO Convert(IDateVersion source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
DateVersionDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
updateStrategy.Update(newItem, source);
|
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<ISaveable, ISaveable>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
newItem.AnalysisVersion = convertLogic.Convert(source.AnalysisVersion);
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<DateVersionDTO, IDateVersion>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class FileVersionFromDTOConvertStrategy : IConvertStrategy<FileVersion, FileVersionDTO>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
|
||||||
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
|
||||||
|
|
||||||
public FileVersionFromDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
}
|
|
||||||
public FileVersionFromDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileVersion Convert(FileVersionDTO source)
|
|
||||||
{
|
|
||||||
FileVersion fileVersion = new(source.Id);
|
|
||||||
updateStrategy.Update(fileVersion, source);
|
|
||||||
return fileVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class FileVersionToDTOConvertStrategy : IConvertStrategy<FileVersionDTO, IFileVersion>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
|
||||||
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
|
|
||||||
public FileVersionToDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
}
|
|
||||||
public FileVersionToDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileVersionDTO Convert(IFileVersion source)
|
|
||||||
{
|
|
||||||
FileVersionDTO fileVersion = new(source.Id);
|
|
||||||
updateStrategy.Update(fileVersion, source);
|
|
||||||
return fileVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
using StructureHelper.Models.Materials;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
|
||||||
{
|
|
||||||
public class HeadMaterialToDTOConvertStrategy : IConvertStrategy<HeadMaterialDTO, IHeadMaterial>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<IHeadMaterial> updateStrategy;
|
|
||||||
private IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy;
|
|
||||||
|
|
||||||
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy,
|
|
||||||
IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
this.convertStrategy = convertStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HeadMaterialToDTOConvertStrategy() : this (
|
|
||||||
new HeadMaterialUpdateStrategy(),
|
|
||||||
new HelperMaterialToDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public HeadMaterialDTO Convert(IHeadMaterial source)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}");
|
|
||||||
HeadMaterialDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
updateStrategy.Update(newItem, source);
|
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<IHelperMaterial, IHelperMaterial>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial);
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
|
|
||||||
{
|
|
||||||
private LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
|
|
||||||
private LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy;
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public HelperMaterialToDTOConvertStrategy(
|
|
||||||
LibMaterialToDTOConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy,
|
|
||||||
LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial> reinforcementConvertStrategy)
|
|
||||||
{
|
|
||||||
this.concreteConvertStrategy = concreteConvertStrategy;
|
|
||||||
this.reinforcementConvertStrategy = reinforcementConvertStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HelperMaterialToDTOConvertStrategy() : this (
|
|
||||||
new ConcreteLibMaterialToDTOConvertStrategy(),
|
|
||||||
new ReinforcementLibMaterialToDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IHelperMaterial Convert(IHelperMaterial source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
if (source is IConcreteLibMaterial concreteLibMaterial)
|
|
||||||
{
|
|
||||||
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
concreteConvertStrategy.TraceLogger = TraceLogger;
|
|
||||||
return concreteConvertStrategy.Convert(concreteLibMaterial);
|
|
||||||
}
|
|
||||||
if (source is IReinforcementLibMaterial reinforcementMaterial)
|
|
||||||
{
|
|
||||||
reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
reinforcementConvertStrategy.TraceLogger = TraceLogger;
|
|
||||||
return reinforcementConvertStrategy.Convert(reinforcementMaterial);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<IHelperMaterial, IHelperMaterial>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using StructureHelperCommon.Services;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class LibMaterialDTOUpdateStrategy : IUpdateStrategy<ILibMaterial>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy;
|
|
||||||
private IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy;
|
|
||||||
|
|
||||||
public LibMaterialDTOUpdateStrategy(IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy,
|
|
||||||
IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy)
|
|
||||||
{
|
|
||||||
this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy;
|
|
||||||
this.partialFactorUpdateStrategy = partialFactorUpdateStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LibMaterialDTOUpdateStrategy() : this (new MaterialSafetyFactorUpdateStrategy(),
|
|
||||||
new MaterialPartialFactorUpdateStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public void Update(ILibMaterial targetObject, ILibMaterial sourceObject)
|
|
||||||
{
|
|
||||||
CheckObject.IsNull(sourceObject);
|
|
||||||
CheckObject.IsNull(targetObject);
|
|
||||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
|
||||||
if (sourceObject.SafetyFactors is not null)
|
|
||||||
{
|
|
||||||
targetObject.SafetyFactors.Clear();
|
|
||||||
foreach (var safetyFactor in sourceObject.SafetyFactors)
|
|
||||||
{
|
|
||||||
MaterialSafetyFactorDTO newSafetyFactor = GetNewSafetyFactorByOld(safetyFactor);
|
|
||||||
targetObject.SafetyFactors.Add(newSafetyFactor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MaterialSafetyFactorDTO GetNewSafetyFactorByOld(IMaterialSafetyFactor safetyFactor)
|
|
||||||
{
|
|
||||||
MaterialSafetyFactorDTO newSafetyFactor = new()
|
|
||||||
{
|
|
||||||
Id = safetyFactor.Id
|
|
||||||
};
|
|
||||||
safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor);
|
|
||||||
newSafetyFactor.PartialFactors.Clear();
|
|
||||||
foreach (var partialFactor in safetyFactor.PartialFactors)
|
|
||||||
{
|
|
||||||
MaterialPartialFactorDTO newPartialFactor = GetNewPartialFactorByOld(partialFactor);
|
|
||||||
newSafetyFactor.PartialFactors.Add(newPartialFactor);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newSafetyFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private MaterialPartialFactorDTO GetNewPartialFactorByOld(IMaterialPartialFactor partialFactor)
|
|
||||||
{
|
|
||||||
MaterialPartialFactorDTO newPartialFactor = new()
|
|
||||||
{
|
|
||||||
Id = partialFactor.Id
|
|
||||||
};
|
|
||||||
partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor);
|
|
||||||
return newPartialFactor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Loggers;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public abstract class LibMaterialToDTOConvertStrategy<T,V> : IConvertStrategy<T, V>
|
|
||||||
where T : V
|
|
||||||
where V : ILibMaterial
|
|
||||||
{
|
|
||||||
public abstract IUpdateStrategy<V> UpdateStrategy { get; }
|
|
||||||
public abstract T GetMaterialDTO(V source);
|
|
||||||
private IUpdateStrategy<ILibMaterial> libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy();
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public T Convert(V source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
T newItem = GetMaterialDTO(source);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
UpdateStrategy.Update(newItem, source);
|
|
||||||
libMaterialUpdateStrategy.Update(newItem, source);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<T, V>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class MaterialSafetyFactorToDTOConvertStrategy : IConvertStrategy<MaterialSafetyFactorDTO, IMaterialSafetyFactor>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<IMaterialSafetyFactor> updateStrategy;
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public MaterialSafetyFactorToDTOConvertStrategy(IUpdateStrategy<IMaterialSafetyFactor> updateStrategy)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MaterialSafetyFactorDTO Convert(IMaterialSafetyFactor source)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class ProjectToDTOConvertStrategy : IConvertStrategy<ProjectDTO, IProject>
|
|
||||||
{
|
|
||||||
private IUpdateStrategy<IProject> updateStrategy;
|
|
||||||
private IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy;
|
|
||||||
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public ProjectToDTOConvertStrategy(IUpdateStrategy<IProject> updateStrategy, IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy)
|
|
||||||
{
|
|
||||||
this.updateStrategy = updateStrategy;
|
|
||||||
this.convertStrategy = convertStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectToDTOConvertStrategy() : this(new ProjectUpdateStrategy(), new VisualAnalysisToDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectDTO Convert(IProject source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
ProjectDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
updateStrategy.Update(newItem, source);
|
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
newItem.VisualAnalyses.Clear();
|
|
||||||
foreach (var item in source.VisualAnalyses)
|
|
||||||
{
|
|
||||||
var newVisualAnalysis = convertLogic.Convert(item);
|
|
||||||
newItem.VisualAnalyses.Add(newVisualAnalysis);
|
|
||||||
}
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<ProjectDTO, IProject>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class ReinforcementLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy<ReinforcementLibMaterialDTO, IReinforcementLibMaterial>
|
|
||||||
{
|
|
||||||
public override IUpdateStrategy<IReinforcementLibMaterial> UpdateStrategy { get; } = new ReinforcementLibUpdateStrategy();
|
|
||||||
|
|
||||||
public override ReinforcementLibMaterialDTO GetMaterialDTO(IReinforcementLibMaterial source)
|
|
||||||
{
|
|
||||||
ReinforcementLibMaterialDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
|
||||||
{
|
|
||||||
public class VersionItemToDTOConvertStrategy : IConvertStrategy<ISaveable, ISaveable>
|
|
||||||
{
|
|
||||||
private const string Message = "Analysis type is";
|
|
||||||
private IConvertStrategy<CrossSectionDTO, ICrossSection> crossSectionConvertStrategy = new CrossSectionToDTOConvertStrategy();
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public ISaveable Convert(ISaveable source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
ISaveable saveable;
|
|
||||||
if (source is ICrossSection crossSection)
|
|
||||||
{
|
|
||||||
saveable = ProcessCrossSection(crossSection);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source);
|
|
||||||
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
|
|
||||||
throw new StructureHelperException(errorString);
|
|
||||||
}
|
|
||||||
return saveable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ISaveable ProcessCrossSection(ICrossSection crossSection)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(Message + " Cross-Section Ndm Analysis", TraceLogStatuses.Debug);
|
|
||||||
ISaveable saveable;
|
|
||||||
crossSectionConvertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
crossSectionConvertStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<CrossSectionDTO, ICrossSection>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = crossSectionConvertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
saveable = convertLogic.Convert(crossSection);
|
|
||||||
return saveable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<ISaveable, ISaveable>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs.Converters
|
|
||||||
{
|
|
||||||
public class VersionProcessorToDTOConvertStrategy : IConvertStrategy<VersionProcessorDTO, IVersionProcessor>
|
|
||||||
{
|
|
||||||
private IConvertStrategy<DateVersionDTO, IDateVersion> convertStrategy = new DateVersionToDTOConvertStrategy();
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public VersionProcessorDTO Convert(IVersionProcessor source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
VersionProcessorDTO newItem = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertStrategy.TraceLogger = TraceLogger;
|
|
||||||
foreach (var item in source.Versions)
|
|
||||||
{
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<DateVersionDTO, IDateVersion>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
newItem.Versions.Add(convertLogic.Convert(item));
|
|
||||||
}
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<VersionProcessorDTO, IVersionProcessor>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
using DataAccess.DTOs.Converters;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using StructureHelperLogic.Models.Analyses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
internal class VisualAnalysisToDTOConvertStrategy : IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
|
|
||||||
{
|
|
||||||
private IConvertStrategy<IAnalysis, IAnalysis> convertStrategy;
|
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public VisualAnalysisToDTOConvertStrategy(IConvertStrategy<IAnalysis, IAnalysis> convertStrategy)
|
|
||||||
{
|
|
||||||
this.convertStrategy = convertStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VisualAnalysisToDTOConvertStrategy() : this(new AnalysisToDTOConvertStrategy())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public VisualAnalysisDTO Convert(IVisualAnalysis source)
|
|
||||||
{
|
|
||||||
Check();
|
|
||||||
VisualAnalysisDTO visualAnalysisDTO = new()
|
|
||||||
{
|
|
||||||
Id = source.Id
|
|
||||||
};
|
|
||||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
|
||||||
convertStrategy.TraceLogger = TraceLogger;
|
|
||||||
var convertLogic = new DictionaryConvertStrategy<IAnalysis, IAnalysis>()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = ReferenceDictionary,
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
visualAnalysisDTO.Analysis = convertLogic.Convert(source.Analysis);
|
|
||||||
return visualAnalysisDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Check()
|
|
||||||
{
|
|
||||||
var checkLogic = new CheckConvertLogic<VisualAnalysisDTO, IVisualAnalysis>();
|
|
||||||
checkLogic.ConvertStrategy = this;
|
|
||||||
checkLogic.TraceLogger = TraceLogger;
|
|
||||||
checkLogic.Check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class CrossSectionDTO : ICrossSection
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("SectionRepository")]
|
|
||||||
public ICrossSectionRepository SectionRepository { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperLogic.Models.Analyses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class CrossSectionNdmAnalysisDTO : ICrossSectionNdmAnalysis
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("Name")]
|
|
||||||
public string Name { get; set; }
|
|
||||||
[JsonProperty("Tags")]
|
|
||||||
public string Tags { get; set; }
|
|
||||||
[JsonProperty("VersionProcessor")]
|
|
||||||
public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessorDTO();
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelper.Models.Materials;
|
|
||||||
using StructureHelperCommon.Models.Calculators;
|
|
||||||
using StructureHelperCommon.Models.Forces;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class CrossSectionRepositoryDTO : ICrossSectionRepository
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("HeadMaterials")]
|
|
||||||
public List<IHeadMaterial> HeadMaterials { get; } = new();
|
|
||||||
[JsonProperty("ForceActions")]
|
|
||||||
public List<IForceAction> ForceActions { get; } = new();
|
|
||||||
[JsonProperty("Primitives")]
|
|
||||||
public List<INdmPrimitive> Primitives { get; } = new();
|
|
||||||
[JsonProperty("Calculators")]
|
|
||||||
public List<ICalculator> Calculators { get; } = new();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class DateVersionDTO : IDateVersion
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("DateTime")]
|
|
||||||
public DateTime DateTime { get; set; }
|
|
||||||
[JsonProperty("AnalysisVersion")]
|
|
||||||
public ISaveable AnalysisVersion { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class ElasticMaterialDTO : IElasticMaterial
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("Modulus")]
|
|
||||||
public double Modulus { get; set; }
|
|
||||||
[JsonProperty("CompressiveStrength")]
|
|
||||||
public double CompressiveStrength { get; set; }
|
|
||||||
[JsonProperty("TensileStrength")]
|
|
||||||
public double TensileStrength { get; set; }
|
|
||||||
[JsonProperty("SafetyFactors")]
|
|
||||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
|
||||||
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class FRMaterialDTO : IFRMaterial
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("ULSConcreteStrength")]
|
|
||||||
public double ULSConcreteStrength { get; set; }
|
|
||||||
[JsonProperty("SunThickness")]
|
|
||||||
public double SumThickness { get; set; }
|
|
||||||
[JsonIgnore]
|
|
||||||
public double GammaF2 { get; }
|
|
||||||
[JsonProperty("Modulus")]
|
|
||||||
public double Modulus { get; set; }
|
|
||||||
[JsonProperty("CompressiveStrength")]
|
|
||||||
public double CompressiveStrength { get; set; }
|
|
||||||
[JsonProperty("TensileStrength")]
|
|
||||||
public double TensileStrength { get; set; }
|
|
||||||
[JsonProperty("SafetyFactors")]
|
|
||||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
|
||||||
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
|
|
||||||
[JsonObject(IsReference = true)]
|
|
||||||
public class FileVersionDTO : IFileVersion
|
|
||||||
{
|
|
||||||
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("VersionNumber")]
|
|
||||||
public int VersionNumber { get; set; }
|
|
||||||
[JsonProperty("SubVersionNumber")]
|
|
||||||
public int SubVersionNumber { get; set; }
|
|
||||||
public FileVersionDTO(Guid id)
|
|
||||||
{
|
|
||||||
Id = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelper.Models.Materials;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class HeadMaterialDTO : IHeadMaterial
|
|
||||||
{
|
|
||||||
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("Name")]
|
|
||||||
public string Name { get; set; }
|
|
||||||
[JsonProperty("Color")]
|
|
||||||
public Color Color { get; set; }
|
|
||||||
[JsonProperty("HelperMaterial")]
|
|
||||||
public IHelperMaterial HelperMaterial { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class MaterialPartialFactorDTO : IMaterialPartialFactor
|
|
||||||
{
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
public double FactorValue { get; set; }
|
|
||||||
public StressStates StressState { get; set; }
|
|
||||||
public CalcTerms CalcTerm { get; set; }
|
|
||||||
public LimitStates LimitState { get; set; }
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class MaterialSafetyFactorDTO : IMaterialSafetyFactor
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("Name")]
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
[JsonProperty("Take")]
|
|
||||||
public bool Take { get; set; }
|
|
||||||
[JsonProperty("Description")]
|
|
||||||
public string Description { get; set; } = string.Empty;
|
|
||||||
[JsonProperty("PartialFactors")]
|
|
||||||
public List<IMaterialPartialFactor> PartialFactors { get; } = new();
|
|
||||||
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double GetFactor(StressStates stressState, CalcTerms calcTerm, LimitStates limitStates)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelper.Models.Materials;
|
|
||||||
using StructureHelperCommon.Models.Forces;
|
|
||||||
using StructureHelperCommon.Models.Shapes;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class NdmPrimitiveDTO : INdmElement
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("HeadMaterial")]
|
|
||||||
public IHeadMaterial? HeadMaterial { get; set; }
|
|
||||||
[JsonProperty("Triangulate")]
|
|
||||||
public bool Triangulate { get; set; }
|
|
||||||
[JsonProperty("UserPrestrain")]
|
|
||||||
public StrainTuple UsersPrestrain { get; } = new StrainTuple();
|
|
||||||
[JsonIgnore]
|
|
||||||
public StrainTuple AutoPrestrain => throw new NotImplementedException();
|
|
||||||
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class ProjectDTO : IProject
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonIgnore]
|
|
||||||
public string FullFileName { get; set; }
|
|
||||||
[JsonIgnore]
|
|
||||||
public bool IsNewFile { get; set; }
|
|
||||||
[JsonIgnore]
|
|
||||||
public bool IsActual { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("VisualAnalyses")]
|
|
||||||
public List<IVisualAnalysis> VisualAnalyses { get; private set; } = new();
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public string FileName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
|
||||||
using StructureHelperCommon.Models.Materials;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class ReinforcementLibMaterialDTO : IReinforcementLibMaterial
|
|
||||||
{
|
|
||||||
const MaterialTypes materialType = MaterialTypes.Reinforcement;
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("MaterialEntityId")]
|
|
||||||
public Guid MaterialEntityId
|
|
||||||
{
|
|
||||||
get => MaterialEntity.Id;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
MaterialEntity = ProgramSetting.MaterialRepository.Repository.Single(x => x.Id == value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[JsonIgnore]
|
|
||||||
public ILibMaterialEntity MaterialEntity { get; set; }
|
|
||||||
[JsonProperty("SafetyFactors")]
|
|
||||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
|
|
||||||
[JsonProperty("MaterialLogicId")]
|
|
||||||
public Guid MaterialLogicId
|
|
||||||
{
|
|
||||||
get => MaterialLogic.Id;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
MaterialLogic = MaterialLogics.Single(x => x.Id == value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[JsonIgnore]
|
|
||||||
public IMaterialLogic MaterialLogic { get; set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public List<IMaterialLogic> MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using Newtonsoft.Json.Serialization;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class TypeBinder : ISerializationBinder
|
|
||||||
{
|
|
||||||
private List<(Type type, string name)> typesNames;
|
|
||||||
public static IShiftTraceLogger TraceLogger;
|
|
||||||
public TypeBinder(List<(Type type, string name)> typesNames, IShiftTraceLogger traceLogger = null)
|
|
||||||
{
|
|
||||||
this.typesNames = typesNames;
|
|
||||||
TraceLogger = traceLogger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BindToName(Type serializedType, out string? assemblyName, out string? typeName)
|
|
||||||
{
|
|
||||||
assemblyName = null;
|
|
||||||
if (typesNames.Any(x => x.type == serializedType))
|
|
||||||
{
|
|
||||||
typeName = typesNames.Single(x => x.type == serializedType).name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
typeName = serializedType.FullName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type BindToType(string? assemblyName, string typeName)
|
|
||||||
{
|
|
||||||
return typesNames.SingleOrDefault(x => x.name == typeName).type;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
using StructureHelper.Models.Materials;
|
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using StructureHelperCommon.Models.Calculators;
|
|
||||||
using StructureHelperCommon.Models.Forces;
|
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
internal enum TypeFileVersion
|
|
||||||
{
|
|
||||||
version_v1
|
|
||||||
}
|
|
||||||
internal static class TypeBinderListFactory
|
|
||||||
{
|
|
||||||
public static List<(Type type, string name)> GetTypeNameList(TypeFileVersion fileVersion)
|
|
||||||
{
|
|
||||||
if (fileVersion == TypeFileVersion.version_v1)
|
|
||||||
{
|
|
||||||
List<(Type type, string name)> typesNames = GetVersionV1();
|
|
||||||
return typesNames;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(fileVersion));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<(Type type, string name)> GetVersionV1()
|
|
||||||
{
|
|
||||||
return new List<(Type type, string name)>
|
|
||||||
{
|
|
||||||
{ (typeof(CirclePrimitiveDTO), "CircleNdmPrimitive") },
|
|
||||||
{ (typeof(ConcreteLibMaterialDTO), "ConcreteLibMaterial") },
|
|
||||||
{ (typeof(CrossSectionDTO), "CrossSection") },
|
|
||||||
{ (typeof(CrossSectionNdmAnalysisDTO), "CrossSectionNdmAnalysis") },
|
|
||||||
{ (typeof(CrossSectionRepositoryDTO), "CrossSectionRepository") },
|
|
||||||
{ (typeof(DateVersionDTO), "DateVersion") },
|
|
||||||
{ (typeof(FileVersionDTO), "FileVersion") },
|
|
||||||
{ (typeof(HeadMaterialDTO), "HeadMaterial") },
|
|
||||||
{ (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") },
|
|
||||||
{ (typeof(NdmPrimitiveDTO), "NdmPrimitive") },
|
|
||||||
{ (typeof(IVisualAnalysis), "IVisualAnalysis") },
|
|
||||||
{ (typeof(List<ICalculator>), "ListOfICalculator") },
|
|
||||||
{ (typeof(List<IDateVersion>), "ListOfIDateVersion") },
|
|
||||||
{ (typeof(List<IForceAction>), "ListOfIForceAction") },
|
|
||||||
{ (typeof(List<IHeadMaterial>), "ListOfIHeadMaterial") },
|
|
||||||
{ (typeof(List<IMaterialSafetyFactor>), "ListOfMaterialSafetyFactor") },
|
|
||||||
{ (typeof(List<IMaterialPartialFactor>), "ListOfMaterialPartialFactor") },
|
|
||||||
{ (typeof(List<INdmPrimitive>), "ListOfINdmPrimitive") },
|
|
||||||
{ (typeof(List<IPartialFactor>), "ListOfPartialFactor") },
|
|
||||||
{ (typeof(List<IVisualAnalysis>), "ListOfIVisualAnalysis") },
|
|
||||||
{ (typeof(ProjectDTO), "Project") },
|
|
||||||
{ (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") },
|
|
||||||
{ (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") },
|
|
||||||
{ (typeof(VersionProcessorDTO), "VersionProcessor") },
|
|
||||||
{ (typeof(VisualAnalysisDTO), "VisualAnalysis") },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class VersionProcessorDTO : IVersionProcessor
|
|
||||||
{
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("Versions")]
|
|
||||||
public List<IDateVersion> Versions { get; } = new();
|
|
||||||
|
|
||||||
public void AddVersion(ISaveable newItem)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IDateVersion GetCurrentVersion()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Models.Analyses;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.DTOs
|
|
||||||
{
|
|
||||||
public class VisualAnalysisDTO : IVisualAnalysis
|
|
||||||
{
|
|
||||||
|
|
||||||
[JsonProperty("Id")]
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
[JsonProperty("Analysis")]
|
|
||||||
public IAnalysis Analysis { get; set; }
|
|
||||||
|
|
||||||
public object Clone()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Run()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
|
|
||||||
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="NewFolder\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="LoaderCalculator">
|
|
||||||
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
|
|
||||||
namespace DataAccess
|
|
||||||
{
|
|
||||||
|
|
||||||
// class Program
|
|
||||||
// {
|
|
||||||
// static void Main(string[] args)
|
|
||||||
// {
|
|
||||||
// var logger = new TraceLogger();
|
|
||||||
|
|
||||||
// // Create objects with complex relationships
|
|
||||||
// var parent1 = new Parent { Name = "Parent_1" };
|
|
||||||
// var parent2 = new Parent { Name = "Parent_2" };
|
|
||||||
|
|
||||||
// var detail1 = new Detail { Description = "Detail_1", InternalNote = "Secret Note 1" };
|
|
||||||
// var detail2 = new Detail { Description = "Detail_2", InternalNote = "Secret Note 2" };
|
|
||||||
// var detail3 = new Detail { Description = "Detail_3", InternalNote = "Secret Note 3" };
|
|
||||||
|
|
||||||
// var subDetail1 = new SubDetail { Info = "SubDetail_1" };
|
|
||||||
|
|
||||||
// // Set up relationships
|
|
||||||
// parent1.Details.Add(detail1);
|
|
||||||
// parent1.Details.Add(detail2);
|
|
||||||
|
|
||||||
// parent2.Details.Add(detail2); // Shared detail
|
|
||||||
// parent2.Details.Add(detail3);
|
|
||||||
|
|
||||||
// detail3.SubDetails.Add(subDetail1);
|
|
||||||
|
|
||||||
// // Serialize with custom converters and trace logging
|
|
||||||
// string json = Serialize(new List<Parent> { parent1, parent2 }, logger);
|
|
||||||
// Console.WriteLine("Serialized JSON:");
|
|
||||||
// Console.WriteLine(json);
|
|
||||||
|
|
||||||
// // Deserialize with custom converters and trace logging
|
|
||||||
// var deserializedParents = Deserialize<List<Parent>>(json, logger);
|
|
||||||
|
|
||||||
// Console.WriteLine("\nDeserialized Objects:");
|
|
||||||
// foreach (var parent in deserializedParents)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine($"Parent: {parent.Name}, Id: {parent.Id}");
|
|
||||||
// foreach (var detail in parent.Details)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine($" Detail: {detail.Description}, Id: {detail.Id}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static string Serialize(object obj, TraceLogger logger)
|
|
||||||
// {
|
|
||||||
// var settings = new JsonSerializerSettings
|
|
||||||
// {
|
|
||||||
// Converters = new List<JsonConverter>
|
|
||||||
// {
|
|
||||||
// new ParentConverter(logger), // Add the specific converter
|
|
||||||
// // Add other converters if needed
|
|
||||||
// },
|
|
||||||
// Formatting = Formatting.Indented
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return JsonConvert.SerializeObject(obj, settings);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static T Deserialize<T>(string json, TraceLogger logger)
|
|
||||||
// {
|
|
||||||
// var settings = new JsonSerializerSettings
|
|
||||||
// {
|
|
||||||
// Converters = new List<JsonConverter>
|
|
||||||
// {
|
|
||||||
// new ParentConverter(logger), // Add the specific converter
|
|
||||||
// // Add other converters if needed
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return JsonConvert.DeserializeObject<T>(json, settings);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//public class Parent
|
|
||||||
// {
|
|
||||||
// public Guid Id { get; set; } = Guid.NewGuid();
|
|
||||||
|
|
||||||
// [JsonProperty("parent_name")]
|
|
||||||
// public string Name { get; set; }
|
|
||||||
|
|
||||||
// public List<Detail> Details { get; set; } = new List<Detail>();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public class Detail
|
|
||||||
// {
|
|
||||||
// public Guid Id { get; set; } = Guid.NewGuid();
|
|
||||||
|
|
||||||
// [JsonPropertyName("detail_description")] // Compatible with System.Text.Json
|
|
||||||
// public string Description { get; set; }
|
|
||||||
|
|
||||||
// [JsonIgnore] // This property will be ignored during serialization
|
|
||||||
// public string InternalNote { get; set; }
|
|
||||||
|
|
||||||
// public List<SubDetail> SubDetails { get; set; } = new List<SubDetail>();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public class SubDetail
|
|
||||||
// {
|
|
||||||
// public Guid Id { get; set; } = Guid.NewGuid();
|
|
||||||
// public string Info { get; set; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.FileDialogs
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
public class FileRepository : IFileRepository
|
|
||||||
{
|
|
||||||
private readonly string _storageDirectory;
|
|
||||||
|
|
||||||
public FileRepository(string storageDirectory)
|
|
||||||
{
|
|
||||||
_storageDirectory = storageDirectory;
|
|
||||||
|
|
||||||
// Ensure the storage directory exists
|
|
||||||
if (!Directory.Exists(_storageDirectory))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(_storageDirectory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save a file to the repository
|
|
||||||
public async Task SaveFileAsync(Stream fileStream, string fileName)
|
|
||||||
{
|
|
||||||
string filePath = Path.Combine(_storageDirectory, fileName);
|
|
||||||
|
|
||||||
// Ensure the file does not already exist
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("File already exists.");
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var file = new FileStream(filePath, FileMode.Create, FileAccess.Write))
|
|
||||||
{
|
|
||||||
await fileStream.CopyToAsync(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve a file from the repository
|
|
||||||
public async Task<Stream> GetFileAsync(string fileName)
|
|
||||||
{
|
|
||||||
string filePath = Path.Combine(_storageDirectory, fileName);
|
|
||||||
|
|
||||||
// Ensure the file exists
|
|
||||||
if (!File.Exists(filePath))
|
|
||||||
{
|
|
||||||
throw new FileNotFoundException("File not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
|
||||||
return await Task.FromResult(fileStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update an existing file in the repository
|
|
||||||
public async Task UpdateFileAsync(Stream fileStream, string fileName)
|
|
||||||
{
|
|
||||||
string filePath = Path.Combine(_storageDirectory, fileName);
|
|
||||||
|
|
||||||
// Ensure the file exists
|
|
||||||
if (!File.Exists(filePath))
|
|
||||||
{
|
|
||||||
throw new FileNotFoundException("File not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
using (var file = new FileStream(filePath, FileMode.Truncate, FileAccess.Write))
|
|
||||||
{
|
|
||||||
await fileStream.CopyToAsync(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete a file from the repository
|
|
||||||
public async Task DeleteFileAsync(string fileName)
|
|
||||||
{
|
|
||||||
string filePath = Path.Combine(_storageDirectory, fileName);
|
|
||||||
|
|
||||||
// Ensure the file exists
|
|
||||||
if (!File.Exists(filePath))
|
|
||||||
{
|
|
||||||
throw new FileNotFoundException("File not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
File.Delete(filePath);
|
|
||||||
await Task.CompletedTask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
using DataAccess.FileDialogs;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace DataAccess.FileDialogs
|
|
||||||
{
|
|
||||||
internal class FileStorage
|
|
||||||
{
|
|
||||||
|
|
||||||
public class FileStorageManager
|
|
||||||
{
|
|
||||||
// Dictionary to store files with unique IDs as keys
|
|
||||||
private readonly Dictionary<Guid, OpenedFile> _openedFiles = new Dictionary<Guid, OpenedFile>();
|
|
||||||
|
|
||||||
// Method to open a file and add it to the storage
|
|
||||||
public Guid OpenFile()
|
|
||||||
{
|
|
||||||
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
|
||||||
{
|
|
||||||
openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
|
|
||||||
openFileDialog.Multiselect = true; // Allow multiple file selection
|
|
||||||
openFileDialog.Title = "Select Files";
|
|
||||||
|
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
foreach (var filePath in openFileDialog.FileNames)
|
|
||||||
{
|
|
||||||
var fileId = Guid.NewGuid();
|
|
||||||
var openedFile = new OpenedFile(fileId, filePath);
|
|
||||||
|
|
||||||
// Add to storage
|
|
||||||
_openedFiles[fileId] = openedFile;
|
|
||||||
|
|
||||||
Console.WriteLine($"File '{openedFile.FilePath}' opened with ID: {fileId}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Guid.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to get an opened file by ID
|
|
||||||
public OpenedFile GetFile(Guid fileId)
|
|
||||||
{
|
|
||||||
if (_openedFiles.TryGetValue(fileId, out var openedFile))
|
|
||||||
{
|
|
||||||
return openedFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new KeyNotFoundException("File not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to close a file by ID
|
|
||||||
public void CloseFile(Guid fileId)
|
|
||||||
{
|
|
||||||
if (_openedFiles.ContainsKey(fileId))
|
|
||||||
{
|
|
||||||
_openedFiles.Remove(fileId);
|
|
||||||
Console.WriteLine($"File with ID: {fileId} has been closed.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new KeyNotFoundException("File not found.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to read content of an opened file by ID
|
|
||||||
public string ReadFileContent(Guid fileId)
|
|
||||||
{
|
|
||||||
var openedFile = GetFile(fileId);
|
|
||||||
return File.ReadAllText(openedFile.FilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to list all opened files
|
|
||||||
public void ListOpenedFiles()
|
|
||||||
{
|
|
||||||
foreach (var file in _openedFiles.Values)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"File ID: {file.Id}, Path: {file.FilePath}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Class representing an opened file
|
|
||||||
public class OpenedFile
|
|
||||||
{
|
|
||||||
public Guid Id { get; }
|
|
||||||
public string FilePath { get; }
|
|
||||||
|
|
||||||
public OpenedFile(Guid id, string filePath)
|
|
||||||
{
|
|
||||||
Id = id;
|
|
||||||
FilePath = filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Program
|
|
||||||
{
|
|
||||||
[STAThread] // Required for OpenFileDialog
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
//var fileStorageManager = new FileStorageManager();
|
|
||||||
|
|
||||||
//// Open files and add them to the storage
|
|
||||||
//fileStorageManager.OpenFile();
|
|
||||||
|
|
||||||
//// List all opened files
|
|
||||||
//Console.WriteLine("\nOpened Files:");
|
|
||||||
//fileStorageManager.ListOpenedFiles();
|
|
||||||
|
|
||||||
//// Example: Read content of the first opened file (if any)
|
|
||||||
//var openedFiles = new List<Guid>(fileStorageManager._openedFiles.Keys);
|
|
||||||
//if (openedFiles.Count > 0)
|
|
||||||
//{
|
|
||||||
// var firstFileId = openedFiles[0];
|
|
||||||
// Console.WriteLine($"\nReading content of the first opened file (ID: {firstFileId}):");
|
|
||||||
// string content = fileStorageManager.ReadFileContent(firstFileId);
|
|
||||||
// Console.WriteLine(content);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//// Close all files
|
|
||||||
//foreach (var fileId in openedFiles)
|
|
||||||
//{
|
|
||||||
// fileStorageManager.CloseFile(fileId);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.FileDialogs
|
|
||||||
{
|
|
||||||
public interface IFileRepository
|
|
||||||
{
|
|
||||||
Task SaveFileAsync(Stream fileStream, string fileName);
|
|
||||||
Task<Stream> GetFileAsync(string fileName);
|
|
||||||
Task DeleteFileAsync(string fileName);
|
|
||||||
Task UpdateFileAsync(Stream fileStream, string fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.FileDialogs
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
class ProgramExample
|
|
||||||
{
|
|
||||||
static async Task Main(string[] args)
|
|
||||||
{
|
|
||||||
string storagePath = Path.Combine(Environment.CurrentDirectory, "UserFiles");
|
|
||||||
IFileRepository fileRepository = new FileRepository(storagePath);
|
|
||||||
|
|
||||||
// Save a file
|
|
||||||
string fileName = "example.txt";
|
|
||||||
using (var fileStream = new MemoryStream(Encoding.UTF8.GetBytes("Hello, World!")))
|
|
||||||
{
|
|
||||||
await fileRepository.SaveFileAsync(fileStream, fileName);
|
|
||||||
Console.WriteLine($"File '{fileName}' saved.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve a file
|
|
||||||
using (Stream retrievedFile = await fileRepository.GetFileAsync(fileName))
|
|
||||||
{
|
|
||||||
using (var reader = new StreamReader(retrievedFile))
|
|
||||||
{
|
|
||||||
string content = await reader.ReadToEndAsync();
|
|
||||||
Console.WriteLine($"Retrieved file content: {content}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update a file
|
|
||||||
using (var updateStream = new MemoryStream(Encoding.UTF8.GetBytes("Updated content!")))
|
|
||||||
{
|
|
||||||
await fileRepository.UpdateFileAsync(updateStream, fileName);
|
|
||||||
Console.WriteLine($"File '{fileName}' updated.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve updated file
|
|
||||||
using (Stream updatedFile = await fileRepository.GetFileAsync(fileName))
|
|
||||||
{
|
|
||||||
using (var reader = new StreamReader(updatedFile))
|
|
||||||
{
|
|
||||||
string updatedContent = await reader.ReadToEndAsync();
|
|
||||||
Console.WriteLine($"Updated file content: {updatedContent}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete a file
|
|
||||||
await fileRepository.DeleteFileAsync(fileName);
|
|
||||||
Console.WriteLine($"File '{fileName}' deleted.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
using DataAccess.DTOs;
|
|
||||||
using DataAccess.JsonConverters;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using NLog;
|
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using StructureHelperCommon.Services.FileServices;
|
|
||||||
|
|
||||||
namespace DataAccess.Infrastructures
|
|
||||||
{
|
|
||||||
public class FileOpenLogic : IFileOpenLogic
|
|
||||||
{
|
|
||||||
private string fileName;
|
|
||||||
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
|
|
||||||
private bool GetFilePath()
|
|
||||||
{
|
|
||||||
var inputData = new OpenFileInputData()
|
|
||||||
{
|
|
||||||
FilterString = "StructureHelper project file (*.shpj)|*.shpj|All Files (*.*)|*.*",
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
var fileDialog = new FileOpener(inputData);
|
|
||||||
var fileDialogResult = fileDialog.OpenFile();
|
|
||||||
if (fileDialogResult.IsValid != true)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fileName = fileDialogResult.FilePath;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenProjectResult OpenFile()
|
|
||||||
{
|
|
||||||
var result = new OpenProjectResult()
|
|
||||||
{
|
|
||||||
IsValid = true
|
|
||||||
};
|
|
||||||
if (GetFilePath() == false)
|
|
||||||
{
|
|
||||||
result.IsValid = false;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (! File.Exists(fileName))
|
|
||||||
{
|
|
||||||
result.IsValid = false;
|
|
||||||
TraceLogger?.AddMessage($"File {fileName} does not exists", TraceLogStatuses.Error);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
var settings = new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
Converters = new List<JsonConverter>
|
|
||||||
{
|
|
||||||
new FileVersionDTOJsonConverter(TraceLogger), // Add the specific converter
|
|
||||||
// Add other converters if needed
|
|
||||||
},
|
|
||||||
Formatting = Formatting.Indented,
|
|
||||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
|
||||||
MissingMemberHandling = MissingMemberHandling.Ignore,
|
|
||||||
TypeNameHandling = TypeNameHandling.All,
|
|
||||||
NullValueHandling = NullValueHandling.Include
|
|
||||||
};
|
|
||||||
using (StreamReader file = File.OpenText(fileName))
|
|
||||||
{
|
|
||||||
JsonSerializer serializer = new JsonSerializer();
|
|
||||||
var fileVersion = (FileVersionDTO)serializer.Deserialize(file, typeof(FileVersionDTO));
|
|
||||||
var checkLogic = new CheckFileVersionLogic()
|
|
||||||
{
|
|
||||||
FileVersion = fileVersion,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
var checkResult = checkLogic.Check();
|
|
||||||
if (checkResult == false)
|
|
||||||
{
|
|
||||||
result.IsValid = false;
|
|
||||||
result.Description += checkLogic.CheckResult;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var currentVersion = ProgramSetting.GetCurrentFileVersion();
|
|
||||||
TraceLogger.AddMessage($"File version is {fileVersion.VersionNumber}.{fileVersion.SubVersionNumber}, current version is {currentVersion.VersionNumber}.{currentVersion.SubVersionNumber}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
using DataAccess.DTOs;
|
|
||||||
using DataAccess.JsonConverters;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using StructureHelperCommon.Services.FileServices;
|
|
||||||
|
|
||||||
namespace DataAccess.Infrastructures
|
|
||||||
{
|
|
||||||
public class FileSaveLogic : IFileSaveLogic
|
|
||||||
{
|
|
||||||
private IFileVersion version;
|
|
||||||
private Dictionary<(Guid id, Type type), ISaveable> refDictinary;
|
|
||||||
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public void SaveFile(IProject project)
|
|
||||||
{
|
|
||||||
if (project.IsNewFile == true)
|
|
||||||
{
|
|
||||||
var result = SelectFileName(project);
|
|
||||||
if (result.IsValid == false)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(result.Description);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
project.FullFileName = result.FileName;
|
|
||||||
project.IsNewFile = false;
|
|
||||||
}
|
|
||||||
SaveToFile(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
private SaveFileResult SelectFileName(IProject project)
|
|
||||||
{
|
|
||||||
FileDialogSaver saver = new();
|
|
||||||
saver.InputData = new SaveDialogInputData()
|
|
||||||
{
|
|
||||||
FilterString = "StructureHelper project file (*.shpj)|*.shpj|All Files (*.*)|*.*",
|
|
||||||
InitialDirectory = project.FullFileName,
|
|
||||||
|
|
||||||
};
|
|
||||||
saver.TraceLogger = TraceLogger;
|
|
||||||
var saveResult = saver.SaveFile();
|
|
||||||
return saveResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveToFile(IProject project)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
version = ProgramSetting.GetCurrentFileVersion();
|
|
||||||
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
|
|
||||||
FileVersionDTO versionDTO = GetVersionDTO();
|
|
||||||
var versionString = Serialize(versionDTO, TraceLogger);
|
|
||||||
File.Delete(project.FullFileName);
|
|
||||||
SaveStringToFile(project, versionString);
|
|
||||||
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
|
|
||||||
ProjectDTO projectDTO = GetProjectDTO(project);
|
|
||||||
var projectString = Serialize(projectDTO, TraceLogger);
|
|
||||||
SaveStringToFile(project, projectString);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SaveStringToFile(IProject project, string versionString)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.AppendAllText(project.FullFileName, versionString);
|
|
||||||
TraceLogger?.AddMessage($"File {project.FullFileName} was saved successfully", TraceLogStatuses.Service);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProjectDTO GetProjectDTO(IProject project)
|
|
||||||
{
|
|
||||||
ProjectToDTOConvertStrategy convertStrategy = new()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = refDictinary,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
DictionaryConvertStrategy<ProjectDTO, IProject> dictionaryConvertStrategy = new()
|
|
||||||
{
|
|
||||||
ConvertStrategy = convertStrategy,
|
|
||||||
ReferenceDictionary = refDictinary,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
return dictionaryConvertStrategy.Convert(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
private FileVersionDTO GetVersionDTO()
|
|
||||||
{
|
|
||||||
FileVersionToDTOConvertStrategy fileVersionDTOConvertStrategy = new()
|
|
||||||
{
|
|
||||||
ReferenceDictionary = refDictinary,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
DictionaryConvertStrategy<FileVersionDTO,IFileVersion> dictionaryConvertStrategy = new()
|
|
||||||
{
|
|
||||||
ConvertStrategy = fileVersionDTOConvertStrategy,
|
|
||||||
ReferenceDictionary = refDictinary,
|
|
||||||
TraceLogger = TraceLogger
|
|
||||||
};
|
|
||||||
var versionDTO = dictionaryConvertStrategy.Convert(version);
|
|
||||||
return versionDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string Serialize(object obj, IShiftTraceLogger logger)
|
|
||||||
{
|
|
||||||
List<(Type type, string name)> typesNames = TypeBinderListFactory.GetTypeNameList(TypeFileVersion.version_v1);
|
|
||||||
TypeBinder typeBinder = new(typesNames);
|
|
||||||
var settings = new JsonSerializerSettings
|
|
||||||
{
|
|
||||||
Converters = new List<JsonConverter>
|
|
||||||
{
|
|
||||||
// Add other converters if needed
|
|
||||||
new FileVersionDTOJsonConverter(logger), // Add the specific converter
|
|
||||||
new ProjectDTOJsonConverter(logger)
|
|
||||||
},
|
|
||||||
SerializationBinder = typeBinder,
|
|
||||||
Formatting = Formatting.Indented,
|
|
||||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
|
||||||
MissingMemberHandling = MissingMemberHandling.Ignore,
|
|
||||||
TypeNameHandling = TypeNameHandling.All,
|
|
||||||
NullValueHandling = NullValueHandling.Include
|
|
||||||
};
|
|
||||||
|
|
||||||
return JsonConvert.SerializeObject(obj, settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveFileAs(IProject project)
|
|
||||||
{
|
|
||||||
var tmpIsNew = project.IsNewFile;
|
|
||||||
var tmpFullFileName = project.FullFileName;
|
|
||||||
project.IsNewFile = true;
|
|
||||||
SaveFile(project);
|
|
||||||
if (project.IsNewFile == true)
|
|
||||||
{
|
|
||||||
project.IsNewFile = tmpIsNew;
|
|
||||||
project.FullFileName = tmpFullFileName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
|
|
||||||
namespace DataAccess.Infrastructures
|
|
||||||
{
|
|
||||||
public interface IFileOpenLogic : ILogic
|
|
||||||
{
|
|
||||||
OpenProjectResult OpenFile();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.Infrastructures
|
|
||||||
{
|
|
||||||
public interface IFileSaveLogic : ILogic
|
|
||||||
{
|
|
||||||
void SaveFile(IProject project);
|
|
||||||
void SaveFileAs(IProject project);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using StructureHelperCommon.Services.FileServices;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.Infrastructures
|
|
||||||
{
|
|
||||||
public interface IProjectAccessLogic : ILogic
|
|
||||||
{
|
|
||||||
OpenProjectResult OpenProject();
|
|
||||||
void SaveProject(IProject project);
|
|
||||||
void SaveProjectAs(IProject project);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using StructureHelperCommon.Models.Calculators;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.Infrastructures
|
|
||||||
{
|
|
||||||
public class OpenProjectResult : IResult
|
|
||||||
{
|
|
||||||
public bool IsValid { get; set; } = true;
|
|
||||||
public string? Description { get; set; } = string.Empty;
|
|
||||||
public IProject Project { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using StructureHelperCommon.Services.FileServices;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.Infrastructures
|
|
||||||
{
|
|
||||||
public class ProjectAccessLogic : IProjectAccessLogic
|
|
||||||
{
|
|
||||||
private IFileOpenLogic openLogic;
|
|
||||||
private IFileSaveLogic saveLogic;
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public ProjectAccessLogic(IFileOpenLogic openLogic, IFileSaveLogic saveLogic)
|
|
||||||
{
|
|
||||||
this.openLogic = openLogic;
|
|
||||||
this.saveLogic = saveLogic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectAccessLogic() : this(new FileOpenLogic(), new FileSaveLogic())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenProjectResult OpenProject()
|
|
||||||
{
|
|
||||||
openLogic.TraceLogger = TraceLogger;
|
|
||||||
return openLogic.OpenFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveProject(IProject project)
|
|
||||||
{
|
|
||||||
saveLogic.TraceLogger = TraceLogger;
|
|
||||||
saveLogic.SaveFile(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveProjectAs(IProject project)
|
|
||||||
{
|
|
||||||
saveLogic.TraceLogger = TraceLogger;
|
|
||||||
saveLogic.SaveFileAs(project);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class BaseJsonConverter<T> : JsonConverter<T>
|
|
||||||
{
|
|
||||||
private IWriteJsonLogic<T> writeJsonLogic;
|
|
||||||
private IReadJsonLogic<T> readJsonLogic;
|
|
||||||
|
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
protected BaseJsonConverter(IShiftTraceLogger logger, IWriteJsonLogic<T> writeJsonLogic, IReadJsonLogic<T> readJsonLogic)
|
|
||||||
{
|
|
||||||
this.writeJsonLogic = writeJsonLogic;
|
|
||||||
this.readJsonLogic = readJsonLogic;
|
|
||||||
TraceLogger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BaseJsonConverter(IShiftTraceLogger logger)
|
|
||||||
: this (logger,
|
|
||||||
new WriteJsonLogic<T>() { TraceLogger = logger},
|
|
||||||
new ReadJsonLogic<T>() { TraceLogger = logger})
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
writeJsonLogic.TraceLogger = TraceLogger;
|
|
||||||
writeJsonLogic.WriteJson(writer, value, serializer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override T ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
readJsonLogic.TraceLogger = TraceLogger;
|
|
||||||
return readJsonLogic.ReadJson(reader, objectType, existingValue, hasExistingValue, serializer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using DataAccess.DTOs;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
public class CrossSectionJsonConverter : BaseJsonConverter<CrossSectionDTO>
|
|
||||||
{
|
|
||||||
public CrossSectionJsonConverter(IShiftTraceLogger logger) : base(logger)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using DataAccess.DTOs;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
public class FileVersionDTOJsonConverter : BaseJsonConverter<FileVersionDTO>
|
|
||||||
{
|
|
||||||
public FileVersionDTOJsonConverter(IShiftTraceLogger logger) : base(logger)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public class GetIdFromObjectLogic : IGetIdFromObjectLogic
|
|
||||||
{
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public Guid GetId(object obj)
|
|
||||||
{
|
|
||||||
var idProp = obj.GetType().GetProperty("Id");
|
|
||||||
return idProp != null ? (Guid)idProp.GetValue(obj) : Guid.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
public class GetPropertyNameLogic : IGetPropertyNameLogic
|
|
||||||
{
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
|
|
||||||
// Helper method to get the property name, considering [JsonProperty] and [JsonPropertyName] attributes
|
|
||||||
public string GetPropertyName(PropertyInfo prop)
|
|
||||||
{
|
|
||||||
// Check for [JsonProperty] attribute (for Newtonsoft.Json)
|
|
||||||
var jsonPropertyAttribute = prop.GetCustomAttribute<JsonPropertyAttribute>();
|
|
||||||
if (jsonPropertyAttribute != null)
|
|
||||||
{
|
|
||||||
return jsonPropertyAttribute.PropertyName;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for [JsonPropertyName] attribute (for System.Text.Json compatibility)
|
|
||||||
var jsonPropertyNameAttribute = prop.GetCustomAttribute<System.Text.Json.Serialization.JsonPropertyNameAttribute>();
|
|
||||||
if (jsonPropertyNameAttribute != null)
|
|
||||||
{
|
|
||||||
return jsonPropertyNameAttribute.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default to the property name if no attributes are found
|
|
||||||
return prop.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Logic to get the ID for logging purposes, assumes all classes have an 'Id' property of type Guid.
|
|
||||||
/// </summary>
|
|
||||||
public interface IGetIdFromObjectLogic : ILogic
|
|
||||||
{
|
|
||||||
Guid GetId(object obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Helper logic to get the property name, considering [JsonProperty] and [JsonPropertyName] attributes
|
|
||||||
/// </summary>
|
|
||||||
public interface IGetPropertyNameLogic : ILogic
|
|
||||||
{
|
|
||||||
string GetPropertyName(PropertyInfo prop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Helper logic for JSON converter
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public interface IReadJsonLogic<T> : ILogic
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reader"></param>
|
|
||||||
/// <param name="objectType"></param>
|
|
||||||
/// <param name="existingValue"></param>
|
|
||||||
/// <param name="hasExistingValue"></param>
|
|
||||||
/// <param name="serializer"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
T ReadJson(JsonReader reader, Type objectType, T existingValue, bool hasExistingValue, JsonSerializer serializer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Helper logic to check if a property should be ignored
|
|
||||||
/// </summary>
|
|
||||||
public interface IShouldIgnorePropertyLogic : ILogic
|
|
||||||
{
|
|
||||||
bool ShouldIgnoreProperty(PropertyInfo prop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
public interface IWriteJsonLogic<T> : ILogic
|
|
||||||
{
|
|
||||||
void WriteJson(JsonWriter writer, T value, JsonSerializer serializer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
public class ReadJsonLogic<T> : IReadJsonLogic<T>
|
|
||||||
{
|
|
||||||
private IShouldIgnorePropertyLogic shouldIgnorePropertyLogic;
|
|
||||||
private IGetPropertyNameLogic getPropertyNameLogic;
|
|
||||||
private IGetIdFromObjectLogic getIdFromObjectLogic;
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
|
|
||||||
public ReadJsonLogic(IShouldIgnorePropertyLogic shouldIgnorePropertyLogic,
|
|
||||||
IGetPropertyNameLogic getPropertyNameLogic,
|
|
||||||
IGetIdFromObjectLogic getIdFromObjectLogic)
|
|
||||||
{
|
|
||||||
this.shouldIgnorePropertyLogic = shouldIgnorePropertyLogic;
|
|
||||||
this.getPropertyNameLogic = getPropertyNameLogic;
|
|
||||||
this.getIdFromObjectLogic = getIdFromObjectLogic;
|
|
||||||
}
|
|
||||||
public ReadJsonLogic()
|
|
||||||
: this(new ShouldIgnorePropertyLogic(),
|
|
||||||
new GetPropertyNameLogic(),
|
|
||||||
new GetIdFromObjectLogic())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public T ReadJson(JsonReader reader, Type objectType, T existingValue, bool hasExistingValue, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage($"Deserializing {typeof(T).Name}");
|
|
||||||
shouldIgnorePropertyLogic.TraceLogger = getPropertyNameLogic.TraceLogger = getIdFromObjectLogic.TraceLogger = TraceLogger;
|
|
||||||
// Use JsonSerializer's default behavior to handle attributes during deserialization
|
|
||||||
JObject jo = JObject.Load(reader);
|
|
||||||
T obj = Activator.CreateInstance<T>();
|
|
||||||
|
|
||||||
foreach (var prop in typeof(T).GetProperties())
|
|
||||||
{
|
|
||||||
if (! shouldIgnorePropertyLogic.ShouldIgnoreProperty(prop) && jo.TryGetValue(getPropertyNameLogic.GetPropertyName(prop), out JToken value))
|
|
||||||
{
|
|
||||||
var propValue = value.ToObject(prop.PropertyType, serializer);
|
|
||||||
prop.SetValue(obj, propValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TraceLogger?.AddMessage($"Deserialized {typeof(T).Name} (ID: {getIdFromObjectLogic.GetId(obj)})");
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
public class ShouldIgnorePropertyLogic : IShouldIgnorePropertyLogic
|
|
||||||
{
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
public bool ShouldIgnoreProperty(PropertyInfo prop)
|
|
||||||
{
|
|
||||||
// Check for [JsonIgnore] attribute
|
|
||||||
var jsonIgnoreAttribute = prop.GetCustomAttribute<JsonIgnoreAttribute>();
|
|
||||||
return jsonIgnoreAttribute != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
public class WriteJsonLogic<T> : IWriteJsonLogic<T>
|
|
||||||
{
|
|
||||||
private IShouldIgnorePropertyLogic shouldIgnorePropertyLogic;
|
|
||||||
private IGetPropertyNameLogic getPropertyNameLogic;
|
|
||||||
private IGetIdFromObjectLogic getIdFromObjectLogic;
|
|
||||||
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
|
||||||
public WriteJsonLogic(IShouldIgnorePropertyLogic shouldIgnorePropertyLogic,
|
|
||||||
IGetPropertyNameLogic getPropertyNameLogic,
|
|
||||||
IGetIdFromObjectLogic getIdFromObjectLogic)
|
|
||||||
{
|
|
||||||
this.shouldIgnorePropertyLogic = shouldIgnorePropertyLogic;
|
|
||||||
this.getPropertyNameLogic = getPropertyNameLogic;
|
|
||||||
this.getIdFromObjectLogic = getIdFromObjectLogic;
|
|
||||||
}
|
|
||||||
public WriteJsonLogic()
|
|
||||||
: this(new ShouldIgnorePropertyLogic(),
|
|
||||||
new GetPropertyNameLogic(),
|
|
||||||
new GetIdFromObjectLogic())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public void WriteJson(JsonWriter writer, T value, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
TraceLogger?.AddMessage($"Serializing {typeof(T).Name} (ID: {getIdFromObjectLogic.GetId(value)})");
|
|
||||||
shouldIgnorePropertyLogic.TraceLogger = getPropertyNameLogic.TraceLogger = getIdFromObjectLogic.TraceLogger = TraceLogger;
|
|
||||||
|
|
||||||
// Use JsonSerializer's default behavior to handle attributes like [JsonIgnore] and [JsonProperty]
|
|
||||||
var jo = new JObject();
|
|
||||||
foreach (var prop in typeof(T).GetProperties())
|
|
||||||
{
|
|
||||||
if (!shouldIgnorePropertyLogic.ShouldIgnoreProperty(prop))
|
|
||||||
{
|
|
||||||
string propertyName = getPropertyNameLogic.GetPropertyName(prop);
|
|
||||||
var propValue = prop.GetValue(value);
|
|
||||||
jo.Add(propertyName, JToken.FromObject(propValue, serializer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jo.WriteTo(writer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using DataAccess.DTOs;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using StructureHelperCommon.Models.Projects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
internal class ProjectDTOJsonConverter : BaseJsonConverter<ProjectDTO>
|
|
||||||
{
|
|
||||||
public ProjectDTOJsonConverter(IShiftTraceLogger logger) : base(logger)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using DataAccess.DTOs;
|
|
||||||
using StructureHelperCommon.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DataAccess.JsonConverters
|
|
||||||
{
|
|
||||||
internal class VisualAnalysisDTOJsonConverter : BaseJsonConverter<VisualAnalysisDTO>
|
|
||||||
{
|
|
||||||
public VisualAnalysisDTOJsonConverter(IShiftTraceLogger logger) : base(logger)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,12 @@
|
|||||||
using FieldVisualizer.InfraStructures.Exceptions;
|
using FieldVisualizer.InfraStructures.Enums;
|
||||||
|
using FieldVisualizer.InfraStructures.Exceptions;
|
||||||
using FieldVisualizer.InfraStructures.Strings;
|
using FieldVisualizer.InfraStructures.Strings;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace FieldVisualizer.Entities.ColorMaps.Factories
|
namespace FieldVisualizer.Entities.ColorMaps.Factories
|
||||||
{
|
{
|
||||||
public enum ColorMapsTypes
|
|
||||||
{
|
|
||||||
LiraSpectrum = 0, //Lira
|
|
||||||
FullSpectrum = 1, //StaDiCon
|
|
||||||
RedToWhite = 2,
|
|
||||||
RedToBlue = 3,
|
|
||||||
BlueToWhite = 4,
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factory for creating of different color maps
|
/// Factory for creating of different color maps
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -24,39 +18,13 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
|
|||||||
if (mapsTypes == ColorMapsTypes.RedToWhite) { return GetRedToWhite(); }
|
if (mapsTypes == ColorMapsTypes.RedToWhite) { return GetRedToWhite(); }
|
||||||
if (mapsTypes == ColorMapsTypes.RedToBlue) { return GetRedToBlue(); }
|
if (mapsTypes == ColorMapsTypes.RedToBlue) { return GetRedToBlue(); }
|
||||||
if (mapsTypes == ColorMapsTypes.BlueToWhite) { return GetBlueToWhite(); }
|
if (mapsTypes == ColorMapsTypes.BlueToWhite) { return GetBlueToWhite(); }
|
||||||
if (mapsTypes == ColorMapsTypes.LiraSpectrum) { return GetLiraSpectrum(); }
|
|
||||||
else { throw new FieldVisulizerException(ErrorStrings.ColorMapTypeIsUnknown); }
|
else { throw new FieldVisulizerException(ErrorStrings.ColorMapTypeIsUnknown); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IColorMap GetLiraSpectrum()
|
|
||||||
{
|
|
||||||
ColorMap colorMap = new()
|
|
||||||
{
|
|
||||||
Name = "LiraSpectrumColorMap"
|
|
||||||
};
|
|
||||||
List<Color> colors = new();
|
|
||||||
byte Alpha = 0xff;
|
|
||||||
colors.AddRange(new Color[]{
|
|
||||||
Color.FromArgb(Alpha, 0, 0, 128) ,//Dark Blue
|
|
||||||
Color.FromArgb(Alpha, 0, 0, 255) ,//Blue
|
|
||||||
Color.FromArgb(Alpha, 0, 128, 255) ,//Blue
|
|
||||||
Color.FromArgb(Alpha, 0, 200, 255) ,//Blue
|
|
||||||
Color.FromArgb(Alpha, 60, 255, 255) ,//Light Blue
|
|
||||||
Color.FromArgb(Alpha, 255, 255, 128) ,//Light Yellow
|
|
||||||
Color.FromArgb(Alpha, 255, 255, 0) ,//Yellow
|
|
||||||
Color.FromArgb(Alpha, 255, 215, 0) ,//Gold
|
|
||||||
Color.FromArgb(Alpha, 255, 128, 0) ,//Orange Red
|
|
||||||
Color.FromArgb(Alpha, 255, 0, 0) ,//Red
|
|
||||||
});
|
|
||||||
colorMap.Colors = colors;
|
|
||||||
return colorMap;
|
|
||||||
}
|
|
||||||
private static IColorMap GetFullSpectrum()
|
private static IColorMap GetFullSpectrum()
|
||||||
{
|
{
|
||||||
ColorMap colorMap = new()
|
ColorMap colorMap = new ColorMap();
|
||||||
{
|
colorMap.Name = "FullSpectrumColorMap";
|
||||||
Name = "FullSpectrumColorMap"
|
|
||||||
};
|
|
||||||
List<Color> colors = new List<Color>();
|
List<Color> colors = new List<Color>();
|
||||||
byte Alpha = 0xff;
|
byte Alpha = 0xff;
|
||||||
colors.AddRange(new Color[]{
|
colors.AddRange(new Color[]{
|
||||||
@@ -75,6 +43,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
|
|||||||
colorMap.Colors = colors;
|
colorMap.Colors = colors;
|
||||||
return colorMap;
|
return colorMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IColorMap GetRedToWhite()
|
private static IColorMap GetRedToWhite()
|
||||||
{
|
{
|
||||||
ColorMap colorMap = new ColorMap();
|
ColorMap colorMap = new ColorMap();
|
||||||
@@ -88,6 +57,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
|
|||||||
colorMap.Colors = colors;
|
colorMap.Colors = colors;
|
||||||
return colorMap;
|
return colorMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IColorMap GetRedToBlue()
|
private static IColorMap GetRedToBlue()
|
||||||
{
|
{
|
||||||
ColorMap colorMap = new ColorMap();
|
ColorMap colorMap = new ColorMap();
|
||||||
@@ -101,6 +71,7 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
|
|||||||
colorMap.Colors = colors;
|
colorMap.Colors = colors;
|
||||||
return colorMap;
|
return colorMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IColorMap GetBlueToWhite()
|
private static IColorMap GetBlueToWhite()
|
||||||
{
|
{
|
||||||
ColorMap colorMap = new ColorMap();
|
ColorMap colorMap = new ColorMap();
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace FieldVisualizer.Entities.ColorMaps
|
|
||||||
{
|
|
||||||
public interface IValueColorArray
|
|
||||||
{
|
|
||||||
double AverageValue { get; set; }
|
|
||||||
Color BottomColor { get; set; }
|
|
||||||
double BottomValue { get; set; }
|
|
||||||
Color TopColor { get; set; }
|
|
||||||
double TopValue { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
using System.Windows.Media;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace FieldVisualizer.Entities.ColorMaps
|
namespace FieldVisualizer.Entities.ColorMaps
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Colored range for building color legend
|
|
||||||
/// </summary>
|
|
||||||
public interface IValueColorRange
|
public interface IValueColorRange
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Flag of activity
|
|
||||||
/// </summary>
|
|
||||||
bool IsActive { get; set; }
|
bool IsActive { get; set; }
|
||||||
IValueColorArray ExactValues { get; }
|
double BottomValue { get; set; }
|
||||||
IValueColorArray RoundedValues { get; }
|
double AverageValue { get; set; }
|
||||||
|
double TopValue {get;set;}
|
||||||
|
Color BottomColor { get; set; }
|
||||||
|
Color TopColor { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace FieldVisualizer.Entities.ColorMaps
|
|
||||||
{
|
|
||||||
public class ValueColorArray : IValueColorArray
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Minimum value of range
|
|
||||||
/// </summary>
|
|
||||||
public double BottomValue { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Average value of range
|
|
||||||
/// </summary>
|
|
||||||
public double AverageValue { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Maximum value of range
|
|
||||||
/// </summary>
|
|
||||||
public double TopValue { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Color correspondent to minimum value
|
|
||||||
/// </summary>
|
|
||||||
public Color BottomColor { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Color correspondent to maximum value
|
|
||||||
/// </summary>
|
|
||||||
public Color TopColor { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,19 @@
|
|||||||
using System.Windows.Media;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace FieldVisualizer.Entities.ColorMaps
|
namespace FieldVisualizer.Entities.ColorMaps
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
|
||||||
public class ValueColorRange : IValueColorRange
|
public class ValueColorRange : IValueColorRange
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
|
public double BottomValue { get; set; }
|
||||||
public IValueColorArray ExactValues { get; private set; } = new ValueColorArray();
|
public double AverageValue { get; set; }
|
||||||
|
public double TopValue { get; set; }
|
||||||
public IValueColorArray RoundedValues { get; private set; } = new ValueColorArray();
|
public Color BottomColor { get; set; }
|
||||||
|
public Color TopColor { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,4 @@
|
|||||||
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="InfraStructures\Enums\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
14
FieldVisualizer/InfraStructures/Enums/ColorMapsTypes.cs
Normal file
14
FieldVisualizer/InfraStructures/Enums/ColorMapsTypes.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace FieldVisualizer.InfraStructures.Enums
|
||||||
|
{
|
||||||
|
public enum ColorMapsTypes
|
||||||
|
{
|
||||||
|
FullSpectrum = 0,
|
||||||
|
RedToWhite = 1,
|
||||||
|
RedToBlue = 2,
|
||||||
|
BlueToWhite = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
using FieldVisualizer.Entities.ColorMaps;
|
using FieldVisualizer.Entities.ColorMaps;
|
||||||
using FieldVisualizer.Entities.Values;
|
using FieldVisualizer.Entities.Values;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
|
||||||
using StructureHelperCommon.Services;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -12,132 +10,54 @@ namespace FieldVisualizer.Services.ColorServices
|
|||||||
public static class ColorOperations
|
public static class ColorOperations
|
||||||
{
|
{
|
||||||
const byte Alpha = 0xff;
|
const byte Alpha = 0xff;
|
||||||
static IMathRoundLogic roundLogic = new SmartRoundLogic();
|
public static Color GetColorByValue(IValueRange range, IColorMap map, double val)
|
||||||
/// <summary>
|
{
|
||||||
///
|
if (range.TopValue == range.BottomValue || map.Colors.Count == 0) { return map.Colors[0]; }
|
||||||
/// </summary>
|
double minVal = range.BottomValue - 1e-15d*(Math.Abs(range.BottomValue));
|
||||||
/// <param name="fullRange"></param>
|
double maxVal = range.TopValue + 1e-15d * (Math.Abs(range.TopValue));
|
||||||
/// <param name="valueRanges"></param>
|
if (val > maxVal || val < minVal) { return Colors.Gray; }
|
||||||
/// <param name="colorMap"></param>
|
if (val == minVal) { return map.Colors[0]; }
|
||||||
/// <returns></returns>
|
if (val == maxVal) { return map.Colors[map.Colors.Count - 1]; }
|
||||||
|
|
||||||
|
double valPerc = (val - minVal) / (maxVal - minVal);// value%
|
||||||
|
if (valPerc >= 1d)
|
||||||
|
{ return map.Colors[map.Colors.Count - 1]; }
|
||||||
|
double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
|
||||||
|
double blockOfColor = valPerc / colorPerc;// the integer part repersents how many block to skip
|
||||||
|
int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
|
||||||
|
double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
|
||||||
|
double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
|
||||||
|
|
||||||
|
Color cTarget = map.Colors[blockIdx];
|
||||||
|
Color cNext = map.Colors[blockIdx + 1];
|
||||||
|
|
||||||
|
var deltaR = cNext.R - cTarget.R;
|
||||||
|
var deltaG = cNext.G - cTarget.G;
|
||||||
|
var deltaB = cNext.B - cTarget.B;
|
||||||
|
|
||||||
|
var R = cTarget.R + (deltaR * percOfColor);
|
||||||
|
var G = cTarget.G + (deltaG * percOfColor);
|
||||||
|
var B = cTarget.B + (deltaB * percOfColor);
|
||||||
|
|
||||||
|
Color c = map.Colors[0];
|
||||||
|
c = Color.FromArgb(Alpha, (byte)R, (byte)G, (byte)B);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
public static IEnumerable<IValueColorRange> GetValueColorRanges(IValueRange fullRange, IEnumerable<IValueRange> valueRanges, IColorMap colorMap)
|
public static IEnumerable<IValueColorRange> GetValueColorRanges(IValueRange fullRange, IEnumerable<IValueRange> valueRanges, IColorMap colorMap)
|
||||||
{
|
{
|
||||||
var colorRanges = new List<IValueColorRange>();
|
var colorRanges = new List<IValueColorRange>();
|
||||||
foreach (var valueRange in valueRanges)
|
foreach (var valueRange in valueRanges)
|
||||||
{
|
{
|
||||||
var valueColorRange = new ValueColorRange
|
IValueColorRange valueColorRange = new ValueColorRange();
|
||||||
{
|
valueColorRange.IsActive = true;
|
||||||
IsActive = true,
|
valueColorRange.BottomValue = valueRange.BottomValue;
|
||||||
};
|
valueColorRange.AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2;
|
||||||
valueColorRange.ExactValues.BottomValue = valueRange.BottomValue;
|
valueColorRange.TopValue = valueRange.TopValue;
|
||||||
valueColorRange.ExactValues.AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2;
|
valueColorRange.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.BottomValue);
|
||||||
valueColorRange.ExactValues.TopValue = valueRange.TopValue;
|
valueColorRange.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.TopValue);
|
||||||
valueColorRange.ExactValues.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.ExactValues.BottomValue);
|
|
||||||
valueColorRange.ExactValues.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.ExactValues.TopValue);
|
|
||||||
valueColorRange.RoundedValues.BottomValue = roundLogic.RoundValue(valueColorRange.ExactValues.BottomValue);
|
|
||||||
valueColorRange.RoundedValues.AverageValue = roundLogic.RoundValue(valueColorRange.ExactValues.AverageValue);
|
|
||||||
valueColorRange.RoundedValues.TopValue = roundLogic.RoundValue(valueColorRange.ExactValues.TopValue);
|
|
||||||
colorRanges.Add(valueColorRange);
|
colorRanges.Add(valueColorRange);
|
||||||
}
|
}
|
||||||
return colorRanges;
|
return colorRanges;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Returns color by value, range of value an color map
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="range">Range of valoue</param>
|
|
||||||
/// <param name="map">Color map</param>
|
|
||||||
/// <param name="val">Value</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Color GetColorByValue(IValueRange range, IColorMap map, double val)
|
|
||||||
{
|
|
||||||
CheckColorMap(map);
|
|
||||||
if (range.TopValue == range.BottomValue || map.Colors.Count == 1) //if range width is zero or map contain just 1 color
|
|
||||||
{
|
|
||||||
return map.Colors[0];
|
|
||||||
}
|
|
||||||
var valueRange = GetExtendedRange(range);
|
|
||||||
if (val >= valueRange.TopValue || val <= valueRange.BottomValue)
|
|
||||||
{
|
|
||||||
return GetColorValueIsOutOfRange(valueRange, map, val);
|
|
||||||
}
|
|
||||||
return GetColorValueIsInRange(valueRange, map, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color GetColorValueIsOutOfRange(IValueRange range, IColorMap map, double val)
|
|
||||||
{
|
|
||||||
if (val > range.TopValue || val < range.BottomValue)
|
|
||||||
{
|
|
||||||
return Colors.Gray;
|
|
||||||
}
|
|
||||||
if (val == range.BottomValue)
|
|
||||||
{
|
|
||||||
return map.Colors[0];
|
|
||||||
}
|
|
||||||
if (val == range.TopValue)
|
|
||||||
{
|
|
||||||
return map.Colors[^1];
|
|
||||||
}
|
|
||||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color GetColorValueIsInRange(IValueRange range, IColorMap map, double val)
|
|
||||||
{
|
|
||||||
var deltaVal = val - range.BottomValue;
|
|
||||||
var rangeWidth = range.TopValue - range.BottomValue;
|
|
||||||
var valPerc = deltaVal / rangeWidth; // percent of value on the distance from minValue to maxValue
|
|
||||||
if (valPerc >= 1d)
|
|
||||||
{
|
|
||||||
return map.Colors[^1];
|
|
||||||
}
|
|
||||||
double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
|
|
||||||
double blockOfColor = valPerc / colorPerc;// the integer part represents how many block to skip
|
|
||||||
int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
|
|
||||||
double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
|
|
||||||
double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
|
|
||||||
|
|
||||||
//in some cases due to accuracy of double type percent of color may be less than zero
|
|
||||||
if (percOfColor <= 0d)
|
|
||||||
{
|
|
||||||
return map.Colors[blockIdx];
|
|
||||||
}
|
|
||||||
Color c = GetColorByColorMap(map, blockIdx, percOfColor);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IValueRange GetExtendedRange(IValueRange range)
|
|
||||||
{
|
|
||||||
var minVal = range.BottomValue - 1e-15d * Math.Abs(range.BottomValue);
|
|
||||||
var maxVal = range.TopValue + 1e-15d * Math.Abs(range.TopValue);
|
|
||||||
return new ValueRange()
|
|
||||||
{
|
|
||||||
BottomValue = minVal,
|
|
||||||
TopValue = maxVal
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Color GetColorByColorMap(IColorMap map, int blockIdx, double percOfColor)
|
|
||||||
{
|
|
||||||
Color cTarget = map.Colors[blockIdx];
|
|
||||||
Color cNext = map.Colors[blockIdx + 1];
|
|
||||||
|
|
||||||
var deltaRed = cNext.R - cTarget.R;
|
|
||||||
var deltaGreen = cNext.G - cTarget.G;
|
|
||||||
var deltaBlue = cNext.B - cTarget.B;
|
|
||||||
|
|
||||||
var Red = cTarget.R + (deltaRed * percOfColor);
|
|
||||||
var Green = cTarget.G + (deltaGreen * percOfColor);
|
|
||||||
var Blue = cTarget.B + (deltaBlue * percOfColor);
|
|
||||||
|
|
||||||
Color c = Color.FromArgb(Alpha, (byte)Red, (byte)Green, (byte)Blue);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CheckColorMap(IColorMap map)
|
|
||||||
{
|
|
||||||
if (map.Colors.Count == 0)
|
|
||||||
{
|
|
||||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": Color map is empty");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,32 @@
|
|||||||
using FieldVisualizer.Entities.ColorMaps;
|
using FieldVisualizer.Entities.ColorMaps.Factories;
|
||||||
using FieldVisualizer.Entities.ColorMaps.Factories;
|
using FieldVisualizer.Entities.ColorMaps;
|
||||||
using FieldVisualizer.Entities.Values;
|
|
||||||
using FieldVisualizer.Entities.Values.Primitives;
|
using FieldVisualizer.Entities.Values.Primitives;
|
||||||
|
using FieldVisualizer.Entities.Values;
|
||||||
using FieldVisualizer.Infrastructure.Commands;
|
using FieldVisualizer.Infrastructure.Commands;
|
||||||
|
using FieldVisualizer.InfraStructures.Enums;
|
||||||
using FieldVisualizer.InfraStructures.Exceptions;
|
using FieldVisualizer.InfraStructures.Exceptions;
|
||||||
using FieldVisualizer.InfraStructures.Strings;
|
using FieldVisualizer.InfraStructures.Strings;
|
||||||
using FieldVisualizer.Services.ColorServices;
|
using FieldVisualizer.Services.ColorServices;
|
||||||
using FieldVisualizer.Services.PrimitiveServices;
|
using FieldVisualizer.Services.PrimitiveServices;
|
||||||
using FieldVisualizer.Services.ValueRanges;
|
using FieldVisualizer.Services.ValueRanges;
|
||||||
using FieldVisualizer.Windows.UserControls;
|
|
||||||
using StructureHelperCommon.Services;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using FieldVisualizer.Windows.UserControls;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
||||||
{
|
{
|
||||||
public class FieldViewerViewModel : ViewModelBase, IDataErrorInfo
|
public class FieldViewerViewModel : ViewModelBase, IDataErrorInfo
|
||||||
{
|
{
|
||||||
private IMathRoundLogic roundLogic = new SmartRoundLogic() { DigitQuant = 3 };
|
|
||||||
public ICommand RebuildCommand { get; }
|
public ICommand RebuildCommand { get; }
|
||||||
public ICommand ZoomInCommand { get; }
|
public ICommand ZoomInCommand { get; }
|
||||||
public ICommand ZoomOutCommand { get; }
|
public ICommand ZoomOutCommand { get; }
|
||||||
@@ -161,8 +164,8 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
|||||||
private ColorMapsTypes _ColorMapType;
|
private ColorMapsTypes _ColorMapType;
|
||||||
private IColorMap _ColorMap;
|
private IColorMap _ColorMap;
|
||||||
private IValueRange valueRange;
|
private IValueRange valueRange;
|
||||||
private IEnumerable<IValueRange> valueRanges;
|
private IEnumerable<IValueRange> _ValueRanges;
|
||||||
private IEnumerable<IValueColorRange> valueColorRanges;
|
private IEnumerable<IValueColorRange> _ValueColorRanges;
|
||||||
private bool setMinValue;
|
private bool setMinValue;
|
||||||
private bool setMaxValue;
|
private bool setMaxValue;
|
||||||
private double crossLineX;
|
private double crossLineX;
|
||||||
@@ -174,7 +177,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
|||||||
|
|
||||||
public FieldViewerViewModel()
|
public FieldViewerViewModel()
|
||||||
{
|
{
|
||||||
_ColorMapType = ColorMapsTypes.LiraSpectrum;
|
_ColorMapType = ColorMapsTypes.FullSpectrum;
|
||||||
RebuildCommand = new RelayCommand(o => ProcessPrimitives(), o => PrimitiveValidation());
|
RebuildCommand = new RelayCommand(o => ProcessPrimitives(), o => PrimitiveValidation());
|
||||||
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
|
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
|
||||||
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
|
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
|
||||||
@@ -192,7 +195,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
|||||||
if ((PrimitiveSet is null) == false)
|
if ((PrimitiveSet is null) == false)
|
||||||
{
|
{
|
||||||
ProcessPrimitives();
|
ProcessPrimitives();
|
||||||
Legend.ValueColorRanges = valueColorRanges;
|
Legend.ValueColorRanges = _ValueColorRanges;
|
||||||
Legend.Refresh();
|
Legend.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,14 +262,14 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
|||||||
{
|
{
|
||||||
SolidColorBrush brush = new SolidColorBrush();
|
SolidColorBrush brush = new SolidColorBrush();
|
||||||
brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value);
|
brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value);
|
||||||
foreach (var valueRange in valueColorRanges)
|
foreach (var valueRange in _ValueColorRanges)
|
||||||
{
|
{
|
||||||
if (valuePrimitive.Value >= valueRange.ExactValues.BottomValue & valuePrimitive.Value <= valueRange.ExactValues.TopValue & (!valueRange.IsActive))
|
if (valuePrimitive.Value >= valueRange.BottomValue & valuePrimitive.Value <= valueRange.TopValue & (!valueRange.IsActive))
|
||||||
{
|
{
|
||||||
brush.Color = Colors.Gray;
|
brush.Color = Colors.Gray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shape.ToolTip = roundLogic.RoundValue(valuePrimitive.Value);
|
shape.ToolTip = valuePrimitive.Value;
|
||||||
shape.Tag = valuePrimitive;
|
shape.Tag = valuePrimitive;
|
||||||
shape.Fill = brush;
|
shape.Fill = brush;
|
||||||
Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX);
|
Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX);
|
||||||
@@ -303,24 +306,10 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
|
|||||||
{
|
{
|
||||||
UserValueRange.TopValue = UserValueRange.BottomValue;
|
UserValueRange.TopValue = UserValueRange.BottomValue;
|
||||||
}
|
}
|
||||||
if (SetMinValue == true)
|
if (SetMinValue) { valueRange.BottomValue = UserValueRange.BottomValue; } else { UserValueRange.BottomValue = valueRange.BottomValue; }
|
||||||
{
|
if (SetMaxValue) { valueRange.TopValue = UserValueRange.TopValue; } else { UserValueRange.TopValue = valueRange.TopValue; }
|
||||||
valueRange.BottomValue = UserValueRange.BottomValue;
|
_ValueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
|
||||||
}
|
_ValueColorRanges = ColorOperations.GetValueColorRanges(valueRange, _ValueRanges, _ColorMap);
|
||||||
else
|
|
||||||
{
|
|
||||||
UserValueRange.BottomValue = valueRange.BottomValue;
|
|
||||||
}
|
|
||||||
if (SetMaxValue == true)
|
|
||||||
{
|
|
||||||
valueRange.TopValue = UserValueRange.TopValue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UserValueRange.TopValue = valueRange.TopValue;
|
|
||||||
}
|
|
||||||
valueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
|
|
||||||
valueColorRanges = ColorOperations.GetValueColorRanges(valueRange, valueRanges, _ColorMap);
|
|
||||||
}
|
}
|
||||||
private void SetCrossLine(object commandParameter)
|
private void SetCrossLine(object commandParameter)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
using FieldVisualizer.Entities.Values.Primitives;
|
using FieldVisualizer.Entities.ColorMaps;
|
||||||
|
using FieldVisualizer.Entities.ColorMaps.Factories;
|
||||||
|
using FieldVisualizer.Entities.Values;
|
||||||
|
using FieldVisualizer.Entities.Values.Primitives;
|
||||||
|
using FieldVisualizer.Infrastructure.Commands;
|
||||||
|
using FieldVisualizer.InfraStructures.Enums;
|
||||||
|
using FieldVisualizer.InfraStructures.Exceptions;
|
||||||
|
using FieldVisualizer.InfraStructures.Strings;
|
||||||
|
using FieldVisualizer.Services.ColorServices;
|
||||||
|
using FieldVisualizer.Services.PrimitiveServices;
|
||||||
|
using FieldVisualizer.Services.ValueRanges;
|
||||||
using FieldVisualizer.ViewModels.FieldViewerViewModels;
|
using FieldVisualizer.ViewModels.FieldViewerViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
namespace FieldVisualizer.Windows.UserControls
|
namespace FieldVisualizer.Windows.UserControls
|
||||||
{
|
{
|
||||||
@@ -23,6 +39,17 @@ namespace FieldVisualizer.Windows.UserControls
|
|||||||
viewModel.Legend = LegendViewer;
|
viewModel.Legend = LegendViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public FieldViewer(FieldViewerViewModel vm)
|
||||||
|
//{
|
||||||
|
// InitializeComponent();
|
||||||
|
// viewModel = vm;
|
||||||
|
// this.DataContext = viewModel;
|
||||||
|
// PrimitiveSet = viewModel.PrimitiveSet;
|
||||||
|
// viewModel.WorkPlaneBox = WorkPlaneBox;
|
||||||
|
// viewModel.WorkPlaneCanvas = WorkPlaneCanvas;
|
||||||
|
// viewModel.Legend = LegendViewer;
|
||||||
|
//}
|
||||||
|
|
||||||
public IPrimitiveSet PrimitiveSet { get => viewModel.PrimitiveSet; set { viewModel.PrimitiveSet = value; } }
|
public IPrimitiveSet PrimitiveSet { get => viewModel.PrimitiveSet; set { viewModel.PrimitiveSet = value; } }
|
||||||
|
|
||||||
internal void Refresh()
|
internal void Refresh()
|
||||||
|
|||||||
@@ -20,23 +20,23 @@
|
|||||||
<ColumnDefinition Width="10"/>
|
<ColumnDefinition Width="10"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<CheckBox Name="ActiveCheckBox" Grid.Column="0" IsChecked="{Binding Path=IsActive}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
<CheckBox Name="ActiveCheckBox" Grid.Column="0" IsChecked="{Binding Path=IsActive}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
<Rectangle Grid.Column="1" Margin="0,2,0,2" ToolTip="{Binding Path=RoundedValues.BottomValue}">
|
<Rectangle Grid.Column="1" Margin="0,2,0,2" ToolTip="{Binding Path=BottomValue}">
|
||||||
<Rectangle.Fill>
|
<Rectangle.Fill>
|
||||||
<SolidColorBrush Color="{Binding Path=ExactValues.BottomColor}"/>
|
<SolidColorBrush Color="{Binding Path=BottomColor}"/>
|
||||||
</Rectangle.Fill>
|
</Rectangle.Fill>
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
<Rectangle Grid.Column="2" Margin="0,2,0,2">
|
<Rectangle Grid.Column="2" Margin="0,2,0,2">
|
||||||
<Rectangle.Fill>
|
<Rectangle.Fill>
|
||||||
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
|
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
|
||||||
<GradientStop Color="{Binding Path=ExactValues.BottomColor}"/>
|
<GradientStop Color="{Binding Path=BottomColor}"/>
|
||||||
<GradientStop Color="{Binding Path=ExactValues.TopColor}" Offset="1"/>
|
<GradientStop Color="{Binding Path=TopColor}" Offset="1"/>
|
||||||
</LinearGradientBrush>
|
</LinearGradientBrush>
|
||||||
</Rectangle.Fill>
|
</Rectangle.Fill>
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
<TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686" Text="{Binding RoundedValues.AverageValue}"/>
|
<TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686" Text="{Binding AverageValue}"/>
|
||||||
<Rectangle Grid.Column="3" Margin="0,2,0,2" ToolTip="{Binding Path=RoundedValues.TopValue}">
|
<Rectangle Grid.Column="3" Margin="0,2,0,2" ToolTip="{Binding Path=TopValue}">
|
||||||
<Rectangle.Fill>
|
<Rectangle.Fill>
|
||||||
<SolidColorBrush Color="{Binding Path=ExactValues.TopColor}"/>
|
<SolidColorBrush Color="{Binding Path=TopColor}"/>
|
||||||
</Rectangle.Fill>
|
</Rectangle.Fill>
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
xmlns:FieldViewerControl="clr-namespace:FieldVisualizer.Windows.UserControls"
|
xmlns:FieldViewerControl="clr-namespace:FieldVisualizer.Windows.UserControls"
|
||||||
xmlns:local="clr-namespace:FieldVisualizer.Windows"
|
xmlns:local="clr-namespace:FieldVisualizer.Windows"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="FieldViewer" Height="800" Width="1200" MinHeight="400" MinWidth="800" MaxHeight="1000" MaxWidth="1500" WindowStartupLocation="CenterScreen" ShowInTaskbar="False">
|
Title="FieldViewer" Height="800" Width="1200" WindowStartupLocation="CenterOwner">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="300"/>
|
<ColumnDefinition Width="300"/>
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ EndProject
|
|||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{C9192AE7-EE6D-409C-A05C-3549D78CBB34}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{C9192AE7-EE6D-409C-A05C-3549D78CBB34}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVisualizer\FieldVisualizer.csproj", "{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVisualizer\FieldVisualizer.csproj", "{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} = {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "DataAccess\DataAccess.csproj", "{BB820532-B66E-4876-903D-D6208C2A5352}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -50,10 +45,6 @@ Global
|
|||||||
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{BB820532-B66E-4876-903D-D6208C2A5352}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{BB820532-B66E-4876-903D-D6208C2A5352}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{BB820532-B66E-4876-903D-D6208C2A5352}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{BB820532-B66E-4876-903D-D6208C2A5352}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
<ResourceDictionary Source="Infrastructure/UI/Resources/IconDictionary.xaml"/>
|
<ResourceDictionary Source="Infrastructure/UI/Resources/IconDictionary.xaml"/>
|
||||||
<ResourceDictionary Source="Infrastructure/UI/Resources/GraphsTemplates.xaml"/>
|
<ResourceDictionary Source="Infrastructure/UI/Resources/GraphsTemplates.xaml"/>
|
||||||
<ResourceDictionary Source="Infrastructure/UI/Resources/LimitCurveTemplates.xaml"/>
|
<ResourceDictionary Source="Infrastructure/UI/Resources/LimitCurveTemplates.xaml"/>
|
||||||
<ResourceDictionary Source="Infrastructure/UI/Resources/ServiceColors.xaml"/>
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|||||||
@@ -22,17 +22,15 @@ namespace StructureHelper
|
|||||||
builder.RegisterType<PrimitiveRepository>().As<IPrimitiveRepository>().SingleInstance();
|
builder.RegisterType<PrimitiveRepository>().As<IPrimitiveRepository>().SingleInstance();
|
||||||
builder.RegisterType<UnitSystemService>().AsSelf().SingleInstance();
|
builder.RegisterType<UnitSystemService>().AsSelf().SingleInstance();
|
||||||
builder.RegisterType<CalculationService>().AsSelf().SingleInstance();
|
builder.RegisterType<CalculationService>().AsSelf().SingleInstance();
|
||||||
//builder.RegisterType<CrossSectionModel>().AsSelf().SingleInstance();
|
builder.RegisterType<CrossSectionModel>().AsSelf().SingleInstance();
|
||||||
//builder.RegisterType<CrossSectionViewModel>().AsSelf().SingleInstance();
|
builder.RegisterType<CrossSectionViewModel>().AsSelf().SingleInstance();
|
||||||
//builder.RegisterType<CrossSectionView>().AsSelf();
|
|
||||||
|
|
||||||
builder.RegisterType<AnalysesManagerViewModel>().AsSelf().SingleInstance();
|
builder.RegisterType<CrossSectionView>().AsSelf();
|
||||||
builder.RegisterType<AnalysesManagerView>().AsSelf();
|
|
||||||
|
|
||||||
Container = builder.Build();
|
Container = builder.Build();
|
||||||
Scope = Container.Resolve<ILifetimeScope>();
|
Scope = Container.Resolve<ILifetimeScope>();
|
||||||
|
|
||||||
var window = Scope.Resolve<AnalysesManagerView>();
|
var window = Scope.Resolve<CrossSectionView>();
|
||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,7 +10,6 @@ namespace StructureHelper.Infrastructure.Enums
|
|||||||
{
|
{
|
||||||
ForceCalculator,
|
ForceCalculator,
|
||||||
LimitCurveCalculator,
|
LimitCurveCalculator,
|
||||||
CrackCalculator,
|
|
||||||
FireCalculator
|
FireCalculator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ namespace StructureHelper.Infrastructure.Enums
|
|||||||
Reinforcement,
|
Reinforcement,
|
||||||
Elastic,
|
Elastic,
|
||||||
CarbonFiber,
|
CarbonFiber,
|
||||||
GlassFiber,
|
GlassFiber
|
||||||
Function,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
internal class Area : UnitBase
|
internal class Area : UnitBase
|
||||||
{
|
{
|
||||||
public override UnitTypes UnitType { get => UnitTypes.Area; }
|
public override UnitTypes UnitType { get => UnitTypes.Area; }
|
||||||
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm2"); }
|
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm2"); }
|
||||||
public override string UnitName { get => "Area"; }
|
public override string UnitName { get => "Area"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Services;
|
|
||||||
using StructureHelperCommon.Services.Units;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|
||||||
{
|
|
||||||
internal class CrackWidth : UnitBase
|
|
||||||
{
|
|
||||||
public CrackWidth()
|
|
||||||
{
|
|
||||||
OperationLogic = new ConvertUnitLogic()
|
|
||||||
{
|
|
||||||
MathRoundLogic = new FixedRoundLogic()
|
|
||||||
{
|
|
||||||
DigitQuant = 3
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public override UnitTypes UnitType { get => UnitTypes.Length; }
|
|
||||||
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm"); }
|
|
||||||
public override string UnitName { get => "Length"; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
internal class Curvature : UnitBase
|
internal class Curvature : UnitBase
|
||||||
{
|
{
|
||||||
public override UnitTypes UnitType { get => UnitTypes.Curvature; }
|
public override UnitTypes UnitType { get => UnitTypes.Curvature; }
|
||||||
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "1/mm"); }
|
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "1/mm"); }
|
||||||
public override string UnitName { get => "Curvature"; }
|
public override string UnitName { get => "Curvature"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
internal class Force : UnitBase
|
internal class Force : UnitBase
|
||||||
{
|
{
|
||||||
public override UnitTypes UnitType { get => UnitTypes.Force; }
|
public override UnitTypes UnitType { get => UnitTypes.Force; }
|
||||||
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "kN"); }
|
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kN"); }
|
||||||
public override string UnitName { get => "Force"; }
|
public override string UnitName { get => "Force"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
{
|
{
|
||||||
internal class Length : UnitBase
|
internal class Length : UnitBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public override UnitTypes UnitType { get => UnitTypes.Length; }
|
public override UnitTypes UnitType { get => UnitTypes.Length; }
|
||||||
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm"); }
|
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm"); }
|
||||||
public override string UnitName { get => "Length"; }
|
public override string UnitName { get => "Length"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
internal class Moment : UnitBase
|
internal class Moment : UnitBase
|
||||||
{
|
{
|
||||||
public override UnitTypes UnitType { get => UnitTypes.Moment; }
|
public override UnitTypes UnitType { get => UnitTypes.Moment; }
|
||||||
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "kNm"); }
|
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kNm"); }
|
||||||
public override string UnitName { get => "Moment"; }
|
public override string UnitName { get => "Moment"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
{
|
{
|
||||||
internal class PlainDouble : IValueConverter
|
internal class PlainDouble : IValueConverter
|
||||||
{
|
{
|
||||||
IConvertUnitLogic operationLogic = new ConvertUnitLogic();
|
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -30,7 +28,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return ProcessString.ConvertCommaToCultureSettings((string)value);
|
return CommonOperation.ConvertToDoubleChangeComma((string)value);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Services;
|
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -13,19 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
{
|
{
|
||||||
internal class Stress : UnitBase
|
internal class Stress : UnitBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public override UnitTypes UnitType { get => UnitTypes.Stress; }
|
public override UnitTypes UnitType { get => UnitTypes.Stress; }
|
||||||
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "MPa"); }
|
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "MPa"); }
|
||||||
public override string UnitName { get => "Stress"; }
|
public override string UnitName { get => "Stress"; }
|
||||||
public Stress()
|
|
||||||
{
|
|
||||||
OperationLogic = new ConvertUnitLogic()
|
|
||||||
{
|
|
||||||
MathRoundLogic = new SmartRoundLogic()
|
|
||||||
{
|
|
||||||
DigitQuant = 3
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
|
||||||
using StructureHelperCommon.Models.Parameters;
|
|
||||||
using StructureHelperCommon.Services;
|
|
||||||
using StructureHelperCommon.Services.Units;
|
using StructureHelperCommon.Services.Units;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -17,61 +14,19 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
|||||||
{
|
{
|
||||||
internal abstract class UnitBase : IValueConverter
|
internal abstract class UnitBase : IValueConverter
|
||||||
{
|
{
|
||||||
IMathRoundLogic roundLogic = new DirectRoundLogic();
|
|
||||||
public IConvertUnitLogic OperationLogic { get; set; } = new ConvertUnitLogic();
|
|
||||||
public IGetUnitLogic UnitLogic { get; set; } = new GetUnitLogic();
|
|
||||||
public abstract UnitTypes UnitType { get; }
|
public abstract UnitTypes UnitType { get; }
|
||||||
public abstract IUnit CurrentUnit { get; }
|
public abstract IUnit CurrentUnit { get; }
|
||||||
public abstract string UnitName { get;}
|
public abstract string UnitName { get;}
|
||||||
/// <summary>
|
|
||||||
/// From variable to user
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
/// <param name="targetType"></param>
|
|
||||||
/// <param name="parameter"></param>
|
|
||||||
/// <param name="culture"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
var pair = OperationLogic.Convert(CurrentUnit, UnitName, value);
|
return CommonOperation.Convert(CurrentUnit, UnitName, value);
|
||||||
var result = pair.Value;
|
|
||||||
if (parameter is not null)
|
|
||||||
{
|
|
||||||
if (parameter is string paramString)
|
|
||||||
{
|
|
||||||
var logic = new ProcessDoublePairLogic() { DigitPlace = DigitPlace.Any };
|
|
||||||
var paramPair = logic.GetValuePairByString(paramString);
|
|
||||||
string paramTextPart = paramPair.Text.ToLower();
|
|
||||||
int paramValuePart = (int)paramPair.Value;
|
|
||||||
if (paramTextPart == "smart")
|
|
||||||
{
|
|
||||||
roundLogic = new SmartRoundLogic() { DigitQuant = paramValuePart };
|
|
||||||
}
|
|
||||||
else if (paramTextPart == "fixed")
|
|
||||||
{
|
|
||||||
roundLogic = new FixedRoundLogic() { DigitQuant = paramValuePart };
|
|
||||||
}
|
|
||||||
result = roundLogic.RoundValue(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
string strValue = $"{result} {pair.Text}";
|
|
||||||
return strValue;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// From user to variable
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
/// <param name="targetType"></param>
|
|
||||||
/// <param name="parameter"></param>
|
|
||||||
/// <param name="culture"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
double result = OperationLogic.ConvertBack(UnitType, CurrentUnit, value);
|
return CommonOperation.ConvertBack(UnitType, CurrentUnit, value);
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
{
|
{
|
||||||
public class CircleViewPrimitive : PrimitiveBase, IHasCenter
|
public class CircleViewPrimitive : PrimitiveBase, IHasCenter
|
||||||
{
|
{
|
||||||
IEllipsePrimitive primitive;
|
ICirclePrimitive primitive;
|
||||||
public double Diameter
|
public double Diameter
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return primitive.DiameterByX;
|
return primitive.Diameter;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
primitive.DiameterByX = value;
|
primitive.Diameter = value;
|
||||||
RefreshPlacement();
|
RefreshPlacement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,13 +31,13 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
|
|
||||||
public CircleViewPrimitive(INdmPrimitive primitive) : base(primitive)
|
public CircleViewPrimitive(INdmPrimitive primitive) : base(primitive)
|
||||||
{
|
{
|
||||||
if (primitive is not IEllipsePrimitive)
|
if (primitive is not ICirclePrimitive)
|
||||||
{
|
{
|
||||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(IEllipsePrimitive)}, But was: {nameof(primitive)}");
|
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(ICirclePrimitive)}, But was: {nameof(primitive)}");
|
||||||
}
|
}
|
||||||
var circle = primitive as IEllipsePrimitive;
|
var circle = primitive as ICirclePrimitive;
|
||||||
this.primitive = circle;
|
this.primitive = circle;
|
||||||
DivisionViewModel = new HasDivisionViewModel(circle.DivisionSize);
|
DivisionViewModel = new HasDivisionViewModel(circle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override INdmPrimitive GetNdmPrimitive()
|
public override INdmPrimitive GetNdmPrimitive()
|
||||||
|
|||||||
@@ -2,15 +2,13 @@
|
|||||||
using StructureHelper.Services.Primitives;
|
using StructureHelper.Services.Primitives;
|
||||||
using StructureHelper.Windows.MainWindow;
|
using StructureHelper.Windows.MainWindow;
|
||||||
using StructureHelper.Windows.ViewModels.NdmCrossSections;
|
using StructureHelper.Windows.ViewModels.NdmCrossSections;
|
||||||
using StructureHelperCommon.Models.Shapes;
|
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
using System;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||||
{
|
{
|
||||||
public abstract class PrimitiveBase : ViewModelBase, IObserver<IRectangleShape>
|
public abstract class PrimitiveBase : ViewModelBase
|
||||||
{
|
{
|
||||||
#region Поля
|
#region Поля
|
||||||
private IPrimitiveRepository primitiveRepository;
|
private IPrimitiveRepository primitiveRepository;
|
||||||
@@ -60,49 +58,49 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
}
|
}
|
||||||
public bool Triangulate
|
public bool Triangulate
|
||||||
{
|
{
|
||||||
get => primitive.NdmElement.Triangulate;
|
get => primitive.Triangulate;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
primitive.NdmElement.Triangulate = value;
|
primitive.Triangulate = value;
|
||||||
OnPropertyChanged(nameof(Triangulate));
|
OnPropertyChanged(nameof(Triangulate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public double InvertedCenterY => - CenterY;
|
public double InvertedCenterY => - CenterY;
|
||||||
public double PrestrainKx
|
public double PrestrainKx
|
||||||
{ get => primitive.NdmElement.UsersPrestrain.Mx;
|
{ get => primitive.UsersPrestrain.Mx;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
primitive.NdmElement.UsersPrestrain.Mx = value;
|
primitive.UsersPrestrain.Mx = value;
|
||||||
OnPropertyChanged(nameof(PrestrainKx));
|
OnPropertyChanged(nameof(PrestrainKx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public double PrestrainKy
|
public double PrestrainKy
|
||||||
{ get => primitive.NdmElement.UsersPrestrain.My;
|
{ get => primitive.UsersPrestrain.My;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
primitive.NdmElement.UsersPrestrain.My = value;
|
primitive.UsersPrestrain.My = value;
|
||||||
OnPropertyChanged(nameof(PrestrainKy));
|
OnPropertyChanged(nameof(PrestrainKy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public double PrestrainEpsZ
|
public double PrestrainEpsZ
|
||||||
{ get => primitive.NdmElement.UsersPrestrain.Nz;
|
{ get => primitive.UsersPrestrain.Nz;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
primitive.NdmElement.UsersPrestrain.Nz = value;
|
primitive.UsersPrestrain.Nz = value;
|
||||||
OnPropertyChanged(nameof(PrestrainEpsZ));
|
OnPropertyChanged(nameof(PrestrainEpsZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double AutoPrestrainKx => primitive.NdmElement.AutoPrestrain.Mx;
|
public double AutoPrestrainKx => primitive.AutoPrestrain.Mx;
|
||||||
public double AutoPrestrainKy => primitive.NdmElement.AutoPrestrain.My;
|
public double AutoPrestrainKy => primitive.AutoPrestrain.My;
|
||||||
public double AutoPrestrainEpsZ => primitive.NdmElement.AutoPrestrain.Nz;
|
public double AutoPrestrainEpsZ => primitive.AutoPrestrain.Nz;
|
||||||
|
|
||||||
public IHeadMaterial HeadMaterial
|
public IHeadMaterial HeadMaterial
|
||||||
{
|
{
|
||||||
get => primitive.NdmElement.HeadMaterial;
|
get => primitive.HeadMaterial;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
primitive.NdmElement.HeadMaterial = value;
|
primitive.HeadMaterial = value;
|
||||||
OnPropertyChanged(nameof(HeadMaterial));
|
OnPropertyChanged(nameof(HeadMaterial));
|
||||||
OnPropertyChanged(nameof(Color));
|
OnPropertyChanged(nameof(Color));
|
||||||
}
|
}
|
||||||
@@ -121,7 +119,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
public Color Color
|
public Color Color
|
||||||
{
|
{
|
||||||
get => ((primitive.VisualProperty.SetMaterialColor == true)
|
get => ((primitive.VisualProperty.SetMaterialColor == true)
|
||||||
& (primitive.NdmElement.HeadMaterial !=null))? primitive.NdmElement.HeadMaterial.Color : primitive.VisualProperty.Color;
|
& (primitive.HeadMaterial !=null))? primitive.HeadMaterial.Color : primitive.VisualProperty.Color;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
SetMaterialColor = false;
|
SetMaterialColor = false;
|
||||||
@@ -238,6 +236,12 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
this.primitive = primitive;
|
this.primitive = primitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegisterDeltas(double dx, double dy)
|
||||||
|
{
|
||||||
|
DeltaX = dx;
|
||||||
|
DeltaY = dy;
|
||||||
|
}
|
||||||
|
|
||||||
public CrossSectionViewModel OwnerVM { get; private set; }
|
public CrossSectionViewModel OwnerVM { get; private set; }
|
||||||
|
|
||||||
public double DeltaX { get; private set; }
|
public double DeltaX { get; private set; }
|
||||||
@@ -249,6 +253,14 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
return primitive;
|
return primitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public virtual void RefreshNdmPrimitive()
|
||||||
|
//{
|
||||||
|
//}
|
||||||
|
|
||||||
|
public void RefreshColor()
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(Color));
|
||||||
|
}
|
||||||
public virtual void Refresh()
|
public virtual void Refresh()
|
||||||
{
|
{
|
||||||
OnPropertyChanged(nameof(Name));
|
OnPropertyChanged(nameof(Name));
|
||||||
@@ -261,22 +273,5 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
OnPropertyChanged(nameof(PrimitiveWidth));
|
OnPropertyChanged(nameof(PrimitiveWidth));
|
||||||
OnPropertyChanged(nameof(PrimitiveHeight));
|
OnPropertyChanged(nameof(PrimitiveHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCompleted()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnError(Exception error)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnNext(IRectangleShape value)
|
|
||||||
{
|
|
||||||
DeltaX = value.Width / 2d;
|
|
||||||
DeltaY = value.Height / 2d;
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
var rect = primitive as IRectanglePrimitive;
|
var rect = primitive as IRectanglePrimitive;
|
||||||
viewItem = new RectangleViewPrimitive(rect);
|
viewItem = new RectangleViewPrimitive(rect);
|
||||||
}
|
}
|
||||||
else if (primitive is IEllipsePrimitive)
|
else if (primitive is ICirclePrimitive)
|
||||||
{
|
{
|
||||||
var circle = primitive as IEllipsePrimitive;
|
var circle = primitive as ICirclePrimitive;
|
||||||
viewItem = new CircleViewPrimitive(circle);
|
viewItem = new CircleViewPrimitive(circle);
|
||||||
}
|
}
|
||||||
else if (primitive is IPointPrimitive & primitive is not RebarPrimitive)
|
else if (primitive is IPointPrimitive & primitive is not RebarPrimitive)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
|||||||
public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive)
|
public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive)
|
||||||
{
|
{
|
||||||
primitive = _primitive;
|
primitive = _primitive;
|
||||||
DivisionViewModel = new HasDivisionViewModel(primitive.DivisionSize);
|
DivisionViewModel = new HasDivisionViewModel(primitive);
|
||||||
}
|
}
|
||||||
public override void Refresh()
|
public override void Refresh()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
<Style TargetType="Button" x:Key="ButtonBase">
|
<Style TargetType="Button" x:Key="ButtonBase">
|
||||||
|
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="Button" x:Key="CommandButton" BasedOn="{StaticResource ButtonBase}">
|
<Style TargetType="Button" x:Key="CommandButton" BasedOn="{StaticResource ButtonBase}">
|
||||||
<Style.Setters>
|
<Style.Setters>
|
||||||
@@ -51,43 +51,11 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="ToolButton" TargetType="Button">
|
<Style x:Key="ToolButton" TargetType="Button">
|
||||||
<Style.Resources>
|
|
||||||
<Style TargetType="Image">
|
|
||||||
<Setter Property="Width" Value="32"/>
|
|
||||||
<Setter Property="Height" Value="32"/>
|
|
||||||
<Setter Property="Margin" Value="-2"/>
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
|
||||||
<Style.Triggers>
|
|
||||||
<Trigger Property="IsEnabled" Value="False">
|
|
||||||
<Setter Property="Opacity" Value="0.25"/>
|
|
||||||
</Trigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
<Style TargetType="Viewbox">
|
|
||||||
<Setter Property="Margin" Value="-2"/>
|
|
||||||
<Setter Property="Width" Value="32"/>
|
|
||||||
<Setter Property="Height" Value="32"/>
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
|
||||||
<Setter Property="Stretch" Value="UniformToFill"/>
|
|
||||||
<Style.Triggers>
|
|
||||||
<Trigger Property="IsEnabled" Value="False">
|
|
||||||
<Setter Property="Opacity" Value="0.25"/>
|
|
||||||
</Trigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
</Style.Resources>
|
|
||||||
<Setter Property="Width" Value="32"/>
|
<Setter Property="Width" Value="32"/>
|
||||||
<Setter Property="Height" Value="32"/>
|
<Setter Property="Height" Value="32"/>
|
||||||
<Setter Property="Margin" Value="2,0,2,0"/>
|
<Setter Property="Margin" Value="2,0,2,0"/>
|
||||||
<Setter Property="Background" Value="#FFA19BC3"/>
|
<Setter Property="Background" Value="#FFA19BC3"/>
|
||||||
<Setter Property="BorderBrush" Value="Black"/>
|
<Setter Property="BorderBrush" Value="#FF857AB9"/>
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style x:Key="ToolButton24" TargetType="Button" BasedOn="{StaticResource ToolButton}">
|
|
||||||
<Setter Property="Height" Value="24"/>
|
|
||||||
<Setter Property="Width" Value="24"/>
|
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="ButtonImage16" TargetType="Image">
|
<Style x:Key="ButtonImage16" TargetType="Image">
|
||||||
@@ -99,252 +67,12 @@
|
|||||||
<Setter Property="Width" Value="32"/>
|
<Setter Property="Width" Value="32"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Color x:Key="ButtonLight" A="255" B="255" G="255" R="255"/>
|
|
||||||
<Color x:Key="CalculatorColor" A="255" B="149" G="149" R="211"/>
|
|
||||||
<Color x:Key="CalculatorFrameColor" A="255" B="109" G="109" R="166"/>
|
|
||||||
<Color x:Key="ResultColor" A="255" B="200" G="200" R="200"/>
|
|
||||||
<Color x:Key="ResultFrameColor" A="255" B="100" G="100" R="100"/>
|
|
||||||
<SolidColorBrush x:Key="CalculatorCanvas" Color="{DynamicResource CalculatorColor}"/>
|
|
||||||
<SolidColorBrush x:Key="CalculatorFrame" Color="{DynamicResource CalculatorFrameColor}"/>
|
|
||||||
<SolidColorBrush x:Key="ResultCanvas" Color="{DynamicResource ResultColor}"/>
|
|
||||||
<SolidColorBrush x:Key="ResultFrame" Color="{DynamicResource ResultFrameColor}"/>
|
|
||||||
|
|
||||||
<Style x:Key="ButtonCanvas" TargetType="Canvas">
|
|
||||||
<Setter Property="Width" Value="32"/>
|
|
||||||
<Setter Property="Height" Value="32"/>
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style x:Key="ButtonCalculatorCanvas" TargetType="Canvas" BasedOn="{StaticResource ButtonCanvas}">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource CalculatorCanvas}"/>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style x:Key="ButtonResultCanvas" TargetType="Canvas" BasedOn="{StaticResource ButtonCanvas}">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource ResultCanvas}"/>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style x:Key="ButtonRect" TargetType="Rectangle">
|
|
||||||
<Setter Property="Margin" Value="3"/>
|
|
||||||
<Setter Property="Width" Value="26"/>
|
|
||||||
<Setter Property="Height" Value="26"/>
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
|
||||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
|
||||||
<Setter Property="StrokeThickness" Value="1"/>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
|
|
||||||
<DataTemplate x:Key="OkCancelButtons">
|
<DataTemplate x:Key="OkCancelButtons">
|
||||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Button Style="{StaticResource CancelButton}" Command="{Binding CancelCommand}"/>
|
<Button Style="{StaticResource CancelButton}" Command="{Binding CancelCommand}"/>
|
||||||
<Button Style="{StaticResource OkButton}" Command="{Binding OkCommand}"/>
|
<Button Style="{StaticResource OkButton}" Command="{Binding OkCommand}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate x:Key="ButtonCalculatorRectangle">
|
|
||||||
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource CalculatorFrame}">
|
|
||||||
<Rectangle.Fill>
|
|
||||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
|
||||||
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
|
|
||||||
<GradientStop Color="{DynamicResource CalculatorColor}" Offset="1"/>
|
|
||||||
</LinearGradientBrush>
|
|
||||||
</Rectangle.Fill>
|
|
||||||
</Rectangle>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="ButtonResultRectangle">
|
|
||||||
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource ResultFrame}">
|
|
||||||
<Rectangle.Fill>
|
|
||||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
|
||||||
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
|
|
||||||
<GradientStop Color="{DynamicResource ResultColor}" Offset="1"/>
|
|
||||||
</LinearGradientBrush>
|
|
||||||
</Rectangle.Fill>
|
|
||||||
</Rectangle>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="DiagramCalculator">
|
|
||||||
<Canvas Style="{DynamicResource ButtonCalculatorCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<ContentControl ContentTemplate="{DynamicResource ButtonCalculatorRectangle}"/>
|
|
||||||
<Line Margin="4" X1="0" Y1="20" X2="25" Y2="20" StrokeThickness="1.5" Stroke="{DynamicResource CalculatorFrame}"/>
|
|
||||||
<Line Margin="4" X1="4" Y1="0" X2="4" Y2="25" StrokeThickness="1.5" Stroke="{DynamicResource CalculatorFrame}"/>
|
|
||||||
<Path Margin="4" Data="M 0 5 l 4 -4 l 7 4 l 7 6 l 2 4 l -2 7 l -2 2 " Stroke="{DynamicResource CalculatorFrame}"/>
|
|
||||||
<TextBlock Margin="4,2,0,0" Text="M-N" Foreground="Black" FontSize="10" HorizontalAlignment="Stretch" FontWeight="Bold" />
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="CrackCalculator">
|
|
||||||
<Canvas Style="{DynamicResource ButtonCalculatorCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<ContentControl ContentTemplate="{DynamicResource ButtonCalculatorRectangle}"/>
|
|
||||||
<Path Margin="4" Data="M 0 0 l 25 0 l 0 20
|
|
||||||
l -4 0
|
|
||||||
l -1 -5 l 1 -5 l -2 5 l -2 5
|
|
||||||
l -3 0
|
|
||||||
l 0 -5 l 0 -10 l -2 10 l -2 5
|
|
||||||
l -3 0
|
|
||||||
l -1 -5 l 1 -5 l -2 5 l -2 5
|
|
||||||
l -4 0" Fill="{DynamicResource CalculatorFrame}"/>
|
|
||||||
<TextBlock Margin="4,2,0,0" Text="Crc" Foreground="White" FontSize="10" HorizontalAlignment="Stretch" FontWeight="Bold" />
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="CalculatorRun">
|
|
||||||
<Canvas Style="{DynamicResource ButtonCalculatorCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<ContentControl ContentTemplate="{DynamicResource ButtonCalculatorRectangle}"/>
|
|
||||||
<Path Margin="4" Data="M 4 2 l 12 10 l -12 10 l 0 -20" Fill="{DynamicResource CalculatorFrame}"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="IsoFieldResult">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<ContentControl ContentTemplate="{DynamicResource ButtonResultRectangle}"/>
|
|
||||||
<Path Margin="4" Data="M 0 0 h 20 A 20 20 90 0 1 0 24 z" Fill="Gray"/>
|
|
||||||
<Path Margin="4" Data="M 0 0 h 16 A 16 16 90 0 1 0 18 z" Fill="DarkGray"/>
|
|
||||||
<Path Margin="4" Data="M 0 0 h 10 A 10 10 90 0 1 0 10 z" Fill="LightGray"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="ShowRebarsResult">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<ContentControl ContentTemplate="{DynamicResource ButtonResultRectangle}"/>
|
|
||||||
<Rectangle Canvas.Left="8" Canvas.Top="6" Width="16" Height="21" Fill="LightGray" Stroke ="Black"/>
|
|
||||||
<Ellipse Canvas.Left="10" Canvas.Top="21" Width="4" Height="4" Fill="DarkGray" Stroke ="Black"/>
|
|
||||||
<Ellipse Canvas.Left="18" Canvas.Top="21" Width="4" Height="4" Fill="DarkGray" Stroke ="Black"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="FileOpen">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Path Margin="4" Data="M 2 6 l 8 0 l 3 3 l 6 0 l 0 12 l -17 0 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
|
|
||||||
<Path Margin="4" Data="M 6 12 l 20 0 l -5 10 l -19 0 z" Fill="LightGray" Stroke="Black" StrokeThickness="1"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="FileSave">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Rectangle Height="26" Width="26" Canvas.Left="3" Canvas.Top="3"
|
|
||||||
Fill="DarkGray" Stroke="Black" StrokeThickness="1"
|
|
||||||
RadiusX="2" RadiusY="2"/>
|
|
||||||
<Rectangle Height="8" Width="12" Canvas.Left="10" Canvas.Top="4"
|
|
||||||
Fill="LightGray" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
<Rectangle Height="6" Width="4" Canvas.Left="16" Canvas.Top="5"
|
|
||||||
Fill="DarkGray" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
<Rectangle Height="14" Width="22" Canvas.Left="5" Canvas.Top="13"
|
|
||||||
Fill="LightGray" Stroke="Black" StrokeThickness="0.5"
|
|
||||||
RadiusX="2" RadiusY="2"/>
|
|
||||||
<Line X1="7" Y1="18" X2="24" Y2="18" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
<Line X1="7" Y1="21" X2="24" Y2="21" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
<Line X1="7" Y1="24" X2="24" Y2="24" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="Diagrams">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Line X1="2" Y1="16" X2="30" Y2="16" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
<Line X1="16" Y1="2" X2="16" Y2="30" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
<Path Margin="2" Data="M 0 21 l 6 0 l 9 -8 l 9 -8 l 4 0" Stroke="Black" StrokeThickness="1"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="NdmCrossSection">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Rectangle Height="16" Width="8" Canvas.Left="12" Canvas.Top="12"
|
|
||||||
Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
|
|
||||||
<Rectangle Height="6" Width="16" Canvas.Left="8" Canvas.Top="7"
|
|
||||||
Fill="LightGray" Stroke="Black" StrokeThickness="1"/>
|
|
||||||
<Line X1="2" Y1="16" X2="30" Y2="16" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
<Line X1="16" Y1="2" X2="16" Y2="30" Stroke="Black" StrokeThickness="0.5"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="SelectAll">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="True" IsEnabled="False"/>
|
|
||||||
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="True" IsEnabled="False"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="DeSelectAll">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="False" IsEnabled="False"/>
|
|
||||||
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="False" IsEnabled="False"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="InvertSelection">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="True" IsEnabled="False"/>
|
|
||||||
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="False" IsEnabled="False"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="RunAnalisis">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Path Margin="4" Data="M 4 2 l 12 10 l -12 10 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="EditAnalisis">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Path Margin="4" Data="M 2 22 l 4 -6 l 15 -16 l 4 4 l -15 14 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<DataTemplate x:Key="DeleteAnalisis">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Line X1="4" Y1="4" X2="26" Y2="26" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
<Line X1="4" Y1="26" X2="26" Y2="4" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
<DataTemplate x:Key="AddTable">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<Rectangle Height="32" Width="32" Fill="LightGreen"/>
|
|
||||||
<Line X1="2" X2="30" Y1="2" Y2="2" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
<Line X1="2" X2="30" Y1="16" Y2="16" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
<Line X1="2" X2="30" Y1="30" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
<Line X1="2" X2="2" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
<Line X1="16" X2="16" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
<Line X1="30" X2="30" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
<DataTemplate x:Key="TestIcon">
|
|
||||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
|
||||||
<Canvas.Children>
|
|
||||||
<TextBlock Text="fx" Width="32" Height="32" Background="LightGreen"/>
|
|
||||||
</Canvas.Children>
|
|
||||||
</Canvas>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -12,6 +12,5 @@
|
|||||||
<convertersUnits:Moment x:Key="MomentConverter"/>
|
<convertersUnits:Moment x:Key="MomentConverter"/>
|
||||||
<convertersUnits:Stress x:Key="StressConverter"/>
|
<convertersUnits:Stress x:Key="StressConverter"/>
|
||||||
<convertersUnits:Curvature x:Key="Curvature"/>
|
<convertersUnits:Curvature x:Key="Curvature"/>
|
||||||
<convertersUnits:CrackWidth x:Key="CrackWidth"/>
|
|
||||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user