79 Commits

Author SHA1 Message Date
Иван Ивашкин
dd927f6da7 Hot fix: MaterialSettings is activate 2025-04-26 23:20:34 +05:00
Иван Ивашкин
decbc10f51 Change ObsCollection to List in Common, write FunctionMaterialCreationVM, remove old UI, binding enums and functions to new UI. 2025-04-26 23:07:18 +05:00
Иван Ивашкин
776fc4c494 Change table UI and VM, add parser dll, add modulus 2025-04-22 17:09:06 +05:00
Иван Ивашкин
9a2cfbb08e Tree MenuItem hot fix 2025-03-06 13:35:48 +05:00
Иван Ивашкин
943f80ad8d Binding function tree 2025-03-06 12:49:23 +05:00
Иван Ивашкин
0829b9c57e Add rename and tree modifiers, binding function purpose enum 2025-03-05 12:58:02 +05:00
Иван Ивашкин
45dc56a63e Binding function by states and terms done 2025-03-04 14:11:41 +05:00
Иван Ивашкин
0a7a696b5f Window function material done 2025-02-21 15:17:10 +05:00
Иван Ивашкин
27d4ca95c8 Save function tree done 2025-02-19 11:50:10 +05:00
Иван Ивашкин
68a1e62c18 Impliment IOneVaribleFunction to delegate 2025-02-15 19:20:52 +05:00
Иван Ивашкин
e0acca2e36 Add FunctionMaterialLogic and FunctionMaterialUpdateStrategy, run function material "Show diagram". 2025-02-12 20:44:12 +05:00
Иван Ивашкин
4ec3ef25fb Add function material interface and button 2025-01-28 14:31:34 +05:00
Иван Ивашкин
ceefe3dbca Add function trace 2024-12-20 15:24:03 +05:00
Иван Ивашкин
7996bd7a3d Draw context menu icons 2024-12-20 11:31:42 +05:00
Иван Ивашкин
5712a85f38 Add graph service 2024-12-19 13:13:55 +05:00
Иван Ивашкин
33820e972b Add function parser 2024-12-15 15:47:04 +05:00
Иван Ивашкин
7c9bc1856b Add extrapolation, debug graphic limits 2024-12-13 13:27:07 +05:00
Иван Ивашкин
585eb9b86b ContextMenu in ListView and TreeView done, but haven't normal icons 2024-12-05 16:27:57 +05:00
Иван Ивашкин
8205dafdbd Color picker done 2024-12-05 00:02:37 +05:00
Иван Ивашкин
bcea9639f6 Interpolation with test done 2024-10-31 17:35:31 +05:00
Иван Ивашкин
96b0fbd6a3 Add GraphSettings 2024-10-31 13:46:50 +05:00
Иван Ивашкин
94387d0d0b Function bounds done, add other decorators 2024-10-30 22:49:43 +05:00
Иван Ивашкин
49d04c7bcc ScaleXDecorator done 2024-10-29 23:58:25 +05:00
Иван Ивашкин
2738b1b7b3 Delete and DrawGraph command done 2024-10-29 19:31:45 +05:00
Иван Ивашкин
2a0704fc4f Function tree in process 2024-10-29 14:44:55 +05:00
Иван Ивашкин
8510db1a85 Add listview group expander 2024-10-26 22:43:27 +05:00
Иван Ивашкин
11ac7c7c48 Add tree graph commands 2024-10-19 21:08:13 +05:00
Иван Ивашкин
88ac95af2f Tree graph commands in process 2024-10-17 13:15:30 +05:00
Иван Ивашкин
d8f0d9dd88 Add GraphViewModel functions realization 2024-10-16 14:41:10 +05:00
Иван Ивашкин
883dbb189f Fix: return graph from player to independent button, develop: add MainGraphView, TreeView, TreeCommand. 2024-10-14 20:36:25 +05:00
Иван Ивашкин
b5ed00341c Add function decorator pattern 2024-10-10 16:11:04 +05:00
Ivan Ivashkin
72add44fe7 Merge pull request #9 from RedikultsevEvg/PrimitivePropsEdit
Primitive props edit
2024-10-08 11:30:21 +05:00
Evgeny Redikultsev
2c5c5db43a Add ElasticMaterial DTOs 2024-10-06 22:18:50 +05:00
Иван Ивашкин
ccc9513416 Add graph application 2024-10-06 18:53:47 +05:00
Evgeny Redikultsev
018a989ba6 Add Safety FactorConverter 2024-10-06 17:53:49 +05:00
Evgeny Redikultsev
58b6e0eb8b Add cross-section convert strategies 2024-09-28 20:46:42 +05:00
Evgeny Redikultsev
c10d6eb94e Add VisualAnalysisDTO 2024-09-14 19:03:35 +05:00
Evgeny Redikultsev
5a9e7c3c4f Objects of NdmElement were added 2024-09-08 21:10:18 +05:00
Evgeny Redikultsev
6e0b7b8070 Serialize converters were added 2024-09-08 17:47:46 +05:00
ear
408e9f6999 FileWork examples were added 2024-09-06 18:13:21 +05:00
Evgeny Redikultsev
2268557672 List of analyses was added into main window 2024-09-01 13:04:00 +05:00
ear
8c030e2271 Tuple cracl calculator was changed 2024-08-27 18:53:36 +05:00
Evgeny Redikultsev
f5deffd237 Ndm prestrain logic was changed 2024-08-26 22:25:49 +05:00
RedikultsevEvg
c1b9f80a96 Analisys manager window was added 2024-08-20 20:38:01 +05:00
RedikultsevEvg
45dbd7a1ca Tests of crack calculator were added 2024-08-12 12:46:40 +05:00
RedikultsevEvg
3eb5aa2b96 Force crack calculator was fixed 2024-08-04 23:01:10 +05:00
RedikultsevEvg
e7c7211f54 Check logic for rebar ndm was created 2024-08-02 23:29:50 +05:00
RedikultsevEvg
35b4000f64 Logic fo TupleCrackCalculator was changed 2024-07-28 22:34:47 +05:00
RedikultsevEvg
732af8bc09 Logic of TupleForceCalculator were changed 2024-07-28 22:34:21 +05:00
RedikultsevEvg
09b53ac4e3 Force calculator was changed 2024-07-28 13:00:38 +05:00
Evgeny Redikultsev
45a87fe7a6 Logic for checking crack input data ws changed 2024-06-23 17:34:16 +05:00
Evgeny Redikultsev
31d668b996 Smart rounding was ajusted 2024-06-02 16:56:44 +05:00
ear
99d5aa3608 RebarStressCalculator was changed 2024-05-29 18:00:28 +05:00
Evgeny Redikultsev
63463662fe Crack func factori has been changed 2024-05-26 17:17:32 +05:00
Evgeny Redikultsev
0913ca85b7 View of tuple crack result was changed 2024-05-26 14:05:02 +05:00
Evgeny Redikultsev
d13304fe06 Checkig Iput data of crack calculator was changed 2024-05-26 11:35:48 +05:00
ear
16cef8e98e Errors in crack calculations were corrected 2024-05-20 16:36:27 +05:00
Evgeny Redikultsev
52c5d35dda Crack calculator was changed 2024-05-19 17:38:54 +05:00
Evgeny Redikultsev
ed2846dc8c Crack edit window was added 2024-05-18 21:45:25 +05:00
Evgeny Redikultsev
845929406e User data for cracks were added 2024-05-18 15:51:59 +05:00
Evgeny Redikultsev
b32a7ce7df Crack width logic was changed 2024-05-11 20:20:27 +05:00
Evgeny Redikultsev
027d9a7666 Crack width calculation was added 2024-05-11 20:19:56 +05:00
Evgeny Redikultsev
08d36dfbd5 Tensile area logic was changed 2024-05-10 20:28:33 +05:00
Evgeny Redikultsev
871355e07b Tuple crack calculator was changed 2024-05-10 20:27:57 +05:00
Evgeny Redikultsev
e75521dc20 CrackedCalculator and TriangulationLogic were changed 2024-05-05 16:39:02 +05:00
Evgeny Redikultsev
f158ba3336 Icons for calculators were changed 2024-04-06 20:14:58 +05:00
Evgeny Redikultsev
f11b97de38 Value point diagram was repaired 2024-03-23 20:27:37 +05:00
Evgeny Redikultsev
f2f6840ffb Value point graph was added 2024-03-16 21:46:24 +05:00
Evgeny Redikultsev
b81b7a0929 Logics of accidental eccentricity were separated and tested 2024-03-10 19:20:01 +05:00
Evgeny Redikultsev
0a453c5a95 Force calculator was repaired for buckling calculations 2024-03-08 17:16:00 +05:00
Evgeny Redikultsev
4359b2c49b Value points were added 2024-03-02 21:40:13 +05:00
ear
2e8ebccc13 ForceCalculator was repaired 2024-02-29 18:24:09 +05:00
Evgeny Redikultsev
9469d53614 Force calculator was changed 2024-02-28 21:03:23 +05:00
ear
24c791c78f Accidental eccentricity logic was changed 2024-02-26 10:48:17 +05:00
ear
716c3764c1 Accidental eccentricity logic was changed 2024-02-25 18:44:26 +05:00
Evgeny Redikultsev
bf72f6d347 Buckling calculator was changed, accidental eccentricity logic was added 2024-02-25 15:31:09 +05:00
Evgeny Redikultsev
541f23c0a8 IsoFieldViewer was changed 2024-02-24 17:59:37 +05:00
Evgeny Redikultsev
8572e1f93d LimitCurveDiagram was repeired (didn't take into account constZ factor) 2024-02-21 21:46:47 +05:00
Evgeny Redikultsev
d650924628 Visual properies of cross section were changed 2024-02-14 21:27:03 +05:00
628 changed files with 22842 additions and 2991 deletions

View File

@@ -0,0 +1,13 @@
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
{
}
}

View File

@@ -0,0 +1,80 @@
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();
}
}
}

View File

@@ -0,0 +1,66 @@
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();
}
}
}

View File

@@ -0,0 +1,24 @@
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;
}
}
}

View File

@@ -0,0 +1,64 @@
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();
}
}
}

View File

@@ -0,0 +1,73 @@
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();
}
}
}

View File

@@ -0,0 +1,61 @@
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();
}
}
}

View File

@@ -0,0 +1,65 @@
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();
}
}
}

View File

@@ -0,0 +1,30 @@
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;
}
}
}

View File

@@ -0,0 +1,30 @@
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;
}
}
}

View File

@@ -0,0 +1,55 @@
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;
}
}
}

View File

@@ -0,0 +1,65 @@
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();
}
}
}

View File

@@ -0,0 +1,75 @@
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;
}
}
}

View File

@@ -0,0 +1,53 @@
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();
}
}
}

View File

@@ -0,0 +1,28 @@
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();
}
}
}

View File

@@ -0,0 +1,65 @@
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();
}
}
}

View File

@@ -0,0 +1,24 @@
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;
}
}
}

View File

@@ -0,0 +1,63 @@
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();
}
}
}

View File

@@ -0,0 +1,48 @@
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();
}
}
}

View File

@@ -0,0 +1,59 @@
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();
}
}
}

View File

@@ -0,0 +1,24 @@
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();
}
}
}

View File

@@ -0,0 +1,28 @@
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();
}
}
}

View File

@@ -0,0 +1,29 @@
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();
}
}

View File

@@ -0,0 +1,22 @@
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; }
}
}

View File

@@ -0,0 +1,43 @@
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();
}
}
}

View File

@@ -0,0 +1,49 @@
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();
}
}
}

View File

@@ -0,0 +1,27 @@
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;
}
}
}

View File

@@ -0,0 +1,44 @@
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();
}
}
}

View File

@@ -0,0 +1,24 @@
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();
}
}
}

View File

@@ -0,0 +1,36 @@
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();
}
}
}

View File

@@ -0,0 +1,33 @@
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();
}
}
}

View File

@@ -0,0 +1,29 @@
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; }
}
}

View File

@@ -0,0 +1,70 @@
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();
}
}
}

View File

@@ -0,0 +1,42 @@
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;
}
}
}

View File

@@ -0,0 +1,67 @@
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") },
};
}
}
}

View File

@@ -0,0 +1,30 @@
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();
}
}
}

View File

@@ -0,0 +1,29 @@
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();
}
}
}

View File

@@ -0,0 +1,28 @@
<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>

113
DataAccess/Example.cs Normal file
View File

@@ -0,0 +1,113 @@
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; }
// }
}

View File

@@ -0,0 +1,93 @@
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;
}
}
}

View File

@@ -0,0 +1,135 @@
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);
//}
}
}
}

View File

@@ -0,0 +1,14 @@
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);
}
}

View File

@@ -0,0 +1,62 @@
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.");
}
}
}

View File

@@ -0,0 +1,90 @@
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;
}
}
}

View File

@@ -0,0 +1,153 @@
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;
}
}
}
}

View File

@@ -0,0 +1,10 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Projects;
namespace DataAccess.Infrastructures
{
public interface IFileOpenLogic : ILogic
{
OpenProjectResult OpenFile();
}
}

View File

@@ -0,0 +1,16 @@
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);
}
}

View File

@@ -0,0 +1,18 @@
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);
}
}

View File

@@ -0,0 +1,17 @@
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; }
}
}

View File

@@ -0,0 +1,47 @@
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);
}
}
}

View File

@@ -0,0 +1,48 @@
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);
}
}
}

View File

@@ -0,0 +1,17 @@
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)
{
}
}
}

View File

@@ -0,0 +1,17 @@
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)
{
}
}
}

View File

@@ -0,0 +1,22 @@
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;
}
}
}

View File

@@ -0,0 +1,38 @@
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;
}
}
}

View File

@@ -0,0 +1,12 @@
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);
}
}

View File

@@ -0,0 +1,13 @@
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);
}
}

View File

@@ -0,0 +1,23 @@
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);
}
}

View File

@@ -0,0 +1,13 @@
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);
}
}

View File

@@ -0,0 +1,10 @@
using Newtonsoft.Json;
using StructureHelperCommon.Infrastructures.Interfaces;
namespace DataAccess.JsonConverters
{
public interface IWriteJsonLogic<T> : ILogic
{
void WriteJson(JsonWriter writer, T value, JsonSerializer serializer);
}
}

View File

@@ -0,0 +1,56 @@
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;
}
}
}

View File

@@ -0,0 +1,22 @@
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;
}
}
}

View File

@@ -0,0 +1,54 @@
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);
}
}
}

View File

@@ -0,0 +1,18 @@
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)
{
}
}
}

View File

@@ -0,0 +1,17 @@
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)
{
}
}
}

View File

@@ -1,12 +1,18 @@
using FieldVisualizer.InfraStructures.Enums; using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings; using FieldVisualizer.InfraStructures.Strings;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Media; using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps.Factories namespace FieldVisualizer.Entities.ColorMaps.Factories
{ {
public enum ColorMapsTypes
{
LiraSpectrum = 0, //Lira
FullSpectrum = 1, //StaDiCon
RedToWhite = 2,
RedToBlue = 3,
BlueToWhite = 4,
}
/// <summary> /// <summary>
/// Factory for creating of different color maps /// Factory for creating of different color maps
/// </summary> /// </summary>
@@ -18,13 +24,39 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
if (mapsTypes == ColorMapsTypes.RedToWhite) { return GetRedToWhite(); } if (mapsTypes == ColorMapsTypes.RedToWhite) { return GetRedToWhite(); }
if (mapsTypes == ColorMapsTypes.RedToBlue) { return GetRedToBlue(); } if (mapsTypes == ColorMapsTypes.RedToBlue) { return GetRedToBlue(); }
if (mapsTypes == ColorMapsTypes.BlueToWhite) { return GetBlueToWhite(); } if (mapsTypes == ColorMapsTypes.BlueToWhite) { return GetBlueToWhite(); }
if (mapsTypes == ColorMapsTypes.LiraSpectrum) { return GetLiraSpectrum(); }
else { throw new FieldVisulizerException(ErrorStrings.ColorMapTypeIsUnknown); } else { throw new FieldVisulizerException(ErrorStrings.ColorMapTypeIsUnknown); }
} }
private static IColorMap GetLiraSpectrum()
{
ColorMap colorMap = new()
{
Name = "LiraSpectrumColorMap"
};
List<Color> colors = new();
byte Alpha = 0xff;
colors.AddRange(new Color[]{
Color.FromArgb(Alpha, 0, 0, 128) ,//Dark Blue
Color.FromArgb(Alpha, 0, 0, 255) ,//Blue
Color.FromArgb(Alpha, 0, 128, 255) ,//Blue
Color.FromArgb(Alpha, 0, 200, 255) ,//Blue
Color.FromArgb(Alpha, 60, 255, 255) ,//Light Blue
Color.FromArgb(Alpha, 255, 255, 128) ,//Light Yellow
Color.FromArgb(Alpha, 255, 255, 0) ,//Yellow
Color.FromArgb(Alpha, 255, 215, 0) ,//Gold
Color.FromArgb(Alpha, 255, 128, 0) ,//Orange Red
Color.FromArgb(Alpha, 255, 0, 0) ,//Red
});
colorMap.Colors = colors;
return colorMap;
}
private static IColorMap GetFullSpectrum() private static IColorMap GetFullSpectrum()
{ {
ColorMap colorMap = new ColorMap(); ColorMap colorMap = new()
colorMap.Name = "FullSpectrumColorMap"; {
Name = "FullSpectrumColorMap"
};
List<Color> colors = new List<Color>(); List<Color> colors = new List<Color>();
byte Alpha = 0xff; byte Alpha = 0xff;
colors.AddRange(new Color[]{ colors.AddRange(new Color[]{
@@ -43,7 +75,6 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
colorMap.Colors = colors; colorMap.Colors = colors;
return colorMap; return colorMap;
} }
private static IColorMap GetRedToWhite() private static IColorMap GetRedToWhite()
{ {
ColorMap colorMap = new ColorMap(); ColorMap colorMap = new ColorMap();
@@ -57,7 +88,6 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
colorMap.Colors = colors; colorMap.Colors = colors;
return colorMap; return colorMap;
} }
private static IColorMap GetRedToBlue() private static IColorMap GetRedToBlue()
{ {
ColorMap colorMap = new ColorMap(); ColorMap colorMap = new ColorMap();
@@ -71,7 +101,6 @@ namespace FieldVisualizer.Entities.ColorMaps.Factories
colorMap.Colors = colors; colorMap.Colors = colors;
return colorMap; return colorMap;
} }
private static IColorMap GetBlueToWhite() private static IColorMap GetBlueToWhite()
{ {
ColorMap colorMap = new ColorMap(); ColorMap colorMap = new ColorMap();

View File

@@ -0,0 +1,13 @@
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps
{
public interface IValueColorArray
{
double AverageValue { get; set; }
Color BottomColor { get; set; }
double BottomValue { get; set; }
Color TopColor { get; set; }
double TopValue { get; set; }
}
}

View File

@@ -1,19 +1,18 @@
using System; using System.Windows.Media;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps namespace FieldVisualizer.Entities.ColorMaps
{ {
/// <summary>
/// Colored range for building color legend
/// </summary>
public interface IValueColorRange public interface IValueColorRange
{ {
/// <summary>
/// Flag of activity
/// </summary>
bool IsActive { get; set; } bool IsActive { get; set; }
double BottomValue { get; set; } IValueColorArray ExactValues { get; }
double AverageValue { get; set; } IValueColorArray RoundedValues { get; }
double TopValue {get;set;}
Color BottomColor { get; set; }
Color TopColor { get; set; }
} }
} }

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps
{
public class ValueColorArray : IValueColorArray
{
/// <summary>
/// Minimum value of range
/// </summary>
public double BottomValue { get; set; }
/// <summary>
/// Average value of range
/// </summary>
public double AverageValue { get; set; }
/// <summary>
/// Maximum value of range
/// </summary>
public double TopValue { get; set; }
/// <summary>
/// Color correspondent to minimum value
/// </summary>
public Color BottomColor { get; set; }
/// <summary>
/// Color correspondent to maximum value
/// </summary>
public Color TopColor { get; set; }
}
}

View File

@@ -1,19 +1,16 @@
using System; using System.Windows.Media;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FieldVisualizer.Entities.ColorMaps namespace FieldVisualizer.Entities.ColorMaps
{ {
/// <inheritdoc/>
public class ValueColorRange : IValueColorRange public class ValueColorRange : IValueColorRange
{ {
/// <inheritdoc/>
public bool IsActive { get; set; } public bool IsActive { get; set; }
public double BottomValue { get; set; }
public double AverageValue { get; set; } public IValueColorArray ExactValues { get; private set; } = new ValueColorArray();
public double TopValue { get; set; }
public Color BottomColor { get; set; } public IValueColorArray RoundedValues { get; private set; } = new ValueColorArray();
public Color TopColor { get; set; }
} }
} }

View File

@@ -8,4 +8,12 @@
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Folder Include="InfraStructures\Enums\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace FieldVisualizer.InfraStructures.Enums
{
public enum ColorMapsTypes
{
FullSpectrum = 0,
RedToWhite = 1,
RedToBlue = 2,
BlueToWhite = 3
}
}

View File

@@ -1,5 +1,7 @@
using FieldVisualizer.Entities.ColorMaps; using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.Values; using FieldVisualizer.Entities.Values;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -10,54 +12,132 @@ namespace FieldVisualizer.Services.ColorServices
public static class ColorOperations public static class ColorOperations
{ {
const byte Alpha = 0xff; const byte Alpha = 0xff;
public static Color GetColorByValue(IValueRange range, IColorMap map, double val) static IMathRoundLogic roundLogic = new SmartRoundLogic();
{ /// <summary>
if (range.TopValue == range.BottomValue || map.Colors.Count == 0) { return map.Colors[0]; } ///
double minVal = range.BottomValue - 1e-15d*(Math.Abs(range.BottomValue)); /// </summary>
double maxVal = range.TopValue + 1e-15d * (Math.Abs(range.TopValue)); /// <param name="fullRange"></param>
if (val > maxVal || val < minVal) { return Colors.Gray; } /// <param name="valueRanges"></param>
if (val == minVal) { return map.Colors[0]; } /// <param name="colorMap"></param>
if (val == maxVal) { return map.Colors[map.Colors.Count - 1]; } /// <returns></returns>
double valPerc = (val - minVal) / (maxVal - minVal);// value%
if (valPerc >= 1d)
{ return map.Colors[map.Colors.Count - 1]; }
double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
double blockOfColor = valPerc / colorPerc;// the integer part repersents how many block to skip
int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
Color cTarget = map.Colors[blockIdx];
Color cNext = map.Colors[blockIdx + 1];
var deltaR = cNext.R - cTarget.R;
var deltaG = cNext.G - cTarget.G;
var deltaB = cNext.B - cTarget.B;
var R = cTarget.R + (deltaR * percOfColor);
var G = cTarget.G + (deltaG * percOfColor);
var B = cTarget.B + (deltaB * percOfColor);
Color c = map.Colors[0];
c = Color.FromArgb(Alpha, (byte)R, (byte)G, (byte)B);
return c;
}
public static IEnumerable<IValueColorRange> GetValueColorRanges(IValueRange fullRange, IEnumerable<IValueRange> valueRanges, IColorMap colorMap) public static IEnumerable<IValueColorRange> GetValueColorRanges(IValueRange fullRange, IEnumerable<IValueRange> valueRanges, IColorMap colorMap)
{ {
var colorRanges = new List<IValueColorRange>(); var colorRanges = new List<IValueColorRange>();
foreach (var valueRange in valueRanges) foreach (var valueRange in valueRanges)
{ {
IValueColorRange valueColorRange = new ValueColorRange(); var valueColorRange = new ValueColorRange
valueColorRange.IsActive = true; {
valueColorRange.BottomValue = valueRange.BottomValue; IsActive = true,
valueColorRange.AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2; };
valueColorRange.TopValue = valueRange.TopValue; valueColorRange.ExactValues.BottomValue = valueRange.BottomValue;
valueColorRange.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.BottomValue); valueColorRange.ExactValues.AverageValue = (valueRange.BottomValue + valueRange.TopValue) / 2;
valueColorRange.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.TopValue); valueColorRange.ExactValues.TopValue = valueRange.TopValue;
valueColorRange.ExactValues.BottomColor = GetColorByValue(fullRange, colorMap, valueColorRange.ExactValues.BottomValue);
valueColorRange.ExactValues.TopColor = GetColorByValue(fullRange, colorMap, valueColorRange.ExactValues.TopValue);
valueColorRange.RoundedValues.BottomValue = roundLogic.RoundValue(valueColorRange.ExactValues.BottomValue);
valueColorRange.RoundedValues.AverageValue = roundLogic.RoundValue(valueColorRange.ExactValues.AverageValue);
valueColorRange.RoundedValues.TopValue = roundLogic.RoundValue(valueColorRange.ExactValues.TopValue);
colorRanges.Add(valueColorRange); colorRanges.Add(valueColorRange);
} }
return colorRanges; return colorRanges;
} }
/// <summary>
/// Returns color by value, range of value an color map
/// </summary>
/// <param name="range">Range of valoue</param>
/// <param name="map">Color map</param>
/// <param name="val">Value</param>
/// <returns></returns>
public static Color GetColorByValue(IValueRange range, IColorMap map, double val)
{
CheckColorMap(map);
if (range.TopValue == range.BottomValue || map.Colors.Count == 1) //if range width is zero or map contain just 1 color
{
return map.Colors[0];
}
var valueRange = GetExtendedRange(range);
if (val >= valueRange.TopValue || val <= valueRange.BottomValue)
{
return GetColorValueIsOutOfRange(valueRange, map, val);
}
return GetColorValueIsInRange(valueRange, map, val);
}
private static Color GetColorValueIsOutOfRange(IValueRange range, IColorMap map, double val)
{
if (val > range.TopValue || val < range.BottomValue)
{
return Colors.Gray;
}
if (val == range.BottomValue)
{
return map.Colors[0];
}
if (val == range.TopValue)
{
return map.Colors[^1];
}
throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
}
private static Color GetColorValueIsInRange(IValueRange range, IColorMap map, double val)
{
var deltaVal = val - range.BottomValue;
var rangeWidth = range.TopValue - range.BottomValue;
var valPerc = deltaVal / rangeWidth; // percent of value on the distance from minValue to maxValue
if (valPerc >= 1d)
{
return map.Colors[^1];
}
double colorPerc = 1d / (map.Colors.Count - 1d); // % of each block of color. the last is the "100% Color"
double blockOfColor = valPerc / colorPerc;// the integer part represents how many block to skip
int blockIdx = (int)Math.Truncate(blockOfColor);// Idx of
double valPercResidual = valPerc - (blockIdx * colorPerc);//remove the part represented of block
double percOfColor = valPercResidual / colorPerc;// % of color of this block that will be filled
//in some cases due to accuracy of double type percent of color may be less than zero
if (percOfColor <= 0d)
{
return map.Colors[blockIdx];
}
Color c = GetColorByColorMap(map, blockIdx, percOfColor);
return c;
}
private static IValueRange GetExtendedRange(IValueRange range)
{
var minVal = range.BottomValue - 1e-15d * Math.Abs(range.BottomValue);
var maxVal = range.TopValue + 1e-15d * Math.Abs(range.TopValue);
return new ValueRange()
{
BottomValue = minVal,
TopValue = maxVal
};
}
private static Color GetColorByColorMap(IColorMap map, int blockIdx, double percOfColor)
{
Color cTarget = map.Colors[blockIdx];
Color cNext = map.Colors[blockIdx + 1];
var deltaRed = cNext.R - cTarget.R;
var deltaGreen = cNext.G - cTarget.G;
var deltaBlue = cNext.B - cTarget.B;
var Red = cTarget.R + (deltaRed * percOfColor);
var Green = cTarget.G + (deltaGreen * percOfColor);
var Blue = cTarget.B + (deltaBlue * percOfColor);
Color c = Color.FromArgb(Alpha, (byte)Red, (byte)Green, (byte)Blue);
return c;
}
private static void CheckColorMap(IColorMap map)
{
if (map.Colors.Count == 0)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": Color map is empty");
}
}
} }
} }

View File

@@ -1,32 +1,29 @@
using FieldVisualizer.Entities.ColorMaps.Factories; using FieldVisualizer.Entities.ColorMaps;
using FieldVisualizer.Entities.ColorMaps; using FieldVisualizer.Entities.ColorMaps.Factories;
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Entities.Values; using FieldVisualizer.Entities.Values;
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Infrastructure.Commands; using FieldVisualizer.Infrastructure.Commands;
using FieldVisualizer.InfraStructures.Enums;
using FieldVisualizer.InfraStructures.Exceptions; using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings; using FieldVisualizer.InfraStructures.Strings;
using FieldVisualizer.Services.ColorServices; using FieldVisualizer.Services.ColorServices;
using FieldVisualizer.Services.PrimitiveServices; using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.Services.ValueRanges; using FieldVisualizer.Services.ValueRanges;
using FieldVisualizer.Windows.UserControls;
using StructureHelperCommon.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes; using System.Windows.Shapes;
using FieldVisualizer.Windows.UserControls;
using System.ComponentModel;
using System.Xml.Serialization;
namespace FieldVisualizer.ViewModels.FieldViewerViewModels namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{ {
public class FieldViewerViewModel : ViewModelBase, IDataErrorInfo public class FieldViewerViewModel : ViewModelBase, IDataErrorInfo
{ {
private IMathRoundLogic roundLogic = new SmartRoundLogic() { DigitQuant = 3 };
public ICommand RebuildCommand { get; } public ICommand RebuildCommand { get; }
public ICommand ZoomInCommand { get; } public ICommand ZoomInCommand { get; }
public ICommand ZoomOutCommand { get; } public ICommand ZoomOutCommand { get; }
@@ -164,8 +161,8 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
private ColorMapsTypes _ColorMapType; private ColorMapsTypes _ColorMapType;
private IColorMap _ColorMap; private IColorMap _ColorMap;
private IValueRange valueRange; private IValueRange valueRange;
private IEnumerable<IValueRange> _ValueRanges; private IEnumerable<IValueRange> valueRanges;
private IEnumerable<IValueColorRange> _ValueColorRanges; private IEnumerable<IValueColorRange> valueColorRanges;
private bool setMinValue; private bool setMinValue;
private bool setMaxValue; private bool setMaxValue;
private double crossLineX; private double crossLineX;
@@ -177,7 +174,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
public FieldViewerViewModel() public FieldViewerViewModel()
{ {
_ColorMapType = ColorMapsTypes.FullSpectrum; _ColorMapType = ColorMapsTypes.LiraSpectrum;
RebuildCommand = new RelayCommand(o => ProcessPrimitives(), o => PrimitiveValidation()); RebuildCommand = new RelayCommand(o => ProcessPrimitives(), o => PrimitiveValidation());
ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation()); ZoomInCommand = new RelayCommand(o => Zoom(1.2), o => PrimitiveValidation());
ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation()); ZoomOutCommand = new RelayCommand(o => Zoom(0.8), o => PrimitiveValidation());
@@ -195,7 +192,7 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
if ((PrimitiveSet is null) == false) if ((PrimitiveSet is null) == false)
{ {
ProcessPrimitives(); ProcessPrimitives();
Legend.ValueColorRanges = _ValueColorRanges; Legend.ValueColorRanges = valueColorRanges;
Legend.Refresh(); Legend.Refresh();
} }
} }
@@ -262,14 +259,14 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{ {
SolidColorBrush brush = new SolidColorBrush(); SolidColorBrush brush = new SolidColorBrush();
brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value); brush.Color = ColorOperations.GetColorByValue(valueRange, _ColorMap, valuePrimitive.Value);
foreach (var valueRange in _ValueColorRanges) foreach (var valueRange in valueColorRanges)
{ {
if (valuePrimitive.Value >= valueRange.BottomValue & valuePrimitive.Value <= valueRange.TopValue & (!valueRange.IsActive)) if (valuePrimitive.Value >= valueRange.ExactValues.BottomValue & valuePrimitive.Value <= valueRange.ExactValues.TopValue & (!valueRange.IsActive))
{ {
brush.Color = Colors.Gray; brush.Color = Colors.Gray;
} }
} }
shape.ToolTip = valuePrimitive.Value; shape.ToolTip = roundLogic.RoundValue(valuePrimitive.Value);
shape.Tag = valuePrimitive; shape.Tag = valuePrimitive;
shape.Fill = brush; shape.Fill = brush;
Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX); Canvas.SetLeft(shape, valuePrimitive.CenterX - addX - dX);
@@ -306,10 +303,24 @@ namespace FieldVisualizer.ViewModels.FieldViewerViewModels
{ {
UserValueRange.TopValue = UserValueRange.BottomValue; UserValueRange.TopValue = UserValueRange.BottomValue;
} }
if (SetMinValue) { valueRange.BottomValue = UserValueRange.BottomValue; } else { UserValueRange.BottomValue = valueRange.BottomValue; } if (SetMinValue == true)
if (SetMaxValue) { valueRange.TopValue = UserValueRange.TopValue; } else { UserValueRange.TopValue = valueRange.TopValue; } {
_ValueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber); valueRange.BottomValue = UserValueRange.BottomValue;
_ValueColorRanges = ColorOperations.GetValueColorRanges(valueRange, _ValueRanges, _ColorMap); }
else
{
UserValueRange.BottomValue = valueRange.BottomValue;
}
if (SetMaxValue == true)
{
valueRange.TopValue = UserValueRange.TopValue;
}
else
{
UserValueRange.TopValue = valueRange.TopValue;
}
valueRanges = ValueRangeOperations.DivideValueRange(valueRange, RangeNumber);
valueColorRanges = ColorOperations.GetValueColorRanges(valueRange, valueRanges, _ColorMap);
} }
private void SetCrossLine(object commandParameter) private void SetCrossLine(object commandParameter)
{ {

View File

@@ -1,23 +1,7 @@
using FieldVisualizer.Entities.ColorMaps; using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Entities.ColorMaps.Factories;
using FieldVisualizer.Entities.Values;
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Infrastructure.Commands;
using FieldVisualizer.InfraStructures.Enums;
using FieldVisualizer.InfraStructures.Exceptions;
using FieldVisualizer.InfraStructures.Strings;
using FieldVisualizer.Services.ColorServices;
using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.Services.ValueRanges;
using FieldVisualizer.ViewModels.FieldViewerViewModels; using FieldVisualizer.ViewModels.FieldViewerViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
namespace FieldVisualizer.Windows.UserControls namespace FieldVisualizer.Windows.UserControls
{ {
@@ -39,17 +23,6 @@ namespace FieldVisualizer.Windows.UserControls
viewModel.Legend = LegendViewer; viewModel.Legend = LegendViewer;
} }
//public FieldViewer(FieldViewerViewModel vm)
//{
// InitializeComponent();
// viewModel = vm;
// this.DataContext = viewModel;
// PrimitiveSet = viewModel.PrimitiveSet;
// viewModel.WorkPlaneBox = WorkPlaneBox;
// viewModel.WorkPlaneCanvas = WorkPlaneCanvas;
// viewModel.Legend = LegendViewer;
//}
public IPrimitiveSet PrimitiveSet { get => viewModel.PrimitiveSet; set { viewModel.PrimitiveSet = value; } } public IPrimitiveSet PrimitiveSet { get => viewModel.PrimitiveSet; set { viewModel.PrimitiveSet = value; } }
internal void Refresh() internal void Refresh()

View File

@@ -20,23 +20,23 @@
<ColumnDefinition Width="10"/> <ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<CheckBox Name="ActiveCheckBox" Grid.Column="0" IsChecked="{Binding Path=IsActive}" HorizontalAlignment="Center" VerticalAlignment="Center"/> <CheckBox Name="ActiveCheckBox" Grid.Column="0" IsChecked="{Binding Path=IsActive}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Rectangle Grid.Column="1" Margin="0,2,0,2" ToolTip="{Binding Path=BottomValue}"> <Rectangle Grid.Column="1" Margin="0,2,0,2" ToolTip="{Binding Path=RoundedValues.BottomValue}">
<Rectangle.Fill> <Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=BottomColor}"/> <SolidColorBrush Color="{Binding Path=ExactValues.BottomColor}"/>
</Rectangle.Fill> </Rectangle.Fill>
</Rectangle> </Rectangle>
<Rectangle Grid.Column="2" Margin="0,2,0,2"> <Rectangle Grid.Column="2" Margin="0,2,0,2">
<Rectangle.Fill> <Rectangle.Fill>
<LinearGradientBrush EndPoint="1,1" StartPoint="0,0"> <LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="{Binding Path=BottomColor}"/> <GradientStop Color="{Binding Path=ExactValues.BottomColor}"/>
<GradientStop Color="{Binding Path=TopColor}" Offset="1"/> <GradientStop Color="{Binding Path=ExactValues.TopColor}" Offset="1"/>
</LinearGradientBrush> </LinearGradientBrush>
</Rectangle.Fill> </Rectangle.Fill>
</Rectangle> </Rectangle>
<TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686" Text="{Binding AverageValue}"/> <TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FF868686" Text="{Binding RoundedValues.AverageValue}"/>
<Rectangle Grid.Column="3" Margin="0,2,0,2" ToolTip="{Binding Path=TopValue}"> <Rectangle Grid.Column="3" Margin="0,2,0,2" ToolTip="{Binding Path=RoundedValues.TopValue}">
<Rectangle.Fill> <Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=TopColor}"/> <SolidColorBrush Color="{Binding Path=ExactValues.TopColor}"/>
</Rectangle.Fill> </Rectangle.Fill>
</Rectangle> </Rectangle>
</Grid> </Grid>

View File

@@ -6,7 +6,7 @@
xmlns:FieldViewerControl="clr-namespace:FieldVisualizer.Windows.UserControls" xmlns:FieldViewerControl="clr-namespace:FieldVisualizer.Windows.UserControls"
xmlns:local="clr-namespace:FieldVisualizer.Windows" xmlns:local="clr-namespace:FieldVisualizer.Windows"
mc:Ignorable="d" mc:Ignorable="d"
Title="FieldViewer" Height="800" Width="1200" WindowStartupLocation="CenterOwner"> Title="FieldViewer" Height="800" Width="1200" MinHeight="400" MinWidth="800" MaxHeight="1000" MaxWidth="1500" WindowStartupLocation="CenterScreen" ShowInTaskbar="False">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/> <ColumnDefinition Width="300"/>

View File

@@ -14,6 +14,11 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{C9192AE7-EE6D-409C-A05C-3549D78CBB34}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{C9192AE7-EE6D-409C-A05C-3549D78CBB34}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVisualizer\FieldVisualizer.csproj", "{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVisualizer\FieldVisualizer.csproj", "{6CAC5B83-81F3-47C2-92A1-0F94A58491C2}"
ProjectSection(ProjectDependencies) = postProject
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} = {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "DataAccess\DataAccess.csproj", "{BB820532-B66E-4876-903D-D6208C2A5352}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -45,6 +50,10 @@ 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

View File

@@ -19,6 +19,7 @@
<ResourceDictionary Source="Infrastructure/UI/Resources/IconDictionary.xaml"/> <ResourceDictionary Source="Infrastructure/UI/Resources/IconDictionary.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/GraphsTemplates.xaml"/> <ResourceDictionary Source="Infrastructure/UI/Resources/GraphsTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/LimitCurveTemplates.xaml"/> <ResourceDictionary Source="Infrastructure/UI/Resources/LimitCurveTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ServiceColors.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>

View File

@@ -22,15 +22,17 @@ 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<CrossSectionView>().AsSelf(); builder.RegisterType<AnalysesManagerViewModel>().AsSelf().SingleInstance();
builder.RegisterType<AnalysesManagerView>().AsSelf();
Container = builder.Build(); Container = builder.Build();
Scope = Container.Resolve<ILifetimeScope>(); Scope = Container.Resolve<ILifetimeScope>();
var window = Scope.Resolve<CrossSectionView>(); var window = Scope.Resolve<AnalysesManagerView>();
window.Show(); window.Show();
} }

View File

@@ -10,6 +10,7 @@ namespace StructureHelper.Infrastructure.Enums
{ {
ForceCalculator, ForceCalculator,
LimitCurveCalculator, LimitCurveCalculator,
CrackCalculator,
FireCalculator FireCalculator
} }
} }

View File

@@ -12,6 +12,7 @@ namespace StructureHelper.Infrastructure.Enums
Reinforcement, Reinforcement,
Elastic, Elastic,
CarbonFiber, CarbonFiber,
GlassFiber GlassFiber,
Function,
} }
} }

View File

@@ -14,7 +14,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Area : UnitBase internal class Area : UnitBase
{ {
public override UnitTypes UnitType { get => UnitTypes.Area; } public override UnitTypes UnitType { get => UnitTypes.Area; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm2"); } public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm2"); }
public override string UnitName { get => "Area"; } public override string UnitName { get => "Area"; }
} }
} }

View File

@@ -0,0 +1,28 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class CrackWidth : UnitBase
{
public CrackWidth()
{
OperationLogic = new ConvertUnitLogic()
{
MathRoundLogic = new FixedRoundLogic()
{
DigitQuant = 3
}
};
}
public override UnitTypes UnitType { get => UnitTypes.Length; }
public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm"); }
public override string UnitName { get => "Length"; }
}
}

View File

@@ -11,7 +11,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Curvature : UnitBase internal class Curvature : UnitBase
{ {
public override UnitTypes UnitType { get => UnitTypes.Curvature; } public override UnitTypes UnitType { get => UnitTypes.Curvature; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "1/mm"); } public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "1/mm"); }
public override string UnitName { get => "Curvature"; } public override string UnitName { get => "Curvature"; }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Force : UnitBase internal class Force : UnitBase
{ {
public override UnitTypes UnitType { get => UnitTypes.Force; } public override UnitTypes UnitType { get => UnitTypes.Force; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kN"); } public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "kN"); }
public override string UnitName { get => "Force"; } public override string UnitName { get => "Force"; }
} }
} }

View File

@@ -5,8 +5,9 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{ {
internal class Length : UnitBase internal class Length : UnitBase
{ {
public override UnitTypes UnitType { get => UnitTypes.Length; } public override UnitTypes UnitType { get => UnitTypes.Length; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm"); } public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "mm"); }
public override string UnitName { get => "Length"; } public override string UnitName { get => "Length"; }
} }
} }

View File

@@ -11,7 +11,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
internal class Moment : UnitBase internal class Moment : UnitBase
{ {
public override UnitTypes UnitType { get => UnitTypes.Moment; } public override UnitTypes UnitType { get => UnitTypes.Moment; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kNm"); } public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "kNm"); }
public override string UnitName { get => "Moment"; } public override string UnitName { get => "Moment"; }
} }
} }

View File

@@ -12,6 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{ {
internal class PlainDouble : IValueConverter internal class PlainDouble : IValueConverter
{ {
IConvertUnitLogic operationLogic = new ConvertUnitLogic();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
try try
@@ -28,7 +30,7 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{ {
try try
{ {
return CommonOperation.ConvertToDoubleChangeComma((string)value); return ProcessString.ConvertCommaToCultureSettings((string)value);
} }
catch (Exception) catch (Exception)
{ {

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services;
using StructureHelperCommon.Services.Units; using StructureHelperCommon.Services.Units;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -12,8 +13,19 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{ {
internal class Stress : UnitBase internal class Stress : UnitBase
{ {
public override UnitTypes UnitType { get => UnitTypes.Stress; } public override UnitTypes UnitType { get => UnitTypes.Stress; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "MPa"); } public override IUnit CurrentUnit { get => UnitLogic.GetUnit(UnitType, "MPa"); }
public override string UnitName { get => "Stress"; } public override string UnitName { get => "Stress"; }
public Stress()
{
OperationLogic = new ConvertUnitLogic()
{
MathRoundLogic = new SmartRoundLogic()
{
DigitQuant = 3
}
};
}
} }
} }

View File

@@ -1,4 +1,7 @@
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services;
using StructureHelperCommon.Services.Units; using StructureHelperCommon.Services.Units;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -14,19 +17,61 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{ {
internal abstract class UnitBase : IValueConverter internal abstract class UnitBase : IValueConverter
{ {
IMathRoundLogic roundLogic = new DirectRoundLogic();
public IConvertUnitLogic OperationLogic { get; set; } = new ConvertUnitLogic();
public IGetUnitLogic UnitLogic { get; set; } = new GetUnitLogic();
public abstract UnitTypes UnitType { get; } public abstract UnitTypes UnitType { get; }
public abstract IUnit CurrentUnit { get; } public abstract IUnit CurrentUnit { get; }
public abstract string UnitName { get;} public abstract string UnitName { get;}
/// <summary>
/// From variable to user
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{ {
return CommonOperation.Convert(CurrentUnit, UnitName, value); var pair = OperationLogic.Convert(CurrentUnit, UnitName, value);
var result = pair.Value;
if (parameter is not null)
{
if (parameter is string paramString)
{
var logic = new ProcessDoublePairLogic() { DigitPlace = DigitPlace.Any };
var paramPair = logic.GetValuePairByString(paramString);
string paramTextPart = paramPair.Text.ToLower();
int paramValuePart = (int)paramPair.Value;
if (paramTextPart == "smart")
{
roundLogic = new SmartRoundLogic() { DigitQuant = paramValuePart };
}
else if (paramTextPart == "fixed")
{
roundLogic = new FixedRoundLogic() { DigitQuant = paramValuePart };
}
result = roundLogic.RoundValue(result);
}
}
string strValue = $"{result} {pair.Text}";
return strValue;
} }
/// <summary>
/// From user to variable
/// </summary>
/// <param name="value"></param>
/// <param name="targetType"></param>
/// <param name="parameter"></param>
/// <param name="culture"></param>
/// <returns></returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{ {
try try
{ {
return CommonOperation.ConvertBack(UnitType, CurrentUnit, value); double result = OperationLogic.ConvertBack(UnitType, CurrentUnit, value);
return result;
} }
catch (Exception) catch (Exception)
{ {

View File

@@ -12,16 +12,16 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
{ {
public class CircleViewPrimitive : PrimitiveBase, IHasCenter public class CircleViewPrimitive : PrimitiveBase, IHasCenter
{ {
ICirclePrimitive primitive; IEllipsePrimitive primitive;
public double Diameter public double Diameter
{ {
get get
{ {
return primitive.Diameter; return primitive.DiameterByX;
} }
set set
{ {
primitive.Diameter = value; primitive.DiameterByX = 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 ICirclePrimitive) if (primitive is not IEllipsePrimitive)
{ {
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(ICirclePrimitive)}, But was: {nameof(primitive)}"); throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(IEllipsePrimitive)}, But was: {nameof(primitive)}");
} }
var circle = primitive as ICirclePrimitive; var circle = primitive as IEllipsePrimitive;
this.primitive = circle; this.primitive = circle;
DivisionViewModel = new HasDivisionViewModel(circle); DivisionViewModel = new HasDivisionViewModel(circle.DivisionSize);
} }
public override INdmPrimitive GetNdmPrimitive() public override INdmPrimitive GetNdmPrimitive()

View File

@@ -2,13 +2,15 @@
using StructureHelper.Services.Primitives; using StructureHelper.Services.Primitives;
using StructureHelper.Windows.MainWindow; using StructureHelper.Windows.MainWindow;
using StructureHelper.Windows.ViewModels.NdmCrossSections; using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
namespace StructureHelper.Infrastructure.UI.DataContexts namespace StructureHelper.Infrastructure.UI.DataContexts
{ {
public abstract class PrimitiveBase : ViewModelBase public abstract class PrimitiveBase : ViewModelBase, IObserver<IRectangleShape>
{ {
#region Поля #region Поля
private IPrimitiveRepository primitiveRepository; private IPrimitiveRepository primitiveRepository;
@@ -58,49 +60,49 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
} }
public bool Triangulate public bool Triangulate
{ {
get => primitive.Triangulate; get => primitive.NdmElement.Triangulate;
set set
{ {
primitive.Triangulate = value; primitive.NdmElement.Triangulate = value;
OnPropertyChanged(nameof(Triangulate)); OnPropertyChanged(nameof(Triangulate));
} }
} }
public double InvertedCenterY => - CenterY; public double InvertedCenterY => - CenterY;
public double PrestrainKx public double PrestrainKx
{ get => primitive.UsersPrestrain.Mx; { get => primitive.NdmElement.UsersPrestrain.Mx;
set set
{ {
primitive.UsersPrestrain.Mx = value; primitive.NdmElement.UsersPrestrain.Mx = value;
OnPropertyChanged(nameof(PrestrainKx)); OnPropertyChanged(nameof(PrestrainKx));
} }
} }
public double PrestrainKy public double PrestrainKy
{ get => primitive.UsersPrestrain.My; { get => primitive.NdmElement.UsersPrestrain.My;
set set
{ {
primitive.UsersPrestrain.My = value; primitive.NdmElement.UsersPrestrain.My = value;
OnPropertyChanged(nameof(PrestrainKy)); OnPropertyChanged(nameof(PrestrainKy));
} }
} }
public double PrestrainEpsZ public double PrestrainEpsZ
{ get => primitive.UsersPrestrain.Nz; { get => primitive.NdmElement.UsersPrestrain.Nz;
set set
{ {
primitive.UsersPrestrain.Nz = value; primitive.NdmElement.UsersPrestrain.Nz = value;
OnPropertyChanged(nameof(PrestrainEpsZ)); OnPropertyChanged(nameof(PrestrainEpsZ));
} }
} }
public double AutoPrestrainKx => primitive.AutoPrestrain.Mx; public double AutoPrestrainKx => primitive.NdmElement.AutoPrestrain.Mx;
public double AutoPrestrainKy => primitive.AutoPrestrain.My; public double AutoPrestrainKy => primitive.NdmElement.AutoPrestrain.My;
public double AutoPrestrainEpsZ => primitive.AutoPrestrain.Nz; public double AutoPrestrainEpsZ => primitive.NdmElement.AutoPrestrain.Nz;
public IHeadMaterial HeadMaterial public IHeadMaterial HeadMaterial
{ {
get => primitive.HeadMaterial; get => primitive.NdmElement.HeadMaterial;
set set
{ {
primitive.HeadMaterial = value; primitive.NdmElement.HeadMaterial = value;
OnPropertyChanged(nameof(HeadMaterial)); OnPropertyChanged(nameof(HeadMaterial));
OnPropertyChanged(nameof(Color)); OnPropertyChanged(nameof(Color));
} }
@@ -119,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.HeadMaterial !=null))? primitive.HeadMaterial.Color : primitive.VisualProperty.Color; & (primitive.NdmElement.HeadMaterial !=null))? primitive.NdmElement.HeadMaterial.Color : primitive.VisualProperty.Color;
set set
{ {
SetMaterialColor = false; SetMaterialColor = false;
@@ -236,12 +238,6 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
this.primitive = primitive; this.primitive = primitive;
} }
public void RegisterDeltas(double dx, double dy)
{
DeltaX = dx;
DeltaY = dy;
}
public CrossSectionViewModel OwnerVM { get; private set; } public CrossSectionViewModel OwnerVM { get; private set; }
public double DeltaX { get; private set; } public double DeltaX { get; private set; }
@@ -253,14 +249,6 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
return primitive; return primitive;
} }
//public virtual void RefreshNdmPrimitive()
//{
//}
public void RefreshColor()
{
OnPropertyChanged(nameof(Color));
}
public virtual void Refresh() public virtual void Refresh()
{ {
OnPropertyChanged(nameof(Name)); OnPropertyChanged(nameof(Name));
@@ -273,5 +261,22 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
OnPropertyChanged(nameof(PrimitiveWidth)); OnPropertyChanged(nameof(PrimitiveWidth));
OnPropertyChanged(nameof(PrimitiveHeight)); OnPropertyChanged(nameof(PrimitiveHeight));
} }
public void OnCompleted()
{
throw new NotImplementedException();
}
public void OnError(Exception error)
{
throw new NotImplementedException();
}
public void OnNext(IRectangleShape value)
{
DeltaX = value.Width / 2d;
DeltaY = value.Height / 2d;
Refresh();
}
} }
} }

View File

@@ -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 ICirclePrimitive) else if (primitive is IEllipsePrimitive)
{ {
var circle = primitive as ICirclePrimitive; var circle = primitive as IEllipsePrimitive;
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)

View File

@@ -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); DivisionViewModel = new HasDivisionViewModel(primitive.DivisionSize);
} }
public override void Refresh() public override void Refresh()
{ {

View File

@@ -51,11 +51,43 @@
</Style> </Style>
<Style x:Key="ToolButton" TargetType="Button"> <Style x:Key="ToolButton" TargetType="Button">
<Style.Resources>
<Style TargetType="Image">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="Margin" Value="-2"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.25"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="Viewbox">
<Setter Property="Margin" Value="-2"/>
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Stretch" Value="UniformToFill"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.25"/>
</Trigger>
</Style.Triggers>
</Style>
</Style.Resources>
<Setter Property="Width" Value="32"/> <Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/> <Setter Property="Height" Value="32"/>
<Setter Property="Margin" Value="2,0,2,0"/> <Setter Property="Margin" Value="2,0,2,0"/>
<Setter Property="Background" Value="#FFA19BC3"/> <Setter Property="Background" Value="#FFA19BC3"/>
<Setter Property="BorderBrush" Value="#FF857AB9"/> <Setter Property="BorderBrush" Value="Black"/>
</Style>
<Style x:Key="ToolButton24" TargetType="Button" BasedOn="{StaticResource ToolButton}">
<Setter Property="Height" Value="24"/>
<Setter Property="Width" Value="24"/>
</Style> </Style>
<Style x:Key="ButtonImage16" TargetType="Image"> <Style x:Key="ButtonImage16" TargetType="Image">
@@ -67,6 +99,41 @@
<Setter Property="Width" Value="32"/> <Setter Property="Width" Value="32"/>
</Style> </Style>
<Color x:Key="ButtonLight" A="255" B="255" G="255" R="255"/>
<Color x:Key="CalculatorColor" A="255" B="149" G="149" R="211"/>
<Color x:Key="CalculatorFrameColor" A="255" B="109" G="109" R="166"/>
<Color x:Key="ResultColor" A="255" B="200" G="200" R="200"/>
<Color x:Key="ResultFrameColor" A="255" B="100" G="100" R="100"/>
<SolidColorBrush x:Key="CalculatorCanvas" Color="{DynamicResource CalculatorColor}"/>
<SolidColorBrush x:Key="CalculatorFrame" Color="{DynamicResource CalculatorFrameColor}"/>
<SolidColorBrush x:Key="ResultCanvas" Color="{DynamicResource ResultColor}"/>
<SolidColorBrush x:Key="ResultFrame" Color="{DynamicResource ResultFrameColor}"/>
<Style x:Key="ButtonCanvas" TargetType="Canvas">
<Setter Property="Width" Value="32"/>
<Setter Property="Height" Value="32"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="ButtonCalculatorCanvas" TargetType="Canvas" BasedOn="{StaticResource ButtonCanvas}">
<Setter Property="Background" Value="{DynamicResource CalculatorCanvas}"/>
</Style>
<Style x:Key="ButtonResultCanvas" TargetType="Canvas" BasedOn="{StaticResource ButtonCanvas}">
<Setter Property="Background" Value="{DynamicResource ResultCanvas}"/>
</Style>
<Style x:Key="ButtonRect" TargetType="Rectangle">
<Setter Property="Margin" Value="3"/>
<Setter Property="Width" Value="26"/>
<Setter Property="Height" Value="26"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="StrokeThickness" Value="1"/>
</Style>
<DataTemplate x:Key="OkCancelButtons"> <DataTemplate x:Key="OkCancelButtons">
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}" Command="{Binding CancelCommand}"/> <Button Style="{StaticResource CancelButton}" Command="{Binding CancelCommand}"/>
@@ -74,5 +141,210 @@
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="ButtonCalculatorRectangle">
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource CalculatorFrame}">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
<GradientStop Color="{DynamicResource CalculatorColor}" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</DataTemplate>
<DataTemplate x:Key="ButtonResultRectangle">
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource ResultFrame}">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
<GradientStop Color="{DynamicResource ResultColor}" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</DataTemplate>
<DataTemplate x:Key="DiagramCalculator">
<Canvas Style="{DynamicResource ButtonCalculatorCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{DynamicResource ButtonCalculatorRectangle}"/>
<Line Margin="4" X1="0" Y1="20" X2="25" Y2="20" StrokeThickness="1.5" Stroke="{DynamicResource CalculatorFrame}"/>
<Line Margin="4" X1="4" Y1="0" X2="4" Y2="25" StrokeThickness="1.5" Stroke="{DynamicResource CalculatorFrame}"/>
<Path Margin="4" Data="M 0 5 l 4 -4 l 7 4 l 7 6 l 2 4 l -2 7 l -2 2 " Stroke="{DynamicResource CalculatorFrame}"/>
<TextBlock Margin="4,2,0,0" Text="M-N" Foreground="Black" FontSize="10" HorizontalAlignment="Stretch" FontWeight="Bold" />
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="CrackCalculator">
<Canvas Style="{DynamicResource ButtonCalculatorCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{DynamicResource ButtonCalculatorRectangle}"/>
<Path Margin="4" Data="M 0 0 l 25 0 l 0 20
l -4 0
l -1 -5 l 1 -5 l -2 5 l -2 5
l -3 0
l 0 -5 l 0 -10 l -2 10 l -2 5
l -3 0
l -1 -5 l 1 -5 l -2 5 l -2 5
l -4 0" Fill="{DynamicResource CalculatorFrame}"/>
<TextBlock Margin="4,2,0,0" Text="Crc" Foreground="White" FontSize="10" HorizontalAlignment="Stretch" FontWeight="Bold" />
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="CalculatorRun">
<Canvas Style="{DynamicResource ButtonCalculatorCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{DynamicResource ButtonCalculatorRectangle}"/>
<Path Margin="4" Data="M 4 2 l 12 10 l -12 10 l 0 -20" Fill="{DynamicResource CalculatorFrame}"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="IsoFieldResult">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{DynamicResource ButtonResultRectangle}"/>
<Path Margin="4" Data="M 0 0 h 20 A 20 20 90 0 1 0 24 z" Fill="Gray"/>
<Path Margin="4" Data="M 0 0 h 16 A 16 16 90 0 1 0 18 z" Fill="DarkGray"/>
<Path Margin="4" Data="M 0 0 h 10 A 10 10 90 0 1 0 10 z" Fill="LightGray"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="ShowRebarsResult">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<ContentControl ContentTemplate="{DynamicResource ButtonResultRectangle}"/>
<Rectangle Canvas.Left="8" Canvas.Top="6" Width="16" Height="21" Fill="LightGray" Stroke ="Black"/>
<Ellipse Canvas.Left="10" Canvas.Top="21" Width="4" Height="4" Fill="DarkGray" Stroke ="Black"/>
<Ellipse Canvas.Left="18" Canvas.Top="21" Width="4" Height="4" Fill="DarkGray" Stroke ="Black"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="FileOpen">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Path Margin="4" Data="M 2 6 l 8 0 l 3 3 l 6 0 l 0 12 l -17 0 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
<Path Margin="4" Data="M 6 12 l 20 0 l -5 10 l -19 0 z" Fill="LightGray" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="FileSave">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Rectangle Height="26" Width="26" Canvas.Left="3" Canvas.Top="3"
Fill="DarkGray" Stroke="Black" StrokeThickness="1"
RadiusX="2" RadiusY="2"/>
<Rectangle Height="8" Width="12" Canvas.Left="10" Canvas.Top="4"
Fill="LightGray" Stroke="Black" StrokeThickness="0.5"/>
<Rectangle Height="6" Width="4" Canvas.Left="16" Canvas.Top="5"
Fill="DarkGray" Stroke="Black" StrokeThickness="0.5"/>
<Rectangle Height="14" Width="22" Canvas.Left="5" Canvas.Top="13"
Fill="LightGray" Stroke="Black" StrokeThickness="0.5"
RadiusX="2" RadiusY="2"/>
<Line X1="7" Y1="18" X2="24" Y2="18" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="7" Y1="21" X2="24" Y2="21" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="7" Y1="24" X2="24" Y2="24" Stroke="Black" StrokeThickness="0.5"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="Diagrams">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Line X1="2" Y1="16" X2="30" Y2="16" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="16" Y1="2" X2="16" Y2="30" Stroke="Black" StrokeThickness="0.5"/>
<Path Margin="2" Data="M 0 21 l 6 0 l 9 -8 l 9 -8 l 4 0" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="NdmCrossSection">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Rectangle Height="16" Width="8" Canvas.Left="12" Canvas.Top="12"
Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
<Rectangle Height="6" Width="16" Canvas.Left="8" Canvas.Top="7"
Fill="LightGray" Stroke="Black" StrokeThickness="1"/>
<Line X1="2" Y1="16" X2="30" Y2="16" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="16" Y1="2" X2="16" Y2="30" Stroke="Black" StrokeThickness="0.5"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="SelectAll">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="True" IsEnabled="False"/>
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="True" IsEnabled="False"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="DeSelectAll">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="False" IsEnabled="False"/>
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="False" IsEnabled="False"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="InvertSelection">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="True" IsEnabled="False"/>
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="False" IsEnabled="False"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="RunAnalisis">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Path Margin="4" Data="M 4 2 l 12 10 l -12 10 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="EditAnalisis">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Path Margin="4" Data="M 2 22 l 4 -6 l 15 -16 l 4 4 l -15 14 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="DeleteAnalisis">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Line X1="4" Y1="4" X2="26" Y2="26" Stroke="Black" StrokeThickness="2"/>
<Line X1="4" Y1="26" X2="26" Y2="4" Stroke="Black" StrokeThickness="2"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="AddTable">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Rectangle Height="32" Width="32" Fill="LightGreen"/>
<Line X1="2" X2="30" Y1="2" Y2="2" Stroke="Black" StrokeThickness="2"/>
<Line X1="2" X2="30" Y1="16" Y2="16" Stroke="Black" StrokeThickness="2"/>
<Line X1="2" X2="30" Y1="30" Y2="30" Stroke="Black" StrokeThickness="2"/>
<Line X1="2" X2="2" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
<Line X1="16" X2="16" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
<Line X1="30" X2="30" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="TestIcon">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<TextBlock Text="fx" Width="32" Height="32" Background="LightGreen"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -12,5 +12,6 @@
<convertersUnits:Moment x:Key="MomentConverter"/> <convertersUnits:Moment x:Key="MomentConverter"/>
<convertersUnits:Stress x:Key="StressConverter"/> <convertersUnits:Stress x:Key="StressConverter"/>
<convertersUnits:Curvature x:Key="Curvature"/> <convertersUnits:Curvature x:Key="Curvature"/>
<convertersUnits:CrackWidth x:Key="CrackWidth"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</ResourceDictionary> </ResourceDictionary>

Some files were not shown because too many files have changed in this diff Show More