SH: recovery
This commit is contained in:
8
StructureHelper/Infrastructure/Enums/PrimitiveType.cs
Normal file
8
StructureHelper/Infrastructure/Enums/PrimitiveType.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace StructureHelper.Infrastructure.Enums
|
||||
{
|
||||
public enum PrimitiveType
|
||||
{
|
||||
Point,
|
||||
Rectangle
|
||||
}
|
||||
}
|
||||
13
StructureHelper/Infrastructure/EventArgs.cs
Normal file
13
StructureHelper/Infrastructure/EventArgs.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
25
StructureHelper/Infrastructure/EventTriggerBase.cs
Normal file
25
StructureHelper/Infrastructure/EventTriggerBase.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
StructureHelper/Infrastructure/MouseBehaviour.cs
Normal file
45
StructureHelper/Infrastructure/MouseBehaviour.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
StructureHelper/Infrastructure/NamedList.cs
Normal file
9
StructureHelper/Infrastructure/NamedList.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StructureHelper.Infrastructure
|
||||
{
|
||||
public class NamedList<T> : List<T>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
27
StructureHelper/Infrastructure/RelayCommand.cs
Normal file
27
StructureHelper/Infrastructure/RelayCommand.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
100
StructureHelper/Infrastructure/UI/Converters/CommonOperation.cs
Normal file
100
StructureHelper/Infrastructure/UI/Converters/CommonOperation.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
20
StructureHelper/Infrastructure/UI/Converters/Units/Area.cs
Normal file
20
StructureHelper/Infrastructure/UI/Converters/Units/Area.cs
Normal 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"; }
|
||||
}
|
||||
}
|
||||
@@ -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"; }
|
||||
}
|
||||
}
|
||||
19
StructureHelper/Infrastructure/UI/Converters/Units/Force.cs
Normal file
19
StructureHelper/Infrastructure/UI/Converters/Units/Force.cs
Normal 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"; }
|
||||
}
|
||||
}
|
||||
22
StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
Normal file
22
StructureHelper/Infrastructure/UI/Converters/Units/Length.cs
Normal 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"; }
|
||||
}
|
||||
}
|
||||
17
StructureHelper/Infrastructure/UI/Converters/Units/Moment.cs
Normal file
17
StructureHelper/Infrastructure/UI/Converters/Units/Moment.cs
Normal 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"; }
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
StructureHelper/Infrastructure/UI/Converters/Units/Stress.cs
Normal file
19
StructureHelper/Infrastructure/UI/Converters/Units/Stress.cs
Normal 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"; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
14
StructureHelper/Infrastructure/UI/DataContexts/IHasCenter.cs
Normal file
14
StructureHelper/Infrastructure/UI/DataContexts/IHasCenter.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
//{
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
268
StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
Normal file
268
StructureHelper/Infrastructure/UI/DataContexts/PrimitiveBase.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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 };
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
21
StructureHelper/Infrastructure/UI/Resources/CommonEnums.xaml
Normal file
21
StructureHelper/Infrastructure/UI/Resources/CommonEnums.xaml
Normal 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>
|
||||
15
StructureHelper/Infrastructure/UI/Resources/Converters.xaml
Normal file
15
StructureHelper/Infrastructure/UI/Resources/Converters.xaml
Normal 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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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="<<" Command="{Binding RemoveSelected}"/>
|
||||
</StackPanel>
|
||||
<ListBox Grid.Column="2" ItemsSource="{Binding TargetItems}"
|
||||
SelectedItem="{Binding SelectedTargetItem}" ItemTemplate="{Binding ItemDataDemplate}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
60
StructureHelper/Infrastructure/UI/Styles.xaml
Normal file
60
StructureHelper/Infrastructure/UI/Styles.xaml
Normal 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>
|
||||
@@ -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) { }
|
||||
}
|
||||
}
|
||||
@@ -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) { }
|
||||
}
|
||||
}
|
||||
@@ -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) { }
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
StructureHelper/Infrastructure/ViewModelBase.cs
Normal file
27
StructureHelper/Infrastructure/ViewModelBase.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user