SH: recovery

This commit is contained in:
NickAppLab
2023-02-12 23:38:24 +05:00
parent f013ddae13
commit 784d3d3a5f
416 changed files with 5188 additions and 1338 deletions

4
StructureHelper/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*\obj
*\bin
*\packages
*\.vs

21
StructureHelper/App.xaml Normal file
View File

@@ -0,0 +1,21 @@
<Application x:Class="StructureHelper.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:StructureHelper">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Infrastructure/UI/Resources/CommonEnums.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Styles.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/DataGridStyles.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ButtonStyles.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/Converters.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/DataGridTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/PrimitiveTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ShapeEditTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/PrimitiveToolTips.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ITemEditPanels.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,43 @@
using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem;
using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.Services.NdmCalculations;
using System.Windows;
using Autofac;
namespace StructureHelper
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public static IContainer Container { get; private set; }
public static ILifetimeScope Scope { get; private set; }
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var builder = new ContainerBuilder();
builder.RegisterType<PrimitiveRepository>().As<IPrimitiveRepository>().SingleInstance();
builder.RegisterType<UnitSystemService>().AsSelf().SingleInstance();
builder.RegisterType<CalculationService>().AsSelf().SingleInstance();
builder.RegisterType<MainModel>().AsSelf().SingleInstance();
builder.RegisterType<MainViewModel>().AsSelf().SingleInstance();
builder.RegisterType<MainView>().AsSelf();
Container = builder.Build();
Scope = Container.Resolve<ILifetimeScope>();
var window = Scope.Resolve<MainView>();
window.Show();
}
protected override void OnExit(ExitEventArgs e)
{
Scope.Dispose();
base.OnExit(e);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

View File

@@ -0,0 +1,8 @@
namespace StructureHelper.Infrastructure.Enums
{
public enum PrimitiveType
{
Point,
Rectangle
}
}

View File

@@ -0,0 +1,13 @@
using System;
namespace StructureHelper.Infrastructure
{
public class EventArgs<T> : EventArgs
{
public EventArgs(T value)
{
Value = value;
}
public T Value { get; private set; }
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Windows;
using EventTrigger = System.Windows.Interactivity.EventTrigger;
namespace StructureHelper.Infrastructure
{
public class EventTriggerBase<T> : EventTrigger where T : RoutedEventArgs
{
readonly Predicate<T> eventTriggerPredicate;
public EventTriggerBase(Predicate<T> eventTriggerPredicate)
{
this.eventTriggerPredicate = eventTriggerPredicate;
}
protected override void OnEvent(EventArgs eventArgs)
{
if (eventArgs is T e && eventTriggerPredicate(e))
{
base.OnEvent(eventArgs);
e.Handled = true;
}
}
}
}

View File

@@ -0,0 +1,31 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace StructureHelper.Infrastructure.Extensions
{
public static class ObservableCollectionExtensions
{
public static void MoveElementToEnd<T>(this ObservableCollection<T> collection, T element)
{
var elementCopy = element;
collection.Remove(element);
collection.Add(elementCopy);
}
public static void MoveElementToBegin<T>(this ObservableCollection<T> collection, T element)
{
var collectionCopy = new List<T>(collection);
collectionCopy.Remove(element);
collection.Clear();
collection.Add(element);
foreach (var collectionElem in collectionCopy)
collection.Add(collectionElem);
}
public static void MoveElementToSelectedIndex<T>(this ObservableCollection<T> collection, T element, int index)
{
collection.Remove(element);
collection.Insert(index - 1, element);
}
}
}

View File

@@ -0,0 +1,45 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interactivity;
namespace StructureHelper.Infrastructure
{
public class MouseBehaviour : Behavior<Panel>
{
public static readonly DependencyProperty MouseYProperty = DependencyProperty.Register(
"MouseY", typeof(double), typeof(MouseBehaviour), new PropertyMetadata(default(double)));
public static readonly DependencyProperty MouseXProperty = DependencyProperty.Register(
"MouseX", typeof(double), typeof(MouseBehaviour), new PropertyMetadata(default(double)));
public double MouseY
{
get => (double)GetValue(MouseYProperty);
set => SetValue(MouseYProperty, value);
}
public double MouseX
{
get => (double)GetValue(MouseXProperty);
set => SetValue(MouseXProperty, value);
}
protected override void OnAttached()
{
AssociatedObject.MouseMove += AssociatedObjectOnMouseMove;
}
protected override void OnDetaching()
{
AssociatedObject.MouseMove -= AssociatedObjectOnMouseMove;
}
private void AssociatedObjectOnMouseMove(object sender, MouseEventArgs mouseEventArgs)
{
var pos = mouseEventArgs.GetPosition(AssociatedObject);
MouseX = pos.X;
MouseY = pos.Y;
}
}
}

View File

@@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace StructureHelper.Infrastructure
{
public class NamedList<T> : List<T>
{
public string Name { get; set; }
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Windows.Input;
namespace StructureHelper.Infrastructure
{
public class RelayCommand : ICommand
{
private Action<object> execute;
private Func<object, bool> canExecute;
public event EventHandler CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
this.execute = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter) => canExecute == null || canExecute(parameter);
public void Execute(object parameter) => execute(parameter);
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Common
{
[ValueConversion(typeof(bool), typeof(bool))]
public class InvertBoolConverter : IValueConverter
{
public InvertBoolConverter()
{
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && value is bool)
{
return !((bool)value);
}
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Convert(value, targetType, parameter, culture);
}
}
}

View File

@@ -0,0 +1,100 @@
using Newtonsoft.Json.Linq;
using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters
{
internal static class CommonOperation
{
private static IEnumerable<IUnit> units = UnitsFactory.GetUnitCollection();
public static double ConvertToDoubleChangeComma(string s)
{
double result;
if (!double.TryParse(s, NumberStyles.Any, CultureInfo.CurrentCulture, out result) &&
!double.TryParse(s, NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out result) &&
!double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
{
throw new StructureHelperException($"{ErrorStrings.IncorrectValue}: {s}");
}
return result;
}
public static IStringDoublePair DivideIntoStringDoublePair(string s)
{
s = s.Replace(" ", "");
string digitPattern = @"^[-]?[+]?\d+(\.?|\,?)\d*";
string textPattern = @"[0-9]|\.|\,";
string caracterPattern = "[a-z]+$";
string target = "";
Regex regexText = new Regex(textPattern);
string textString = regexText.Replace(s, target);
var textMatch = Regex.Match(textString, caracterPattern, RegexOptions.IgnoreCase);
if (textMatch.Success) {textString = textMatch.Value.ToLower();}
var match = Regex.Match(s, digitPattern);
if (match.Success)
{
string digitString = match.Value;
double digit = ConvertToDoubleChangeComma(digitString);
return new StringDoublePair() { Digit = digit, Text = textString };
}
throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
}
public static IUnit GetUnit(UnitTypes unitType, string unitName)
{
return units.Where(u => u.UnitType == unitType & u.Name == unitName).Single();
}
public static string Convert(IUnit unit, string unitName, object value)
{
double val;
if (value != null) { val = (double)value; }
else { throw new Exception($"{unitName} value is null"); }
val *= unit.Multiplyer;
string strValue = $"{val} {unit.Name}";
return strValue;
}
public static double ConvertBack(UnitTypes unitType, IUnit unit, object value)
{
double val;
double multy;
double coefficient = unit.Multiplyer;
var strVal = value as string;
IStringDoublePair pair = DivideIntoStringDoublePair(strVal);
try
{
multy = GetMultiplyer(unitType, pair.Text);
}
catch (Exception ex)
{
multy = coefficient;
}
val = pair.Digit / multy;
return val;
}
private static double GetMultiplyer(UnitTypes unitType, string unitName)
{
try
{
return units.Where(u => u.UnitType == unitType & u.Name == unitName).Single().Multiplyer;
}
catch (Exception ex)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ex);
}
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters
{
internal interface IStringDoublePair
{
double Digit { get; }
string Text { get; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters
{
internal class StringDoublePair : IStringDoublePair
{
public double Digit { get; set; }
public string Text { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Area : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Area; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm2"); }
public override string UnitName { get => "Area"; }
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Curvature : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Curvature; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "1/mm"); }
public override string UnitName { get => "Curvature"; }
}
}

View File

@@ -0,0 +1,19 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Force : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Force; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kN"); }
public override string UnitName { get => "Force"; }
}
}

View File

@@ -0,0 +1,22 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Length : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Length; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm"); }
public override string UnitName { get => "Length"; }
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Moment : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Moment; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kNm"); }
public override string UnitName { get => "Moment"; }
}
}

View File

@@ -0,0 +1,39 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class PlainDouble : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
return (double)value;
}
catch(Exception)
{
return new StructureHelperException(ErrorStrings.DataIsInCorrect);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
return CommonOperation.ConvertToDoubleChangeComma((string)value);
}
catch (Exception)
{
return new StructureHelperException(ErrorStrings.DataIsInCorrect);
}
}
}
}

View File

@@ -0,0 +1,19 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Stress : UnitBase
{
public override UnitTypes UnitType { get => UnitTypes.Stress; }
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "MPa"); }
public override string UnitName { get => "Stress"; }
}
}

View File

@@ -0,0 +1,39 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal abstract class UnitBase : IValueConverter
{
public abstract UnitTypes UnitType { get; }
public abstract IUnit CurrentUnit { get; }
public abstract string UnitName { get;}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return CommonOperation.Convert(CurrentUnit, UnitName, value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
try
{
return CommonOperation.ConvertBack(UnitType, CurrentUnit, value);
}
catch (Exception)
{
MessageBox.Show($"Value of {UnitName}={(string)value} is not correct", "Error of conversion", MessageBoxButtons.OK);
return 0;
}
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal static class UnitConstatnts
{
public static double Length = 1e3d;
public static double Force = 1e-3d;
public static double Stress = 1e-6d;
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal interface IHasCenter
{
double PrimitiveLeft { get; }
double PrimitiveTop { get; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal interface IHasDivision
{
int NdmMinDivision { get; set; }
double NdmMaxSize { get; set; }
}
}

View File

@@ -0,0 +1,27 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal class LineViewPrimitive : PrimitiveBase
{
public LineViewPrimitive(ILinePrimitive primitive) : base(primitive)
{
}
//public LineViewPrimitive(double x, double y, MainViewModel ownerVM) : base(x, y, ownerVM)
//{
//}
}
}

View File

@@ -0,0 +1,56 @@
using System;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.Models.Materials;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class PointViewPrimitive : PrimitiveBase, IHasCenter
{
IPointPrimitive primitive;
public double Area
{ get => primitive.Area;
set
{
primitive.Area = value;
RefreshPlacement();
}
}
public double PrimitiveLeft
{
get => DeltaX - Diameter / 2d;
}
public double PrimitiveTop
{
get => DeltaY - Diameter / 2d;
}
public PointViewPrimitive(IPointPrimitive _primitive) : base(_primitive)
{
primitive = _primitive;
}
public double Diameter { get => Math.Sqrt(primitive.Area / Math.PI) * 2; }
public override INdmPrimitive GetNdmPrimitive()
{
return primitive;
}
private void RefreshPlacement()
{
OnPropertyChanged(nameof(Area));
OnPropertyChanged(nameof(Diameter));
OnPropertyChanged(nameof(CenterX));
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(PrimitiveLeft));
OnPropertyChanged(nameof(PrimitiveTop));
}
}
}

View File

@@ -0,0 +1,268 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Models.Materials;
using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.Materials;
using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Primitives;
using System.Windows.Controls;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public abstract class PrimitiveBase : ViewModelBase
{
#region Поля
private IPrimitiveRepository primitiveRepository;
private INdmPrimitive primitive;
private bool captured, parameterCaptured, elementLock, paramsPanelVisibilty, popupCanBeClosed = true, borderCaptured;
private double showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight;
protected double delta = 0.5;
private int showedZIndex = 1;
#endregion
#region Свойства
public INdmPrimitive NdmPrimitive
{
get => primitive;
}
public IPrimitiveRepository PrimitiveRepository => primitiveRepository;
public string Name
{
get => primitive.Name;
set
{
primitive.Name = value;
OnPropertyChanged(nameof(Name));
}
}
public double CenterX
{
get => primitive.CenterX;
set
{
primitive.CenterX = value;
OnPropertyChanged(nameof(CenterX));
}
}
public double CenterY
{
get => primitive.CenterY;
set
{
primitive.CenterY = value;
OnPropertyChanged(nameof(CenterY));
OnPropertyChanged(nameof(InvertedCenterY));
}
}
public double InvertedCenterY => - CenterY;
public double PrestrainKx
{ get => primitive.UsersPrestrain.Kx;
set
{
primitive.UsersPrestrain.Kx = value;
OnPropertyChanged(nameof(PrestrainKx));
}
}
public double PrestrainKy
{ get => primitive.UsersPrestrain.Ky;
set
{
primitive.UsersPrestrain.Ky = value;
OnPropertyChanged(nameof(PrestrainKy));
}
}
public double PrestrainEpsZ
{ get => primitive.UsersPrestrain.EpsZ;
set
{
primitive.UsersPrestrain.EpsZ = value;
OnPropertyChanged(nameof(PrestrainEpsZ));
}
}
public double AutoPrestrainKx => primitive.AutoPrestrain.Kx;
public double AutoPrestrainKy => primitive.AutoPrestrain.Ky;
public double AutoPrestrainEpsZ => primitive.AutoPrestrain.EpsZ;
public IHeadMaterial HeadMaterial
{
get => primitive.HeadMaterial;
set
{
primitive.HeadMaterial = value;
OnPropertyChanged(nameof(HeadMaterial));
OnPropertyChanged(nameof(Color));
}
}
public bool SetMaterialColor
{
get => primitive.VisualProperty.SetMaterialColor;
set
{
primitive.VisualProperty.SetMaterialColor = value;
OnPropertyChanged(nameof(Color));
}
}
public Color Color
{
get => ((primitive.VisualProperty.SetMaterialColor == true)
& (primitive.HeadMaterial !=null))? primitive.HeadMaterial.Color : primitive.VisualProperty.Color;
set
{
SetMaterialColor = false;
primitive.VisualProperty.Color = value;
OnPropertyChanged(nameof(Color));
}
}
public bool Captured
{
set => OnPropertyChanged(value, ref captured);
get => captured;
}
public bool ParameterCaptured
{
set => OnPropertyChanged(value, ref parameterCaptured);
get => parameterCaptured;
}
public bool ElementLock
{
get => elementLock;
set => OnPropertyChanged(value, ref elementLock);
}
public bool ParamsPanelVisibilty
{
get => paramsPanelVisibilty;
set => OnPropertyChanged(value, ref paramsPanelVisibilty);
}
public bool PopupCanBeClosed
{
get => popupCanBeClosed;
set => OnPropertyChanged(value, ref popupCanBeClosed);
}
public double ShowedOpacity
{
get => showedOpacity;
set
{
Opacity = (100 - value) / 100;
OnPropertyChanged(nameof(Opacity));
OnPropertyChanged(value, ref showedOpacity);
}
}
public bool IsVisible
{
get => primitive.VisualProperty.IsVisible;
set
{
primitive.VisualProperty.IsVisible = value;
OnPropertyChanged(nameof(IsVisible));
}
}
public double Opacity
{
get => primitive.VisualProperty.Opacity;
set
{
primitive.VisualProperty.Opacity = value;
OnPropertyChanged(nameof(Opacity));
}
}
public int ShowedZIndex
{
get => showedZIndex;
set
{
ZIndex = value - 1;
OnPropertyChanged(nameof(ZIndex));
OnPropertyChanged(value, ref showedZIndex);
}
}
public int ZIndex
{
get => primitive.VisualProperty.ZIndex;
set
{
primitive.VisualProperty.ZIndex = value;
OnPropertyChanged(nameof(ZIndex));
}
}
public double Xy1
{
get => xY1;
set => OnPropertyChanged(value, ref xY1);
}
public double Yx1
{
get => yX1;
set => OnPropertyChanged(value, ref yX1);
}
public virtual double PrimitiveWidth { get; set; }
public virtual double PrimitiveHeight { get;set; }
public bool BorderCaptured
{
get => borderCaptured;
set => OnPropertyChanged(value, ref borderCaptured);
}
#endregion
#region Команды
public ICommand PrimitiveLeftButtonDown { get; }
public ICommand PrimitiveLeftButtonUp { get; }
public ICommand PreviewMouseMove { get; protected set; }
public ICommand PrimitiveDoubleClick { get; }
#endregion
public PrimitiveBase(INdmPrimitive primitive)
{
this.primitive = primitive;
}
public void RegisterDeltas(double dx, double dy)
{
DeltaX = dx;
DeltaY = dy;
}
public MainViewModel OwnerVM { get; private set; }
public double DeltaX { get; private set; }
public double DeltaY { get; private set; }
public virtual INdmPrimitive GetNdmPrimitive()
{
RefreshNdmPrimitive();
return primitive;
}
public virtual void RefreshNdmPrimitive()
{
}
public void RefreshColor()
{
OnPropertyChanged(nameof(Color));
}
}
}

View File

@@ -0,0 +1,37 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
internal static class PrimitiveOperations
{
public static ObservableCollection<PrimitiveBase> ConvertNdmPrimitivesToPrimitiveBase(IEnumerable<INdmPrimitive> primitives)
{
ObservableCollection<PrimitiveBase> viewItems = new ObservableCollection<PrimitiveBase>();
foreach (var item in primitives)
{
if (item is IPointPrimitive)
{
var point = item as IPointPrimitive;
viewItems.Add(new PointViewPrimitive(point));
}
else if (item is IRectanglePrimitive)
{
var rect = item as IRectanglePrimitive;
viewItems.Add(new RectangleViewPrimitive(rect));
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
}
return viewItems;
}
}
}

View File

@@ -0,0 +1,74 @@
using StructureHelper.Infrastructure.Enums;
using StructureHelper.UnitSystem.Systems;
using StructureHelper.Windows.MainWindow;
using StructureHelperLogics.Models.Materials;
using StructureHelperCommon.Models.Shapes;
using System;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class RectangleViewPrimitive : PrimitiveBase, IHasDivision, IHasCenter
{
private IRectanglePrimitive primitive;
public override double PrimitiveWidth
{
get => primitive.Width;
set
{
primitive.Width = value;
OnPropertyChanged(nameof(PrimitiveLeft));
OnPropertyChanged(nameof(PrimitiveWidth));
}
}
public override double PrimitiveHeight
{
get => primitive.Height;
set
{
primitive.Height = value;
OnPropertyChanged(nameof(PrimitiveTop));
OnPropertyChanged(nameof(PrimitiveHeight));
}
}
public double PrimitiveLeft
{
get => DeltaX - primitive.Width / 2d;
}
public double PrimitiveTop
{
get => DeltaY - primitive.Height / 2d;
}
public int NdmMinDivision
{
get => primitive.NdmMinDivision;
set
{
primitive.NdmMinDivision = value;
OnPropertyChanged(nameof(NdmMinDivision));
}
}
public double NdmMaxSize
{
get => primitive.NdmMaxSize;
set
{
primitive.NdmMaxSize = value;
OnPropertyChanged(nameof(NdmMaxSize));
}
}
public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive)
{
primitive = _primitive;
}
public override INdmPrimitive GetNdmPrimitive()
{
return primitive;
}
}
}

View File

@@ -0,0 +1,48 @@
<UserControl x:Class="StructureHelper.Infrastructure.UI.DataTemplates.EllipseTemplate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
mc:Ignorable="d">
<StackPanel>
<Ellipse Style="{StaticResource EllipseStyle}" d:DataContext="{d:DesignInstance dataContexts:PointViewPrimitive}">
<Ellipse.ToolTip>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Name: " FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" FontWeight="Bold"/>
<TextBlock Grid.Row="1" Text="Material Name: " FontWeight="Bold"/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding HeadMaterial.Name}" FontWeight="Bold"/>
<TextBlock Grid.Row="2" Text="Center X: "/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="3" Text="Center Y: "/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="4" Text="Area: "/>
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding Area, Converter={StaticResource AreaConverter}}"/>
</Grid>
</Ellipse.ToolTip>
<Ellipse.RenderTransform>
<TransformGroup>
<TranslateTransform X="{Binding CenterX}" Y="{Binding InvertedCenterY}"/>
<RotateTransform/>
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<userControls:PrimitivePopup Type="Rectangle" IsOpen="{Binding ParamsPanelVisibilty}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}"/>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace StructureHelper.Infrastructure.UI.DataTemplates
{
/// <summary>
/// Логика взаимодействия для EllipseTemplate.xaml
/// </summary>
public partial class EllipseTemplate : UserControl
{
public EllipseTemplate()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,57 @@
<UserControl x:Class="StructureHelper.Infrastructure.UI.DataTemplates.RectangleTemplate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:infrastructure="clr-namespace:StructureHelper.Infrastructure"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance dataContexts:RectangleViewPrimitive}">
<UserControl.Resources>
</UserControl.Resources>
<StackPanel>
<Grid>
<Rectangle x:Name="Rect" Style="{StaticResource RectangleStyle}" Tag="{Binding}">
<Rectangle.ToolTip>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Name: " FontWeight="Bold"/>
<TextBlock Grid.Column="1" Text="{Binding Name}" FontWeight="Bold"/>
<TextBlock Grid.Row="1" Text="Material Name: " FontWeight="Bold"/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding HeadMaterial.Name}" FontWeight="Bold"/>
<TextBlock Grid.Row="2" Text="Center X: "/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="3" Text="Center Y: "/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="4" Text="Width: "/>
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding PrimitiveWidth, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="5" Text="Height: "/>
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding PrimitiveHeight, Converter={StaticResource LengthConverter}}"/>
</Grid>
</Rectangle.ToolTip>
<Rectangle.RenderTransform>
<TransformGroup>
<TranslateTransform X="{Binding CenterX}" Y="{Binding InvertedCenterY}"/>
<RotateTransform/>
</TransformGroup>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
<userControls:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}"/>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace StructureHelper.Infrastructure.UI.DataTemplates
{
/// <summary>
/// Логика взаимодействия для RectangleTemplate.xaml
/// </summary>
public partial class RectangleTemplate : UserControl
{
public RectangleTemplate()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.PrimitiveTemplates
{
public interface IRectangleBeamProperties
{
IShape Shape { get; }
}
}

View File

@@ -0,0 +1,41 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Templates.RCs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Shapes = StructureHelperCommon.Models.Shapes;
namespace StructureHelper.Infrastructure.UI.PrimitiveTemplates
{
internal static class TemplateFactory
{
//public static IEnumerable<PrimitiveBase> RectangleBeam(IRectangleBeamTemplate properties)
//{
// var rect = properties.Shape as Shapes.Rectangle;
// var width = rect.Width;
// var height = rect.Height;
// var area1 = Math.PI * properties.BottomDiameter * properties.BottomDiameter / 4d;
// var area2 = Math.PI * properties.TopDiameter * properties.TopDiameter / 4d;
// var gap = properties.CoverGap;
//IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete 40" };
//concrete.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Concrete & x.Name.Contains("40"))).First();
//IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement 400" };
//reinforcement.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Reinforcement & x.Name.Contains("400"))).First();
//headMaterials.Add(concrete);
//headMaterials.Add(reinforcement);
//OnPropertyChanged(nameof(headMaterials));
//yield return new Rectangle(width, height, 0, 0, this) { HeadMaterial = concrete };
//yield return new Point(area1, -width / 2 + gap, -height / 2 + gap, this) { HeadMaterial = reinforcement };
//yield return new Point(area1, width / 2 - gap, -height / 2 + gap, this) { HeadMaterial = reinforcement };
//yield return new Point(area2, -width / 2 + gap, height / 2 - gap, this) { HeadMaterial = reinforcement };
//yield return new Point(area2, width / 2 - gap, height / 2 - gap, this) { HeadMaterial = reinforcement };
//}
}
}

View File

@@ -0,0 +1,53 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button" x:Key="ButtonBase">
</Style>
<Style TargetType="Button" x:Key="CommandButton" BasedOn="{StaticResource ButtonBase}">
<Style.Setters>
<Setter Property="Height" Value="25"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="AddButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Add"/>
<Setter Property="Command" Value="{Binding Add}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="EditButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Edit"/>
<Setter Property="Command" Value="{Binding Edit}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="DeleteButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Delete"/>
<Setter Property="Command" Value="{Binding Delete}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="CopyButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Copy"/>
<Setter Property="Command" Value="{Binding Copy}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="OkButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Ok"/>
<Setter Property="IsDefault" Value="True"/>
<Setter Property="Width" Value="60"/>
<Setter Property="Margin" Value="5"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="CancelButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Cancel"/>
<Setter Property="IsCancel" Value="True"/>
<Setter Property="Width" Value="60"/>
<Setter Property="Margin" Value="5"/>
</Style.Setters>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="clr-namespace:System;assembly=mscorlib"
xmlns:enums="clr-namespace:StructureHelperCommon.Infrastructures.Enums;assembly=StructureHelperCommon">
<ObjectDataProvider x:Key="StressStateEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="enums:StressStates"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="LimitStateEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="enums:LimitStates"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="CalcTermEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="enums:CalcTerms"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ResourceDictionary>

View File

@@ -0,0 +1,15 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:convertersCommon ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Common"
xmlns:convertersUnits ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Units">
<convertersCommon:InvertBoolConverter x:Key="InvertBoolConverter"/>
<convertersUnits:PlainDouble x:Key="PlainDouble"/>
<convertersUnits:Length x:Key="LengthConverter"/>
<convertersUnits:Area x:Key="AreaConverter"/>
<convertersUnits:Force x:Key="ForceConverter"/>
<convertersUnits:Moment x:Key="MomentConverter"/>
<convertersUnits:Stress x:Key="StressConverter"/>
<convertersUnits:Curvature x:Key="Curvature"/>
</ResourceDictionary>

View File

@@ -0,0 +1,14 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="DataGrid" x:Key="DataGridBase">
<Style.Setters>
<Setter Property="AutoGenerateColumns" Value="False"/>
</Style.Setters>
</Style>
<Style TargetType="DataGrid" x:Key="ItemsDataGrid" BasedOn="{StaticResource DataGridBase}">
<Style.Setters>
<Setter Property="ItemsSource" Value="{Binding Items}"/>
<Setter Property="SelectedItem" Value="{Binding SelectedItem}"/>
</Style.Setters>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="MaterialSafetyFactors">
<DataGrid Style="{StaticResource ItemsDataGrid}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding Take}" Value="false">
<Setter Property="Background" Value="LightGray"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Take" Width="40" Binding="{Binding Take}"/>
<DataGridTextColumn Header="Name" Width="70" MinWidth="70" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Description" Width="300" MinWidth="100" Binding="{Binding Description}"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,22 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="SourceToTarget">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="60"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox ItemsSource="{Binding SourceItems}" SelectedItem="{Binding SelectedSourceItem}" ItemTemplate="{Binding ItemDataDemplate}"/>
<StackPanel Grid.Column="1">
<Button Content="Add all" Command="{Binding AddAll}"/>
<Button Content="Clear all" Command="{Binding ClearAll}"/>
<Button Content=">>" Command="{Binding AddSelected}"/>
<Button Content="&lt;&lt;" Command="{Binding RemoveSelected}"/>
</StackPanel>
<ListBox Grid.Column="2" ItemsSource="{Binding TargetItems}"
SelectedItem="{Binding SelectedTargetItem}" ItemTemplate="{Binding ItemDataDemplate}"/>
</Grid>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="ColoredItemTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Margin="3">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="SimpleItemTemplate">
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,27 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="RectanglePrimitiveToolTip">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<TextBlock Text="Name: "/>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
<TextBlock Grid.Row="1" Text="Material Name: "/>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding HeadMaterial.Name}"/>
<TextBlock Grid.Row="2" Text="Center X: "/>
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="3" Text="Center Y: "/>
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}}"/>
</Grid>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="RectangleShapeEdit">
<DataTemplate.Resources>
</DataTemplate.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Width"/>
<TextBlock Grid.Row="1" Text="Height"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding Width, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding Height, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
</Grid>
</DataTemplate>
</ResourceDictionary>

View File

@@ -0,0 +1,60 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
xmlns:converters ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Units"
mc:Ignorable="d" >
<converters:Length x:Key="LengthConverter"/>
<converters:Area x:Key="AreaConverter"/>
<Style TargetType="TextBox" x:Key="ValidatedError">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Shape}" x:Key="ShapeStyle">
<Setter Property="Fill">
<Setter.Value>
<SolidColorBrush Color="{Binding Color}"/>
</Setter.Value>
</Setter>
<Setter Property="Opacity" Value="{Binding Opacity, Mode=TwoWay}"/>
<Setter Property="Stroke" Value="Black"/>
<Setter Property="StrokeThickness" Value="0.001"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Stroke" Value="Red"/>
<Setter Property="StrokeThickness" Value="0.002"/>
</Trigger>
<!--<Trigger Property="IsVisible" Value="False">
<Setter Property="Visibility" Value="Hidden"/>
</Trigger>-->
</Style.Triggers>
</Style>
<Style x:Key="EllipseStyle" TargetType="Ellipse" BasedOn="{StaticResource ShapeStyle}">
<Style.Setters>
<Setter Property="Width" Value="{Binding Diameter}"/>
<Setter Property="Height" Value="{Binding Diameter}"/>
</Style.Setters>
</Style>
<Style x:Key="RectangleStyle" TargetType="Rectangle" BasedOn="{StaticResource ShapeStyle}">
<Setter Property="Width" Value="{Binding PrimitiveWidth}"/>
<Setter Property="Height" Value="{Binding PrimitiveHeight}"/>
</Style>
<Style x:Key="LinePrimitiveStyle" TargetType="Line" BasedOn="{StaticResource ShapeStyle}">
<Setter Property="X1" Value="{Binding StartPoinX}"/>
<Setter Property="Y1" Value="{Binding StartPoinY}"/>
<Setter Property="X2" Value="{Binding EndPoinX}"/>
<Setter Property="Y2" Value="{Binding EndPoinY}"/>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,9 @@
using System.Windows.Input;
namespace StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers
{
public class DoubleClickEventTrigger : EventTriggerBase<MouseButtonEventArgs>
{
public DoubleClickEventTrigger() : base(args => args.ClickCount == 2) { }
}
}

View File

@@ -0,0 +1,9 @@
using System.Windows.Input;
namespace StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers
{
public class MouseWheelDownEventTrigger : EventTriggerBase<MouseWheelEventArgs>
{
public MouseWheelDownEventTrigger() : base(args => args.Delta > 0) { }
}
}

View File

@@ -0,0 +1,9 @@
using System.Windows.Input;
namespace StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers
{
public class MouseWheelUpEventTrigger : EventTriggerBase<MouseWheelEventArgs>
{
public MouseWheelUpEventTrigger() : base(args => args.Delta < 0) { }
}
}

View File

@@ -0,0 +1,71 @@
<Popup x:Class="StructureHelper.Infrastructure.UI.UserControls.PrimitivePopup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d" IsOpen="{Binding ParamsPanelVisibilty}">
<Grid>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetPopupCanBeClosedTrue}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetPopupCanBeClosedFalse}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<Border Background="White" BorderBrush="Black" BorderThickness="1">
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="{Binding HeightRowHeight}"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="170"/>
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text="Координата X" Margin="10"/>
<TextBox Grid.Column="1" VerticalAlignment="Center" Margin="10" Text="{Binding ShowedX, Mode=TwoWay}"/>
<TextBlock Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Координата Y" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" Margin="10" Text="{Binding ShowedY, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="{Binding PrimitiveDimension}" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="10" Text="{Binding PrimitiveWidth, Mode=TwoWay}"/>
<TextBlock Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Высота" Margin="10" Visibility="{Binding RectangleFieldVisibility}"/>
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="10" Text="{Binding PrimitiveHeight, Mode=TwoWay}" Visibility="{Binding RectangleFieldVisibility}"/>
<TextBlock Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Материал" Margin="10"/>
<Button Grid.Row="4" Grid.Column="1" Margin="10" Background="White"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.OpenMaterialCatalogWithSelection}" CommandParameter="{Binding}"
Content="{Binding MaterialName, Mode=TwoWay}"/>
<TextBlock Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Цвет"/>
<Button Grid.Row="5" Grid.Column="1" Margin="10" Background="{Binding Brush, Mode=TwoWay}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetColor}" CommandParameter="{Binding}"/>
<TextBlock Grid.Row="6" Margin="10" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Прозрачность"/>
<TextBox Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" Margin="10,10,50,10" Text="{Binding ShowedOpacity, Mode=TwoWay}"/>
<TextBlock Grid.Row="6" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Text="%" Margin="25,10"/>
<TextBlock Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Заблокировать объект" Grid.ColumnSpan="2"/>
<CheckBox Grid.Row="7" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" IsChecked="{Binding ElementLock, Mode=TwoWay}"/>
<TextBlock Grid.Row="8" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10" Text="Z-порядок"/>
<StackPanel Grid.Row="8" Grid.Column="1" Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Width="50" Margin="10"
Text="{Binding ShowedZIndex, Mode=TwoWay}"/>
<TextBlock VerticalAlignment="Center" Text="Max = "/>
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount}"/>
</StackPanel>
<Button Grid.Row="9" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить впереди всех" Margin="10"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInFrontOfAll}" CommandParameter="{Binding}"/>
<Button Grid.Row="9" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Установить позади всех" Margin="10"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetInBackOfAll}" CommandParameter="{Binding}"/>
</Grid>
</Border>
</Grid>
</Popup>

View File

@@ -0,0 +1,47 @@
using System.Windows;
using System.Windows.Controls.Primitives;
using StructureHelper.Infrastructure.Enums;
namespace StructureHelper.Infrastructure.UI.UserControls
{
/// <summary>
/// Interaction logic for PrimitivePopup.xaml
/// </summary>
public partial class PrimitivePopup : Popup
{
public static readonly DependencyProperty TypeProperty =
DependencyProperty.Register("Type", typeof(PrimitiveType), typeof(PrimitivePopup));
public static readonly DependencyProperty IsOpenProperty =
DependencyProperty.Register("IsOpen", typeof(bool), typeof(PrimitivePopup));
private PrimitiveType type;
private bool isOpen;
public PrimitiveType Type
{
get => type;
set
{
if (value != type)
{
type = value;
}
}
}
public bool IsOpen
{
get => isOpen;
set
{
if (value != isOpen)
isOpen = value;
}
}
public PrimitivePopup()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,27 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using StructureHelper.Properties;
namespace StructureHelper.Infrastructure
{
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged<T>(T value, T prop, [CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged<T>(T value, ref T prop, [CallerMemberName] string propertyName = null)
{
prop = value;
OnPropertyChanged(propertyName);
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

Binary file not shown.

View File

@@ -0,0 +1,59 @@
using System.Collections.Generic;
using StructureHelper.Infrastructure;
using StructureHelper.Models.Materials;
namespace StructureHelper.MaterialCatalogWindow
{
public class MaterialCatalogModel
{
public NamedList<MaterialDefinitionBase> ConcreteDefinitions;
public NamedList<MaterialDefinitionBase> RebarDefinitions;
public List<NamedList<MaterialDefinitionBase>> Materials;
public MaterialCatalogModel()
{
InitializeMaterialCollections();
Materials = new List<NamedList<MaterialDefinitionBase>>();
Materials.Add(ConcreteDefinitions);
Materials.Add(RebarDefinitions);
}
public void InitializeMaterialCollections()
{
InitializeConcreteDefinitions();
InitializeRebarDefinitions();
}
private void InitializeRebarDefinitions()
{
RebarDefinitions = new NamedList<MaterialDefinitionBase>
{
new RebarDefinition("S240", 2, 240, 240, 1.15, 1.15),
new RebarDefinition("S400", 2, 400, 400, 1.15, 1.15),
new RebarDefinition("S500", 2, 500, 500, 1.15, 1.15)
};
RebarDefinitions.Name = "Арматура";
}
private void InitializeConcreteDefinitions()
{
ConcreteDefinitions = new NamedList<MaterialDefinitionBase>
{
new ConcreteDefinition("C10", 0, 10, 0, 1.3, 1.5),
new ConcreteDefinition("C15", 0, 15, 0, 1.3, 1.5),
new ConcreteDefinition("C20", 0, 20, 0, 1.3, 1.5),
new ConcreteDefinition("C25", 0, 25, 0, 1.3, 1.5),
new ConcreteDefinition("C30", 0, 30, 0, 1.3, 1.5),
new ConcreteDefinition("C35", 0, 35, 0, 1.3, 1.5),
new ConcreteDefinition("C40", 0, 40, 0, 1.3, 1.5),
new ConcreteDefinition("C45", 0, 45, 0, 1.3, 1.5),
new ConcreteDefinition("C50", 0, 50, 0, 1.3, 1.5),
new ConcreteDefinition("C60", 0, 60, 0, 1.3, 1.5),
new ConcreteDefinition("C70", 0, 70, 0, 1.3, 1.5),
new ConcreteDefinition("C80", 0, 80, 0, 1.3, 1.5)
};
ConcreteDefinitions.Name = "Бетон";
}
}
}

View File

@@ -0,0 +1,80 @@
<Window x:Class="StructureHelper.MaterialCatalogWindow.MaterialCatalogView"
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"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:MaterialCatalogViewModel}"
Title="Справочник материалов" Height="900" Width="1100">
<Window.Resources>
<DataTemplate x:Key="RebarYoungModulusTemplate">
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding YoungModulus}"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text=" x 10^11"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="CompressiveStrengthTemplate">
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding CompressiveStrength}"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text=" x 10^6"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="TensileStrengthTemplate">
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding TensileStrength}"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Left" Text=" x 10^6"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="MaterialClassTemplate">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding MaterialClass}"/>
</DataTemplate>
<DataTemplate x:Key="MaterialCoefInCompressTemplate">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding MaterialCoefInCompress}"/>
</DataTemplate>
<DataTemplate x:Key="MaterialCoefInTensionTemplate">
<TextBox VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0" Text="{Binding MaterialCoefInTension}"/>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="10">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,20,10,10" Text="Бетон" FontSize="16"/>
<DataGrid ItemsSource="{Binding ConcreteDefinitions}" AutoGenerateColumns="False" SelectedItem="{Binding SelectedMaterial}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Класс" CellTemplate="{StaticResource MaterialClassTemplate}"/>
<DataGridTextColumn Header="Модуль упругости" Binding="{Binding YoungModulus, StringFormat={}{0} x 10^6}" IsReadOnly="True"/>
<DataGridTemplateColumn Header="Нормативная прочность на сжатие" CellTemplate="{StaticResource CompressiveStrengthTemplate}"/>
<DataGridTextColumn Header="Нормативная прочность на растяжение" Binding="{Binding TensileStrength, StringFormat={}{0} x 10^3}" IsReadOnly="True"/>
<DataGridTemplateColumn Header="Коэффициент надежности при сжатии" CellTemplate="{StaticResource MaterialCoefInCompressTemplate}"/>
<DataGridTemplateColumn Header="Коэффициент надежности при растяжении" CellTemplate="{StaticResource MaterialCoefInTensionTemplate}"/>
</DataGrid.Columns>
</DataGrid>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,20,10,10" Text="Арматура" FontSize="16"/>
<DataGrid ItemsSource="{Binding RebarDefinitions}" AutoGenerateColumns="False" SelectedItem="{Binding SelectedMaterial}">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Класс" CellTemplate="{StaticResource MaterialClassTemplate}"/>
<DataGridTemplateColumn Header="Модуль упругости" CellTemplate="{StaticResource RebarYoungModulusTemplate}"/>
<DataGridTemplateColumn Header="Нормативная прочность на сжатие" CellTemplate="{StaticResource CompressiveStrengthTemplate}"/>
<DataGridTemplateColumn Header="Нормативная прочность на растяжение" CellTemplate="{StaticResource TensileStrengthTemplate}"/>
<DataGridTemplateColumn Header="Коэффициент надежности при сжатии" CellTemplate="{StaticResource MaterialCoefInCompressTemplate}"/>
<DataGridTemplateColumn Header="Коэффициент надежности при растяжении" CellTemplate="{StaticResource MaterialCoefInTensionTemplate}"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="300"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Content="Добавить материал" Margin="10" Command="{Binding AddMaterial}"/>
<Button Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Выбрать материал" Margin="10" Command="{Binding SelectMaterial}" Visibility="{Binding SelectMaterialButtonVisibility}"/>
<Button Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Left" Content="Сохранить справочник" Margin="10" Command="{Binding SaveCatalog}"/>
<Button Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Загрузить справочник" Margin="10" Command="{Binding LoadCatalog}"/>
</Grid>
</Grid>
</Window>

View File

@@ -0,0 +1,19 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using System.Windows;
namespace StructureHelper.MaterialCatalogWindow
{
/// <summary>
/// Логика взаимодействия для MaterialCatalogView.xaml
/// </summary>
public partial class MaterialCatalogView : Window
{
public MaterialCatalogView(bool isMaterialCanBeSelected = false, PrimitiveBase primitive = null)
{
var materialCatalogModel = new MaterialCatalogModel();
var materialCatalogViewModel = new MaterialCatalogViewModel(materialCatalogModel, this, isMaterialCanBeSelected, primitive);
DataContext = materialCatalogViewModel;
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,116 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using Newtonsoft.Json;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelper.Properties;
using StructureHelper.Windows.AddMaterialWindow;
using OpenFileDialog = System.Windows.Forms.OpenFileDialog;
using SaveFileDialog = System.Windows.Forms.SaveFileDialog;
namespace StructureHelper.MaterialCatalogWindow
{
[JsonObject(MemberSerialization.OptIn)]
public class MaterialCatalogViewModel : INotifyPropertyChanged
{
private MaterialCatalogModel materialCatalogModel;
private MaterialCatalogView materialCatalogView;
[JsonProperty]
public ObservableCollection<MaterialDefinitionBase> ConcreteDefinitions { get; set; }
[JsonProperty]
public ObservableCollection<MaterialDefinitionBase> RebarDefinitions { get; set; }
public ICommand AddMaterial { get; }
public ICommand SaveCatalog { get; }
public ICommand LoadCatalog { get; }
public ICommand SelectMaterial { get; }
private MaterialDefinitionBase selectedMaterial;
public MaterialDefinitionBase SelectedMaterial
{
get => selectedMaterial;
set
{
selectedMaterial = value;
OnPropertyChanged();
}
}
private bool isMaterialCanBeSelected;
public bool IsMaterialCanBeSelected
{
get => isMaterialCanBeSelected;
set
{
isMaterialCanBeSelected = value;
OnPropertyChanged();
OnPropertyChanged(nameof(SelectMaterialButtonVisibility));
}
}
public Visibility SelectMaterialButtonVisibility => IsMaterialCanBeSelected ? Visibility.Visible : Visibility.Hidden;
public MaterialCatalogViewModel() { }
public MaterialCatalogViewModel(MaterialCatalogModel materialCatalogModel, MaterialCatalogView materialCatalogView, bool isMaterialCanBeSelected, PrimitiveBase primitive = null)
{
this.materialCatalogModel = materialCatalogModel;
this.materialCatalogView = materialCatalogView;
IsMaterialCanBeSelected = isMaterialCanBeSelected;
ConcreteDefinitions = new ObservableCollection<MaterialDefinitionBase>(materialCatalogModel.ConcreteDefinitions);
RebarDefinitions = new ObservableCollection<MaterialDefinitionBase>(materialCatalogModel.RebarDefinitions);
AddMaterial = new RelayCommand(o =>
{
AddMaterialView addMaterialView = new AddMaterialView(this.materialCatalogModel, this);
addMaterialView.ShowDialog();
OnPropertyChanged(nameof(ConcreteDefinitions));
OnPropertyChanged(nameof(RebarDefinitions));
});
SaveCatalog = new RelayCommand(o =>
{
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.InitialDirectory = @"C:\";
saveDialog.Filter = "json files (*.json)|*.json|All files(*.*)|*.*";
string path = null;
if (saveDialog.ShowDialog() == DialogResult.OK)
{
path = saveDialog.FileName;
File.WriteAllText(path, json);
}
});
LoadCatalog = new RelayCommand(o =>
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.InitialDirectory = @"C:\";
openFileDialog.Filter = "json files (*.json)|*.json|All files(*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
var path = openFileDialog.FileName;
var content = File.ReadAllText(path);
var vm = JsonConvert.DeserializeObject<MaterialCatalogViewModel>(content);
ConcreteDefinitions = vm.ConcreteDefinitions;
OnPropertyChanged(nameof(ConcreteDefinitions));
RebarDefinitions = vm.RebarDefinitions;
OnPropertyChanged(nameof(RebarDefinitions));
}
});
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -0,0 +1,28 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Models.Forces
{
internal class ForceCombinationViewObject
{
IForceCombinationList forceCombinationList;
private IDesignForceTuple ulsShort;
public IDesignForceTuple ULSShort
{
get { return ulsShort; }
}
public ForceCombinationViewObject(ForceCombinationList _forceCombinationList)
{
forceCombinationList = _forceCombinationList;
ulsShort = forceCombinationList.DesignForces.Where(x => x.LimitState == LimitStates.ULS & x.CalcTerm == CalcTerms.ShortTerm).Single();
}
}
}

View File

@@ -0,0 +1,59 @@
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Models.Forces
{
internal class ForceTupleViewObject
{
IForceTuple forceTuple;
private double mx;
public double Mx
{
get { return mx; }
set { mx = value; }
}
private double my;
public double My
{
get { return my; }
set { my = value; }
}
private double nz;
public double Nz
{
get { return nz; }
set { nz = value; }
}
private double qx;
public double Qx
{
get { return qx; }
set { qx = value; }
}
private double qy;
public double Qy
{
get { return qy; }
set { qy = value; }
}
private double mz;
public double Mz
{
get { return mz; }
set { mz = value; }
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace StructureHelper.Models.Materials
{
public class ConcreteDefinition : MaterialDefinitionBase
{
public ConcreteDefinition(string materialClass, double youngModulus, double compressiveStrengthCoef, double tensileStrengthCoef, double materialCoefInCompress, double materialCoefInTension)
: base(materialClass, youngModulus, compressiveStrengthCoef, tensileStrengthCoef, materialCoefInCompress, materialCoefInTension)
{
CompressiveStrength = compressiveStrengthCoef/* * Math.Pow(10, 6)*/;
TensileStrength = Math.Round(620 * Math.Sqrt(CompressiveStrength), 2);
YoungModulus = Math.Round(4.7 * Math.Sqrt(DesignCompressiveStrength), 2);
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
namespace StructureHelper.Models.Materials
{
public class MaterialDefinitionBase
{
public string MaterialClass { get; set; }
public double YoungModulus { get; set; }
public double CompressiveStrength { get; set; }
public double TensileStrength { get; set; }
public double MaterialCoefInCompress { get; set; }
public double MaterialCoefInTension { get; set; }
public double DesignCompressiveStrength { get; set; }
public double DesingTensileStrength { get; set; }
public MaterialDefinitionBase(string materialClass, double youngModulus, double compressiveStrengthCoef, double tensileStrengthCoef, double materialCoefInCompress, double materialCoefInTension)
{
MaterialClass = materialClass;
YoungModulus = youngModulus;
CompressiveStrength = compressiveStrengthCoef;
TensileStrength = tensileStrengthCoef;
MaterialCoefInCompress = materialCoefInCompress;
MaterialCoefInTension = materialCoefInTension;
DesignCompressiveStrength = compressiveStrengthCoef * Math.Pow(10, 6) * 1 / 1;
DesingTensileStrength = tensileStrengthCoef * Math.Pow(10, 3) * 1 / materialCoefInTension;
}
}
}

View File

@@ -0,0 +1,12 @@
namespace StructureHelper.Models.Materials
{
public class RebarDefinition : MaterialDefinitionBase
{
public RebarDefinition(string materialClass, double youngModulus, double compressiveStrengthCoef, double tensileStrengthCoef, double materialCoefInCompress, double materialCoefInTension) : base(materialClass, youngModulus, compressiveStrengthCoef, tensileStrengthCoef, materialCoefInCompress, materialCoefInTension)
{
YoungModulus = youngModulus/* * Math.Pow(10, 11)*/;
CompressiveStrength = compressiveStrengthCoef/* * Math.Pow(10, 6)*/;
TensileStrength = tensileStrengthCoef/* * Math.Pow(10, 6)*/;
}
}
}

View File

@@ -0,0 +1,81 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperLogics.Models.Primitives;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Models.Primitives.Factories
{
internal static class PrimitiveFactory
{
public static IEnumerable<PrimitiveBase> GetRectangleRCElement(RectangleBeamTemplate template, IHeadMaterial concrete, IHeadMaterial reinforcement)
{
List<PrimitiveBase> primitives = new List<PrimitiveBase>();
var rect = template.Shape as StructureHelperCommon.Models.Shapes.RectangleShape;
var width = rect.Width;
var height = rect.Height;
var area1 = Math.PI * template.BottomDiameter * template.BottomDiameter / 4d;
var area2 = Math.PI * template.TopDiameter * template.TopDiameter / 4d;
var gap = template.CoverGap;
double[] xs = new double[] { -width / 2 + gap, width / 2 - gap };
double[] ys = new double[] { -height / 2 + gap, height / 2 - gap };
var rectangle = new RectanglePrimitive() { Width = width, Height = height, Name = "Concrete block" };
primitives.Add(new RectangleViewPrimitive(rectangle) { HeadMaterial = concrete});
var point = new PointPrimitive() { CenterX = xs[0], CenterY = ys[0], Area = area1};
var viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Left bottom point" };
viewPoint.RegisterDeltas(xs[0], ys[0]);
primitives.Add(viewPoint);
point = new PointPrimitive() {CenterX = xs[1], CenterY = ys[0], Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Right bottom point" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[0], CenterY = ys[1], Area = area2 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Left top point" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[1], CenterY = ys[1], Area = area2 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = "Right top point" };
viewPoint.RegisterDeltas(xs[1], ys[1]);
primitives.Add(viewPoint);
if (template.WidthCount > 2)
{
int count = template.WidthCount - 1;
double dist = (xs[1] - xs[0]) / count;
for (int i = 1; i < count; i++)
{
point = new PointPrimitive() {CenterX = xs[0] + dist * i, CenterY = ys[0], Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Bottom point {i}" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[0] + dist * i, CenterY = ys[1], Area = area2 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Top point {i}" };
primitives.Add(viewPoint);
}
}
if (template.HeightCount > 2)
{
int count = template.HeightCount - 1;
double dist = (ys[1] - ys[0]) / count;
for (int i = 1; i < count; i++)
{
point = new PointPrimitive() {CenterX = xs[0], CenterY = ys[0] + dist * i, Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Left point {i}" };
primitives.Add(viewPoint);
point = new PointPrimitive() { CenterX = xs[1], CenterY = ys[0] + dist * i, Area = area1 };
viewPoint = new PointViewPrimitive(point) { HeadMaterial = reinforcement, Name = $"Right point {i}" };
primitives.Add(viewPoint);
}
}
return primitives;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
// Общие сведения об этой сборке предоставляются следующим набором
// набор атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
// связанные со сборкой.
[assembly: AssemblyTitle("StructureHelper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StructureHelper")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// из модели COM, установите атрибут ComVisible для этого типа в значение true.
[assembly: ComVisible(false)]
//Чтобы начать создание локализуемых приложений, задайте
//<UICulture>CultureYouAreCodingWith</UICulture> в файле .csproj
//в <PropertyGroup>. Например, при использовании английского (США)
//в своих исходных файлах установите <UICulture> в en-US. Затем отмените преобразование в комментарий
//атрибута NeutralResourceLanguage ниже. Обновите "en-US" в
//строка внизу для обеспечения соответствия настройки UICulture в файле проекта.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам
//(используется, если ресурс не найден на странице,
// или в словарях ресурсов приложения)
ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов
//(используется, если ресурс не найден на странице,
// в приложении или в каких-либо словарях ресурсов для конкретной темы)
)]
// Сведения о версии для сборки включают четыре следующих значения:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Номер редакции
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2023.01.08.01")]
[assembly: AssemblyFileVersion("2023.01.08.01")]

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using Point = StructureHelper.Infrastructure.UI.DataContexts.PointViewPrimitive;
using Rectangle = StructureHelper.Infrastructure.UI.DataContexts.RectangleViewPrimitive;
namespace StructureHelper.Services.Primitives
{
public interface IPrimitiveRepository
{
IEnumerable<PrimitiveBase> Primitives { get; }
void Add(PrimitiveBase primitive);
void Delete(PrimitiveBase primitive);
void Clear();
}
}

View File

@@ -0,0 +1,36 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.Primitives
{
public class PrimitiveRepository : IPrimitiveRepository
{
List<PrimitiveBase> primitives;
public IEnumerable<PrimitiveBase> Primitives { get => primitives; }
public PrimitiveRepository()
{
primitives = new List<PrimitiveBase>();
}
public void Add(PrimitiveBase primitive)
{
primitives.Add(primitive);
}
public void Clear()
{
primitives = new List<PrimitiveBase>();
}
public void Delete(PrimitiveBase primitive)
{
primitives.Remove(primitive);
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.Reports.CalculationReports
{
interface IIsoFieldReport : IReport
{
}
}

View File

@@ -0,0 +1,37 @@
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.Services.PrimitiveServices;
using FieldVisualizer.WindowsOperation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.Reports.CalculationReports
{
public class IsoFieldReport : IIsoFieldReport
{
private IEnumerable<IPrimitiveSet> primitiveSets;
public void Prepare()
{
//
}
public void ShowPrepared()
{
FieldViewerOperation.ShowViewer(primitiveSets);
}
public void Show()
{
Prepare();
ShowPrepared();
}
public IsoFieldReport(IEnumerable<IPrimitiveSet> primitiveSets)
{
this.primitiveSets = primitiveSets;
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.Reports
{
public interface IReport
{
void Prepare();
void ShowPrepared();
void Show();
}
}

View File

@@ -0,0 +1,17 @@
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
public interface IResultFunc
{
string Name { get; }
Func<IStrainMatrix, INdm, double> ResultFunction { get; }
double UnitFactor { get; }
}
}

View File

@@ -0,0 +1,22 @@
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
public class ResultFunc : IResultFunc
{
public string Name { get; set; }
public Func<IStrainMatrix, INdm, double> ResultFunction { get; set; }
public double UnitFactor { get; set; }
public ResultFunc()
{
UnitFactor = 1d;
}
}
}

View File

@@ -0,0 +1,30 @@
using LoaderCalculator.Logics;
using StructureHelper.Infrastructure.UI.Converters.Units;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
public static class ResultFuncFactory
{
public static IEnumerable<IResultFunc> GetResultFuncs()
{
List<IResultFunc> resultFuncs = new List<IResultFunc>();
IStressLogic stressLogic = new StressLogic();
resultFuncs.Add(new ResultFunc() { Name = "Total Strain", ResultFunction = stressLogic.GetTotalStrain });
resultFuncs.Add(new ResultFunc() { Name = "Total Strain with prestrain", ResultFunction = stressLogic.GetTotalStrainWithPresrain });
resultFuncs.Add(new ResultFunc() { Name = "Elastic Strain", ResultFunction = stressLogic.GetElasticStrain });
resultFuncs.Add(new ResultFunc() { Name = "Plastic Strain", ResultFunction = stressLogic.GetPlasticStrain });
resultFuncs.Add(new ResultFunc() { Name = "Stress", ResultFunction = stressLogic.GetStress, UnitFactor = UnitConstatnts.Stress });
resultFuncs.Add(new ResultFunc() { Name = "Secant modulus", ResultFunction = stressLogic.GetSecantModulus, UnitFactor = UnitConstatnts.Stress });
resultFuncs.Add(new ResultFunc() { Name = "Modulus degradation", ResultFunction = stressLogic.GetModulusDegradation });
resultFuncs.Add(new ResultFunc() { Name = "Force", ResultFunction = stressLogic.GetForce, UnitFactor = UnitConstatnts.Force });
resultFuncs.Add(new ResultFunc() { Name = "Moment X", ResultFunction = stressLogic.GetMomentX, UnitFactor = UnitConstatnts.Force });
resultFuncs.Add(new ResultFunc() { Name = "Moment Y", ResultFunction = stressLogic.GetMomentY, UnitFactor = UnitConstatnts.Force });
return resultFuncs;
}
}
}

View File

@@ -0,0 +1,51 @@
using FieldVisualizer.Entities.Values.Primitives;
using FieldVisualizer.WindowsOperation;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.ResultData;
using LoaderCalculator.Logics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Services.ResultViewers
{
public static class ShowIsoFieldResult
{
public static void ShowResult(IStrainMatrix strainMatrix, IEnumerable<INdm> ndms, IEnumerable<IResultFunc> resultFuncs)
{
var primitiveSets = GetPrimitiveSets(strainMatrix, ndms, resultFuncs);
FieldViewerOperation.ShowViewer(primitiveSets);
}
public static List<IPrimitiveSet> GetPrimitiveSets(IStrainMatrix strainMatrix, IEnumerable<INdm> ndms, IEnumerable<IResultFunc> resultFuncs)
{
List<IPrimitiveSet> primitiveSets = new List<IPrimitiveSet>();
foreach (var valDelegate in resultFuncs)
{
PrimitiveSet primitiveSet = new PrimitiveSet() { Name = valDelegate.Name };
List<IValuePrimitive> primitives = new List<IValuePrimitive>();
foreach (INdm ndm in ndms)
{
double val = valDelegate.ResultFunction.Invoke(strainMatrix, ndm) * valDelegate.UnitFactor;
IValuePrimitive valuePrimitive;
if (ndm is IRectangleNdm)
{
var shapeNdm = ndm as IRectangleNdm;
valuePrimitive = new RectanglePrimitive() { CenterX = ndm.CenterX, CenterY = ndm.CenterY, Height = shapeNdm.Height, Width = shapeNdm.Width, Value = val };
}
else
{
valuePrimitive = new CirclePrimitive() { CenterX = ndm.CenterX, CenterY = ndm.CenterY, Diameter = Math.Sqrt(ndm.Area / Math.PI) * 2, Value = val };
}
primitives.Add(valuePrimitive);
}
primitiveSet.ValuePrimitives = primitives;
primitiveSets.Add(primitiveSet);
}
return primitiveSets;
}
}
}

View File

@@ -0,0 +1,44 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ImplicitUsings>disable</ImplicitUsings>
<SupportedOSPlatformVersion>10.0.18362.0</SupportedOSPlatformVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Compile Remove="StructureHelperCommon\**" />
<Compile Remove="StructureHelperLogics\**" />
<EmbeddedResource Remove="StructureHelperCommon\**" />
<EmbeddedResource Remove="StructureHelperLogics\**" />
<None Remove="StructureHelperCommon\**" />
<None Remove="StructureHelperLogics\**" />
<Page Remove="StructureHelperCommon\**" />
<Page Remove="StructureHelperLogics\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.5.0" />
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.2" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="System.Windows.Interactivity.WPF" Version="2.0.20525" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FieldVisualizer\FieldVisualizer.csproj" />
<ProjectReference Include="..\StructureHelperCommon\StructureHelperCommon.csproj" />
<ProjectReference Include="..\StructureHelperLogics\StructureHelperLogics.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="LoaderCalculator">
<HintPath>Libraries\LoaderCalculator.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup />
</Project>

View File

@@ -0,0 +1,61 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32630.192
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelper", "StructureHelper.csproj", "{BAD27E27-4444-4300-ADF8-E21042C0781D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperTests", "StructureHelperTests\StructureHelperTests.csproj", "{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}"
ProjectSection(ProjectDependencies) = postProject
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3} = {330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureHelperLogics", "StructureHelperLogics\StructureHelperLogics.csproj", "{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}"
ProjectSection(ProjectDependencies) = postProject
{5DFEC3FD-9677-47BB-9E88-EB71828B5913} = {5DFEC3FD-9677-47BB-9E88-EB71828B5913}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureHelperCommon", "StructureHelperCommon\StructureHelperCommon.csproj", "{5DFEC3FD-9677-47BB-9E88-EB71828B5913}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FieldVisualizer", "FieldVisualizer\FieldVisualizer.csproj", "{87064B50-3B7C-4A91-AF4A-941C6F95D997}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FieldVisualzerDemo", "FiledVisualzerDemo\FieldVisualzerDemo.csproj", "{C92A5F2E-567B-48C9-A524-5740DB03509D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BAD27E27-4444-4300-ADF8-E21042C0781D}.Release|Any CPU.Build.0 = Release|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AC480BB-8A34-4913-B7AA-C6A5D7F35509}.Release|Any CPU.Build.0 = Release|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{330BEF5B-15BE-4D2C-A750-B1AE50FB2BE3}.Release|Any CPU.Build.0 = Release|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DFEC3FD-9677-47BB-9E88-EB71828B5913}.Release|Any CPU.Build.0 = Release|Any CPU
{87064B50-3B7C-4A91-AF4A-941C6F95D997}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87064B50-3B7C-4A91-AF4A-941C6F95D997}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87064B50-3B7C-4A91-AF4A-941C6F95D997}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87064B50-3B7C-4A91-AF4A-941C6F95D997}.Release|Any CPU.Build.0 = Release|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C92A5F2E-567B-48C9-A524-5740DB03509D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A4F97ACA-7F64-4D3E-AB47-8EE61B5BAB9A}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,8 @@
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum CalcTerms
{
ShortTerm,
LongTerm,
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum CodeTypes
{
SP63_13330_2018,
EuroCode_2_1990
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum Directions
{
X,
Y,
Z
}
}

View File

@@ -0,0 +1,9 @@
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum LimitStates
{
ULS = 1,
SLS = 2,
Special = 3,
}
}

View File

@@ -0,0 +1,11 @@
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum MaterialTypes
{
Concrete,
Reinforcement,
//Steel,
//CarbonFiber,
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum StressStates
{
Tension,
Compression
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum UnitTypes
{
Length,
Area,
Stress,
Force,
Moment,
Curvature
}
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Exceptions
{
public class StructureHelperException : Exception
{
public StructureHelperException(string errorString) : base(errorString)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IHasForceCombinations
{
List<IForceCombinationList> ForceCombinationLists { get; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IHasParent
{
object Parent { get; }
void RegisterParent();
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface ISaveable
{
int Id { get; set; }
void Save();
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Infrastructures.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Settings
{
public static class ProgramSetting
{
public static CodeTypes CodeType => CodeTypes.SP63_13330_2018;
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Strings
{
public static class ErrorStrings
{
public static string UnknownError => "#0000: Unknown error";
public static string ObjectTypeIsUnknown => "#0001: Object type is unknown";
public static string MaterialTypeIsUnknown => "#0002: Material type is unknown";
public static string DataIsInCorrect => "#0003: Data is not correct";
public static string ShapeIsNotCorrect => "#0004: Shape is not valid";
public static string LimitStatesIsNotValid => "#0005: Type of limite state is not valid";
public static string LoadTermIsNotValid => "#0006: Load term is not valid";
public static string IncorrectValue => "#0007: value is not valid";
public static string FileCantBeDeleted => "#0008: File can't be deleted";
public static string FileCantBeSaved => "#0009: File can't be saved";
public static string VisualPropertyIsNotRight => "#0010: VisualPropertyIsNotRight";
public static string FactorMustBeGraterThanZero => "#0011: Partial factor must not be less than zero";
public static string LongitudinalForceMustBeLessThanZero => "#0012: Longitudinal force must be less than zero";
public static string LongitudinalForceMustBeLessThanCriticalForce => "#0013: Absolute value of longitudinal force must be greater than critical force";
public static string SizeMustBeGreaterThanZero => "#0014: Size must be greater than zero";
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Calculators
{
public class Accuracy : IAccuracy
{
public double IterationAccuracy { get; set; }
public int MaxIterationCount { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Calculators
{
public interface IAccuracy
{
double IterationAccuracy { get; set; }
int MaxIterationCount { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Calculators
{
public interface IHelperCalculator <in TInputData, TCalculationResult>
where TInputData : class
where TCalculationResult : class
{
}
}

View File

@@ -0,0 +1,34 @@
using StructureHelperCommon.Infrastructures.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public class DesignForceTuple : IDesignForceTuple
{
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public IForceTuple ForceTuple { get; set; }
public DesignForceTuple(LimitStates limitState, CalcTerms calcTerm) : this()
{
LimitState = limitState;
CalcTerm = calcTerm;
}
public DesignForceTuple()
{
ForceTuple = new ForceTuple();
}
public object Clone()
{
var newTuple = new DesignForceTuple(this.LimitState, this.CalcTerm);
newTuple.ForceTuple = this.ForceTuple.Clone() as IForceTuple;
return newTuple;
}
}
}

View File

@@ -0,0 +1,38 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public enum ForceType
{
Force_zero,
Force_Mx50My50Nz100,
}
public static class DesignForceFactory
{
public static IDesignForceTuple GetDesignForce(ForceType forceType, LimitStates limitState, CalcTerms calcTerm)
{
if (forceType == ForceType.Force_zero)
{
return new DesignForceTuple(limitState, calcTerm);
}
else if (forceType == ForceType.Force_Mx50My50Nz100)
{
var tuple = new DesignForceTuple(limitState, calcTerm);
var forceTuple = tuple.ForceTuple;
forceTuple.Mx = -50e3d;
forceTuple.My = -50e3d;
forceTuple.Nz = -100e3d;
return tuple;
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
}
}
}

View File

@@ -0,0 +1,34 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public enum DesignForceType
{
Suit_1,
Suit_2
}
public static class ForceCombinationListFactory
{
public static List<IDesignForceTuple> GetDesignForces(DesignForceType forceType)
{
if (forceType == DesignForceType.Suit_1)
{
var designForces = new List<IDesignForceTuple>();
designForces.Add(DesignForceFactory.GetDesignForce(ForceType.Force_Mx50My50Nz100, LimitStates.ULS, CalcTerms.ShortTerm));
designForces.Add(DesignForceFactory.GetDesignForce(ForceType.Force_Mx50My50Nz100, LimitStates.ULS, CalcTerms.LongTerm));
designForces.Add(DesignForceFactory.GetDesignForce(ForceType.Force_Mx50My50Nz100, LimitStates.SLS, CalcTerms.ShortTerm));
designForces.Add(DesignForceFactory.GetDesignForce(ForceType.Force_Mx50My50Nz100, LimitStates.SLS, CalcTerms.LongTerm));
return designForces;
}
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
}
}
}

View File

@@ -0,0 +1,47 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public class ForceCombinationList : IForceCombinationList
{
public string Name { get; set; }
public bool SetInGravityCenter { get; set; }
public Point2D ForcePoint { get; private set; }
public List<IDesignForceTuple> DesignForces { get; private set; }
public ForceCombinationList()
{
SetInGravityCenter = true;
ForcePoint = new Point2D() { X = 0, Y = 0 };
DesignForces = new List<IDesignForceTuple>();
DesignForces.Add(new DesignForceTuple(LimitStates.ULS, CalcTerms.ShortTerm));
DesignForces.Add(new DesignForceTuple(LimitStates.ULS, CalcTerms.LongTerm));
DesignForces.Add(new DesignForceTuple(LimitStates.SLS, CalcTerms.ShortTerm));
DesignForces.Add(new DesignForceTuple(LimitStates.SLS, CalcTerms.LongTerm));
}
public object Clone()
{
var newItem = new ForceCombinationList();
newItem.Name = Name + " copy";
newItem.SetInGravityCenter = SetInGravityCenter;
newItem.ForcePoint.X = ForcePoint.X;
newItem.ForcePoint.Y = ForcePoint.Y;
newItem.DesignForces.Clear();
foreach (var item in DesignForces)
{
var newForce = item.Clone() as IDesignForceTuple;
newItem.DesignForces.Add(newForce);
}
return newItem;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
/// <inheritdoc/>
public class ForceTuple : IForceTuple
{
/// <inheritdoc/>
public double Mx { get; set; }
/// <inheritdoc/>
public double My { get; set; }
/// <inheritdoc/>
public double Nz { get; set; }
/// <inheritdoc/>
public double Qx { get; set; }
/// <inheritdoc/>
public double Qy { get; set; }
/// <inheritdoc/>
public double Mz { get; set; }
/// <inheritdoc/>
public object Clone()
{
IForceTuple forceTuple = new ForceTuple() { Mx = Mx, My = My, Nz = Nz, Qx = Qx, Qy = Qy, Mz = Mz};
return forceTuple;
}
}
}

View File

@@ -0,0 +1,16 @@
using StructureHelperCommon.Infrastructures.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Forces
{
public interface IDesignForceTuple : ICloneable
{
LimitStates LimitState { get; set; }
CalcTerms CalcTerm { get; set; }
IForceTuple ForceTuple { get; set; }
}
}

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