Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20421a79b3 | ||
|
|
0319fe1a51 | ||
|
|
0dfff6a1f1 | ||
|
|
91d31084cc |
@@ -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)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,8 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVis
|
|||||||
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} = {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}
|
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} = {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "DataAccess\DataAccess.csproj", "{BB820532-B66E-4876-903D-D6208C2A5352}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -50,10 +48,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
|
||||||
|
|||||||
@@ -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.
@@ -12,7 +12,6 @@ namespace StructureHelper.Infrastructure.Enums
|
|||||||
Reinforcement,
|
Reinforcement,
|
||||||
Elastic,
|
Elastic,
|
||||||
CarbonFiber,
|
CarbonFiber,
|
||||||
GlassFiber,
|
GlassFiber
|
||||||
Function,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -60,49 +60,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 +121,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;
|
||||||
|
|||||||
@@ -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()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -85,11 +85,6 @@
|
|||||||
<Setter Property="BorderBrush" Value="Black"/>
|
<Setter Property="BorderBrush" Value="Black"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="ToolButton24" TargetType="Button" BasedOn="{StaticResource ToolButton}">
|
|
||||||
<Setter Property="Height" Value="24"/>
|
|
||||||
<Setter Property="Width" Value="24"/>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style x:Key="ButtonImage16" TargetType="Image">
|
<Style x:Key="ButtonImage16" TargetType="Image">
|
||||||
<Setter Property="Height" Value="16"/>
|
<Setter Property="Height" Value="16"/>
|
||||||
<Setter Property="Width" Value="16"/>
|
<Setter Property="Width" Value="16"/>
|
||||||
@@ -141,15 +136,15 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate x:Key="ButtonCalculatorRectangle">
|
<DataTemplate x:Key="ButtonCalculatorRectangle">
|
||||||
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource CalculatorFrame}">
|
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource CalculatorFrame}">
|
||||||
<Rectangle.Fill>
|
<Rectangle.Fill>
|
||||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||||
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
|
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
|
||||||
<GradientStop Color="{DynamicResource CalculatorColor}" Offset="1"/>
|
<GradientStop Color="{DynamicResource CalculatorColor}" Offset="1"/>
|
||||||
</LinearGradientBrush>
|
</LinearGradientBrush>
|
||||||
</Rectangle.Fill>
|
</Rectangle.Fill>
|
||||||
</Rectangle>
|
</Rectangle>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate x:Key="ButtonResultRectangle">
|
<DataTemplate x:Key="ButtonResultRectangle">
|
||||||
@@ -223,128 +218,4 @@
|
|||||||
</Canvas>
|
</Canvas>
|
||||||
</DataTemplate>
|
</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>
|
||||||
Binary file not shown.
Binary file not shown.
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<History>True|2024-08-13T09:00:35.8311260Z||;True|2024-08-12T12:59:16.1785759+05:00||;True|2024-03-11T20:33:14.1457807+05:00||;True|2024-03-10T19:11:27.6834663+05:00||;True|2024-02-02T12:22:50.1454015+05:00||;True|2023-02-25T13:37:39.2738786+05:00||;False|2023-02-25T13:37:24.0284261+05:00||;True|2023-02-25T13:34:01.6858860+05:00||;True|2023-02-25T13:31:18.8295711+05:00||;False|2023-02-25T13:25:21.5807199+05:00||;False|2023-02-25T13:24:41.7164398+05:00||;</History>
|
<History>True|2024-03-11T15:33:14.1457807Z;True|2024-03-10T19:11:27.6834663+05:00;True|2024-02-02T12:22:50.1454015+05:00;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;</History>
|
||||||
<LastFailureDetails />
|
<LastFailureDetails />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -20,7 +20,7 @@ namespace StructureHelper.Services.Settings
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
materials ??= new ListRepository<IHeadMaterial>(new HeadMaterialUpdateStrategy());
|
materials ??= new ListRepository<IHeadMaterial>(new MaterialUpdateStrategy());
|
||||||
return materials;
|
return materials;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,6 @@
|
|||||||
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
|
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
|
||||||
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
|
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
|
||||||
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
|
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
|
||||||
<None Remove="Windows\MainWindow\AddFormula.png" />
|
|
||||||
<None Remove="Windows\MainWindow\AddTable.png" />
|
|
||||||
<None Remove="Windows\MainWindow\Analysis32.png" />
|
<None Remove="Windows\MainWindow\Analysis32.png" />
|
||||||
<None Remove="Windows\MainWindow\Beam32.png" />
|
<None Remove="Windows\MainWindow\Beam32.png" />
|
||||||
<None Remove="Windows\MainWindow\Calculator32.png" />
|
<None Remove="Windows\MainWindow\Calculator32.png" />
|
||||||
@@ -39,11 +37,7 @@
|
|||||||
<None Remove="Windows\MainWindow\Delete.png" />
|
<None Remove="Windows\MainWindow\Delete.png" />
|
||||||
<None Remove="Windows\MainWindow\Edit.png" />
|
<None Remove="Windows\MainWindow\Edit.png" />
|
||||||
<None Remove="Windows\MainWindow\ElasticMaterial32.png" />
|
<None Remove="Windows\MainWindow\ElasticMaterial32.png" />
|
||||||
<None Remove="Windows\MainWindow\FunctionMaterial.png" />
|
|
||||||
<None Remove="Windows\MainWindow\GetY.png" />
|
|
||||||
<None Remove="Windows\MainWindow\GlassMaterial32.png" />
|
<None Remove="Windows\MainWindow\GlassMaterial32.png" />
|
||||||
<None Remove="Windows\MainWindow\LimX.png" />
|
|
||||||
<None Remove="Windows\MainWindow\LimY.png" />
|
|
||||||
<None Remove="Windows\MainWindow\Materials32.png" />
|
<None Remove="Windows\MainWindow\Materials32.png" />
|
||||||
<None Remove="Windows\MainWindow\MovePrimitivesToCenter.png" />
|
<None Remove="Windows\MainWindow\MovePrimitivesToCenter.png" />
|
||||||
<None Remove="Windows\MainWindow\Point32.png" />
|
<None Remove="Windows\MainWindow\Point32.png" />
|
||||||
@@ -52,28 +46,24 @@
|
|||||||
<None Remove="Windows\MainWindow\RectangleColumn32.png" />
|
<None Remove="Windows\MainWindow\RectangleColumn32.png" />
|
||||||
<None Remove="Windows\MainWindow\RFMaterial32.png" />
|
<None Remove="Windows\MainWindow\RFMaterial32.png" />
|
||||||
<None Remove="Windows\MainWindow\Run.png" />
|
<None Remove="Windows\MainWindow\Run.png" />
|
||||||
<None Remove="Windows\MainWindow\ScaleX.png" />
|
|
||||||
<None Remove="Windows\MainWindow\ScaleY.png" />
|
|
||||||
<None Remove="Windows\MainWindow\Slab32.png" />
|
<None Remove="Windows\MainWindow\Slab32.png" />
|
||||||
<None Remove="Windows\MainWindow\ToBackground.png" />
|
<None Remove="Windows\MainWindow\ToBackground.png" />
|
||||||
<None Remove="Windows\MainWindow\ToForeground.png" />
|
<None Remove="Windows\MainWindow\ToForeground.png" />
|
||||||
<None Remove="Windows\MainWindow\Tools_Settings.png" />
|
<None Remove="Windows\MainWindow\Tools_Settings.png" />
|
||||||
<None Remove="Windows\MainWindow\Tree.png" />
|
|
||||||
<None Remove="Windows\MainWindow\СarbonMaterial32.png" />
|
<None Remove="Windows\MainWindow\СarbonMaterial32.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Autofac" Version="8.1.0" />
|
<PackageReference Include="Autofac" Version="6.5.0" />
|
||||||
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
|
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
|
||||||
<PackageReference Include="LiveCharts.Wpf.Core" Version="0.9.8" />
|
<PackageReference Include="LiveCharts.Wpf.Core" Version="0.9.8" />
|
||||||
<PackageReference Include="LiveCharts.Wpf.NetCore3" Version="0.9.8" />
|
<PackageReference Include="LiveCharts.Wpf.NetCore3" Version="0.9.7" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||||
<PackageReference Include="System.Windows.Interactivity.WPF" Version="2.0.20525" />
|
<PackageReference Include="System.Windows.Interactivity.WPF" Version="2.0.20525" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DataAccess\DataAccess.csproj" />
|
|
||||||
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
|
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
|
||||||
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
|
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
|
||||||
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj" />
|
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj" />
|
||||||
@@ -103,8 +93,6 @@
|
|||||||
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
|
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
|
||||||
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
|
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
|
||||||
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
|
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
|
||||||
<Resource Include="Windows\MainWindow\AddFormula.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\AddTable.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\Analysis32.png" />
|
<Resource Include="Windows\MainWindow\Analysis32.png" />
|
||||||
<Resource Include="Windows\MainWindow\Beam32.png" />
|
<Resource Include="Windows\MainWindow\Beam32.png" />
|
||||||
<Resource Include="Windows\MainWindow\Calculator32.png" />
|
<Resource Include="Windows\MainWindow\Calculator32.png" />
|
||||||
@@ -115,26 +103,19 @@
|
|||||||
<Resource Include="Windows\MainWindow\Delete.png" />
|
<Resource Include="Windows\MainWindow\Delete.png" />
|
||||||
<Resource Include="Windows\MainWindow\Edit.png" />
|
<Resource Include="Windows\MainWindow\Edit.png" />
|
||||||
<Resource Include="Windows\MainWindow\ElasticMaterial32.png" />
|
<Resource Include="Windows\MainWindow\ElasticMaterial32.png" />
|
||||||
<Resource Include="Windows\MainWindow\GetY.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\GlassMaterial32.png" />
|
<Resource Include="Windows\MainWindow\GlassMaterial32.png" />
|
||||||
<Resource Include="Windows\MainWindow\LimX.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\LimY.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\Materials32.png" />
|
<Resource Include="Windows\MainWindow\Materials32.png" />
|
||||||
<Resource Include="Windows\MainWindow\MovePrimitivesToCenter.png" />
|
<Resource Include="Windows\MainWindow\MovePrimitivesToCenter.png" />
|
||||||
<Resource Include="Windows\MainWindow\Point32.png" />
|
<Resource Include="Windows\MainWindow\Point32.png" />
|
||||||
<Resource Include="Windows\MainWindow\Rebar32.png" />
|
<Resource Include="Windows\MainWindow\Rebar32.png" />
|
||||||
<Resource Include="Windows\MainWindow\Rectangle32.png" />
|
<Resource Include="Windows\MainWindow\Rectangle32.png" />
|
||||||
<Resource Include="Windows\MainWindow\RectangleColumn32.png" />
|
<Resource Include="Windows\MainWindow\RectangleColumn32.png" />
|
||||||
<Resource Include="Windows\MainWindow\FunctionMaterial.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\RFMaterial32.png" />
|
<Resource Include="Windows\MainWindow\RFMaterial32.png" />
|
||||||
<Resource Include="Windows\MainWindow\Run.png" />
|
<Resource Include="Windows\MainWindow\Run.png" />
|
||||||
<Resource Include="Windows\MainWindow\ScaleX.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\ScaleY.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\Slab32.png" />
|
<Resource Include="Windows\MainWindow\Slab32.png" />
|
||||||
<Resource Include="Windows\MainWindow\ToBackground.png" />
|
<Resource Include="Windows\MainWindow\ToBackground.png" />
|
||||||
<Resource Include="Windows\MainWindow\ToForeground.png" />
|
<Resource Include="Windows\MainWindow\ToForeground.png" />
|
||||||
<Resource Include="Windows\MainWindow\Tools_Settings.png" />
|
<Resource Include="Windows\MainWindow\Tools_Settings.png" />
|
||||||
<Resource Include="Windows\MainWindow\Tree.png" />
|
|
||||||
<Resource Include="Windows\MainWindow\СarbonMaterial32.png" />
|
<Resource Include="Windows\MainWindow\СarbonMaterial32.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_LastSelectedProfileId>C:\Repos\StructureHelper\StructureHelper\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
<_LastSelectedProfileId>C:\Source\Repos\StructureHelper\StructureHelper\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ApplicationDefinition Update="App.xaml">
|
<ApplicationDefinition Update="App.xaml">
|
||||||
@@ -57,24 +57,9 @@
|
|||||||
<Compile Update="Windows\Graphs\GraphView.xaml.cs">
|
<Compile Update="Windows\Graphs\GraphView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Windows\MainGraph\FormulaView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\MainGraph\TableView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\MainGraph\GraphView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\MainWindow\AboutView.xaml.cs">
|
<Compile Update="Windows\MainWindow\AboutView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Windows\MainWindow\AnalysesManagerView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\MainWindow\Analyses\AnalysisView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\MainWindow\Materials\HeadMaterialView.xaml.cs">
|
<Compile Update="Windows\MainWindow\Materials\HeadMaterialView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -87,21 +72,6 @@
|
|||||||
<Compile Update="Windows\Services\CopyByParameterView.xaml.cs">
|
<Compile Update="Windows\Services\CopyByParameterView.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Windows\TreeGraph\GetValueView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\TreeGraph\LimView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\TreeGraph\RenameView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\TreeGraph\ScaleView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\TreeGraph\TreeGraphView.xaml.cs">
|
|
||||||
<SubType>Code</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Windows\UserControls\MultiplyDouble.xaml.cs">
|
<Compile Update="Windows\UserControls\MultiplyDouble.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -179,24 +149,9 @@
|
|||||||
<Page Update="Windows\Graphs\GraphView.xaml">
|
<Page Update="Windows\Graphs\GraphView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Update="Windows\MainGraph\FormulaView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\MainGraph\TableView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\MainGraph\GraphView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\MainWindow\AboutView.xaml">
|
<Page Update="Windows\MainWindow\AboutView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Update="Windows\MainWindow\AnalysesManagerView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\MainWindow\Analyses\AnalysisView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\MainWindow\Materials\HeadMaterialView.xaml">
|
<Page Update="Windows\MainWindow\Materials\HeadMaterialView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
@@ -209,18 +164,6 @@
|
|||||||
<Page Update="Windows\Services\CopyByParameterView.xaml">
|
<Page Update="Windows\Services\CopyByParameterView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Update="Windows\TreeGraph\LimView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\TreeGraph\RenameView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\TreeGraph\ScaleView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\TreeGraph\TreeGraphView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</Page>
|
|
||||||
<Page Update="Windows\UserControls\MultiplyDouble.xaml">
|
<Page Update="Windows\UserControls\MultiplyDouble.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
|||||||
{
|
{
|
||||||
static IConvertUnitLogic operationLogic = new ConvertUnitLogic();
|
static IConvertUnitLogic operationLogic = new ConvertUnitLogic();
|
||||||
static IGetUnitLogic unitLogic = new GetUnitLogic();
|
static IGetUnitLogic unitLogic = new GetUnitLogic();
|
||||||
static readonly CrackForceBynarySearchCalculator calculator = new();
|
static readonly CrackForceCalculator calculator = new();
|
||||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||||
|
|
||||||
private List<IForcesTupleResult> ValidTupleList { get; set; }
|
private List<IForcesTupleResult> ValidTupleList { get; set; }
|
||||||
@@ -103,7 +103,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
|||||||
validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
|
validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
|
||||||
validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer
|
validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer
|
||||||
};
|
};
|
||||||
calculator.InputData.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple;
|
calculator.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple;
|
||||||
var limitState = validTupleList[i].DesignForceTuple.LimitState;
|
var limitState = validTupleList[i].DesignForceTuple.LimitState;
|
||||||
var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm;
|
var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm;
|
||||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||||
@@ -114,7 +114,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
|||||||
TraceLogger = TraceLogger
|
TraceLogger = TraceLogger
|
||||||
};
|
};
|
||||||
var ndms = triangulateLogic.GetNdms();
|
var ndms = triangulateLogic.GetNdms();
|
||||||
calculator.InputData.CheckedNdmCollection = calculator.InputData.SectionNdmCollection = ndms;
|
calculator.NdmCollection = ndms;
|
||||||
calculator.Run();
|
calculator.Run();
|
||||||
var result = (CrackForceResult)calculator.Result;
|
var result = (CrackForceResult)calculator.Result;
|
||||||
if (result.IsValid == false)
|
if (result.IsValid == false)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
|
|||||||
public class CrackCalculatorInputDataViewModel : OkCancelViewModelBase
|
public class CrackCalculatorInputDataViewModel : OkCancelViewModelBase
|
||||||
{
|
{
|
||||||
private CrackCalculator calculator;
|
private CrackCalculator calculator;
|
||||||
ICrackCalculatorInputData crackInputData;
|
CrackInputData crackInputData;
|
||||||
private bool setUserValueSofteningFactor;
|
private bool setUserValueSofteningFactor;
|
||||||
private double softeningFactor;
|
private double softeningFactor;
|
||||||
private string name;
|
private string name;
|
||||||
|
|||||||
@@ -12,95 +12,86 @@
|
|||||||
<Style x:Key="cbStyle" TargetType="CheckBox">
|
<Style x:Key="cbStyle" TargetType="CheckBox">
|
||||||
<Setter Property="Margin" Value="0,5,0,5"/>
|
<Setter Property="Margin" Value="0,5,0,5"/>
|
||||||
</Style>
|
</Style>
|
||||||
<DataTemplate x:Key="InputDataTemplate">
|
|
||||||
<TabControl>
|
|
||||||
<TabItem Header="General">
|
|
||||||
<StackPanel>
|
|
||||||
<GroupBox Header="Limit States">
|
|
||||||
<StackPanel>
|
|
||||||
<CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State" IsChecked="{Binding ULS}"/>
|
|
||||||
<CheckBox Style="{StaticResource cbStyle}" Content="Serviceability Limit State" IsChecked="{Binding SLS}"/>
|
|
||||||
</StackPanel>
|
|
||||||
</GroupBox>
|
|
||||||
<GroupBox Header="Duration">
|
|
||||||
<StackPanel>
|
|
||||||
<CheckBox Style="{StaticResource cbStyle}" Content="Short Term" IsChecked="{Binding ShortTerm}"/>
|
|
||||||
<CheckBox Style="{StaticResource cbStyle}" Content="Long Term" IsChecked="{Binding LongTerm}"/>
|
|
||||||
</StackPanel>
|
|
||||||
</GroupBox>
|
|
||||||
</StackPanel>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="Forces">
|
|
||||||
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding CombinationViewModel}"/>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="Primitives">
|
|
||||||
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding PrimitivesViewModel}"/>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="S-Order">
|
|
||||||
<Grid DataContext="{Binding SecondOrder}">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition/>
|
|
||||||
<ColumnDefinition/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="22"/>
|
|
||||||
<RowDefinition Height="22"/>
|
|
||||||
<RowDefinition Height="22"/>
|
|
||||||
<RowDefinition Height="22"/>
|
|
||||||
<RowDefinition Height="22"/>
|
|
||||||
<RowDefinition Height="22"/>
|
|
||||||
<RowDefinition/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Text="Consider second order effects"/>
|
|
||||||
<TextBlock Grid.Row="1" Text="Geometry length"/>
|
|
||||||
<TextBlock Grid.Row="2" Text="Buckling factor x-axis"/>
|
|
||||||
<TextBlock Grid.Row="3" Text="Buckling factor y-axis"/>
|
|
||||||
<CheckBox Grid.Column="1" IsChecked="{Binding Buckling}"/>
|
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding GeometryLength, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
|
|
||||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LengthFactorX, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
|
||||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding LengthFactorY, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
<TabItem Header="Iterations">
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="170"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBlock Text="Required Accuracy" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
|
|
||||||
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Margin="5,5,5,5" Text="{Binding IterationAccuracy, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
|
|
||||||
<TextBlock Grid.Row="1" Text="Maximum Iteration Count" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
|
|
||||||
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Text="{Binding MaxIterationCount, ValidatesOnDataErrors=True}"/>
|
|
||||||
</Grid>
|
|
||||||
</TabItem>
|
|
||||||
</TabControl>
|
|
||||||
</DataTemplate>
|
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition Height="35"/>
|
<RowDefinition Height="35"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid>
|
<TabControl>
|
||||||
<Grid.RowDefinitions>
|
<TabItem Header="General">
|
||||||
<RowDefinition Height="25"/>
|
<StackPanel>
|
||||||
<RowDefinition/>
|
<Grid>
|
||||||
</Grid.RowDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<Grid>
|
<ColumnDefinition Width="100"/>
|
||||||
<Grid.ColumnDefinitions>
|
<ColumnDefinition Width="300"/>
|
||||||
<ColumnDefinition Width="100"/>
|
</Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="300"/>
|
<TextBlock Text="Name"/>
|
||||||
</Grid.ColumnDefinitions>
|
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
||||||
<TextBlock Text="Name"/>
|
</Grid>
|
||||||
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
<GroupBox Header="Limit States">
|
||||||
</Grid>
|
<StackPanel>
|
||||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource InputDataTemplate}" Content="{Binding InputData}" />
|
<CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State" IsChecked="{Binding ULS}"/>
|
||||||
</Grid>
|
<CheckBox Style="{StaticResource cbStyle}" Content="Serviceability Limit State" IsChecked="{Binding SLS}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</GroupBox>
|
||||||
|
<GroupBox Header="Duration">
|
||||||
|
<StackPanel>
|
||||||
|
<CheckBox Style="{StaticResource cbStyle}" Content="Short Term" IsChecked="{Binding ShortTerm}"/>
|
||||||
|
<CheckBox Style="{StaticResource cbStyle}" Content="Long Term" IsChecked="{Binding LongTerm}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</GroupBox>
|
||||||
|
</StackPanel>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Forces">
|
||||||
|
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding CombinationViewModel}"/>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Primitives">
|
||||||
|
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding PrimitivesViewModel}"/>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="S-Order">
|
||||||
|
<Grid DataContext="{Binding SecondOrder}">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="22"/>
|
||||||
|
<RowDefinition Height="22"/>
|
||||||
|
<RowDefinition Height="22"/>
|
||||||
|
<RowDefinition Height="22"/>
|
||||||
|
<RowDefinition Height="22"/>
|
||||||
|
<RowDefinition Height="22"/>
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Text="Consider second order effects"/>
|
||||||
|
<TextBlock Grid.Row="1" Text="Geometry length"/>
|
||||||
|
<TextBlock Grid.Row="2" Text="Buckling factor x-axis"/>
|
||||||
|
<TextBlock Grid.Row="3" Text="Buckling factor y-axis"/>
|
||||||
|
<CheckBox Grid.Column="1" IsChecked="{Binding Buckling}"/>
|
||||||
|
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding GeometryLength, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
|
||||||
|
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LengthFactorX, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
||||||
|
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding LengthFactorY, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Iterations">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="30"/>
|
||||||
|
<RowDefinition Height="30"/>
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="170"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Required Accuracy" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
|
||||||
|
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Margin="5,5,5,5" Text="{Binding IterationAccuracy, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
|
||||||
|
<TextBlock Grid.Row="1" Text="Maximum Iteration Count" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
|
||||||
|
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Text="{Binding MaxIterationCount, ValidatesOnDataErrors=True}"/>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
internal class ShowCrackResultLogic
|
internal class ShowCrackResultLogic
|
||||||
{
|
{
|
||||||
private CrackForceBynarySearchCalculator calculator;
|
private CrackForceCalculator calculator;
|
||||||
private ITriangulatePrimitiveLogic triangulateLogic;
|
private ITriangulatePrimitiveLogic triangulateLogic;
|
||||||
|
|
||||||
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
|
||||||
@@ -39,18 +39,17 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
|
|
||||||
private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple)
|
private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple)
|
||||||
{
|
{
|
||||||
calculator = new CrackForceBynarySearchCalculator();
|
calculator = new CrackForceCalculator();
|
||||||
calculator.TraceLogger = new ShiftTraceLogger();
|
calculator.TraceLogger = new ShiftTraceLogger();
|
||||||
calculator.InputData.StartTuple = startDesignTuple;
|
calculator.StartTuple = startDesignTuple;
|
||||||
calculator.InputData.EndTuple = finishDesignTuple;
|
calculator.EndTuple = finishDesignTuple;
|
||||||
triangulateLogic = new TriangulatePrimitiveLogic()
|
triangulateLogic = new TriangulatePrimitiveLogic()
|
||||||
{
|
{
|
||||||
Primitives = ndmPrimitives,
|
Primitives = ndmPrimitives,
|
||||||
LimitState = LimitState,
|
LimitState = LimitState,
|
||||||
CalcTerm = CalcTerm
|
CalcTerm = CalcTerm
|
||||||
};
|
};
|
||||||
var ndms = triangulateLogic.GetNdms();
|
calculator.NdmCollection = triangulateLogic.GetNdms();
|
||||||
calculator.InputData.CheckedNdmCollection = calculator.InputData.SectionNdmCollection = ndms;
|
|
||||||
calculator.Run();
|
calculator.Run();
|
||||||
var result = (CrackForceResult)calculator.Result;
|
var result = (CrackForceResult)calculator.Result;
|
||||||
if (result.IsValid)
|
if (result.IsValid)
|
||||||
|
|||||||
@@ -139,9 +139,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
var limitState = tuple.DesignForceTuple.LimitState;
|
var limitState = tuple.DesignForceTuple.LimitState;
|
||||||
var calcTerm = tuple.DesignForceTuple.CalcTerm;
|
var calcTerm = tuple.DesignForceTuple.CalcTerm;
|
||||||
var material = valuePoint.ndmPrimitive.NdmElement.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
|
var material = valuePoint.ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
|
||||||
var userPrestrain = valuePoint.ndmPrimitive.NdmElement.UsersPrestrain;
|
var userPrestrain = valuePoint.ndmPrimitive.UsersPrestrain;
|
||||||
var autoPrestrain = valuePoint.ndmPrimitive.NdmElement.AutoPrestrain;
|
var autoPrestrain = valuePoint.ndmPrimitive.AutoPrestrain;
|
||||||
var ndm = new Ndm()
|
var ndm = new Ndm()
|
||||||
{
|
{
|
||||||
Area = valuePoint.areaPoint.Area,
|
Area = valuePoint.areaPoint.Area,
|
||||||
@@ -149,10 +149,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
CenterY = valuePoint.areaPoint.Point.Y,
|
CenterY = valuePoint.areaPoint.Point.Y,
|
||||||
Material = material,
|
Material = material,
|
||||||
};
|
};
|
||||||
var prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * valuePoint.areaPoint.Point.Y
|
ndm.Prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * valuePoint.areaPoint.Point.Y
|
||||||
+ (userPrestrain.My + autoPrestrain.My) * valuePoint.areaPoint.Point.X
|
+ (userPrestrain.My + autoPrestrain.My) * valuePoint.areaPoint.Point.X
|
||||||
+ userPrestrain.Nz + autoPrestrain.Nz;
|
+ userPrestrain.Nz + autoPrestrain.Nz;
|
||||||
ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, prestrain);
|
|
||||||
return ndm;
|
return ndm;
|
||||||
}
|
}
|
||||||
private List<string> GetValueLabels(IEnumerable<ForceResultFunc> selectedDelegates)
|
private List<string> GetValueLabels(IEnumerable<ForceResultFunc> selectedDelegates)
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
foreach (var item in ndmPrimitives)
|
foreach (var item in ndmPrimitives)
|
||||||
{
|
{
|
||||||
ForceTupleService.CopyProperties(wnd.StrainTuple, item.NdmElement.AutoPrestrain);
|
ForceTupleService.CopyProperties(wnd.StrainTuple, item.AutoPrestrain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,7 +408,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
{
|
{
|
||||||
this.forceCalculator = forceCalculator;
|
this.forceCalculator = forceCalculator;
|
||||||
forcesResults = forceCalculator.Result as IForcesResults;
|
forcesResults = forceCalculator.Result as IForcesResults;
|
||||||
ndmPrimitives = forceCalculator.InputData.Primitives;
|
ndmPrimitives = forceCalculator.Primitives;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowIsoField()
|
private void ShowIsoField()
|
||||||
@@ -439,21 +439,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
|||||||
var ndmRange = new List<INdm>();
|
var ndmRange = new List<INdm>();
|
||||||
foreach (var item in orderedNdmPrimitives)
|
foreach (var item in orderedNdmPrimitives)
|
||||||
{
|
{
|
||||||
if (item is IHasDivisionSize hasDivision)
|
if (item is IHasDivisionSize)
|
||||||
{
|
{
|
||||||
|
var hasDivision = item as IHasDivisionSize;
|
||||||
if (hasDivision.DivisionSize.ClearUnderlying == true)
|
if (hasDivision.ClearUnderlying == true)
|
||||||
{
|
{
|
||||||
ndmRange.RemoveAll(x =>
|
ndmRange.RemoveAll(x => hasDivision.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true);
|
||||||
hasDivision
|
|
||||||
.IsPointInside(new Point2D()
|
|
||||||
{
|
|
||||||
X = x.CenterX, Y = x.CenterY
|
|
||||||
}
|
|
||||||
) == true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectedNdmPrimitives.Contains(item) & item.NdmElement.Triangulate == true)
|
if (selectedNdmPrimitives.Contains(item) & item.Triangulate == true)
|
||||||
{
|
{
|
||||||
|
|
||||||
ndmRange.AddRange(item.GetNdms(triangulationOptions));
|
ndmRange.AddRange(item.GetNdms(triangulationOptions));
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
|
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
|
||||||
d:DataContext="{d:DesignInstance local:TraceDocumentVM}"
|
d:DataContext="{d:DesignInstance local:TraceDocumentVM}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Trace Document Viewer" Height="450" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen">
|
Title="Trace Document Viewer" Height="450" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen" ShowInTaskbar="False">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
|
|||||||
this.viewModel.DocumentReader = this.DocumentReader;
|
this.viewModel.DocumentReader = this.DocumentReader;
|
||||||
this.viewModel.Show();
|
this.viewModel.Show();
|
||||||
}
|
}
|
||||||
public TraceDocumentView(ITraceLogger traceLogger) : this (traceLogger.TraceLoggerEntries) { }
|
|
||||||
|
|
||||||
public TraceDocumentView(IEnumerable<ITraceLoggerEntry> loggerEntries) : this(new TraceDocumentVM(loggerEntries)) { }
|
public TraceDocumentView(IEnumerable<ITraceLoggerEntry> loggerEntries) : this(new TraceDocumentVM(loggerEntries)) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
lineSeries.LineSmoothness = visualProps.LineSmoothness;
|
lineSeries.LineSmoothness = visualProps.LineSmoothness;
|
||||||
lineSeries.PointGeometry = DefaultGeometries.Circle;
|
lineSeries.PointGeometry = DefaultGeometries.Circle;
|
||||||
lineSeries.PointGeometrySize = visualProps.StrokeSize;
|
lineSeries.PointGeometrySize = visualProps.StrokeSize;
|
||||||
Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.LightGray;
|
Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.Black;
|
||||||
//lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
//lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
||||||
lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
VisualProps = new();
|
VisualProps = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void DrawSeries()
|
private void DrawSeries()
|
||||||
{
|
{
|
||||||
SetLines();
|
SetLines();
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace StructureHelper.Windows.Graphs
|
|||||||
OnPropertyChanged(nameof(Opacity));
|
OnPropertyChanged(nameof(Opacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphVisualProps()
|
public GraphVisualProps()
|
||||||
{
|
{
|
||||||
MaxLineSmoothness = 1d;
|
MaxLineSmoothness = 1d;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using StructureHelper.Windows.ViewModels;
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
using StructureHelperCommon.Services.ColorServices;
|
using StructureHelperCommon.Services.ColorServices;
|
||||||
using StructureHelperLogics.Models.Materials;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -1,206 +0,0 @@
|
|||||||
<Window x:Class="StructureHelper.Windows.MainGraph.FormulaView"
|
|
||||||
x:Name="FormulaFunction_win"
|
|
||||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
|
||||||
xmlns:ens="clr-namespace:StructureHelperCommon.Infrastructures.Enums;assembly=StructureHelperCommon"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DataContext="{d:DesignInstance local:FormulaViewModel}"
|
|
||||||
Title="FormulaFunction" Height="640" Width="400">
|
|
||||||
<Window.Resources>
|
|
||||||
<ObjectDataProvider x:Key="PurposeEnum" MethodName="GetValues"
|
|
||||||
ObjectType="{x:Type sys:Enum}">
|
|
||||||
<ObjectDataProvider.MethodParameters>
|
|
||||||
<x:Type TypeName="ens:FunctionPurpose"/>
|
|
||||||
</ObjectDataProvider.MethodParameters>
|
|
||||||
</ObjectDataProvider>
|
|
||||||
</Window.Resources>
|
|
||||||
<Grid>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="60"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="150"/>
|
|
||||||
<RowDefinition Height="60"/>
|
|
||||||
<RowDefinition Height="60"/>
|
|
||||||
<RowDefinition Height="60"/>
|
|
||||||
<RowDefinition Height="60"/>
|
|
||||||
<RowDefinition Height="60"/>
|
|
||||||
<RowDefinition Height="50"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid Grid.Row="0">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Grid.Row="0"
|
|
||||||
Margin="5"
|
|
||||||
Text="Formula:"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<Grid Grid.Row="1">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="50"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBlock Grid.Column="0" Text="y(x) ="
|
|
||||||
Margin="5"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right"/>
|
|
||||||
<TextBox Grid.Column="1" Text="{Binding Formula, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
Margin="5"/>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
<TextBlock Grid.Row="1"
|
|
||||||
Margin="5"
|
|
||||||
Background="LightYellow"
|
|
||||||
Text="{Binding FormulaText, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
TextAlignment="Center"
|
|
||||||
FontSize="20"
|
|
||||||
TextWrapping="Wrap">
|
|
||||||
</TextBlock>
|
|
||||||
<Grid Grid.Row="2">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="90"/>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid Grid.Row="0">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="20"/>
|
|
||||||
<ColumnDefinition Width="10"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBlock Grid.Row="0" Grid.ColumnSpan="3"
|
|
||||||
Margin="5"
|
|
||||||
Text="Enter limit bounds:"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<TextBlock Grid.Column="0"
|
|
||||||
Grid.Row="1"
|
|
||||||
Text="{Binding X}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right"/>
|
|
||||||
<TextBlock Grid.Column="1"
|
|
||||||
Grid.Row="1"
|
|
||||||
Text="{Binding GREATER}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right"/>
|
|
||||||
<TextBox Grid.Column="2"
|
|
||||||
Grid.Row="1"
|
|
||||||
Text="{Binding LeftBound,
|
|
||||||
UpdateSourceTrigger=PropertyChanged,
|
|
||||||
StringFormat=\{0:n\}}"
|
|
||||||
Margin="5"/>
|
|
||||||
<TextBlock Grid.Column="0"
|
|
||||||
Grid.Row="2"
|
|
||||||
Text="{Binding X}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right"/>
|
|
||||||
<TextBlock Grid.Column="1"
|
|
||||||
Grid.Row="2"
|
|
||||||
Text="{Binding LESS}"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
HorizontalAlignment="Right"/>
|
|
||||||
<TextBox Grid.Column="2"
|
|
||||||
Grid.Row="2"
|
|
||||||
Text="{Binding RightBound,
|
|
||||||
UpdateSourceTrigger=PropertyChanged,
|
|
||||||
StringFormat=\{0:n\}}"
|
|
||||||
Margin="5"/>
|
|
||||||
</Grid>
|
|
||||||
<TextBlock Grid.Row="1"
|
|
||||||
Margin="5"
|
|
||||||
Background="LightYellow"
|
|
||||||
Text="{Binding LimitText, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
TextAlignment="Center"
|
|
||||||
FontSize="20"
|
|
||||||
TextWrapping="Wrap">
|
|
||||||
</TextBlock>
|
|
||||||
</Grid>
|
|
||||||
<Grid Grid.Row="3">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Grid.Row="0"
|
|
||||||
Margin="5"
|
|
||||||
Text="Step:"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<TextBox Grid.Row="1" Text="{Binding Step}" Margin="5"/>
|
|
||||||
</Grid>
|
|
||||||
<Grid Grid.Row="4">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Grid.Row="0"
|
|
||||||
Margin="5"
|
|
||||||
Text="Name:"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<TextBox Grid.Row="1" Text="{Binding Name}" Margin="5"/>
|
|
||||||
</Grid>
|
|
||||||
<Grid Grid.Row="5">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Grid.Row="0"
|
|
||||||
Margin="5"
|
|
||||||
Text="Purpose:"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<ComboBox Grid.Row="1"
|
|
||||||
Margin="5"
|
|
||||||
ItemsSource="{Binding Source={StaticResource PurposeEnum}}"
|
|
||||||
SelectedItem="{Binding FunctionPurpose}"/>
|
|
||||||
</Grid>
|
|
||||||
<Grid Grid.Row="6">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Grid.Row="0"
|
|
||||||
Margin="5"
|
|
||||||
Text="Description:"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<TextBox Grid.Row="1" Text="{Binding Description}" Margin="5"/>
|
|
||||||
</Grid>
|
|
||||||
<Grid Grid.Row="7">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBlock
|
|
||||||
Grid.Row="0"
|
|
||||||
Margin="5"
|
|
||||||
Text="Color:"
|
|
||||||
VerticalAlignment="Center"/>
|
|
||||||
<Button Grid.Row="1"
|
|
||||||
Grid.Column="1"
|
|
||||||
Margin="5,5,5,5"
|
|
||||||
Command="{Binding EditColorCommand}"
|
|
||||||
Content="Press to change color">
|
|
||||||
</Button>
|
|
||||||
<Rectangle
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="0"
|
|
||||||
Margin="5,5,5,5">
|
|
||||||
<Rectangle.Fill>
|
|
||||||
<SolidColorBrush Color="{Binding Color, UpdateSourceTrigger=PropertyChanged}"/>
|
|
||||||
</Rectangle.Fill>
|
|
||||||
</Rectangle>
|
|
||||||
</Grid>
|
|
||||||
<Button Grid.Row="8" Margin="5" Content="Save"
|
|
||||||
Command="{Binding SaveCommand}"
|
|
||||||
CommandParameter="{Binding ElementName=FormulaFunction_win}">
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace StructureHelper.Windows.MainGraph
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for FormulaView.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormulaView : Window
|
|
||||||
{
|
|
||||||
public FormulaView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,205 +0,0 @@
|
|||||||
|
|
||||||
using StructureHelper.Infrastructure;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Models.Functions;
|
|
||||||
using StructureHelperCommon.Services.ColorServices;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace StructureHelper.Windows.MainGraph
|
|
||||||
{
|
|
||||||
public class FormulaViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
private const string ERROR_BOUNDS = "The left bound must be less than the right bound";
|
|
||||||
private const string ERROR_STEP = "The number of steps should not be more than";
|
|
||||||
private const string DEFAULT_NAME = "Put function name here...";
|
|
||||||
private const string DEFAULT_DESCRIPTION = "Put function description here...";
|
|
||||||
private const string DEFAULT_FORMULA = "x^2";
|
|
||||||
private const double DEFAULT_LEFT_BOUND = 1;
|
|
||||||
private const double DEFAULT_RIGHT_BOUND = 1000;
|
|
||||||
private const int DEFAULT_STEP = 100;
|
|
||||||
private const int MAX_STEP = 1000;
|
|
||||||
public char GREATER { get; } = '\u2265';
|
|
||||||
public char LESS { get; } = '\u2264';
|
|
||||||
public char X { get; } = 'x';
|
|
||||||
private RelayCommand saveCommand;
|
|
||||||
private RelayCommand editColor;
|
|
||||||
public int Step { get; set; }
|
|
||||||
private double leftBound;
|
|
||||||
public double LeftBound
|
|
||||||
{
|
|
||||||
get => leftBound;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
leftBound = value;
|
|
||||||
LimitText = $"x\u2208[{value};{RightBound}]";
|
|
||||||
OnPropertyChanged(nameof(LeftBound));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private double rightBound;
|
|
||||||
public double RightBound
|
|
||||||
{
|
|
||||||
get => rightBound;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
rightBound = value;
|
|
||||||
LimitText = $"x\u2208[{LeftBound};{value}]";
|
|
||||||
OnPropertyChanged(nameof(RightBound));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public ObservableCollection<Color> Colors { get; set; }
|
|
||||||
public ICommand EditColorCommand
|
|
||||||
{
|
|
||||||
get => editColor ??= new RelayCommand(o => EditColor());
|
|
||||||
}
|
|
||||||
public ICommand SaveCommand
|
|
||||||
{
|
|
||||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
|
||||||
}
|
|
||||||
private string formula;
|
|
||||||
public string Formula
|
|
||||||
{
|
|
||||||
get => formula;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
formula = value;
|
|
||||||
FormulaText = $"y(x)={Formula}";
|
|
||||||
OnPropertyChanged(nameof(Formula));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private string formulaText = "y(x)=";
|
|
||||||
public string FormulaText
|
|
||||||
{
|
|
||||||
get => formulaText;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
formulaText = value;
|
|
||||||
OnPropertyChanged(nameof(FormulaText));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private IOneVariableFunction function;
|
|
||||||
public IOneVariableFunction Function
|
|
||||||
{
|
|
||||||
get => function;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
function = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private string name;
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get => name;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
name = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private FunctionPurpose functionPurpose;
|
|
||||||
public FunctionPurpose FunctionPurpose
|
|
||||||
{
|
|
||||||
get => functionPurpose;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
functionPurpose = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private string description;
|
|
||||||
public string Description
|
|
||||||
{
|
|
||||||
get => description;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
description = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private Color color;
|
|
||||||
public Color Color
|
|
||||||
{
|
|
||||||
get => color;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
color = value;
|
|
||||||
OnPropertyChanged(nameof(Color));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private string limitText;
|
|
||||||
public string LimitText
|
|
||||||
{
|
|
||||||
get => limitText;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
limitText = value;
|
|
||||||
OnPropertyChanged(nameof(LimitText));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public FormulaViewModel()
|
|
||||||
{
|
|
||||||
Name = DEFAULT_NAME;
|
|
||||||
Description = DEFAULT_DESCRIPTION;
|
|
||||||
Step = DEFAULT_STEP;
|
|
||||||
LeftBound = DEFAULT_LEFT_BOUND;
|
|
||||||
RightBound = DEFAULT_RIGHT_BOUND;
|
|
||||||
LimitText = $"x\u2208[{LeftBound};{RightBound}]";
|
|
||||||
Color = Brushes.Red.Color;
|
|
||||||
}
|
|
||||||
public FormulaViewModel(FormulaFunction formulaFunction)
|
|
||||||
{
|
|
||||||
Function = formulaFunction;
|
|
||||||
Formula = formulaFunction.Formula;
|
|
||||||
Step = formulaFunction.Step;
|
|
||||||
Name = Function.Name;
|
|
||||||
FunctionPurpose = Function.FunctionPurpose;
|
|
||||||
Description = Function.Description;
|
|
||||||
LeftBound = Function.MinArg;
|
|
||||||
RightBound = Function.MaxArg;
|
|
||||||
Color = Function.Color;
|
|
||||||
}
|
|
||||||
private void EditColor()
|
|
||||||
{
|
|
||||||
Color color = new Color();
|
|
||||||
ColorProcessor.EditColor(ref color);
|
|
||||||
Color = color;
|
|
||||||
}
|
|
||||||
private void Save(object parameter)
|
|
||||||
{
|
|
||||||
if (Function is null)
|
|
||||||
{
|
|
||||||
Function = new FormulaFunction(isUser: true);
|
|
||||||
}
|
|
||||||
Function.Name = Name;
|
|
||||||
Function.FullName = Name;
|
|
||||||
Function.Description = Description;
|
|
||||||
Function.IsUser = true;
|
|
||||||
(Function as FormulaFunction).Step = Step;
|
|
||||||
(Function as FormulaFunction).Formula = Formula;
|
|
||||||
Function.Color = Color;
|
|
||||||
Function.MinArg = LeftBound;
|
|
||||||
Function.MaxArg = RightBound;
|
|
||||||
Function.FunctionPurpose = FunctionPurpose;
|
|
||||||
var window = parameter as Window;
|
|
||||||
if (LeftBound > RightBound)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"{ERROR_BOUNDS}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Step > MAX_STEP)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"{ERROR_STEP} {MAX_STEP}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.DialogResult = true;
|
|
||||||
window.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
<Window x:Class="StructureHelper.Windows.MainGraph.GraphView"
|
|
||||||
x:Name="GraphView_win"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
|
||||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
|
||||||
Loaded="Window_Loaded"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DataContext="{d:DesignInstance local:GraphViewModel}"
|
|
||||||
Title="StructureHelper" Height="700"
|
|
||||||
Width="1000"
|
|
||||||
MinHeight="400"
|
|
||||||
MinWidth="600">
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="300"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="170"/>
|
|
||||||
<RowDefinition Height="100"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<ListView Name="FunctionList"
|
|
||||||
Grid.Row="0" Grid.Column="0" Margin="5"
|
|
||||||
ItemsSource="{Binding Functions, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
SelectedItem="{Binding SelectedFuntion, UpdateSourceTrigger=PropertyChanged}">
|
|
||||||
<ListView.GroupStyle>
|
|
||||||
<GroupStyle>
|
|
||||||
<GroupStyle.HeaderTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
|
|
||||||
</DataTemplate>
|
|
||||||
</GroupStyle.HeaderTemplate>
|
|
||||||
<GroupStyle.ContainerStyle>
|
|
||||||
<Style TargetType="{x:Type GroupItem}">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<Setter.Value>
|
|
||||||
<ControlTemplate>
|
|
||||||
<Expander IsExpanded="True">
|
|
||||||
<Expander.Header>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Text="{Binding Name}" FontWeight="Bold"
|
|
||||||
Foreground="DarkSlateBlue"
|
|
||||||
VerticalAlignment="Bottom"/>
|
|
||||||
<TextBlock Text=": " FontWeight="Bold"
|
|
||||||
Foreground="DarkSlateBlue"
|
|
||||||
VerticalAlignment="Bottom"/>
|
|
||||||
<TextBlock Text="{Binding ItemCount}" FontWeight="Bold"
|
|
||||||
Foreground="Gray"
|
|
||||||
VerticalAlignment="Bottom" />
|
|
||||||
</StackPanel>
|
|
||||||
</Expander.Header>
|
|
||||||
<ItemsPresenter/>
|
|
||||||
</Expander>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
</GroupStyle.ContainerStyle>
|
|
||||||
</GroupStyle>
|
|
||||||
</ListView.GroupStyle>
|
|
||||||
<ListView.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<Rectangle
|
|
||||||
Margin="1,1,1,1"
|
|
||||||
Height="15"
|
|
||||||
Width="30">
|
|
||||||
<Rectangle.Fill>
|
|
||||||
<SolidColorBrush Color="{Binding Path=Color, UpdateSourceTrigger=PropertyChanged}"/>
|
|
||||||
</Rectangle.Fill>
|
|
||||||
</Rectangle>
|
|
||||||
<TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"/>
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListView.ItemTemplate>
|
|
||||||
<ListView.ContextMenu>
|
|
||||||
<ContextMenu>
|
|
||||||
<MenuItem Header="Add table"
|
|
||||||
Command="{Binding AddTableCommand}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/AddTable.png" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Add formula"
|
|
||||||
Command="{Binding AddFormulaCommand}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Addformula.png" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Edit"
|
|
||||||
Command="{Binding EditCommand}"
|
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Edit.png" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Copy"
|
|
||||||
Command="{Binding CopyCommand}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Copy.png" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Delete"
|
|
||||||
Command="{Binding DeleteCommand}"
|
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
<MenuItem Header="Tree"
|
|
||||||
Command="{Binding TreeCommand}"
|
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
|
|
||||||
<MenuItem.Icon>
|
|
||||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Tree.png" />
|
|
||||||
</MenuItem.Icon>
|
|
||||||
</MenuItem>
|
|
||||||
</ContextMenu>
|
|
||||||
</ListView.ContextMenu>
|
|
||||||
</ListView>
|
|
||||||
<ContentControl Grid.Row="1"
|
|
||||||
ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}"
|
|
||||||
Content="{Binding VisualProps}"/>
|
|
||||||
<Grid Grid.Row="2" Grid.Column="0">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="100"/>
|
|
||||||
<ColumnDefinition Width="100"/>
|
|
||||||
<ColumnDefinition Width="100"/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="50"/>
|
|
||||||
<RowDefinition Height="50"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Button Grid.Column="0" Grid.Row="0" Margin="5" Content="Add table"
|
|
||||||
Command="{Binding AddTableCommand}"
|
|
||||||
Background="LightGreen"/>
|
|
||||||
<Button Grid.Column="0" Grid.Row="1" Margin="5" Content="Add formula"
|
|
||||||
Command="{Binding AddFormulaCommand}"
|
|
||||||
Background="LightGreen"/>
|
|
||||||
<Button Grid.Column="1" Grid.Row="0" Margin="5" Content="Edit"
|
|
||||||
Command="{Binding EditCommand}"
|
|
||||||
CommandParameter="{Binding ElementName=GraphView_win}"
|
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
Background="LightYellow"/>
|
|
||||||
<Button Grid.Column="1" Grid.Row="1" Margin="5" Content="Delete"
|
|
||||||
Command="{Binding DeleteCommand}"
|
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
Background="LightPink"/>
|
|
||||||
<Button Grid.Column="2" Grid.Row="0" Margin="5" Content="Copy"
|
|
||||||
Command="{Binding CopyCommand}"
|
|
||||||
Background="LightBlue"/>
|
|
||||||
<Button Grid.Column="2" Grid.Row="1" Margin="5" Content="Tree"
|
|
||||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
Command="{Binding TreeCommand}"
|
|
||||||
Background="AntiqueWhite"/>
|
|
||||||
</Grid>
|
|
||||||
<lvc:CartesianChart Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"
|
|
||||||
Series="{Binding SeriesCollection, UpdateSourceTrigger=PropertyChanged}" Margin="5"
|
|
||||||
Zoom="Xy">
|
|
||||||
<lvc:CartesianChart.AxisY>
|
|
||||||
<lvc:Axis Title="Y"></lvc:Axis>
|
|
||||||
</lvc:CartesianChart.AxisY>
|
|
||||||
<lvc:CartesianChart.AxisX>
|
|
||||||
<lvc:Axis Title="X" Labels="{Binding Labels, UpdateSourceTrigger=PropertyChanged}"></lvc:Axis>
|
|
||||||
</lvc:CartesianChart.AxisX>
|
|
||||||
</lvc:CartesianChart>
|
|
||||||
<Grid Grid.Row="2" Grid.Column="1">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="30"/>
|
|
||||||
<RowDefinition Height="70"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Grid.Row="0" Text="Description:" Margin="5"/>
|
|
||||||
<TextBlock Grid.Row="1"
|
|
||||||
Name="DescriptionTextBlock"
|
|
||||||
Text="{Binding SelectedFuntion.Description}"
|
|
||||||
Margin="5" TextWrapping="Wrap"
|
|
||||||
VerticalAlignment="Center" Height="60"/>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Window>
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
using StructureHelper.Windows.MainWindow;
|
|
||||||
using StructureHelper.Windows.ViewModels.Materials;
|
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
|
||||||
using StructureHelperLogics.Models.Graphs;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace StructureHelper.Windows.MainGraph
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for GraphView.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class GraphView : Window
|
|
||||||
{
|
|
||||||
private const string GROUP_FACTOR = "Group";
|
|
||||||
private GraphViewModel viewModel;
|
|
||||||
public GraphView(GraphViewModel viewModel)
|
|
||||||
{
|
|
||||||
this.viewModel = viewModel;
|
|
||||||
DataContext = this.viewModel;
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
public GraphView() : this(new GraphViewModel())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(FunctionList.ItemsSource);
|
|
||||||
PropertyGroupDescription groupDescription = new PropertyGroupDescription(GROUP_FACTOR);
|
|
||||||
view.GroupDescriptions.Clear();
|
|
||||||
view.GroupDescriptions.Add(groupDescription);
|
|
||||||
}
|
|
||||||
public void Refresh()
|
|
||||||
{
|
|
||||||
FunctionList.Items.Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
using LiveCharts;
|
|
||||||
using LiveCharts.Wpf;
|
|
||||||
using StructureHelper.Infrastructure;
|
|
||||||
using StructureHelper.Windows.Graphs;
|
|
||||||
using StructureHelper.Windows.TreeGraph;
|
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
|
||||||
using StructureHelperCommon.Models.Functions;
|
|
||||||
using StructureHelperLogics.Models.Graphs;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace StructureHelper.Windows.MainGraph
|
|
||||||
{
|
|
||||||
public class GraphViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
private LineSeries lineSeries;
|
|
||||||
private SeriesCollection seriesCollection;
|
|
||||||
private List<string> labels;
|
|
||||||
private GraphVisualProps visualProps = new();
|
|
||||||
public LineSeries LineSeries
|
|
||||||
{
|
|
||||||
get => lineSeries;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
lineSeries = value;
|
|
||||||
OnPropertyChanged(nameof(lineSeries));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public SeriesCollection SeriesCollection
|
|
||||||
{
|
|
||||||
get => seriesCollection;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
seriesCollection = value;
|
|
||||||
OnPropertyChanged(nameof(SeriesCollection));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public List<string> Labels
|
|
||||||
{
|
|
||||||
get => labels;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
labels = value;
|
|
||||||
OnPropertyChanged(nameof(labels));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public GraphVisualProps VisualProps
|
|
||||||
{
|
|
||||||
get => visualProps;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
visualProps = value;
|
|
||||||
DrawGraph();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private IOneVariableFunction selectedFunction;
|
|
||||||
public IOneVariableFunction SelectedFuntion
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return selectedFunction;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
selectedFunction = value;
|
|
||||||
DrawGraph();
|
|
||||||
OnPropertyChanged(nameof(SelectedFuntion));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private ObservableCollection<IOneVariableFunction> functions;
|
|
||||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
|
||||||
|
|
||||||
private RelayCommand addTableCommand;
|
|
||||||
private RelayCommand addFormulaCommand;
|
|
||||||
private RelayCommand editCommand;
|
|
||||||
private RelayCommand deleteCommand;
|
|
||||||
private RelayCommand copyCommand;
|
|
||||||
private RelayCommand treeCommand;
|
|
||||||
private RelayCommand drawGraphCommand;
|
|
||||||
private RelayCommand _saveCommand;
|
|
||||||
public ICommand AddTableCommand
|
|
||||||
{
|
|
||||||
get => addTableCommand ??= new RelayCommand(o => AddTable());
|
|
||||||
}
|
|
||||||
public ICommand AddFormulaCommand
|
|
||||||
{
|
|
||||||
get => addFormulaCommand ??= new RelayCommand(o => AddFormula());
|
|
||||||
}
|
|
||||||
public ICommand EditCommand
|
|
||||||
{
|
|
||||||
get => editCommand ??= new RelayCommand(o => Edit(o));
|
|
||||||
}
|
|
||||||
public ICommand DeleteCommand
|
|
||||||
{
|
|
||||||
get => deleteCommand ??= new RelayCommand(o => Delete());
|
|
||||||
}
|
|
||||||
public ICommand CopyCommand
|
|
||||||
{
|
|
||||||
get => copyCommand ??= new RelayCommand(o => Copy());
|
|
||||||
}
|
|
||||||
public ICommand TreeCommand
|
|
||||||
{
|
|
||||||
get => treeCommand ??= new RelayCommand(o => Tree());
|
|
||||||
}
|
|
||||||
public ICommand DrawGraphCommand
|
|
||||||
{
|
|
||||||
get => drawGraphCommand ??= new RelayCommand(o => DrawGraph());
|
|
||||||
}
|
|
||||||
public ICommand SaveCommand
|
|
||||||
{
|
|
||||||
get => _saveCommand ??= new RelayCommand(o => Save());
|
|
||||||
}
|
|
||||||
public GraphViewModel()
|
|
||||||
{
|
|
||||||
Functions = new ObservableCollection<IOneVariableFunction>(ProgramSetting.Functions);
|
|
||||||
}
|
|
||||||
private void AddTable()
|
|
||||||
{
|
|
||||||
var tableViewModel = new TableViewModel();
|
|
||||||
var tableView = new TableView();
|
|
||||||
tableView.DataContext = tableViewModel;
|
|
||||||
if (tableView.ShowDialog() == true)
|
|
||||||
{
|
|
||||||
Functions.Add(tableViewModel.Function);
|
|
||||||
SelectedFuntion = tableViewModel.Function;
|
|
||||||
}
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
private void AddFormula()
|
|
||||||
{
|
|
||||||
var formulaViewModel = new FormulaViewModel();
|
|
||||||
var formulaView = new FormulaView();
|
|
||||||
formulaView.DataContext = formulaViewModel;
|
|
||||||
if (formulaView.ShowDialog() == true)
|
|
||||||
{
|
|
||||||
Functions.Add(formulaViewModel.Function);
|
|
||||||
SelectedFuntion = formulaViewModel.Function;
|
|
||||||
}
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
private void Edit(object parameter)
|
|
||||||
{
|
|
||||||
if (SelectedFuntion is null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (SelectedFuntion.Type == FunctionType.TableFunction)
|
|
||||||
{
|
|
||||||
var tableViewModel = new TableViewModel(SelectedFuntion as TableFunction);
|
|
||||||
var tableView = new TableView();
|
|
||||||
tableView.DataContext = tableViewModel;
|
|
||||||
tableView.ShowDialog();
|
|
||||||
SelectedFuntion = tableViewModel.Function;
|
|
||||||
}
|
|
||||||
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
|
|
||||||
{
|
|
||||||
var formulaViewModel = new FormulaViewModel(SelectedFuntion as FormulaFunction);
|
|
||||||
var formulaView = new FormulaView();
|
|
||||||
formulaView.DataContext = formulaViewModel;
|
|
||||||
formulaView.ShowDialog();
|
|
||||||
SelectedFuntion = formulaViewModel.Function;
|
|
||||||
}
|
|
||||||
var graphView = parameter as GraphView;
|
|
||||||
graphView.Refresh();
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
private void Delete()
|
|
||||||
{
|
|
||||||
if (SelectedFuntion is null)
|
|
||||||
{
|
|
||||||
var lastFunction = Functions[Functions.Count - 1];
|
|
||||||
if (lastFunction.IsUser)
|
|
||||||
{
|
|
||||||
Functions.Remove(lastFunction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Functions.Remove(SelectedFuntion);
|
|
||||||
}
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
private void Copy()
|
|
||||||
{
|
|
||||||
if (SelectedFuntion is null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (SelectedFuntion.Type == FunctionType.TableFunction)
|
|
||||||
{
|
|
||||||
Functions.Add(SelectedFuntion.Clone() as TableFunction);
|
|
||||||
}
|
|
||||||
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
|
|
||||||
{
|
|
||||||
Functions.Add(SelectedFuntion.Clone() as FormulaFunction);
|
|
||||||
}
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
private void Tree()
|
|
||||||
{
|
|
||||||
if (SelectedFuntion is null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var treeGraphVM = new TreeGraphViewModel(SelectedFuntion);
|
|
||||||
var treeGraph = new TreeGraphView();
|
|
||||||
treeGraph.DataContext = treeGraphVM;
|
|
||||||
treeGraphVM.TreeGraphView_win = treeGraph;
|
|
||||||
treeGraph.ShowDialog();
|
|
||||||
}
|
|
||||||
private void DrawGraph()
|
|
||||||
{
|
|
||||||
var graphSettings = SelectedFuntion.GetGraphSettings();
|
|
||||||
Labels = graphSettings.GetLabels();
|
|
||||||
LineSeries = graphSettings.GetLineSeries();
|
|
||||||
GraphService.SetVisualProps(LineSeries, VisualProps);
|
|
||||||
SeriesCollection = new SeriesCollection();
|
|
||||||
SeriesCollection.Add(LineSeries);
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
public void Save()
|
|
||||||
{
|
|
||||||
ProgramSetting.Functions = new List<IOneVariableFunction>(Functions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user