Merge branch 'master' into develop

This commit is contained in:
Nikolai Smirnov
2022-07-08 11:39:10 +05:00
43 changed files with 832 additions and 833 deletions

View File

@@ -4,6 +4,10 @@
xmlns:local="clr-namespace:StructureHelper"
StartupUri="Windows/MainWindow/MainView.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Infrastructure/UI/Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

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

View File

@@ -1,6 +1,6 @@
using System;
namespace StructureHelper
namespace StructureHelper.Infrastructure
{
public class EventArgs<T> : EventArgs
{

View File

@@ -2,7 +2,7 @@
using System.Windows;
using EventTrigger = System.Windows.Interactivity.EventTrigger;
namespace StructureHelper
namespace StructureHelper.Infrastructure
{
public class EventTriggerBase<T> : EventTrigger where T : RoutedEventArgs
{

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace StructureHelper
namespace StructureHelper.Infrastructure.Extensions
{
public static class ObservableCollectionExtensions
{

View File

@@ -3,7 +3,7 @@ using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interactivity;
namespace StructureHelper
namespace StructureHelper.Infrastructure
{
public class MouseBehaviour : Behavior<Panel>
{

View File

@@ -1,7 +1,7 @@
using System;
using System.Windows.Input;
namespace StructureHelper
namespace StructureHelper.Infrastructure
{
public class RelayCommand : ICommand
{

View File

@@ -0,0 +1,30 @@
using System;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.MainWindow;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class Ellipse : PrimitiveBase
{
private double square;
public double Square
{
get => square;
set
{
square = value;
PrimitiveWidth = Math.Round(Math.Sqrt(4 * value / Math.PI), 2);
OnPropertyChanged(nameof(PrimitiveWidth));
OnPropertyChanged();
}
}
public Ellipse(double square, double ellipseX, double ellipseY, MainViewModel mainViewModel) : base(PrimitiveType.Ellipse, ellipseX, ellipseY, mainViewModel)
{
Square = square;
ShowedX = 0;
ShowedY = 0;
}
}
}

View File

@@ -0,0 +1,258 @@
using System;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Models.Materials;
using StructureHelper.Windows.MainWindow;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public abstract class PrimitiveBase : ViewModelBase
{
#region Поля
private readonly PrimitiveType type;
private bool captured, parameterCaptured, elementLock, paramsPanelVisibilty, popupCanBeClosed = true, borderCaptured;
private Brush brush;
private MaterialDefinitionBase material;
private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight, showedX, showedY, delta = 0.5;
private int showedZIndex = 1, zIndex;
#endregion
#region Свойства
public PrimitiveType Type => type;
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 Brush Brush
{
get => brush;
set => OnPropertyChanged(value, ref brush);
}
public MaterialDefinitionBase Material
{
get => material;
set
{
MaterialName = material.MaterialClass;
OnPropertyChanged(value, ref material);
OnPropertyChanged(nameof(MaterialName));
}
}
private string materialName = string.Empty;
public string MaterialName
{
get => materialName;
set => OnPropertyChanged(value, ref materialName);
}
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 double Opacity
{
get => opacity;
set => OnPropertyChanged(value, ref opacity);
}
public int ShowedZIndex
{
get => showedZIndex;
set
{
ZIndex = value - 1;
OnPropertyChanged(nameof(ZIndex));
OnPropertyChanged(value, ref showedZIndex);
}
}
public int ZIndex
{
get => zIndex;
set => OnPropertyChanged(value, ref zIndex);
}
public double X
{
get => x;
set => OnPropertyChanged(value, ref x);
}
public double Y
{
get => y;
set => OnPropertyChanged(value, ref y);
}
public double Xy1
{
get => xY1;
set => OnPropertyChanged(value, ref xY1);
}
public double Yx1
{
get => yX1;
set => OnPropertyChanged(value, ref yX1);
}
public double PrimitiveWidth
{
get => primitiveWidth;
set => OnPropertyChanged(value, ref primitiveWidth);
}
public double PrimitiveHeight
{
get => primitiveHeight;
set => OnPropertyChanged(value, ref primitiveHeight);
}
public double ShowedX
{
get => showedX;
set
{
UpdateCoordinatesX(value);
OnPropertyChanged(value, ref showedX);
OnPropertyChanged(nameof(X));
}
}
public double ShowedY
{
get => showedY;
set
{
UpdateCoordinatesY(value);
OnPropertyChanged(value, ref showedY);
OnPropertyChanged(nameof(Y));
}
}
public bool BorderCaptured
{
get => borderCaptured;
set => OnPropertyChanged(value, ref borderCaptured);
}
#endregion
#region Команды
public ICommand PrimitiveLeftButtonDown { get; }
public ICommand PrimitiveLeftButtonUp { get; }
public ICommand RectanglePreviewMouseMove { get; }
public ICommand EllipsePreviewMouseMove { get; }
public ICommand PrimitiveDoubleClick { get; }
#endregion
protected PrimitiveBase(PrimitiveType type, double rectX, double rectY, MainViewModel mainViewModel)
{
this.type = type;
Yx1 = rectX;
Xy1 = rectY;
var randomR = new Random().Next(150, 255);
var randomG = new Random().Next(0, 255);
var randomB = new Random().Next(30, 130);
var color = Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
Brush = new SolidColorBrush(color);
PrimitiveLeftButtonUp = new RelayCommand(o => Captured = false);
PrimitiveLeftButtonDown = new RelayCommand(o => Captured = true);
RectanglePreviewMouseMove = new RelayCommand(o =>
{
if (!(o is Rectangle rect)) return;
if (Captured && !rect.BorderCaptured && !ElementLock)
{
var deltaX = PrimitiveWidth / 2;
var deltaY = PrimitiveHeight / 2;
if (rect.ShowedX % 10 <= delta || rect.ShowedX % 10 >= 10 - delta)
rect.ShowedX = Math.Round((mainViewModel.PanelX - deltaX - Yx1) / 10) * 10;
else
rect.ShowedX = mainViewModel.PanelX - deltaX - Yx1;
if (rect.ShowedY % 10 <= delta || rect.ShowedY % 10 >= 10 - delta)
rect.ShowedY = -(Math.Round((mainViewModel.PanelY - deltaY - Xy1 + rect.PrimitiveHeight) / 10) * 10);
else
rect.ShowedY = -(mainViewModel.PanelY - deltaY - Xy1 + rect.PrimitiveHeight);
}
if (ParameterCaptured)
{
//RectParameterX = rect.ShowedX;
//RectParameterY = rect.ShowedY;
//RectParameterWidth = rect.PrimitiveWidth;
//RectParameterHeight = rect.PrimitiveHeight;
//ParameterOpacity = rect.ShowedOpacity;
//ElementLock = rect.ElementLock;
}
});
EllipsePreviewMouseMove = new RelayCommand(o =>
{
if (!(o is Ellipse ellipse)) return;
if (ellipse.Captured && !ellipse.ElementLock)
{
var ellipseDelta = ellipse.PrimitiveWidth / 2;
if (ellipse.ShowedX % 10 <= ellipseDelta || ellipse.ShowedX % 10 >= 10 - ellipseDelta)
ellipse.ShowedX = Math.Round((mainViewModel.PanelX - Yx1) / 10) * 10;
else
ellipse.ShowedX = mainViewModel.PanelX - ellipseDelta - Yx1;
if (ellipse.ShowedY % 10 <= ellipseDelta || ellipse.ShowedY % 10 >= 10 - ellipseDelta)
ellipse.ShowedY = -(Math.Round((mainViewModel.PanelY - Xy1) / 10) * 10);
else
ellipse.ShowedY = -(mainViewModel.PanelY - ellipseDelta - Xy1);
}
if (ParameterCaptured)
{
//EllipseParameterX = ellipse.ShowedX;
//EllipseParameterY = ellipse.ShowedY;
//EllipseParameterSquare = ellipse.Square;
//ParameterOpacity = ellipse.ShowedOpacity;
//ElementLock = ellipse.ElementLock;
}
});
PrimitiveDoubleClick = new RelayCommand(o =>
{
PopupCanBeClosed = false;
Captured = false;
ParamsPanelVisibilty = true;
//if (primitive is Rectangle rect)
// rect.BorderCaptured = false;
});
}
private void UpdateCoordinatesX(double showedX)
{
if (Type == PrimitiveType.Rectangle) X = showedX + Yx1;
if (Type == PrimitiveType.Ellipse) X = showedX + Yx1 - PrimitiveWidth / 2;
}
private void UpdateCoordinatesY(double showedY)
{
if (Type == PrimitiveType.Rectangle) Y = -showedY + Xy1 - PrimitiveHeight;
if (Type == PrimitiveType.Ellipse) Y = -showedY + Xy1 - PrimitiveWidth / 2;
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.MainWindow;
namespace StructureHelper.Infrastructure.UI.DataContexts
{
public class Rectangle : PrimitiveBase
{
public Rectangle(double primitiveWidth, double primitiveHeight, double rectX, double rectY, MainViewModel mainViewModel) : base(PrimitiveType.Rectangle, rectX, rectY, mainViewModel)
{
PrimitiveWidth = primitiveWidth;
PrimitiveHeight = primitiveHeight;
ShowedX = 0;
ShowedY = 0;
}
}
}

View File

@@ -0,0 +1,15 @@
<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">
<Grid>
<ContentControl Content="{StaticResource EllipsePrimitive}"/>
</Grid>
</UserControl>

View File

@@ -0,0 +1,16 @@
using System.Windows;
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,28 @@
<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"
mc:Ignorable="d">
<Grid>
<ContentControl Content="{StaticResource RectanglePrimitive}"/>
<Rectangle Cursor="SizeNWSE" Width="20" Height="20" Fill="{Binding Brush}" VerticalAlignment="Bottom" HorizontalAlignment="Right">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Rectangle>
</Grid>
</UserControl>

View File

@@ -0,0 +1,16 @@
using System.Windows;
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,89 @@
<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"
mc:Ignorable="d" >
<Style TargetType="Shape" x:Key="ShapeStyle">
<Setter Property="Fill" Value="{Binding Brush, Mode=TwoWay}"/>
<Setter Property="Opacity" Value="{Binding Opacity, Mode=TwoWay}"/>
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip Background="White" BorderBrush="Black" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата X:"/>
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedX}"/>
<TextBox Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата Y:"/>
<TextBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedY}"/>
<TextBox Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Ширина:"/>
<TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding PrimitiveWidth}"/>
<TextBox Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Высота:"/>
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding PrimitiveHeight}"/>
<TextBox Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Материал:"/>
<TextBox Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding MaterialName, Mode=TwoWay}"/>
</Grid>
</ToolTip>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="EllipseStyle" TargetType="Ellipse" BasedOn="{StaticResource ShapeStyle}">
<Style.Setters>
<Setter Property="Width" Value="{Binding PrimitiveWidth}"/>
<Setter Property="Height" Value="{Binding PrimitiveWidth}"/>
</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>
<Rectangle x:Key="RectanglePrimitive" Style="{StaticResource RectangleStyle}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding RectanglePreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<mouseEventTriggers:DoubleClickEventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
</mouseEventTriggers:DoubleClickEventTrigger>
</i:Interaction.Triggers>
</Rectangle>
<Ellipse x:Key="EllipsePrimitive" Style="{StaticResource EllipseStyle}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding EllipsePreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<mouseEventTriggers:DoubleClickEventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
</mouseEventTriggers:DoubleClickEventTrigger>
</i:Interaction.Triggers>
</Ellipse>
</ResourceDictionary>

View File

@@ -1,6 +1,6 @@
using System.Windows.Input;
namespace StructureHelper.Infrastructure
namespace StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers
{
public class DoubleClickEventTrigger : EventTriggerBase<MouseButtonEventArgs>
{

View File

@@ -1,6 +1,6 @@
using System.Windows.Input;
namespace StructureHelper.Infrastructure
namespace StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers
{
public class MouseWheelDownEventTrigger : EventTriggerBase<MouseWheelEventArgs>
{

View File

@@ -1,6 +1,6 @@
using System.Windows.Input;
namespace StructureHelper.Infrastructure
namespace StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers
{
public class MouseWheelUpEventTrigger : EventTriggerBase<MouseWheelEventArgs>
{

View File

@@ -0,0 +1,142 @@
<UserControl 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:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
mc:Ignorable="d">
<Grid>
<!--Rectangle-->
<local:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}" d:DataContext="{d:DesignInstance dataContexts:Rectangle}" Type="Rectangle">
<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="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterX, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterY, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Ширина" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterWidth, Mode=TwoWay}"/>
<TextBlock Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Высота" Margin="10"/>
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterHeight, Mode=TwoWay}"/>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ParameterOpacity, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ElementLock, Mode=TwoWay}"></CheckBox>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveIndex, Mode=TwoWay}"/>
<TextBlock VerticalAlignment="Center" Text="Max = "/>
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount, Mode=TwoWay}"/>
</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}"/>
<Button Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Установить параметры"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetParameters}" CommandParameter="{Binding}"/>
</Grid>
</Border>
</local:PrimitivePopup>
<!--Ellipse-->
<local:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}" d:DataContext="{d:DesignInstance dataContexts:Ellipse}" Type="Ellipse">
<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="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterX, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterY, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Площадь" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterSquare, Mode=TwoWay}"/>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ParameterOpacity, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ElementLock, Mode=TwoWay}"></CheckBox>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveIndex, Mode=TwoWay}"/>
<TextBlock VerticalAlignment="Center" Text="Max = "/>
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount, Mode=TwoWay}"/>
</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}"/>
<Button Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Установить параметры"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetParameters}" CommandParameter="{Binding}"/>
</Grid>
</Border>
</local:PrimitivePopup>
</Grid>
</UserControl>

View File

@@ -0,0 +1,47 @@
using System.Windows;
using System.Windows.Controls;
using StructureHelper.Infrastructure.Enums;
namespace StructureHelper.Infrastructure.UI.UserControls
{
/// <summary>
/// Interaction logic for PrimitivePopup.xaml
/// </summary>
public partial class PrimitivePopup : UserControl
{
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

@@ -1,12 +1,18 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using StructureHelper.Annotations;
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)
{

View File

@@ -1,7 +1,8 @@
using System.Collections.Generic;
using StructureHelper.Infrastructure;
using StructureHelper.Models.Materials;
namespace StructureHelper
namespace StructureHelper.MaterialCatalogWindow
{
public class MaterialCatalogModel
{

View File

@@ -1,4 +1,4 @@
<Window x:Class="StructureHelper.MaterialCatalogView"
<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"

View File

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

View File

@@ -6,11 +6,15 @@ using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using Newtonsoft.Json;
using StructureHelper.Annotations;
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
namespace StructureHelper.MaterialCatalogWindow
{
[JsonObject(MemberSerialization.OptIn)]
public class MaterialCatalogViewModel : INotifyPropertyChanged
@@ -54,7 +58,7 @@ namespace StructureHelper
public Visibility SelectMaterialButtonVisibility => IsMaterialCanBeSelected ? Visibility.Visible : Visibility.Hidden;
public MaterialCatalogViewModel() { }
public MaterialCatalogViewModel(MaterialCatalogModel materialCatalogModel, MaterialCatalogView materialCatalogView, bool isMaterialCanBeSelected, PrimitiveDefinitionBase primitive = null)
public MaterialCatalogViewModel(MaterialCatalogModel materialCatalogModel, MaterialCatalogView materialCatalogView, bool isMaterialCanBeSelected, PrimitiveBase primitive = null)
{
this.materialCatalogModel = materialCatalogModel;
this.materialCatalogView = materialCatalogView;

View File

@@ -1,6 +1,6 @@
using System;
namespace StructureHelper
namespace StructureHelper.Models.Materials
{
public class ConcreteDefinition : MaterialDefinitionBase
{

View File

@@ -1,6 +1,6 @@
using System;
namespace StructureHelper
namespace StructureHelper.Models.Materials
{
public class MaterialDefinitionBase
{

View File

@@ -1,4 +1,4 @@
namespace StructureHelper
namespace StructureHelper.Models.Materials
{
public class RebarDefinition : MaterialDefinitionBase
{

View File

@@ -1,103 +0,0 @@
using System;
using System.Windows.Media;
namespace StructureHelper
{
public class EllipseDefinition : PrimitiveDefinitionBase
{
private double diameter, showedDiameter, ellipseX, ellipseY;
public double Diameter
{
get => diameter;
set
{
diameter = value;
ShowedDiameter = Math.Round(value, 2);
OnPropertyChanged();
}
}
public double ShowedDiameter
{
get => showedDiameter;
set
{
showedDiameter = value;
OnPropertyChanged();
}
}
public double EllipseX
{
get => ellipseX;
set
{
ellipseX = value;
OnPropertyChanged();
}
}
public double EllipseY
{
get => ellipseY;
set
{
ellipseY = value;
OnPropertyChanged();
}
}
private double showedEllipseX, showedEllipseY;
private double initialEllipseX, initialEllipseY;
public double ShowedEllipseX
{
get => showedEllipseX;
set
{
showedEllipseX = value;
EllipseX = value + initialEllipseX - Diameter / 2;
OnPropertyChanged(nameof(EllipseX));
OnPropertyChanged();
}
}
public double ShowedEllipseY
{
get => showedEllipseY;
set
{
showedEllipseY = value;
EllipseY = -value + initialEllipseY - Diameter / 2;
OnPropertyChanged(nameof(ShowedEllipseY));
OnPropertyChanged();
}
}
private double square;
public double Square
{
get => square;
set
{
square = value;
Diameter = Math.Sqrt(4 * value / Math.PI);
OnPropertyChanged(nameof(Diameter));
OnPropertyChanged();
}
}
public EllipseDefinition(double square, double ellipseX, double ellipseY)
{
Square = square;
initialEllipseX = ellipseX;
initialEllipseY = ellipseY;
ShowedEllipseX = 0;
ShowedEllipseY = 0;
var randomR = new Random().Next(150, 255);
var randomG = new Random().Next(0, 255);
var randomB = new Random().Next(30, 130);
var color = Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
Brush = new SolidColorBrush(color);
}
}
}

View File

@@ -1,146 +0,0 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using StructureHelper.Annotations;
namespace StructureHelper
{
public class PrimitiveDefinitionBase : INotifyPropertyChanged
{
private bool captured, parameterCaptured, elementLock;
public bool Captured
{
set
{
captured = value;
OnPropertyChanged();
}
get => captured;
}
public bool ParameterCaptured
{
set
{
parameterCaptured = value;
OnPropertyChanged();
}
get => parameterCaptured;
}
public bool ElementLock
{
get => elementLock;
set
{
elementLock = value;
OnPropertyChanged();
}
}
private SolidColorBrush brush = null;
public SolidColorBrush Brush
{
get => brush;
set
{
brush = value;
OnPropertyChanged();
}
}
private MaterialDefinitionBase material = null;
public MaterialDefinitionBase Material
{
get => material;
set
{
material = value;
MaterialName = material.MaterialClass;
OnPropertyChanged();
OnPropertyChanged(nameof(MaterialName));
}
}
private string materialName = string.Empty;
public string MaterialName
{
get => materialName;
set
{
materialName = value;
OnPropertyChanged();
}
}
private bool paramsPanelVisibilty;
public bool ParamsPanelVisibilty
{
get => paramsPanelVisibilty;
set
{
paramsPanelVisibilty = value;
OnPropertyChanged();
}
}
private bool popupCanBeClosed = true;
public bool PopupCanBeClosed
{
get => popupCanBeClosed;
set
{
popupCanBeClosed = value;
OnPropertyChanged();
}
}
private double opacity = 1;
private double showedOpacity = 0;
public double ShowedOpacity
{
get => showedOpacity;
set
{
showedOpacity = value;
Opacity = (100 - value) / 100;
OnPropertyChanged(nameof(Opacity));
OnPropertyChanged();
}
}
public double Opacity
{
get => opacity;
set
{
opacity = value;
OnPropertyChanged();
}
}
private int showedZIndex = 1;
public int ShowedZIndex
{
get => showedZIndex;
set
{
showedZIndex = value;
ZIndex = value - 1;
OnPropertyChanged(nameof(ZIndex));
OnPropertyChanged();
}
}
private int zIndex;
public int ZIndex
{
get => zIndex;
set
{
zIndex = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -1,97 +0,0 @@
using System;
using System.Windows.Media;
namespace StructureHelper
{
public class RectangleDefinition : PrimitiveDefinitionBase
{
private bool borderCaptured = false;
private double rectX, rectY, borderWidth, borderHeight;
public bool BorderCaptured
{
set
{
borderCaptured = value;
OnPropertyChanged();
}
get => borderCaptured;
}
public double RectX
{
get => rectX;
set
{
rectX = value;
OnPropertyChanged();
}
}
public double RectY
{
get => rectY;
set
{
rectY = value;
OnPropertyChanged();
}
}
private double showedRectX, showedRectY;
private double initialRectX, initialRectY;
public double ShowedRectX
{
get => showedRectX;
set
{
showedRectX = value;
RectX = value + initialRectX;
OnPropertyChanged(nameof(RectX));
OnPropertyChanged();
}
}
public double ShowedRectY
{
get => showedRectY;
set
{
showedRectY = value;
RectY = -value + initialRectY - BorderHeight;
OnPropertyChanged(nameof(RectY));
OnPropertyChanged();
}
}
public double BorderWidth
{
get => borderWidth;
set
{
borderWidth = value;
OnPropertyChanged();
}
}
public double BorderHeight
{
get => borderHeight;
set
{
borderHeight = value;
OnPropertyChanged();
}
}
public RectangleDefinition(double borderWidth, double borderHeight, double rectX, double rectY)
{
BorderWidth = borderWidth;
BorderHeight = borderHeight;
initialRectX = rectX;
initialRectY = rectY;
ShowedRectX = 0;
ShowedRectY = 0;
var randomR = new Random().Next(150, 255);
var randomG = new Random().Next(0, 255);
var randomB = new Random().Next(30, 130);
var color = Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
Brush = new SolidColorBrush(color);
}
}
}

View File

@@ -21,6 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
using System;
// ReSharper disable UnusedType.Global
#pragma warning disable 1591
@@ -31,7 +32,7 @@ using System;
// ReSharper disable MemberCanBeProtected.Global
// ReSharper disable InconsistentNaming
namespace StructureHelper.Annotations
namespace StructureHelper.Properties
{
/// <summary>
/// Indicates that the value of the marked element could be <c>null</c> sometimes,

View File

@@ -65,6 +65,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Infrastructure\Enums\PrimitiveType.cs" />
<Compile Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml.cs">
<DependentUpon>PrimitivePopup.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\AddMaterialWindow\AddMaterialView.xaml.cs">
<DependentUpon>AddMaterialView.xaml</DependentUpon>
</Compile>
@@ -79,24 +83,30 @@
<Compile Include="Windows\ColorPickerWindow\ColorPickerViewModel.cs" />
<Compile Include="Infrastructure\Extensions\ObservableCollectionExtensions.cs" />
<Compile Include="Infrastructure\EventTriggerBase.cs" />
<Compile Include="Infrastructure\MouseEventTriggers\MouseWheelUpEventTrigger.cs" />
<Compile Include="Infrastructure\MouseEventTriggers\MouseWheelDownEventTrigger.cs" />
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\MouseWheelUpEventTrigger.cs" />
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\MouseWheelDownEventTrigger.cs" />
<Compile Include="Infrastructure\ViewModelBase.cs" />
<Compile Include="Models\MaterialDefinition\ConcreteDefinition.cs" />
<Compile Include="Models\Materials\ConcreteDefinition.cs" />
<Compile Include="Infrastructure\NamedList.cs" />
<Compile Include="Models\MaterialDefinition\MaterialDefinitionBase.cs" />
<Compile Include="Models\PrimitiveDefinition\EllipseDefinition.cs" />
<Compile Include="Models\PrimitiveDefinition\PrimitiveDefinitionBase.cs" />
<Compile Include="Models\Materials\MaterialDefinitionBase.cs" />
<Compile Include="Infrastructure\UI\DataContexts\Ellipse.cs" />
<Compile Include="Infrastructure\UI\DataContexts\PrimitiveBase.cs" />
<Compile Include="Properties\Annotations.cs" />
<Compile Include="Models\MaterialDefinition\RebarDefinition.cs" />
<Compile Include="Models\PrimitiveDefinition\RectangleDefinition.cs" />
<Compile Include="Models\Materials\RebarDefinition.cs" />
<Compile Include="Infrastructure\UI\DataContexts\Rectangle.cs" />
<Compile Include="Infrastructure\UI\DataTemplates\EllipseTemplate.xaml.cs">
<DependentUpon>EllipseTemplate.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow\MainModel.cs" />
<Compile Include="Windows\MainWindow\MainView.xaml.cs" />
<Compile Include="Windows\MainWindow\MainViewModel.cs" />
<Compile Include="Infrastructure\RelayCommand.cs" />
<Compile Include="Infrastructure\UI\DataTemplates\RectangleTemplate.xaml.cs">
<DependentUpon>RectangleTemplate.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Infrastructure\MouseEventTriggers\DoubleClickEventTrigger.cs" />
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\DoubleClickEventTrigger.cs" />
<Compile Include="Infrastructure\EventArgs.cs" />
<Compile Include="MaterialCatalogWindow\MaterialCatalogModel.cs" />
<Compile Include="MaterialCatalogWindow\MaterialCatalogView.xaml.cs" />
@@ -111,6 +121,14 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Page Include="Infrastructure\UI\Styles.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\AddMaterialWindow\AddMaterialView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -123,10 +141,18 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Infrastructure\UI\DataTemplates\EllipseTemplate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\MainWindow\MainView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Infrastructure\UI\DataTemplates\RectangleTemplate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Folder Include="Logics\" />

View File

@@ -1,11 +1,12 @@
<Window x:Class="StructureHelper.AddMaterialView"
<Window x:Class="StructureHelper.Windows.AddMaterialWindow.AddMaterialView"
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"
xmlns:addMaterialWindow="clr-namespace:StructureHelper.Windows.AddMaterialWindow"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:AddMaterialViewModel}"
d:DataContext="{d:DesignInstance addMaterialWindow:AddMaterialViewModel}"
Title="Добавление материала" Height="350" Width="400">
<Grid>
<Grid.RowDefinitions>

View File

@@ -1,6 +1,7 @@
using System.Windows;
using StructureHelper.MaterialCatalogWindow;
namespace StructureHelper
namespace StructureHelper.Windows.AddMaterialWindow
{
/// <summary>
/// Логика взаимодействия для AddMaterialView.xaml

View File

@@ -2,8 +2,10 @@
using System.Linq;
using System.Windows.Input;
using StructureHelper.Infrastructure;
using StructureHelper.MaterialCatalogWindow;
using StructureHelper.Models.Materials;
namespace StructureHelper
namespace StructureHelper.Windows.AddMaterialWindow
{
public class AddMaterialViewModel : ViewModelBase
{

View File

@@ -1,4 +1,4 @@
<Window x:Class="StructureHelper.ColorPickerView"
<Window x:Class="StructureHelper.Windows.ColorPickerWindow.ColorPickerView"
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"

View File

@@ -1,13 +1,14 @@
using System.Windows;
using StructureHelper.Infrastructure.UI.DataContexts;
namespace StructureHelper
namespace StructureHelper.Windows.ColorPickerWindow
{
/// <summary>
/// Логика взаимодействия для ColorPickerView.xaml
/// </summary>
public partial class ColorPickerView : Window
{
public ColorPickerView(PrimitiveDefinitionBase primitive)
public ColorPickerView(PrimitiveBase primitive)
{
var viewModel = new ColorPickerViewModel(primitive);
DataContext = viewModel;

View File

@@ -1,69 +1,12 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Media;
using StructureHelper.Annotations;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
namespace StructureHelper
namespace StructureHelper.Windows.ColorPickerWindow
{
//public class ColorPickerViewModel : ViewModelBase
//{
// private int red, green, blue;
// public int Red
// {
// get => red;
// set => OnColorItemChanged(value, ref red);
// }
// public int Green
// {
// get => green;
// set => OnColorItemChanged(value, ref green);
// }
// public int Blue
// {
// get => blue;
// set => OnColorItemChanged(value, ref blue);
// }
// private SolidColorBrush selectedColor;
// public SolidColorBrush SelectedColor
// {
// get => selectedColor;
// set => OnPropertyChanged(value, selectedColor);
// }
// public ICommand SetColor { get; }
// public ColorPickerViewModel(PrimitiveDefinitionBase primitive)
// {
// if (primitive != null)
// {
// var solidBrush = primitive.Brush;
// Red = solidBrush.Color.R;
// Green = solidBrush.Color.G;
// Blue = solidBrush.Color.B;
// SetColor = new RelayCommand(o => primitive.Brush = SelectedColor);
// }
// }
// private void OnColorItemChanged(int value, ref int colorItem, [CallerMemberName] string propertyName = null)
// {
// if (value >= 0 && value <= 255 && Math.Abs(colorItem - value) > 0.001)
// {
// colorItem = value;
// OnPropertyChanged(propertyName);
// UpdateSelectedColor();
// }
// }
// private void UpdateSelectedColor()
// {
// var color = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue);
// SelectedColor = new SolidColorBrush(color);
// OnPropertyChanged(nameof(SelectedColor));
// }
//}
public class ColorPickerViewModel : ViewModelBase
{
private int red, green, blue;
@@ -84,19 +27,18 @@ namespace StructureHelper
set => OnColorItemChanged(value, ref blue);
}
private SolidColorBrush selectedColor;
public SolidColorBrush SelectedColor
private Brush selectedColor;
public Brush SelectedColor
{
get => selectedColor;
//selectedColor = value;
set => OnPropertyChanged(value, ref selectedColor);
set => OnPropertyChanged(value, selectedColor);
}
public ICommand SetColor { get; }
public ColorPickerViewModel(PrimitiveDefinitionBase primitive)
public ColorPickerViewModel(PrimitiveBase primitive)
{
if (primitive != null)
{
var solidBrush = primitive.Brush;
var solidBrush = (SolidColorBrush)primitive.Brush;
Red = solidBrush.Color.R;
Green = solidBrush.Color.G;
Blue = solidBrush.Color.B;

View File

@@ -1,4 +1,4 @@
namespace StructureHelper
namespace StructureHelper.Windows.MainWindow
{
public class MainModel
{

View File

@@ -1,11 +1,14 @@
<Window x:Class="StructureHelper.MainView"
<Window x:Class="StructureHelper.Windows.MainWindow.MainView"
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"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:infrastructure="clr-namespace:StructureHelper.Infrastructure"
xmlns:dataTemplates="clr-namespace:StructureHelper.Infrastructure.UI.DataTemplates"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:MainViewModel}"
Title="StructureHelper" Height="700" Width="1000">
@@ -13,238 +16,11 @@
<KeyBinding Command="{Binding SetParameters}" Key="Enter"/>
</Window.InputBindings>
<Window.Resources>
<DataTemplate x:Key="rectangleTemplate">
<DockPanel>
<Border x:Name="Border" Width="{Binding BorderWidth, Mode=TwoWay}" Height="{Binding BorderHeight, Mode=TwoWay}" Background="{Binding Brush, Mode=TwoWay}"
Opacity="{Binding Opacity, Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.BorderPreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<infrastructure:DoubleClickEventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
</infrastructure:DoubleClickEventTrigger>
</i:Interaction.Triggers>
<Border.ToolTip>
<ToolTip Background="White" BorderBrush="Black" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата X:"/>
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedRectX}"/>
<TextBox Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата Y:"/>
<TextBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedRectY}"/>
<TextBox Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Ширина:"/>
<TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding BorderWidth}"/>
<TextBox Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Высота:"/>
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding BorderHeight}"/>
<TextBox Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Материал:"/>
<TextBox Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding MaterialName, Mode=TwoWay}"/>
</Grid>
</ToolTip>
</Border.ToolTip>
<Rectangle Name="testRect" Fill="{Binding Brush, Mode=TwoWay}" Width="20" Height="20" StrokeThickness="2" Stroke="{Binding Brush, Mode=TwoWay}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Rectangle>
</Border>
<Popup IsOpen="{Binding ParamsPanelVisibilty}">
<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="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterX, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterY, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Ширина" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterWidth, Mode=TwoWay}"/>
<TextBlock Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Высота" Margin="10"/>
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RectParameterHeight, Mode=TwoWay}"/>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ParameterOpacity, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ElementLock, Mode=TwoWay}"></CheckBox>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveIndex, Mode=TwoWay}"/>
<TextBlock VerticalAlignment="Center" Text="Max = "/>
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount, Mode=TwoWay}"/>
</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}"/>
<Button Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Установить параметры"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetParameters}" CommandParameter="{Binding}"/>
</Grid>
</Border>
</Popup>
</DockPanel>
<DataTemplate DataType="{x:Type dataContexts:Rectangle}">
<dataTemplates:RectangleTemplate/>
</DataTemplate>
<DataTemplate x:Key="ellipseTemplate">
<DockPanel>
<Ellipse Width="{Binding Diameter}" Height="{Binding Diameter}" Fill="{Binding Brush, Mode=TwoWay}" Opacity="{Binding Opacity, Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseMove">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipsePreviewMouseMove}" CommandParameter="{Binding}"/>
</i:EventTrigger>
<infrastructure:DoubleClickEventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
</infrastructure:DoubleClickEventTrigger>
</i:Interaction.Triggers>
<Ellipse.ToolTip>
<ToolTip Background="White" BorderBrush="Black" BorderThickness="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата центра X:"/>
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedEllipseX}"/>
<TextBox Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата центра Y:"/>
<TextBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedEllipseY}"/>
<TextBox Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Диаметр:"/>
<TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedDiameter}"/>
<TextBox Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Материал:"/>
<TextBox Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding MaterialName, Mode=TwoWay}"/>
</Grid>
</ToolTip>
</Ellipse.ToolTip>
</Ellipse>
<Popup IsOpen="{Binding ParamsPanelVisibilty}">
<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="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterX, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterY, Mode=TwoWay}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="Площадь" Margin="10"/>
<TextBox Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" Margin="10" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.EllipseParameterSquare, Mode=TwoWay}"/>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ParameterOpacity, 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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ElementLock, Mode=TwoWay}"></CheckBox>
<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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitiveIndex, Mode=TwoWay}"/>
<TextBlock VerticalAlignment="Center" Text="Max = "/>
<TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PrimitivesCount, Mode=TwoWay}"/>
</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}"/>
<Button Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10" Content="Установить параметры"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SetParameters}" CommandParameter="{Binding}"/>
</Grid>
</Border>
</Popup>
</DockPanel>
<DataTemplate DataType="{x:Type dataContexts:Ellipse}">
<dataTemplates:EllipseTemplate/>
</DataTemplate>
</Window.Resources>
<Grid>
@@ -262,15 +38,15 @@
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
<Canvas ClipToBounds="True" Width="{Binding CanvasWidth}" Height="{Binding CanvasHeight}">
<i:Interaction.Behaviors>
<local:MouseBehaviour MouseX="{Binding PanelX, Mode=OneWayToSource}" MouseY="{Binding PanelY, Mode=OneWayToSource}"/>
<infrastructure:MouseBehaviour MouseX="{Binding PanelX, Mode=OneWayToSource}" MouseY="{Binding PanelY, Mode=OneWayToSource}"/>
</i:Interaction.Behaviors>
<i:Interaction.Triggers>
<infrastructure:MouseWheelDownEventTrigger EventName="PreviewMouseWheel">
<i:InvokeCommandAction Command="{Binding ScaleCanvasDown}" CommandParameter="{Binding}"/>
</infrastructure:MouseWheelDownEventTrigger>
<infrastructure:MouseWheelUpEventTrigger EventName="PreviewMouseWheel">
<i:InvokeCommandAction Command="{Binding ScaleCanvasUp}" CommandParameter="{Binding}"/>
</infrastructure:MouseWheelUpEventTrigger>
<mouseEventTriggers:MouseWheelDownEventTrigger EventName="PreviewMouseWheel">
<i:InvokeCommandAction Command="{Binding ScaleCanvasDown}"/>
</mouseEventTriggers:MouseWheelDownEventTrigger>
<mouseEventTriggers:MouseWheelUpEventTrigger EventName="PreviewMouseWheel">
<i:InvokeCommandAction Command="{Binding ScaleCanvasUp}"/>
</mouseEventTriggers:MouseWheelUpEventTrigger>
</i:Interaction.Triggers>
<Canvas.RenderTransform>
<TransformGroup>
@@ -294,7 +70,7 @@
</Canvas.Background>
<Line X1="0" X2="{Binding XX2}" Y1="{Binding XY1}" Y2="{Binding XY1}" Stroke="Red" StrokeThickness="1"/>
<Line X1="{Binding YX1}" X2="{Binding YX1}" Y1="0" Y2="{Binding YY2}" Stroke="ForestGreen" StrokeThickness="1"/>
<ItemsControl ItemsSource="{Binding Rectangles}" ItemTemplate="{StaticResource rectangleTemplate}">
<ItemsControl ItemsSource="{Binding Primitives}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
@@ -303,22 +79,8 @@
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}"/>
<Setter Property="Canvas.Left" Value="{Binding RectX}"/>
<Setter Property="Canvas.Top" Value="{Binding RectY}"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
<ItemsControl ItemsSource="{Binding Ellipses}" ItemTemplate="{StaticResource ellipseTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}"/>
<Setter Property="Canvas.Left" Value="{Binding EllipseX}"/>
<Setter Property="Canvas.Top" Value="{Binding EllipseY}"/>
<Setter Property="Canvas.Left" Value="{Binding X}"/>
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>

View File

@@ -1,6 +1,6 @@
using System.Windows;
namespace StructureHelper
namespace StructureHelper.Windows.MainWindow
{
public partial class MainView : Window
{

View File

@@ -3,16 +3,18 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.Extensions;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.MaterialCatalogWindow;
using StructureHelper.Windows.ColorPickerWindow;
namespace StructureHelper
namespace StructureHelper.Windows.MainWindow
{
public class MainViewModel : ViewModelBase
{
private MainModel rectanglesModel;
private MainView rectanglesView;
public ObservableCollection<RectangleDefinition> Rectangles { get; set; }
public ObservableCollection<EllipseDefinition> Ellipses { get; set; }
public ObservableCollection<PrimitiveDefinitionBase> Primitives { get; set; }
public ObservableCollection<PrimitiveBase> Primitives { get; set; }
public ICommand AddRectangle { get; }
private double panelX, panelY, scrollPanelX, scrollPanelY;
@@ -157,19 +159,13 @@ namespace StructureHelper
set => OnPropertyChanged(value, ref yY2);
}
private double delta = 0.5;
public ICommand LeftButtonDown { get; }
public ICommand LeftButtonUp { get; }
public ICommand PreviewMouseMove { get; }
public ICommand PrimitiveLeftButtonDown { get; }
public ICommand PrimitiveLeftButtonUp { get; }
public ICommand BorderPreviewMouseMove { get; }
public ICommand PrimitiveDoubleClick { get; }
public ICommand SetParameters { get; }
public ICommand ClearSelection { get; }
public ICommand SetPopupCanBeClosedTrue { get; }
public ICommand SetPopupCanBeClosedFalse { get; }
public ICommand OpenMaterialCatalog { get; }
public ICommand OpenMaterialCatalogWithSelection { get; }
public ICommand SetColor { get; }
@@ -178,7 +174,11 @@ namespace StructureHelper
public ICommand ScaleCanvasDown { get; }
public ICommand ScaleCanvasUp { get; }
public ICommand AddEllipse { get; }
public ICommand EllipsePreviewMouseMove { get; }
public ICommand SetPopupCanBeClosedTrue { get; }
public ICommand SetPopupCanBeClosedFalse { get; }
private double delta = 0.5;
public MainViewModel() { }
public MainViewModel(MainModel rectanglesModel, MainView rectanglesView)
@@ -193,67 +193,29 @@ namespace StructureHelper
YX1 = CanvasWidth / 2;
YY2 = CanvasHeight;
BorderPreviewMouseMove = new RelayCommand(o =>
{
if (!(o is RectangleDefinition rect)) return;
if (rect.Captured && !rect.BorderCaptured && !rect.ElementLock)
{
var deltaX = rect.BorderWidth / 2;
var deltaY = rect.BorderHeight / 2;
if (rect.ShowedRectX % 10 <= delta || rect.ShowedRectX % 10 >= 10 - delta)
rect.ShowedRectX = Math.Round((PanelX - deltaX - YX1) / 10) * 10;
else
rect.ShowedRectX = PanelX - deltaX - YX1;
if (rect.ShowedRectY % 10 <= delta || rect.ShowedRectY % 10 >= 10 - delta)
rect.ShowedRectY = -(Math.Round((PanelY - deltaY - XY1 + rect.BorderHeight) / 10) * 10);
else
rect.ShowedRectY = -(PanelY - deltaY - XY1 + rect.BorderHeight);
}
if (rect.ParameterCaptured)
{
RectParameterX = rect.ShowedRectX;
RectParameterY = rect.ShowedRectY;
RectParameterWidth = rect.BorderWidth;
RectParameterHeight = rect.BorderHeight;
ParameterOpacity = rect.ShowedOpacity;
ElementLock = rect.ElementLock;
}
});
PrimitiveLeftButtonUp = new RelayCommand(o =>
{
if (o is PrimitiveDefinitionBase primitive) primitive.Captured = false;
});
PrimitiveLeftButtonDown = new RelayCommand(o =>
{
if (!(o is PrimitiveDefinitionBase primitive)) return;
primitive.Captured = true;
foreach (var primitiveDefinition in Primitives)
primitiveDefinition.ParameterCaptured = false;
primitive.ParameterCaptured = true;
});
LeftButtonUp = new RelayCommand(o =>
{
if (o is RectangleDefinition rect) rect.BorderCaptured = false;
if (o is Rectangle rect) rect.BorderCaptured = false;
});
LeftButtonDown = new RelayCommand(o =>
{
if (o is RectangleDefinition rect) rect.BorderCaptured = true;
if (o is Rectangle rect) rect.BorderCaptured = true;
});
PreviewMouseMove = new RelayCommand(o =>
{
if (o is RectangleDefinition rect && rect.BorderCaptured && rect.Captured && !rect.ElementLock)
if (o is Rectangle rect && rect.BorderCaptured && !rect.ElementLock)
{
if (rect.BorderWidth % 10 < delta || rect.BorderWidth % 10 >= delta)
rect.BorderWidth = Math.Round(PanelX / 10) * 10 - rect.RectX + 10;
if (rect.PrimitiveWidth % 10 < delta || rect.PrimitiveWidth % 10 >= delta)
rect.PrimitiveWidth = Math.Round(PanelX / 10) * 10 - rect.X + 10;
else
rect.BorderWidth = PanelX - rect.RectX + 10;
rect.PrimitiveWidth = PanelX - rect.X + 10;
if (rect.BorderHeight % 10 < delta || rect.BorderHeight % 10 >= delta)
rect.BorderHeight = Math.Round(PanelY / 10) * 10 - rect.RectY + 10;
if (rect.PrimitiveHeight % 10 < delta || rect.PrimitiveHeight % 10 >= delta)
rect.PrimitiveHeight = Math.Round(PanelY / 10) * 10 - rect.Y + 10;
else
rect.BorderHeight = PanelY - rect.RectY + 10;
rect.PrimitiveHeight = PanelY - rect.Y + 10;
}
});
SetParameters = new RelayCommand(o =>
@@ -269,16 +231,16 @@ namespace StructureHelper
switch (primitive)
{
case RectangleDefinition rectangle:
rectangle.ShowedRectX = RectParameterX;
rectangle.ShowedRectY = RectParameterY;
rectangle.BorderWidth = RectParameterWidth;
rectangle.BorderHeight = RectParameterHeight;
case Rectangle rectangle:
rectangle.ShowedX = RectParameterX;
rectangle.ShowedY = RectParameterY;
rectangle.PrimitiveWidth = RectParameterWidth;
rectangle.PrimitiveHeight = RectParameterHeight;
break;
case EllipseDefinition ellipse:
case Ellipse ellipse:
ellipse.Square = EllipseParameterSquare;
ellipse.ShowedEllipseX = EllipseParameterX;
ellipse.ShowedEllipseY = EllipseParameterY;
ellipse.ShowedX = EllipseParameterX;
ellipse.ShowedY = EllipseParameterY;
break;
}
}
@@ -289,26 +251,8 @@ namespace StructureHelper
if (primitive != null && primitive.PopupCanBeClosed)
primitive.ParamsPanelVisibilty = false;
});
PrimitiveDoubleClick = new RelayCommand(o =>
{
if (!(o is PrimitiveDefinitionBase primitive)) return;
primitive.PopupCanBeClosed = false;
primitive.Captured = false;
primitive.ParamsPanelVisibilty = true;
if (primitive is RectangleDefinition rect)
rect.BorderCaptured = false;
});
SetPopupCanBeClosedTrue = new RelayCommand(o =>
{
var primitiveParamsVisible = Primitives.FirstOrDefault(x => x.ParameterCaptured);
if (primitiveParamsVisible != null) primitiveParamsVisible.PopupCanBeClosed = true;
});
SetPopupCanBeClosedFalse = new RelayCommand(o =>
{
var primitiveParamsVisible = Primitives.FirstOrDefault(x => x.ParameterCaptured);
if (primitiveParamsVisible != null) primitiveParamsVisible.PopupCanBeClosed = false;
});
OpenMaterialCatalog = new RelayCommand(o =>
{
var materialCatalogView = new MaterialCatalogView();
@@ -316,19 +260,19 @@ namespace StructureHelper
});
OpenMaterialCatalogWithSelection = new RelayCommand(o =>
{
var primitive = o as PrimitiveDefinitionBase;
var primitive = o as PrimitiveBase;
var materialCatalogView = new MaterialCatalogView(true, primitive);
materialCatalogView.ShowDialog();
});
SetColor = new RelayCommand(o =>
{
var primitive = o as PrimitiveDefinitionBase;
var primitive = o as PrimitiveBase;
var colorPickerView = new ColorPickerView(primitive);
colorPickerView.ShowDialog();
});
SetInFrontOfAll = new RelayCommand(o =>
{
if (!(o is PrimitiveDefinitionBase primitive)) return;
if (!(o is PrimitiveBase primitive)) return;
foreach (var primitiveDefinition in Primitives)
if (primitiveDefinition.ShowedZIndex > primitive.ShowedZIndex && primitiveDefinition != primitive)
primitiveDefinition.ShowedZIndex--;
@@ -337,7 +281,7 @@ namespace StructureHelper
});
SetInBackOfAll = new RelayCommand(o =>
{
if (!(o is PrimitiveDefinitionBase primitive)) return;
if (!(o is PrimitiveBase primitive)) return;
foreach (var primitiveDefinition in Primitives)
if (primitiveDefinition.ShowedZIndex < primitive.ShowedZIndex && primitiveDefinition != primitive)
primitiveDefinition.ShowedZIndex++;
@@ -359,48 +303,29 @@ namespace StructureHelper
ScaleValue /= scaleRate;
});
Primitives = new ObservableCollection<PrimitiveDefinitionBase>();
Rectangles = new ObservableCollection<RectangleDefinition>();
Ellipses = new ObservableCollection<EllipseDefinition>();
Primitives = new ObservableCollection<PrimitiveBase>();
AddRectangle = new RelayCommand(o =>
{
var rectangle = new RectangleDefinition(60, 40, YX1, XY1);
Rectangles.Add(rectangle);
var rectangle = new Rectangle(60, 40, YX1, XY1, this);
Primitives.Add(rectangle);
PrimitivesCount = Primitives.Count;
});
AddEllipse = new RelayCommand(o =>
{
var ellipse = new EllipseDefinition(2000, YX1, XY1);
Ellipses.Add(ellipse);
var ellipse = new Ellipse(2000, YX1, XY1, this);
Primitives.Add(ellipse);
PrimitivesCount = Primitives.Count;
});
EllipsePreviewMouseMove = new RelayCommand(o =>
SetPopupCanBeClosedTrue = new RelayCommand(o =>
{
if (!(o is EllipseDefinition ellipse)) return;
if (ellipse.Captured && !ellipse.ElementLock)
{
var ellipseDelta = ellipse.Diameter / 2;
if (ellipse.ShowedEllipseX % 10 <= ellipseDelta || ellipse.ShowedEllipseX % 10 >= 10 - ellipseDelta)
ellipse.ShowedEllipseX = Math.Round((PanelX - YX1) / 10) * 10;
else
ellipse.ShowedEllipseX = PanelX - ellipseDelta - YX1;
if (ellipse.ShowedEllipseY % 10 <= ellipseDelta || ellipse.ShowedEllipseY % 10 >= 10 - ellipseDelta)
ellipse.ShowedEllipseY = -(Math.Round((PanelY - XY1) / 10) * 10);
else
ellipse.ShowedEllipseY = -(PanelY - ellipseDelta - XY1);
}
if (ellipse.ParameterCaptured)
{
EllipseParameterX = ellipse.ShowedEllipseX;
EllipseParameterY = ellipse.ShowedEllipseY;
EllipseParameterSquare = ellipse.Square;
ParameterOpacity = ellipse.ShowedOpacity;
ElementLock = ellipse.ElementLock;
}
if (!(o is PrimitiveBase primitive)) return;
primitive.PopupCanBeClosed = true;
});
SetPopupCanBeClosedFalse = new RelayCommand(o =>
{
if (!(o is PrimitiveBase primitive)) return;
primitive.PopupCanBeClosed = false;
});
}
}