mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-18 07:26:36 +08:00
Revert "Revert "block 可以拖拽到内部,还有少量问题待解决""
This reverts commit fcd7beb193.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class BlockContainDesignerItemViewModel : BlockDesignerItemViewModel
|
||||
{
|
||||
public BlockContainDesignerItemViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public BlockContainDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public BlockContainDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public BlockContainDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
base.InitNew();
|
||||
|
||||
Contains.Add(new ItemsContainerInfo(this.Root, this));
|
||||
}
|
||||
|
||||
public override void AddChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
var oldchildren = FirstContain.Children.FirstOrDefault();
|
||||
if (oldchildren != null)
|
||||
{
|
||||
this.RemoveChild(oldchildren);
|
||||
}
|
||||
|
||||
Root.Items.Remove(child);
|
||||
FirstContain.Children.Add(child);
|
||||
|
||||
base.AddChild(child);
|
||||
}
|
||||
|
||||
public override void RemoveChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
Root.Items.Add(child);
|
||||
FirstContain.Children.Remove(child);
|
||||
|
||||
this.RemoveFromSelection();
|
||||
child.AddToSelection(true, false);
|
||||
|
||||
base.RemoveChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class BlockContainListDesignerItemViewModel : BlockDesignerItemViewModel
|
||||
{
|
||||
public BlockContainListDesignerItemViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public BlockContainListDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public BlockContainListDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public BlockContainListDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
base.InitNew();
|
||||
|
||||
Contains.Add(new ItemsContainerInfo(this.Root, this));
|
||||
}
|
||||
|
||||
public override void AddChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
Root.Items.Remove(child);
|
||||
FirstContain.Children.Add(child);
|
||||
|
||||
base.AddChild(child);
|
||||
}
|
||||
|
||||
public override void RemoveChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
Root.Items.Add(child);
|
||||
FirstContain.Children.Remove(child);
|
||||
|
||||
base.RemoveChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -27,28 +28,57 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
protected override void InitNew()
|
||||
{
|
||||
ItemWidth = double.NaN;
|
||||
ItemHeight = double.NaN;
|
||||
AddConnector(new BlockConnectorInfo(this.Root, this, ConnectorOrientation.Top));
|
||||
AddConnector(new BlockConnectorInfo(this.Root, this, ConnectorOrientation.Bottom));
|
||||
IsReadOnlyText = true;
|
||||
}
|
||||
|
||||
public BlockDesignerItemViewModel Next
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
|
||||
public void AddNext(BlockDesignerItemViewModel next)
|
||||
{
|
||||
this.ParentId = new Guid();
|
||||
this.Parent = null;
|
||||
next.Left = this.Left;
|
||||
next.Top = this.Top + this.ItemHeight;
|
||||
next.Top = this.Top + this.GetItemHeight();
|
||||
next.ParentId = this.Id;
|
||||
next.Parent = this;
|
||||
this.Next = next;
|
||||
if (next.Next != null)
|
||||
//if (oldnext != null)
|
||||
//{
|
||||
// next.AddNext(oldnext);
|
||||
//}
|
||||
}
|
||||
|
||||
public void RemoveNext()
|
||||
{
|
||||
var next = this.Next;
|
||||
if (next != null)
|
||||
{
|
||||
next.AddNext(next.Next);
|
||||
next.ParentId = new Guid();
|
||||
next.Parent = null;
|
||||
this.Next = null;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockDesignerItemViewModel GetLastNext()
|
||||
{
|
||||
var next = this.Next;
|
||||
if (next != null)
|
||||
{
|
||||
while (next.Next != null)
|
||||
{
|
||||
next = next.Next;
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
public override void AddToSelection(bool selected, bool clearother)
|
||||
{
|
||||
if (clearother)
|
||||
@@ -64,5 +94,31 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
IsSelected = selected;
|
||||
}
|
||||
|
||||
|
||||
public virtual void AddChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
child.RemoveFromSelection();
|
||||
this.AddToSelection(true, false);
|
||||
}
|
||||
|
||||
public virtual void RemoveChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
this.RemoveFromSelection();
|
||||
child.AddToSelection(true, false);
|
||||
}
|
||||
|
||||
public ObservableCollection<ItemsContainerInfo> Contains
|
||||
{
|
||||
get; set;
|
||||
} = new ObservableCollection<ItemsContainerInfo>();
|
||||
|
||||
public ItemsContainerInfo FirstContain
|
||||
{
|
||||
get
|
||||
{
|
||||
return Contains?.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,8 +115,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true);
|
||||
MouseButtonEventArgs mosueArg = ((EventToCommandArgs)parameter).EventArgs as MouseButtonEventArgs;
|
||||
var position = mosueArg.GetPosition(((EventToCommandArgs)parameter).Sender as IInputElement);
|
||||
connector.XRatio = (position.X - connector.ConnectorWidth / 2) / connector.DataItem.ItemWidth;
|
||||
connector.YRatio = (position.Y - connector.ConnectorHeight / 2) / connector.DataItem.ItemHeight;
|
||||
connector.XRatio = (position.X - connector.ConnectorWidth / 2) / connector.DataItem.GetItemWidth();
|
||||
connector.YRatio = (position.Y - connector.ConnectorHeight / 2) / connector.DataItem.GetItemHeight();
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user