2021-07-23 09:42:22 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reactive.Linq;
|
2023-05-14 23:26:08 +08:00
|
|
|
|
using System.Windows;
|
2023-12-21 19:51:50 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Controls;
|
2023-01-12 23:02:53 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
2023-05-14 23:26:08 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2022-10-28 22:45:39 +08:00
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-24 09:02:40 +08:00
|
|
|
|
public abstract class DesignerItemViewModelBase : SelectableDesignerItemViewModelBase
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public DesignerItemViewModelBase() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DesignerItemViewModelBase(IDiagramViewModel root) : base(root)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-12 23:02:53 +08:00
|
|
|
|
ShapeDefiner = Shapes.Rectangle;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public DesignerItemViewModelBase(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-12 23:02:53 +08:00
|
|
|
|
ShapeDefiner = Shapes.Rectangle;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public DesignerItemViewModelBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
2023-01-12 23:02:53 +08:00
|
|
|
|
ShapeDefiner = Shapes.Rectangle;
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public override SelectableItemBase GetSerializableObject()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DesignerItemBase(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected override void InitNew()
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-05 20:35:10 +08:00
|
|
|
|
AddConnector(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Top));
|
|
|
|
|
|
AddConnector(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Bottom));
|
|
|
|
|
|
AddConnector(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Left));
|
|
|
|
|
|
AddConnector(new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.Right));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
base.LoadDesignerItemViewModel(designerbase);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
if (designerbase is DesignerItemBase designer)
|
|
|
|
|
|
{
|
2023-02-11 22:20:24 +08:00
|
|
|
|
this.PhysicalLeft = designer.PhysicalLeft;
|
|
|
|
|
|
this.PhysicalTop = designer.PhysicalTop;
|
2023-01-24 17:53:04 +08:00
|
|
|
|
this.Angle = designer.Angle;
|
|
|
|
|
|
this.ScaleX = designer.ScaleX;
|
|
|
|
|
|
this.ScaleY = designer.ScaleY;
|
2023-02-11 22:20:24 +08:00
|
|
|
|
this.PhysicalItemWidth = designer.PhysicalItemWidth;
|
|
|
|
|
|
this.PhysicalItemHeight = designer.PhysicalItemHeight;
|
2023-07-15 10:20:50 +08:00
|
|
|
|
this.MinItemWidth = designer.MinItemWidth;
|
|
|
|
|
|
this.MinItemHeight = designer.MinItemHeight;
|
2023-01-24 17:53:04 +08:00
|
|
|
|
this.Icon = designer.Icon;
|
2023-03-01 19:28:06 +08:00
|
|
|
|
this.CornerRadius = designer.CornerRadius;
|
|
|
|
|
|
this.BorderThickness = designer.BorderThickness;
|
2023-04-16 12:21:51 +08:00
|
|
|
|
if (designer.Connectors != null)
|
2023-03-25 11:59:31 +08:00
|
|
|
|
{
|
2023-04-16 12:21:51 +08:00
|
|
|
|
foreach (var connector in designer.Connectors)
|
|
|
|
|
|
{
|
|
|
|
|
|
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
|
|
|
|
|
|
AddConnector(fullyCreatedConnectorInfo);
|
|
|
|
|
|
}
|
2023-03-25 11:59:31 +08:00
|
|
|
|
}
|
2023-01-24 17:53:04 +08:00
|
|
|
|
}
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
2023-07-30 22:49:50 +08:00
|
|
|
|
#region
|
2023-02-21 23:23:03 +08:00
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo FirstConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault();
|
2023-02-21 23:23:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public FullyCreatedConnectorInfo TopConnector
|
|
|
|
|
|
{
|
2023-01-25 23:55:30 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Top);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo BottomConnector
|
|
|
|
|
|
{
|
2023-01-25 23:55:30 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Bottom);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo LeftConnector
|
|
|
|
|
|
{
|
2023-01-25 23:55:30 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Left);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo RightConnector
|
|
|
|
|
|
{
|
2023-01-25 23:55:30 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.Right);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo TopLeftConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.TopLeft);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo TopRightConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.TopRight);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo BottomLeftConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.BottomLeft);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FullyCreatedConnectorInfo BottomRightConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
return Connectors?.FirstOrDefault(p => p.Orientation == ConnectorOrientation.BottomRight);
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 20:10:17 +08:00
|
|
|
|
private FullyCreatedConnectorInfo _portlessConnector;
|
|
|
|
|
|
public FullyCreatedConnectorInfo PortlessConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_portlessConnector == null)
|
|
|
|
|
|
_portlessConnector = new FullyCreatedConnectorInfo(this.Root, this, ConnectorOrientation.None) { IsPortless = true };
|
|
|
|
|
|
|
|
|
|
|
|
return _portlessConnector;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-23 15:43:44 +08:00
|
|
|
|
public Style ConnectorStyle
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-08 09:22:37 +08:00
|
|
|
|
public ShapeDefiner ShapeDefiner
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-02-11 10:03:06 +08:00
|
|
|
|
public virtual PointBase MiddlePosition
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetBounds().Center;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private string _icon;
|
|
|
|
|
|
[CanDo]
|
|
|
|
|
|
public string Icon
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _icon;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _icon, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double _itemWidth = 65;
|
|
|
|
|
|
[CanDo]
|
2023-04-16 14:56:53 +08:00
|
|
|
|
[Browsable(true)]
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public double ItemWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _itemWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value <= 0) return;
|
2023-02-11 22:20:24 +08:00
|
|
|
|
if (SetProperty(ref _itemWidth, value))
|
2023-02-10 18:49:02 +08:00
|
|
|
|
{
|
2023-02-11 22:20:24 +08:00
|
|
|
|
RaisePropertyChanged(nameof(PhysicalItemWidth));
|
2023-02-10 18:49:02 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-11 10:25:40 +08:00
|
|
|
|
private double _itemHeight = 65;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
[CanDo]
|
2023-04-16 14:56:53 +08:00
|
|
|
|
[Browsable(true)]
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public double ItemHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _itemHeight;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value <= 0) return;
|
2023-02-11 22:20:24 +08:00
|
|
|
|
if (SetProperty(ref _itemHeight, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
RaisePropertyChanged(nameof(PhysicalItemHeight));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-09-11 10:25:40 +08:00
|
|
|
|
}
|
2023-02-11 22:20:24 +08:00
|
|
|
|
|
2023-02-12 09:26:27 +08:00
|
|
|
|
[DisplayName("ItemWidth(mm)")]
|
2023-02-11 22:20:24 +08:00
|
|
|
|
[Browsable(true)]
|
|
|
|
|
|
public double PhysicalItemWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
return ScreenHelper.WidthToMm(ItemWidth);
|
2023-02-11 22:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
ItemWidth = ScreenHelper.MmToWidth(value);
|
2023-02-11 22:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-12 09:26:27 +08:00
|
|
|
|
[DisplayName("ItemHeight(mm)")]
|
2023-02-11 22:20:24 +08:00
|
|
|
|
[Browsable(true)]
|
|
|
|
|
|
public double PhysicalItemHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
return ScreenHelper.WidthToMm(ItemHeight);
|
2023-02-11 22:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
ItemHeight = ScreenHelper.MmToWidth(value);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[CanDo]
|
2023-01-08 09:22:37 +08:00
|
|
|
|
public SizeBase Size
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
return new SizeBase(GetItemWidth(), GetItemHeight());
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-01-08 09:22:37 +08:00
|
|
|
|
ItemWidth = value.Width;
|
|
|
|
|
|
ItemHeight = value.Height;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-05 20:35:10 +08:00
|
|
|
|
private double _connectorMargin = -4;
|
|
|
|
|
|
public double ConnectorMargin
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _connectorMargin;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _connectorMargin, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private bool _showConnectors = false;
|
|
|
|
|
|
public bool ShowConnectors
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _showConnectors;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SetProperty(ref _showConnectors, value))
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
foreach (var connector in Connectors)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
connector.ShowConnectors = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool _showResize = true;
|
|
|
|
|
|
public bool ShowResize
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _showResize;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _showResize, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-22 21:46:59 +08:00
|
|
|
|
private bool _showRotate = false;
|
|
|
|
|
|
public bool ShowRotate
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _showRotate;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _showRotate, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-01 22:30:12 +08:00
|
|
|
|
public bool ShowArrow { get; set; } = true;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-03-07 22:59:27 +08:00
|
|
|
|
private bool alwayForResized;
|
|
|
|
|
|
public bool AlwayForResized
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return alwayForResized;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref alwayForResized, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-19 21:38:28 +08:00
|
|
|
|
private bool enabledForConnection = true;
|
|
|
|
|
|
public bool EnabledForConnection
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return enabledForConnection;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref enabledForConnection, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-17 22:38:47 +08:00
|
|
|
|
protected double _left;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
[CanDo]
|
2023-04-16 14:56:53 +08:00
|
|
|
|
[Browsable(true)]
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public double Left
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _left;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
if (Root != null && BeyondBoundary > 0)
|
2023-07-30 22:49:50 +08:00
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
if (value + GetItemWidth() < BeyondBoundary)
|
2023-07-30 22:49:50 +08:00
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
value = BeyondBoundary - GetItemWidth();
|
2023-07-30 22:49:50 +08:00
|
|
|
|
}
|
2023-08-12 22:58:24 +08:00
|
|
|
|
else if (value > Root.DiagramOption.LayoutOption.PageSize.Width - BeyondBoundary)
|
2023-07-30 22:49:50 +08:00
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
value = Root.DiagramOption.LayoutOption.PageSize.Width - BeyondBoundary;
|
2023-07-30 22:49:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
SetProperty(ref _left, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double _top;
|
|
|
|
|
|
[CanDo]
|
2023-04-16 14:56:53 +08:00
|
|
|
|
[Browsable(true)]
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public double Top
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _top;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
if (Root != null && BeyondBoundary > 0)
|
2023-07-30 22:49:50 +08:00
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
if (value + GetItemHeight() < BeyondBoundary)
|
2023-07-30 22:49:50 +08:00
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
value = BeyondBoundary - GetItemHeight();
|
2023-07-30 22:49:50 +08:00
|
|
|
|
}
|
2023-08-12 22:58:24 +08:00
|
|
|
|
else if (value > Root.DiagramOption.LayoutOption.PageSize.Height - BeyondBoundary)
|
2023-07-30 22:49:50 +08:00
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
value = Root.DiagramOption.LayoutOption.PageSize.Height - BeyondBoundary;
|
2023-07-30 22:49:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
SetProperty(ref _top, value);
|
|
|
|
|
|
}
|
2023-01-08 09:22:37 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-02-12 09:26:27 +08:00
|
|
|
|
[DisplayName("Left(mm)")]
|
2023-02-11 22:20:24 +08:00
|
|
|
|
[Browsable(true)]
|
|
|
|
|
|
public double PhysicalLeft
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
return ScreenHelper.WidthToMm(Left);
|
2023-02-11 22:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
Left = ScreenHelper.MmToWidth(value);
|
2023-02-11 22:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-12 09:26:27 +08:00
|
|
|
|
[DisplayName("Top(mm)")]
|
2023-02-11 22:20:24 +08:00
|
|
|
|
[Browsable(true)]
|
|
|
|
|
|
public double PhysicalTop
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
return ScreenHelper.WidthToMm(Top);
|
2023-02-11 22:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2023-02-11 23:51:48 +08:00
|
|
|
|
Top = ScreenHelper.MmToWidth(value);
|
2023-02-11 22:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-08 09:22:37 +08:00
|
|
|
|
public PointBase Position
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-12-21 19:51:50 +08:00
|
|
|
|
return TopLeft;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
TopLeft = value;
|
2023-01-08 09:22:37 +08:00
|
|
|
|
}
|
2023-09-11 10:25:40 +08:00
|
|
|
|
}
|
2023-01-08 09:22:37 +08:00
|
|
|
|
|
2023-01-25 23:55:30 +08:00
|
|
|
|
[CanDo]
|
2023-01-08 09:22:37 +08:00
|
|
|
|
public PointBase TopLeft
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-01-08 09:22:37 +08:00
|
|
|
|
return new PointBase(Left, Top);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Left = value.X;
|
|
|
|
|
|
Top = value.Y;
|
2023-07-23 17:40:44 +08:00
|
|
|
|
RaisePropertyChanged(nameof(TopLeft));
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-14 23:26:08 +08:00
|
|
|
|
public PointBase RightBottom
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
return new Point(Left + GetItemWidth(), Top + GetItemHeight());
|
2023-05-14 23:26:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private double _angle;
|
|
|
|
|
|
[CanDo]
|
|
|
|
|
|
public double Angle
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _angle;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _angle, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double _scaleX = 1;
|
|
|
|
|
|
[CanDo]
|
|
|
|
|
|
public double ScaleX
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _scaleX;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _scaleX, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double _scaleY = 1;
|
|
|
|
|
|
[CanDo]
|
|
|
|
|
|
public double ScaleY
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _scaleY;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _scaleY, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double _margin;
|
|
|
|
|
|
|
|
|
|
|
|
public double Margin
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _margin;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _margin, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-01 19:28:06 +08:00
|
|
|
|
private CornerRadius _cornerRadius = new CornerRadius(3);
|
|
|
|
|
|
public CornerRadius CornerRadius
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _cornerRadius;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _cornerRadius, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Thickness _borderThickness = new Thickness(1);
|
|
|
|
|
|
public Thickness BorderThickness
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _borderThickness;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _borderThickness, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-14 00:31:25 +08:00
|
|
|
|
private double _minItemWidth;
|
|
|
|
|
|
public double MinItemWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _minItemWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _minItemWidth, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double _minItemHeight;
|
|
|
|
|
|
public double MinItemHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _minItemHeight;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _minItemHeight, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-11 23:58:22 +08:00
|
|
|
|
private double _actualItemWidth;
|
|
|
|
|
|
public double ActualItemWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _actualItemWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _actualItemWidth, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private double _actualItemHeight;
|
|
|
|
|
|
public double ActualItemHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _actualItemHeight;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
SetProperty(ref _actualItemHeight, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-12 22:58:24 +08:00
|
|
|
|
public double BeyondBoundary
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
} = -1;
|
|
|
|
|
|
|
2021-08-01 22:30:12 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 连接点是否可以按偏移自定义
|
|
|
|
|
|
/// </summary>
|
2023-01-25 23:55:30 +08:00
|
|
|
|
public bool IsInnerConnector
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
2021-08-01 22:30:12 +08:00
|
|
|
|
|
2023-01-25 23:55:30 +08:00
|
|
|
|
protected ObservableCollection<FullyCreatedConnectorInfo> connectors = new ObservableCollection<FullyCreatedConnectorInfo>();
|
2023-05-21 22:06:59 +08:00
|
|
|
|
public ObservableCollection<FullyCreatedConnectorInfo> Connectors
|
2023-01-25 23:55:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return connectors;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-12-21 19:51:50 +08:00
|
|
|
|
public List<FullyCreatedConnectorInfo> InputConnectors
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Connectors.Where(p => p.Orientation == ConnectorOrientation.Left || p.Orientation == ConnectorOrientation.Top).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<FullyCreatedConnectorInfo> OutputConnectors
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Connectors.Where(p => p.Orientation == ConnectorOrientation.Right || p.Orientation == ConnectorOrientation.Bottom).ToList();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
protected ObservableCollection<CinchMenuItem> menuOptions;
|
2023-01-25 23:55:30 +08:00
|
|
|
|
public IEnumerable<CinchMenuItem> MenuOptions
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return menuOptions;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
public bool ShowMenuOptions
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (MenuOptions == null || MenuOptions.Count() == 0)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
else
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IObservable<NotifyCollectionChangedEventArgs> WhenConnectorsChanged
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Observable
|
|
|
|
|
|
.FromEventPattern<NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>(
|
2023-05-21 22:06:59 +08:00
|
|
|
|
h => this.Connectors.CollectionChanged += h,
|
|
|
|
|
|
h => this.Connectors.CollectionChanged -= h)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
.Select(x => x.EventArgs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-23 15:43:44 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 方法
|
2021-07-23 09:42:22 +08:00
|
|
|
|
public void AddConnector(FullyCreatedConnectorInfo connector)
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
if (!Connectors.Contains(connector))
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Connectors.Add(connector);
|
2023-07-20 22:40:04 +08:00
|
|
|
|
if (!double.IsNaN(connector.ConnectorWidth))
|
|
|
|
|
|
ConnectorMargin = 0 - connector.ConnectorWidth / 2;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveConnector(FullyCreatedConnectorInfo connector)
|
|
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
if (Connectors.Contains(connector))
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Connectors.Remove(connector);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-23 22:44:15 +08:00
|
|
|
|
public virtual void ClearConnectors()
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-05-21 22:06:59 +08:00
|
|
|
|
Connectors.Clear();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetCellAlignment()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!(this is TextDesignerItemViewModel))
|
|
|
|
|
|
{
|
2023-05-11 19:14:39 +08:00
|
|
|
|
if (Root.DiagramOption.LayoutOption.CellHorizontalAlignment == CellHorizontalAlignment.Center)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
if (Root.DiagramOption.LayoutOption.GridCellSize.Width > this.GetItemWidth())
|
2021-08-01 22:30:12 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
this.Left = (int)(this.Left / Root.DiagramOption.LayoutOption.GridCellSize.Width) * Root.DiagramOption.LayoutOption.GridCellSize.Width + Root.DiagramOption.LayoutOption.GridMarginSize.Width + (Root.DiagramOption.LayoutOption.GridCellSize.Width - this.GetItemWidth()) / 2;
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-05-11 19:14:39 +08:00
|
|
|
|
else if (Root.DiagramOption.LayoutOption.CellHorizontalAlignment == CellHorizontalAlignment.Left)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-05-11 19:14:39 +08:00
|
|
|
|
this.Left = (int)(this.Left / Root.DiagramOption.LayoutOption.GridCellSize.Width) * Root.DiagramOption.LayoutOption.GridCellSize.Width + Root.DiagramOption.LayoutOption.GridMarginSize.Width;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-05-11 19:14:39 +08:00
|
|
|
|
else if (Root.DiagramOption.LayoutOption.CellHorizontalAlignment == CellHorizontalAlignment.Right)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
if (Root.DiagramOption.LayoutOption.GridCellSize.Width > this.GetItemWidth())
|
2021-08-01 22:30:12 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
this.Left = (int)(this.Left / Root.DiagramOption.LayoutOption.GridCellSize.Width) * Root.DiagramOption.LayoutOption.GridCellSize.Width + Root.DiagramOption.LayoutOption.GridMarginSize.Width + (Root.DiagramOption.LayoutOption.GridCellSize.Width - this.GetItemWidth());
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-11 19:14:39 +08:00
|
|
|
|
if (Root.DiagramOption.LayoutOption.CellVerticalAlignment == CellVerticalAlignment.Center)
|
2021-08-01 22:30:12 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
if (Root.DiagramOption.LayoutOption.GridCellSize.Height > this.GetItemHeight())
|
2021-08-01 22:30:12 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
this.Top = (int)(this.Top / Root.DiagramOption.LayoutOption.GridCellSize.Height) * Root.DiagramOption.LayoutOption.GridCellSize.Height + Root.DiagramOption.LayoutOption.GridMarginSize.Height + (Root.DiagramOption.LayoutOption.GridCellSize.Height - this.GetItemHeight()) / 2;
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-05-11 19:14:39 +08:00
|
|
|
|
else if (Root.DiagramOption.LayoutOption.CellVerticalAlignment == CellVerticalAlignment.Top)
|
2021-08-01 22:30:12 +08:00
|
|
|
|
{
|
2023-05-11 19:14:39 +08:00
|
|
|
|
this.Top = (int)(this.Top / Root.DiagramOption.LayoutOption.GridCellSize.Height) * Root.DiagramOption.LayoutOption.GridCellSize.Height + Root.DiagramOption.LayoutOption.GridMarginSize.Height;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-05-11 19:14:39 +08:00
|
|
|
|
else if (Root.DiagramOption.LayoutOption.CellVerticalAlignment == CellVerticalAlignment.Bottom)
|
2021-08-01 22:30:12 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
if (Root.DiagramOption.LayoutOption.GridCellSize.Height > this.GetItemHeight())
|
2021-08-01 22:30:12 +08:00
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
this.Top = (int)(this.Top / Root.DiagramOption.LayoutOption.GridCellSize.Height) * Root.DiagramOption.LayoutOption.GridCellSize.Height + Root.DiagramOption.LayoutOption.GridMarginSize.Height + (Root.DiagramOption.LayoutOption.GridCellSize.Height - this.GetItemHeight());
|
2021-08-01 22:30:12 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
2023-01-25 23:55:30 +08:00
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RaiseTopLeft()
|
|
|
|
|
|
{
|
2023-01-08 09:22:37 +08:00
|
|
|
|
this.RaisePropertyChanged(nameof(TopLeft), new PointBase(GetOldValue<double>(nameof(Left)), GetOldValue<double>(nameof(Top))), TopLeft);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RaiseItemWidthHeight()
|
|
|
|
|
|
{
|
2023-01-08 09:22:37 +08:00
|
|
|
|
this.RaisePropertyChanged(nameof(Size), new SizeBase(GetOldValue<double>(nameof(ItemWidth)), GetOldValue<double>(nameof(ItemHeight))), Size);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RaiseAngle()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.RaisePropertyChanged(nameof(Angle), GetOldValue<double>(nameof(Angle)), Angle);
|
|
|
|
|
|
}
|
2023-01-08 09:22:37 +08:00
|
|
|
|
|
2023-02-03 18:23:53 +08:00
|
|
|
|
public FullyCreatedConnectorInfo GetFullConnectorInfo(Guid connectorId, ConnectorOrientation connectorOrientation, double xRatio, double yRatio, bool isInnerPoint, bool isPortless)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isInnerPoint)
|
|
|
|
|
|
{
|
2023-09-11 10:25:40 +08:00
|
|
|
|
var connector = Connectors.FirstOrDefault(p => p.XRatio == xRatio && p.YRatio == yRatio);
|
|
|
|
|
|
if (connector == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
connector = Connectors.FirstOrDefault(p => p.Id == connectorId);
|
|
|
|
|
|
}
|
|
|
|
|
|
return connector;
|
2023-02-03 18:23:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
else if (isPortless)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.PortlessConnector;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (connectorOrientation)
|
|
|
|
|
|
{
|
|
|
|
|
|
case ConnectorOrientation.Left:
|
|
|
|
|
|
return this.LeftConnector;
|
|
|
|
|
|
case ConnectorOrientation.TopLeft:
|
|
|
|
|
|
return this.TopLeftConnector;
|
|
|
|
|
|
case ConnectorOrientation.Top:
|
|
|
|
|
|
return this.TopConnector;
|
|
|
|
|
|
case ConnectorOrientation.TopRight:
|
|
|
|
|
|
return this.TopRightConnector;
|
|
|
|
|
|
case ConnectorOrientation.Right:
|
|
|
|
|
|
return this.RightConnector;
|
|
|
|
|
|
case ConnectorOrientation.BottomRight:
|
|
|
|
|
|
return this.BottomRightConnector;
|
|
|
|
|
|
case ConnectorOrientation.Bottom:
|
|
|
|
|
|
return this.BottomConnector;
|
|
|
|
|
|
case ConnectorOrientation.BottomLeft:
|
|
|
|
|
|
return this.BottomLeftConnector;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
throw new InvalidOperationException(
|
|
|
|
|
|
string.Format("Found invalid persisted Connector Orientation for Connector Id: {0}", connectorId));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-08 09:22:37 +08:00
|
|
|
|
public RectangleBase GetBounds(bool includePorts = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!includePorts)
|
2023-01-12 23:02:53 +08:00
|
|
|
|
return new RectangleBase(Position, Size);
|
2023-01-08 09:22:37 +08:00
|
|
|
|
|
|
|
|
|
|
var leftPort = LeftConnector;
|
|
|
|
|
|
var topPort = TopConnector;
|
|
|
|
|
|
var rightPort = RightConnector;
|
|
|
|
|
|
var bottomPort = BottomConnector;
|
|
|
|
|
|
|
2023-01-25 23:55:30 +08:00
|
|
|
|
var left = leftPort == null ? Position.X : Math.Min(Position.X, leftPort.Position.X);
|
2023-01-15 20:27:39 +08:00
|
|
|
|
var top = topPort == null ? Position.Y : Math.Min(Position.Y, topPort.Position.Y);
|
2023-06-11 23:58:22 +08:00
|
|
|
|
var right = rightPort == null ? Position.X + GetItemWidth() :
|
|
|
|
|
|
Math.Max(rightPort.Position.X + rightPort.ConnectorWidth, Position.X + GetItemWidth());
|
2023-01-12 23:02:53 +08:00
|
|
|
|
var bottom = bottomPort == null ? Position.Y + ItemHeight :
|
2023-06-11 23:58:22 +08:00
|
|
|
|
Math.Max(bottomPort.Position.Y + bottomPort.ConnectorHeight, Position.Y + GetItemHeight());
|
2023-01-08 09:22:37 +08:00
|
|
|
|
|
2023-01-12 23:02:53 +08:00
|
|
|
|
return new RectangleBase(left, top, right, bottom, true);
|
2023-01-08 09:22:37 +08:00
|
|
|
|
}
|
2023-01-12 23:02:53 +08:00
|
|
|
|
|
2023-08-06 22:24:26 +08:00
|
|
|
|
public virtual double GetItemWidth()
|
2023-06-11 23:58:22 +08:00
|
|
|
|
{
|
2023-07-02 11:23:00 +08:00
|
|
|
|
return double.IsNaN(ItemWidth) ? Math.Max(ActualItemWidth, MinItemWidth) : ItemWidth;
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-06 22:24:26 +08:00
|
|
|
|
public virtual double GetItemHeight()
|
2023-06-11 23:58:22 +08:00
|
|
|
|
{
|
2023-07-02 11:23:00 +08:00
|
|
|
|
return double.IsNaN(ItemHeight) ? Math.Max(ActualItemHeight, MinItemHeight) : ItemHeight;
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-12 23:02:53 +08:00
|
|
|
|
public IShape GetShape() => ShapeDefiner(this);
|
2023-01-23 15:43:44 +08:00
|
|
|
|
|
2023-05-01 13:17:26 +08:00
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
2023-08-12 22:58:24 +08:00
|
|
|
|
return $"{ParentId}-{Id}-{Name}-{Text}-({Left},{Top},{ItemWidth},{ItemHeight})";
|
2023-05-01 13:17:26 +08:00
|
|
|
|
}
|
2023-01-23 15:43:44 +08:00
|
|
|
|
#endregion
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|