51 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
446 changed files with 14579 additions and 1853 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

@@ -18,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVis
{F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} = {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A} = {F1548BD2-7FE8-46C2-9BC4-9BA813A5C59A}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "DataAccess\DataAccess.csproj", "{BB820532-B66E-4876-903D-D6208C2A5352}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -48,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

@@ -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

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

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

@@ -60,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));
} }
@@ -121,7 +121,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
public Color Color public Color Color
{ {
get => ((primitive.VisualProperty.SetMaterialColor == true) get => ((primitive.VisualProperty.SetMaterialColor == true)
& (primitive.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;

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

@@ -85,6 +85,11 @@
<Setter Property="BorderBrush" Value="Black"/> <Setter Property="BorderBrush" Value="Black"/>
</Style> </Style>
<Style x:Key="ToolButton24" TargetType="Button" BasedOn="{StaticResource ToolButton}">
<Setter Property="Height" Value="24"/>
<Setter Property="Width" Value="24"/>
</Style>
<Style x:Key="ButtonImage16" TargetType="Image"> <Style x:Key="ButtonImage16" TargetType="Image">
<Setter Property="Height" Value="16"/> <Setter Property="Height" Value="16"/>
<Setter Property="Width" Value="16"/> <Setter Property="Width" Value="16"/>
@@ -218,4 +223,128 @@
</Canvas> </Canvas>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="FileOpen">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Path Margin="4" Data="M 2 6 l 8 0 l 3 3 l 6 0 l 0 12 l -17 0 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
<Path Margin="4" Data="M 6 12 l 20 0 l -5 10 l -19 0 z" Fill="LightGray" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="FileSave">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Rectangle Height="26" Width="26" Canvas.Left="3" Canvas.Top="3"
Fill="DarkGray" Stroke="Black" StrokeThickness="1"
RadiusX="2" RadiusY="2"/>
<Rectangle Height="8" Width="12" Canvas.Left="10" Canvas.Top="4"
Fill="LightGray" Stroke="Black" StrokeThickness="0.5"/>
<Rectangle Height="6" Width="4" Canvas.Left="16" Canvas.Top="5"
Fill="DarkGray" Stroke="Black" StrokeThickness="0.5"/>
<Rectangle Height="14" Width="22" Canvas.Left="5" Canvas.Top="13"
Fill="LightGray" Stroke="Black" StrokeThickness="0.5"
RadiusX="2" RadiusY="2"/>
<Line X1="7" Y1="18" X2="24" Y2="18" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="7" Y1="21" X2="24" Y2="21" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="7" Y1="24" X2="24" Y2="24" Stroke="Black" StrokeThickness="0.5"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="Diagrams">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Line X1="2" Y1="16" X2="30" Y2="16" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="16" Y1="2" X2="16" Y2="30" Stroke="Black" StrokeThickness="0.5"/>
<Path Margin="2" Data="M 0 21 l 6 0 l 9 -8 l 9 -8 l 4 0" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="NdmCrossSection">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Rectangle Height="16" Width="8" Canvas.Left="12" Canvas.Top="12"
Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
<Rectangle Height="6" Width="16" Canvas.Left="8" Canvas.Top="7"
Fill="LightGray" Stroke="Black" StrokeThickness="1"/>
<Line X1="2" Y1="16" X2="30" Y2="16" Stroke="Black" StrokeThickness="0.5"/>
<Line X1="16" Y1="2" X2="16" Y2="30" Stroke="Black" StrokeThickness="0.5"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="SelectAll">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="True" IsEnabled="False"/>
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="True" IsEnabled="False"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="DeSelectAll">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="False" IsEnabled="False"/>
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="False" IsEnabled="False"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="InvertSelection">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<CheckBox Canvas.Left="13" Canvas.Top="13" IsChecked="True" IsEnabled="False"/>
<CheckBox Canvas.Left="2" Canvas.Top="2" IsChecked="False" IsEnabled="False"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="RunAnalisis">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Path Margin="4" Data="M 4 2 l 12 10 l -12 10 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="EditAnalisis">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Path Margin="4" Data="M 2 22 l 4 -6 l 15 -16 l 4 4 l -15 14 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="DeleteAnalisis">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Line X1="4" Y1="4" X2="26" Y2="26" Stroke="Black" StrokeThickness="2"/>
<Line X1="4" Y1="26" X2="26" Y2="4" Stroke="Black" StrokeThickness="2"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="AddTable">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Rectangle Height="32" Width="32" Fill="LightGreen"/>
<Line X1="2" X2="30" Y1="2" Y2="2" Stroke="Black" StrokeThickness="2"/>
<Line X1="2" X2="30" Y1="16" Y2="16" Stroke="Black" StrokeThickness="2"/>
<Line X1="2" X2="30" Y1="30" Y2="30" Stroke="Black" StrokeThickness="2"/>
<Line X1="2" X2="2" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
<Line X1="16" X2="16" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
<Line X1="30" X2="30" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="TestIcon">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<TextBlock Text="fx" Width="32" Height="32" Background="LightGreen"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
</ResourceDictionary> </ResourceDictionary>

Binary file not shown.

View File

@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
--> -->
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<History>True|2024-03-11T15:33:14.1457807Z;True|2024-03-10T19:11:27.6834663+05:00;True|2024-02-02T12:22:50.1454015+05:00;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;</History> <History>True|2024-08-13T09:00:35.8311260Z||;True|2024-08-12T12:59:16.1785759+05:00||;True|2024-03-11T20:33:14.1457807+05:00||;True|2024-03-10T19:11:27.6834663+05:00||;True|2024-02-02T12:22:50.1454015+05:00||;True|2023-02-25T13:37:39.2738786+05:00||;False|2023-02-25T13:37:24.0284261+05:00||;True|2023-02-25T13:34:01.6858860+05:00||;True|2023-02-25T13:31:18.8295711+05:00||;False|2023-02-25T13:25:21.5807199+05:00||;False|2023-02-25T13:24:41.7164398+05:00||;</History>
<LastFailureDetails /> <LastFailureDetails />
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -20,7 +20,7 @@ namespace StructureHelper.Services.Settings
{ {
get get
{ {
materials ??= new ListRepository<IHeadMaterial>(new MaterialUpdateStrategy()); materials ??= new ListRepository<IHeadMaterial>(new HeadMaterialUpdateStrategy());
return materials; return materials;
} }
} }

View File

@@ -27,6 +27,8 @@
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" /> <None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" /> <None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" /> <None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
<None Remove="Windows\MainWindow\AddFormula.png" />
<None Remove="Windows\MainWindow\AddTable.png" />
<None Remove="Windows\MainWindow\Analysis32.png" /> <None Remove="Windows\MainWindow\Analysis32.png" />
<None Remove="Windows\MainWindow\Beam32.png" /> <None Remove="Windows\MainWindow\Beam32.png" />
<None Remove="Windows\MainWindow\Calculator32.png" /> <None Remove="Windows\MainWindow\Calculator32.png" />
@@ -37,7 +39,11 @@
<None Remove="Windows\MainWindow\Delete.png" /> <None Remove="Windows\MainWindow\Delete.png" />
<None Remove="Windows\MainWindow\Edit.png" /> <None Remove="Windows\MainWindow\Edit.png" />
<None Remove="Windows\MainWindow\ElasticMaterial32.png" /> <None Remove="Windows\MainWindow\ElasticMaterial32.png" />
<None Remove="Windows\MainWindow\FunctionMaterial.png" />
<None Remove="Windows\MainWindow\GetY.png" />
<None Remove="Windows\MainWindow\GlassMaterial32.png" /> <None Remove="Windows\MainWindow\GlassMaterial32.png" />
<None Remove="Windows\MainWindow\LimX.png" />
<None Remove="Windows\MainWindow\LimY.png" />
<None Remove="Windows\MainWindow\Materials32.png" /> <None Remove="Windows\MainWindow\Materials32.png" />
<None Remove="Windows\MainWindow\MovePrimitivesToCenter.png" /> <None Remove="Windows\MainWindow\MovePrimitivesToCenter.png" />
<None Remove="Windows\MainWindow\Point32.png" /> <None Remove="Windows\MainWindow\Point32.png" />
@@ -46,24 +52,28 @@
<None Remove="Windows\MainWindow\RectangleColumn32.png" /> <None Remove="Windows\MainWindow\RectangleColumn32.png" />
<None Remove="Windows\MainWindow\RFMaterial32.png" /> <None Remove="Windows\MainWindow\RFMaterial32.png" />
<None Remove="Windows\MainWindow\Run.png" /> <None Remove="Windows\MainWindow\Run.png" />
<None Remove="Windows\MainWindow\ScaleX.png" />
<None Remove="Windows\MainWindow\ScaleY.png" />
<None Remove="Windows\MainWindow\Slab32.png" /> <None Remove="Windows\MainWindow\Slab32.png" />
<None Remove="Windows\MainWindow\ToBackground.png" /> <None Remove="Windows\MainWindow\ToBackground.png" />
<None Remove="Windows\MainWindow\ToForeground.png" /> <None Remove="Windows\MainWindow\ToForeground.png" />
<None Remove="Windows\MainWindow\Tools_Settings.png" /> <None Remove="Windows\MainWindow\Tools_Settings.png" />
<None Remove="Windows\MainWindow\Tree.png" />
<None Remove="Windows\MainWindow\СarbonMaterial32.png" /> <None Remove="Windows\MainWindow\СarbonMaterial32.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac" Version="6.5.0" /> <PackageReference Include="Autofac" Version="8.1.0" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" /> <PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="LiveCharts.Wpf.Core" Version="0.9.8" /> <PackageReference Include="LiveCharts.Wpf.Core" Version="0.9.8" />
<PackageReference Include="LiveCharts.Wpf.NetCore3" Version="0.9.7" /> <PackageReference Include="LiveCharts.Wpf.NetCore3" Version="0.9.8" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Windows.Interactivity.WPF" Version="2.0.20525" /> <PackageReference Include="System.Windows.Interactivity.WPF" Version="2.0.20525" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\DataAccess\DataAccess.csproj" />
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" /> <ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" /> <ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj" /> <ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj" />
@@ -93,6 +103,8 @@
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" /> <Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" /> <Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" /> <Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
<Resource Include="Windows\MainWindow\AddFormula.png" />
<Resource Include="Windows\MainWindow\AddTable.png" />
<Resource Include="Windows\MainWindow\Analysis32.png" /> <Resource Include="Windows\MainWindow\Analysis32.png" />
<Resource Include="Windows\MainWindow\Beam32.png" /> <Resource Include="Windows\MainWindow\Beam32.png" />
<Resource Include="Windows\MainWindow\Calculator32.png" /> <Resource Include="Windows\MainWindow\Calculator32.png" />
@@ -103,19 +115,26 @@
<Resource Include="Windows\MainWindow\Delete.png" /> <Resource Include="Windows\MainWindow\Delete.png" />
<Resource Include="Windows\MainWindow\Edit.png" /> <Resource Include="Windows\MainWindow\Edit.png" />
<Resource Include="Windows\MainWindow\ElasticMaterial32.png" /> <Resource Include="Windows\MainWindow\ElasticMaterial32.png" />
<Resource Include="Windows\MainWindow\GetY.png" />
<Resource Include="Windows\MainWindow\GlassMaterial32.png" /> <Resource Include="Windows\MainWindow\GlassMaterial32.png" />
<Resource Include="Windows\MainWindow\LimX.png" />
<Resource Include="Windows\MainWindow\LimY.png" />
<Resource Include="Windows\MainWindow\Materials32.png" /> <Resource Include="Windows\MainWindow\Materials32.png" />
<Resource Include="Windows\MainWindow\MovePrimitivesToCenter.png" /> <Resource Include="Windows\MainWindow\MovePrimitivesToCenter.png" />
<Resource Include="Windows\MainWindow\Point32.png" /> <Resource Include="Windows\MainWindow\Point32.png" />
<Resource Include="Windows\MainWindow\Rebar32.png" /> <Resource Include="Windows\MainWindow\Rebar32.png" />
<Resource Include="Windows\MainWindow\Rectangle32.png" /> <Resource Include="Windows\MainWindow\Rectangle32.png" />
<Resource Include="Windows\MainWindow\RectangleColumn32.png" /> <Resource Include="Windows\MainWindow\RectangleColumn32.png" />
<Resource Include="Windows\MainWindow\FunctionMaterial.png" />
<Resource Include="Windows\MainWindow\RFMaterial32.png" /> <Resource Include="Windows\MainWindow\RFMaterial32.png" />
<Resource Include="Windows\MainWindow\Run.png" /> <Resource Include="Windows\MainWindow\Run.png" />
<Resource Include="Windows\MainWindow\ScaleX.png" />
<Resource Include="Windows\MainWindow\ScaleY.png" />
<Resource Include="Windows\MainWindow\Slab32.png" /> <Resource Include="Windows\MainWindow\Slab32.png" />
<Resource Include="Windows\MainWindow\ToBackground.png" /> <Resource Include="Windows\MainWindow\ToBackground.png" />
<Resource Include="Windows\MainWindow\ToForeground.png" /> <Resource Include="Windows\MainWindow\ToForeground.png" />
<Resource Include="Windows\MainWindow\Tools_Settings.png" /> <Resource Include="Windows\MainWindow\Tools_Settings.png" />
<Resource Include="Windows\MainWindow\Tree.png" />
<Resource Include="Windows\MainWindow\СarbonMaterial32.png" /> <Resource Include="Windows\MainWindow\СarbonMaterial32.png" />
</ItemGroup> </ItemGroup>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<_LastSelectedProfileId>C:\Source\Repos\StructureHelper\StructureHelper\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId> <_LastSelectedProfileId>C:\Repos\StructureHelper\StructureHelper\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ApplicationDefinition Update="App.xaml"> <ApplicationDefinition Update="App.xaml">
@@ -57,9 +57,24 @@
<Compile Update="Windows\Graphs\GraphView.xaml.cs"> <Compile Update="Windows\Graphs\GraphView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\MainGraph\FormulaView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\MainGraph\TableView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\MainGraph\GraphView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\MainWindow\AboutView.xaml.cs"> <Compile Update="Windows\MainWindow\AboutView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\MainWindow\AnalysesManagerView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\MainWindow\Analyses\AnalysisView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\MainWindow\Materials\HeadMaterialView.xaml.cs"> <Compile Update="Windows\MainWindow\Materials\HeadMaterialView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@@ -72,6 +87,21 @@
<Compile Update="Windows\Services\CopyByParameterView.xaml.cs"> <Compile Update="Windows\Services\CopyByParameterView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\TreeGraph\GetValueView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\TreeGraph\LimView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\TreeGraph\RenameView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\TreeGraph\ScaleView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\TreeGraph\TreeGraphView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\UserControls\MultiplyDouble.xaml.cs"> <Compile Update="Windows\UserControls\MultiplyDouble.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@@ -149,9 +179,24 @@
<Page Update="Windows\Graphs\GraphView.xaml"> <Page Update="Windows\Graphs\GraphView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\MainGraph\FormulaView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\MainGraph\TableView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\MainGraph\GraphView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\MainWindow\AboutView.xaml"> <Page Update="Windows\MainWindow\AboutView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\MainWindow\AnalysesManagerView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\MainWindow\Analyses\AnalysisView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\MainWindow\Materials\HeadMaterialView.xaml"> <Page Update="Windows\MainWindow\Materials\HeadMaterialView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
@@ -164,6 +209,18 @@
<Page Update="Windows\Services\CopyByParameterView.xaml"> <Page Update="Windows\Services\CopyByParameterView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\TreeGraph\LimView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\TreeGraph\RenameView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\TreeGraph\ScaleView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\TreeGraph\TreeGraphView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\UserControls\MultiplyDouble.xaml"> <Page Update="Windows\UserControls\MultiplyDouble.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>

View File

@@ -23,7 +23,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
{ {
static IConvertUnitLogic operationLogic = new ConvertUnitLogic(); static IConvertUnitLogic operationLogic = new ConvertUnitLogic();
static IGetUnitLogic unitLogic = new GetUnitLogic(); static IGetUnitLogic unitLogic = new GetUnitLogic();
static readonly CrackForceCalculator calculator = new(); static readonly CrackForceBynarySearchCalculator calculator = new();
private ITriangulatePrimitiveLogic triangulateLogic; private ITriangulatePrimitiveLogic triangulateLogic;
private List<IForcesTupleResult> ValidTupleList { get; set; } private List<IForcesTupleResult> ValidTupleList { get; set; }
@@ -103,7 +103,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer, validTupleList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer validTupleList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer
}; };
calculator.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple; calculator.InputData.EndTuple = validTupleList[i].DesignForceTuple.ForceTuple;
var limitState = validTupleList[i].DesignForceTuple.LimitState; var limitState = validTupleList[i].DesignForceTuple.LimitState;
var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm; var calcTerm = validTupleList[i].DesignForceTuple.CalcTerm;
triangulateLogic = new TriangulatePrimitiveLogic() triangulateLogic = new TriangulatePrimitiveLogic()
@@ -114,7 +114,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
TraceLogger = TraceLogger TraceLogger = TraceLogger
}; };
var ndms = triangulateLogic.GetNdms(); var ndms = triangulateLogic.GetNdms();
calculator.NdmCollection = ndms; calculator.InputData.CheckedNdmCollection = calculator.InputData.SectionNdmCollection = ndms;
calculator.Run(); calculator.Run();
var result = (CrackForceResult)calculator.Result; var result = (CrackForceResult)calculator.Result;
if (result.IsValid == false) if (result.IsValid == false)

View File

@@ -15,7 +15,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews
public class CrackCalculatorInputDataViewModel : OkCancelViewModelBase public class CrackCalculatorInputDataViewModel : OkCancelViewModelBase
{ {
private CrackCalculator calculator; private CrackCalculator calculator;
CrackInputData crackInputData; ICrackCalculatorInputData crackInputData;
private bool setUserValueSofteningFactor; private bool setUserValueSofteningFactor;
private double softeningFactor; private double softeningFactor;
private string name; private string name;

View File

@@ -12,23 +12,10 @@
<Style x:Key="cbStyle" TargetType="CheckBox"> <Style x:Key="cbStyle" TargetType="CheckBox">
<Setter Property="Margin" Value="0,5,0,5"/> <Setter Property="Margin" Value="0,5,0,5"/>
</Style> </Style>
</Window.Resources> <DataTemplate x:Key="InputDataTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<TabControl> <TabControl>
<TabItem Header="General"> <TabItem Header="General">
<StackPanel> <StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="300"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
</Grid>
<GroupBox Header="Limit States"> <GroupBox Header="Limit States">
<StackPanel> <StackPanel>
<CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State" IsChecked="{Binding ULS}"/> <CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State" IsChecked="{Binding ULS}"/>
@@ -92,6 +79,28 @@
</Grid> </Grid>
</TabItem> </TabItem>
</TabControl> </TabControl>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="300"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
</Grid>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource InputDataTemplate}" Content="{Binding InputData}" />
</Grid>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/> <ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid> </Grid>
</Window> </Window>

View File

@@ -17,7 +17,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
internal class ShowCrackResultLogic internal class ShowCrackResultLogic
{ {
private CrackForceCalculator calculator; private CrackForceBynarySearchCalculator calculator;
private ITriangulatePrimitiveLogic triangulateLogic; private ITriangulatePrimitiveLogic triangulateLogic;
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames; public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
@@ -39,17 +39,18 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple) private void FindCrackFactor(IForceTuple finishDesignTuple, IForceTuple startDesignTuple)
{ {
calculator = new CrackForceCalculator(); calculator = new CrackForceBynarySearchCalculator();
calculator.TraceLogger = new ShiftTraceLogger(); calculator.TraceLogger = new ShiftTraceLogger();
calculator.StartTuple = startDesignTuple; calculator.InputData.StartTuple = startDesignTuple;
calculator.EndTuple = finishDesignTuple; calculator.InputData.EndTuple = finishDesignTuple;
triangulateLogic = new TriangulatePrimitiveLogic() triangulateLogic = new TriangulatePrimitiveLogic()
{ {
Primitives = ndmPrimitives, Primitives = ndmPrimitives,
LimitState = LimitState, LimitState = LimitState,
CalcTerm = CalcTerm CalcTerm = CalcTerm
}; };
calculator.NdmCollection = triangulateLogic.GetNdms(); var ndms = triangulateLogic.GetNdms();
calculator.InputData.CheckedNdmCollection = calculator.InputData.SectionNdmCollection = ndms;
calculator.Run(); calculator.Run();
var result = (CrackForceResult)calculator.Result; var result = (CrackForceResult)calculator.Result;
if (result.IsValid) if (result.IsValid)

View File

@@ -139,9 +139,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
var limitState = tuple.DesignForceTuple.LimitState; var limitState = tuple.DesignForceTuple.LimitState;
var calcTerm = tuple.DesignForceTuple.CalcTerm; var calcTerm = tuple.DesignForceTuple.CalcTerm;
var material = valuePoint.ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm); var material = valuePoint.ndmPrimitive.NdmElement.HeadMaterial.GetLoaderMaterial(limitState, calcTerm);
var userPrestrain = valuePoint.ndmPrimitive.UsersPrestrain; var userPrestrain = valuePoint.ndmPrimitive.NdmElement.UsersPrestrain;
var autoPrestrain = valuePoint.ndmPrimitive.AutoPrestrain; var autoPrestrain = valuePoint.ndmPrimitive.NdmElement.AutoPrestrain;
var ndm = new Ndm() var ndm = new Ndm()
{ {
Area = valuePoint.areaPoint.Area, Area = valuePoint.areaPoint.Area,
@@ -149,9 +149,10 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
CenterY = valuePoint.areaPoint.Point.Y, CenterY = valuePoint.areaPoint.Point.Y,
Material = material, Material = material,
}; };
ndm.Prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * valuePoint.areaPoint.Point.Y var prestrain = (userPrestrain.Mx + autoPrestrain.Mx) * valuePoint.areaPoint.Point.Y
+ (userPrestrain.My + autoPrestrain.My) * valuePoint.areaPoint.Point.X + (userPrestrain.My + autoPrestrain.My) * valuePoint.areaPoint.Point.X
+ userPrestrain.Nz + autoPrestrain.Nz; + userPrestrain.Nz + autoPrestrain.Nz;
ndm.PrestrainLogic.Add(PrestrainTypes.Prestrain, prestrain);
return ndm; return ndm;
} }
private List<string> GetValueLabels(IEnumerable<ForceResultFunc> selectedDelegates) private List<string> GetValueLabels(IEnumerable<ForceResultFunc> selectedDelegates)

View File

@@ -338,7 +338,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
foreach (var item in ndmPrimitives) foreach (var item in ndmPrimitives)
{ {
ForceTupleService.CopyProperties(wnd.StrainTuple, item.AutoPrestrain); ForceTupleService.CopyProperties(wnd.StrainTuple, item.NdmElement.AutoPrestrain);
} }
} }
} }
@@ -408,7 +408,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
this.forceCalculator = forceCalculator; this.forceCalculator = forceCalculator;
forcesResults = forceCalculator.Result as IForcesResults; forcesResults = forceCalculator.Result as IForcesResults;
ndmPrimitives = forceCalculator.Primitives; ndmPrimitives = forceCalculator.InputData.Primitives;
} }
private void ShowIsoField() private void ShowIsoField()
@@ -439,15 +439,21 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
var ndmRange = new List<INdm>(); var ndmRange = new List<INdm>();
foreach (var item in orderedNdmPrimitives) foreach (var item in orderedNdmPrimitives)
{ {
if (item is IHasDivisionSize) if (item is IHasDivisionSize hasDivision)
{ {
var hasDivision = item as IHasDivisionSize;
if (hasDivision.ClearUnderlying == true) if (hasDivision.DivisionSize.ClearUnderlying == true)
{ {
ndmRange.RemoveAll(x => hasDivision.IsPointInside(new Point2D() { X = x.CenterX, Y = x.CenterY }) == true); ndmRange.RemoveAll(x =>
hasDivision
.IsPointInside(new Point2D()
{
X = x.CenterX, Y = x.CenterY
}
) == true);
} }
} }
if (selectedNdmPrimitives.Contains(item) & item.Triangulate == true) if (selectedNdmPrimitives.Contains(item) & item.NdmElement.Triangulate == true)
{ {
ndmRange.AddRange(item.GetNdms(triangulationOptions)); ndmRange.AddRange(item.GetNdms(triangulationOptions));

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews" xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.ProgressViews"
d:DataContext="{d:DesignInstance local:TraceDocumentVM}" d:DataContext="{d:DesignInstance local:TraceDocumentVM}"
mc:Ignorable="d" mc:Ignorable="d"
Title="Trace Document Viewer" Height="450" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen" ShowInTaskbar="False"> Title="Trace Document Viewer" Height="450" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>

View File

@@ -18,6 +18,8 @@ namespace StructureHelper.Windows.CalculationWindows.ProgressViews
this.viewModel.DocumentReader = this.DocumentReader; this.viewModel.DocumentReader = this.DocumentReader;
this.viewModel.Show(); this.viewModel.Show();
} }
public TraceDocumentView(ITraceLogger traceLogger) : this (traceLogger.TraceLoggerEntries) { }
public TraceDocumentView(IEnumerable<ITraceLoggerEntry> loggerEntries) : this(new TraceDocumentVM(loggerEntries)) { } public TraceDocumentView(IEnumerable<ITraceLoggerEntry> loggerEntries) : this(new TraceDocumentVM(loggerEntries)) { }
} }
} }

View File

@@ -22,7 +22,7 @@ namespace StructureHelper.Windows.Graphs
lineSeries.LineSmoothness = visualProps.LineSmoothness; lineSeries.LineSmoothness = visualProps.LineSmoothness;
lineSeries.PointGeometry = DefaultGeometries.Circle; lineSeries.PointGeometry = DefaultGeometries.Circle;
lineSeries.PointGeometrySize = visualProps.StrokeSize; lineSeries.PointGeometrySize = visualProps.StrokeSize;
Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.Black; Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.LightGray;
//lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity }; //lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity }; lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };

View File

@@ -131,8 +131,6 @@ namespace StructureHelper.Windows.Graphs
VisualProps = new(); VisualProps = new();
} }
private void DrawSeries() private void DrawSeries()
{ {
SetLines(); SetLines();

View File

@@ -49,7 +49,6 @@ namespace StructureHelper.Windows.Graphs
OnPropertyChanged(nameof(Opacity)); OnPropertyChanged(nameof(Opacity));
} }
} }
public GraphVisualProps() public GraphVisualProps()
{ {
MaxLineSmoothness = 1d; MaxLineSmoothness = 1d;

View File

@@ -7,6 +7,7 @@ using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Services.ColorServices; using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Materials;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@@ -0,0 +1,206 @@
<Window x:Class="StructureHelper.Windows.MainGraph.FormulaView"
x:Name="FormulaFunction_win"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
xmlns:ens="clr-namespace:StructureHelperCommon.Infrastructures.Enums;assembly=StructureHelperCommon"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:FormulaViewModel}"
Title="FormulaFunction" Height="640" Width="400">
<Window.Resources>
<ObjectDataProvider x:Key="PurposeEnum" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="ens:FunctionPurpose"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
<RowDefinition Height="150"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="60"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="5"
Text="Formula:"
VerticalAlignment="Center"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="y(x) ="
Margin="5"
VerticalAlignment="Center"
HorizontalAlignment="Right"/>
<TextBox Grid.Column="1" Text="{Binding Formula, UpdateSourceTrigger=PropertyChanged}"
Margin="5"/>
</Grid>
</Grid>
<TextBlock Grid.Row="1"
Margin="5"
Background="LightYellow"
Text="{Binding FormulaText, UpdateSourceTrigger=PropertyChanged}"
TextAlignment="Center"
FontSize="20"
TextWrapping="Wrap">
</TextBlock>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="90"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="3"
Margin="5"
Text="Enter limit bounds:"
VerticalAlignment="Center"/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="{Binding X}"
VerticalAlignment="Center"
HorizontalAlignment="Right"/>
<TextBlock Grid.Column="1"
Grid.Row="1"
Text="{Binding GREATER}"
VerticalAlignment="Center"
HorizontalAlignment="Right"/>
<TextBox Grid.Column="2"
Grid.Row="1"
Text="{Binding LeftBound,
UpdateSourceTrigger=PropertyChanged,
StringFormat=\{0:n\}}"
Margin="5"/>
<TextBlock Grid.Column="0"
Grid.Row="2"
Text="{Binding X}"
VerticalAlignment="Center"
HorizontalAlignment="Right"/>
<TextBlock Grid.Column="1"
Grid.Row="2"
Text="{Binding LESS}"
VerticalAlignment="Center"
HorizontalAlignment="Right"/>
<TextBox Grid.Column="2"
Grid.Row="2"
Text="{Binding RightBound,
UpdateSourceTrigger=PropertyChanged,
StringFormat=\{0:n\}}"
Margin="5"/>
</Grid>
<TextBlock Grid.Row="1"
Margin="5"
Background="LightYellow"
Text="{Binding LimitText, UpdateSourceTrigger=PropertyChanged}"
TextAlignment="Center"
FontSize="20"
TextWrapping="Wrap">
</TextBlock>
</Grid>
<Grid Grid.Row="3">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="5"
Text="Step:"
VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Text="{Binding Step}" Margin="5"/>
</Grid>
<Grid Grid.Row="4">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="5"
Text="Name:"
VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Text="{Binding Name}" Margin="5"/>
</Grid>
<Grid Grid.Row="5">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="5"
Text="Purpose:"
VerticalAlignment="Center"/>
<ComboBox Grid.Row="1"
Margin="5"
ItemsSource="{Binding Source={StaticResource PurposeEnum}}"
SelectedItem="{Binding FunctionPurpose}"/>
</Grid>
<Grid Grid.Row="6">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Margin="5"
Text="Description:"
VerticalAlignment="Center"/>
<TextBox Grid.Row="1" Text="{Binding Description}" Margin="5"/>
</Grid>
<Grid Grid.Row="7">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="0"
Margin="5"
Text="Color:"
VerticalAlignment="Center"/>
<Button Grid.Row="1"
Grid.Column="1"
Margin="5,5,5,5"
Command="{Binding EditColorCommand}"
Content="Press to change color">
</Button>
<Rectangle
Grid.Row="1"
Grid.Column="0"
Margin="5,5,5,5">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color, UpdateSourceTrigger=PropertyChanged}"/>
</Rectangle.Fill>
</Rectangle>
</Grid>
<Button Grid.Row="8" Margin="5" Content="Save"
Command="{Binding SaveCommand}"
CommandParameter="{Binding ElementName=FormulaFunction_win}">
</Button>
</Grid>
</Window>

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace StructureHelper.Windows.MainGraph
{
/// <summary>
/// Interaction logic for FormulaView.xaml
/// </summary>
public partial class FormulaView : Window
{
public FormulaView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,205 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Functions;
using StructureHelperCommon.Services.ColorServices;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace StructureHelper.Windows.MainGraph
{
public class FormulaViewModel : ViewModelBase
{
private const string ERROR_BOUNDS = "The left bound must be less than the right bound";
private const string ERROR_STEP = "The number of steps should not be more than";
private const string DEFAULT_NAME = "Put function name here...";
private const string DEFAULT_DESCRIPTION = "Put function description here...";
private const string DEFAULT_FORMULA = "x^2";
private const double DEFAULT_LEFT_BOUND = 1;
private const double DEFAULT_RIGHT_BOUND = 1000;
private const int DEFAULT_STEP = 100;
private const int MAX_STEP = 1000;
public char GREATER { get; } = '\u2265';
public char LESS { get; } = '\u2264';
public char X { get; } = 'x';
private RelayCommand saveCommand;
private RelayCommand editColor;
public int Step { get; set; }
private double leftBound;
public double LeftBound
{
get => leftBound;
set
{
leftBound = value;
LimitText = $"x\u2208[{value};{RightBound}]";
OnPropertyChanged(nameof(LeftBound));
}
}
private double rightBound;
public double RightBound
{
get => rightBound;
set
{
rightBound = value;
LimitText = $"x\u2208[{LeftBound};{value}]";
OnPropertyChanged(nameof(RightBound));
}
}
public ObservableCollection<Color> Colors { get; set; }
public ICommand EditColorCommand
{
get => editColor ??= new RelayCommand(o => EditColor());
}
public ICommand SaveCommand
{
get => saveCommand ??= new RelayCommand(o => Save(o));
}
private string formula;
public string Formula
{
get => formula;
set
{
formula = value;
FormulaText = $"y(x)={Formula}";
OnPropertyChanged(nameof(Formula));
}
}
private string formulaText = "y(x)=";
public string FormulaText
{
get => formulaText;
set
{
formulaText = value;
OnPropertyChanged(nameof(FormulaText));
}
}
private IOneVariableFunction function;
public IOneVariableFunction Function
{
get => function;
set
{
function = value;
}
}
private string name;
public string Name
{
get => name;
set
{
name = value;
}
}
private FunctionPurpose functionPurpose;
public FunctionPurpose FunctionPurpose
{
get => functionPurpose;
set
{
functionPurpose = value;
}
}
private string description;
public string Description
{
get => description;
set
{
description = value;
}
}
private Color color;
public Color Color
{
get => color;
set
{
color = value;
OnPropertyChanged(nameof(Color));
}
}
private string limitText;
public string LimitText
{
get => limitText;
set
{
limitText = value;
OnPropertyChanged(nameof(LimitText));
}
}
public FormulaViewModel()
{
Name = DEFAULT_NAME;
Description = DEFAULT_DESCRIPTION;
Step = DEFAULT_STEP;
LeftBound = DEFAULT_LEFT_BOUND;
RightBound = DEFAULT_RIGHT_BOUND;
LimitText = $"x\u2208[{LeftBound};{RightBound}]";
Color = Brushes.Red.Color;
}
public FormulaViewModel(FormulaFunction formulaFunction)
{
Function = formulaFunction;
Formula = formulaFunction.Formula;
Step = formulaFunction.Step;
Name = Function.Name;
FunctionPurpose = Function.FunctionPurpose;
Description = Function.Description;
LeftBound = Function.MinArg;
RightBound = Function.MaxArg;
Color = Function.Color;
}
private void EditColor()
{
Color color = new Color();
ColorProcessor.EditColor(ref color);
Color = color;
}
private void Save(object parameter)
{
if (Function is null)
{
Function = new FormulaFunction(isUser: true);
}
Function.Name = Name;
Function.FullName = Name;
Function.Description = Description;
Function.IsUser = true;
(Function as FormulaFunction).Step = Step;
(Function as FormulaFunction).Formula = Formula;
Function.Color = Color;
Function.MinArg = LeftBound;
Function.MaxArg = RightBound;
Function.FunctionPurpose = FunctionPurpose;
var window = parameter as Window;
if (LeftBound > RightBound)
{
MessageBox.Show($"{ERROR_BOUNDS}");
return;
}
if (Step > MAX_STEP)
{
MessageBox.Show($"{ERROR_STEP} {MAX_STEP}");
return;
}
window.DialogResult = true;
window.Close();
}
}
}

View File

@@ -0,0 +1,183 @@
<Window x:Class="StructureHelper.Windows.MainGraph.GraphView"
x:Name="GraphView_win"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
Loaded="Window_Loaded"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:GraphViewModel}"
Title="StructureHelper" Height="700"
Width="1000"
MinHeight="400"
MinWidth="600">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="170"/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<ListView Name="FunctionList"
Grid.Row="0" Grid.Column="0" Margin="5"
ItemsSource="{Binding Functions, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding SelectedFuntion, UpdateSourceTrigger=PropertyChanged}">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Expander IsExpanded="True">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="Bold"
Foreground="DarkSlateBlue"
VerticalAlignment="Bottom"/>
<TextBlock Text=": " FontWeight="Bold"
Foreground="DarkSlateBlue"
VerticalAlignment="Bottom"/>
<TextBlock Text="{Binding ItemCount}" FontWeight="Bold"
Foreground="Gray"
VerticalAlignment="Bottom" />
</StackPanel>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Rectangle
Margin="1,1,1,1"
Height="15"
Width="30">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Path=Color, UpdateSourceTrigger=PropertyChanged}"/>
</Rectangle.Fill>
</Rectangle>
<TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Add table"
Command="{Binding AddTableCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/AddTable.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Add formula"
Command="{Binding AddFormulaCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Addformula.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Edit"
Command="{Binding EditCommand}"
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Edit.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Copy"
Command="{Binding CopyCommand}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Copy.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Delete"
Command="{Binding DeleteCommand}"
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Tree"
Command="{Binding TreeCommand}"
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Tree.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</ListView.ContextMenu>
</ListView>
<ContentControl Grid.Row="1"
ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}"
Content="{Binding VisualProps}"/>
<Grid Grid.Row="2" Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.Row="0" Margin="5" Content="Add table"
Command="{Binding AddTableCommand}"
Background="LightGreen"/>
<Button Grid.Column="0" Grid.Row="1" Margin="5" Content="Add formula"
Command="{Binding AddFormulaCommand}"
Background="LightGreen"/>
<Button Grid.Column="1" Grid.Row="0" Margin="5" Content="Edit"
Command="{Binding EditCommand}"
CommandParameter="{Binding ElementName=GraphView_win}"
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
Background="LightYellow"/>
<Button Grid.Column="1" Grid.Row="1" Margin="5" Content="Delete"
Command="{Binding DeleteCommand}"
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
Background="LightPink"/>
<Button Grid.Column="2" Grid.Row="0" Margin="5" Content="Copy"
Command="{Binding CopyCommand}"
Background="LightBlue"/>
<Button Grid.Column="2" Grid.Row="1" Margin="5" Content="Tree"
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
Command="{Binding TreeCommand}"
Background="AntiqueWhite"/>
</Grid>
<lvc:CartesianChart Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"
Series="{Binding SeriesCollection, UpdateSourceTrigger=PropertyChanged}" Margin="5"
Zoom="Xy">
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="Y"></lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis Title="X" Labels="{Binding Labels, UpdateSourceTrigger=PropertyChanged}"></lvc:Axis>
</lvc:CartesianChart.AxisX>
</lvc:CartesianChart>
<Grid Grid.Row="2" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Description:" Margin="5"/>
<TextBlock Grid.Row="1"
Name="DescriptionTextBlock"
Text="{Binding SelectedFuntion.Description}"
Margin="5" TextWrapping="Wrap"
VerticalAlignment="Center" Height="60"/>
</Grid>
</Grid>
</Window>

View File

@@ -0,0 +1,50 @@
using StructureHelper.Windows.MainWindow;
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Graphs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace StructureHelper.Windows.MainGraph
{
/// <summary>
/// Interaction logic for GraphView.xaml
/// </summary>
public partial class GraphView : Window
{
private const string GROUP_FACTOR = "Group";
private GraphViewModel viewModel;
public GraphView(GraphViewModel viewModel)
{
this.viewModel = viewModel;
DataContext = this.viewModel;
InitializeComponent();
}
public GraphView() : this(new GraphViewModel())
{
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(FunctionList.ItemsSource);
PropertyGroupDescription groupDescription = new PropertyGroupDescription(GROUP_FACTOR);
view.GroupDescriptions.Clear();
view.GroupDescriptions.Add(groupDescription);
}
public void Refresh()
{
FunctionList.Items.Refresh();
}
}
}

View File

@@ -0,0 +1,232 @@
using LiveCharts;
using LiveCharts.Wpf;
using StructureHelper.Infrastructure;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.TreeGraph;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Functions;
using StructureHelperLogics.Models.Graphs;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace StructureHelper.Windows.MainGraph
{
public class GraphViewModel : ViewModelBase
{
private LineSeries lineSeries;
private SeriesCollection seriesCollection;
private List<string> labels;
private GraphVisualProps visualProps = new();
public LineSeries LineSeries
{
get => lineSeries;
set
{
lineSeries = value;
OnPropertyChanged(nameof(lineSeries));
}
}
public SeriesCollection SeriesCollection
{
get => seriesCollection;
set
{
seriesCollection = value;
OnPropertyChanged(nameof(SeriesCollection));
}
}
public List<string> Labels
{
get => labels;
set
{
labels = value;
OnPropertyChanged(nameof(labels));
}
}
public GraphVisualProps VisualProps
{
get => visualProps;
set
{
visualProps = value;
DrawGraph();
}
}
private IOneVariableFunction selectedFunction;
public IOneVariableFunction SelectedFuntion
{
get
{
return selectedFunction;
}
set
{
selectedFunction = value;
DrawGraph();
OnPropertyChanged(nameof(SelectedFuntion));
}
}
private ObservableCollection<IOneVariableFunction> functions;
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
private RelayCommand addTableCommand;
private RelayCommand addFormulaCommand;
private RelayCommand editCommand;
private RelayCommand deleteCommand;
private RelayCommand copyCommand;
private RelayCommand treeCommand;
private RelayCommand drawGraphCommand;
private RelayCommand _saveCommand;
public ICommand AddTableCommand
{
get => addTableCommand ??= new RelayCommand(o => AddTable());
}
public ICommand AddFormulaCommand
{
get => addFormulaCommand ??= new RelayCommand(o => AddFormula());
}
public ICommand EditCommand
{
get => editCommand ??= new RelayCommand(o => Edit(o));
}
public ICommand DeleteCommand
{
get => deleteCommand ??= new RelayCommand(o => Delete());
}
public ICommand CopyCommand
{
get => copyCommand ??= new RelayCommand(o => Copy());
}
public ICommand TreeCommand
{
get => treeCommand ??= new RelayCommand(o => Tree());
}
public ICommand DrawGraphCommand
{
get => drawGraphCommand ??= new RelayCommand(o => DrawGraph());
}
public ICommand SaveCommand
{
get => _saveCommand ??= new RelayCommand(o => Save());
}
public GraphViewModel()
{
Functions = new ObservableCollection<IOneVariableFunction>(ProgramSetting.Functions);
}
private void AddTable()
{
var tableViewModel = new TableViewModel();
var tableView = new TableView();
tableView.DataContext = tableViewModel;
if (tableView.ShowDialog() == true)
{
Functions.Add(tableViewModel.Function);
SelectedFuntion = tableViewModel.Function;
}
Save();
}
private void AddFormula()
{
var formulaViewModel = new FormulaViewModel();
var formulaView = new FormulaView();
formulaView.DataContext = formulaViewModel;
if (formulaView.ShowDialog() == true)
{
Functions.Add(formulaViewModel.Function);
SelectedFuntion = formulaViewModel.Function;
}
Save();
}
private void Edit(object parameter)
{
if (SelectedFuntion is null)
{
return;
}
if (SelectedFuntion.Type == FunctionType.TableFunction)
{
var tableViewModel = new TableViewModel(SelectedFuntion as TableFunction);
var tableView = new TableView();
tableView.DataContext = tableViewModel;
tableView.ShowDialog();
SelectedFuntion = tableViewModel.Function;
}
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
{
var formulaViewModel = new FormulaViewModel(SelectedFuntion as FormulaFunction);
var formulaView = new FormulaView();
formulaView.DataContext = formulaViewModel;
formulaView.ShowDialog();
SelectedFuntion = formulaViewModel.Function;
}
var graphView = parameter as GraphView;
graphView.Refresh();
Save();
}
private void Delete()
{
if (SelectedFuntion is null)
{
var lastFunction = Functions[Functions.Count - 1];
if (lastFunction.IsUser)
{
Functions.Remove(lastFunction);
}
}
else
{
Functions.Remove(SelectedFuntion);
}
Save();
}
private void Copy()
{
if (SelectedFuntion is null)
{
return;
}
else if (SelectedFuntion.Type == FunctionType.TableFunction)
{
Functions.Add(SelectedFuntion.Clone() as TableFunction);
}
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
{
Functions.Add(SelectedFuntion.Clone() as FormulaFunction);
}
Save();
}
private void Tree()
{
if (SelectedFuntion is null)
{
return;
}
var treeGraphVM = new TreeGraphViewModel(SelectedFuntion);
var treeGraph = new TreeGraphView();
treeGraph.DataContext = treeGraphVM;
treeGraphVM.TreeGraphView_win = treeGraph;
treeGraph.ShowDialog();
}
private void DrawGraph()
{
var graphSettings = SelectedFuntion.GetGraphSettings();
Labels = graphSettings.GetLabels();
LineSeries = graphSettings.GetLineSeries();
GraphService.SetVisualProps(LineSeries, VisualProps);
SeriesCollection = new SeriesCollection();
SeriesCollection.Add(LineSeries);
Save();
}
public void Save()
{
ProgramSetting.Functions = new List<IOneVariableFunction>(Functions);
}
}
}

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