mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-12 04:29:27 +08:00
Revert "Revert "block 可以拖拽到内部,还有少量问题待解决""
This reverts commit fcd7beb193.
This commit is contained in:
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ItemsContainerInfo : SelectableViewModelBase
|
||||
{
|
||||
public ItemsContainerInfo(BlockDesignerItemViewModel dataItem) : this(null, dataItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ItemsContainerInfo(IDiagramViewModel root, BlockDesignerItemViewModel dataItem) : base(root)
|
||||
{
|
||||
this.Parent = dataItem;
|
||||
}
|
||||
|
||||
public ItemsContainerInfo(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ItemsContainerInfo(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//public override SelectableItemBase GetSerializableObject()
|
||||
//{
|
||||
// return new ConnectorInfoItemBase(this);
|
||||
//}
|
||||
|
||||
protected override void Init(IDiagramViewModel root, bool initNew)
|
||||
{
|
||||
base.Init(root, initNew);
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
ColorViewModel = new ColorViewModel()
|
||||
{
|
||||
LineWidth = 1,
|
||||
LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) },
|
||||
FillColor = new ColorObject() { Color = Colors.Transparent },
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(designerbase);
|
||||
|
||||
//if (designerbase is ConnectorInfoItemBase designer)
|
||||
//{
|
||||
// PhysicalConnectorWidth = designer.PhysicalConnectorWidth;
|
||||
// PhysicalConnectorHeight = designer.PhysicalConnectorHeight;
|
||||
// Orientation = designer.Orientation;
|
||||
//}
|
||||
}
|
||||
|
||||
#region 属性
|
||||
private double _itemWidth = double.NaN;
|
||||
public double ItemWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return _itemWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= 0) return;
|
||||
SetProperty(ref _itemWidth, value);
|
||||
}
|
||||
}
|
||||
|
||||
private double _itemHeight = double.NaN;
|
||||
public double ItemHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return _itemHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value <= 0) return;
|
||||
SetProperty(ref _itemHeight, value);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//public PointBase Position
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// var offset = GetOffSetFunc?.Invoke() ?? new Point(0, 0);
|
||||
// return new PointBase(DataItem.Left + offset.X, DataItem.Top + offset.Y);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public PointBase MiddlePosition
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return new PointBase(Position.X + GetItemWidth() / 2, Position.Y + GetItemHeight() / 2);
|
||||
// }
|
||||
//}
|
||||
|
||||
public RectangleBase GetBounds()
|
||||
{
|
||||
var offset = GetOffSetFunc?.Invoke() ?? new Point(0, 0);
|
||||
|
||||
return new RectangleBase(DataItem.Left + offset.X, DataItem.Top + offset.Y, GetItemWidth(), GetItemHeight());
|
||||
}
|
||||
|
||||
public BlockDesignerItemViewModel DataItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return Parent as BlockDesignerItemViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<BlockDesignerItemViewModel> Children
|
||||
{
|
||||
get; set;
|
||||
} = new ObservableCollection<BlockDesignerItemViewModel>();
|
||||
|
||||
|
||||
private Func<Point> _getOffSetFunc;
|
||||
public Func<Point> GetOffSetFunc
|
||||
{
|
||||
get
|
||||
{
|
||||
return _getOffSetFunc;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _getOffSetFunc, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _beAttachTo;
|
||||
public bool BeAttachTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _beAttachTo;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _beAttachTo, value);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _disableAttachTo;
|
||||
public bool DisableAttachTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _disableAttachTo;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _disableAttachTo, value);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanAttachTo(DesignerItemViewModelBase item)
|
||||
=> item != null && item != this.DataItem && !item.IsReadOnly && item is BlockDesignerItemViewModel;
|
||||
#endregion
|
||||
|
||||
public double GetItemWidth()
|
||||
{
|
||||
return double.IsNaN(ItemWidth) ? ActualItemWidth : ItemWidth;
|
||||
}
|
||||
|
||||
public double GetItemHeight()
|
||||
{
|
||||
return double.IsNaN(ItemHeight) ? ActualItemHeight : ItemHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user