mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-08 10:16:36 +08:00
修复demo中彩色节点的bug
This commit is contained in:
@@ -41,36 +41,56 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private Point? rubberbandSelectionStartPoint = null;
|
||||
|
||||
private Connector sourceConnector;
|
||||
private Connector _sourceConnector;
|
||||
public Connector SourceConnector
|
||||
{
|
||||
get
|
||||
{
|
||||
return sourceConnector;
|
||||
return _sourceConnector;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (sourceConnector != value)
|
||||
if (_sourceConnector != value)
|
||||
{
|
||||
sourceConnector = value;
|
||||
_sourceConnector = value;
|
||||
if (_sourceConnector != null)
|
||||
{
|
||||
ConnectorInfoBase sourceDataItem = _sourceConnector.Info;
|
||||
|
||||
ConnectorInfoBase sourceDataItem = sourceConnector.Info;
|
||||
//Rect rectangleBounds = _sourceConnector.TransformToVisual(this).TransformBounds(new Rect(_sourceConnector.RenderSize));
|
||||
//Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
||||
// rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
||||
|
||||
//Rect rectangleBounds = sourceConnector.TransformToVisual(this).TransformBounds(new Rect(sourceConnector.RenderSize));
|
||||
//Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
||||
// rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
||||
Point point = sourceDataItem.MiddlePosition;
|
||||
|
||||
Point point = sourceDataItem.MiddlePosition;
|
||||
partialConnection = new ConnectionViewModel(_viewModel, sourceDataItem, new PartCreatedConnectorInfo(point.X, point.Y), DrawMode, RouterMode);
|
||||
|
||||
partialConnection = new ConnectionViewModel(_viewModel, sourceDataItem, new PartCreatedConnectorInfo(point.X, point.Y), DrawMode, RouterMode);
|
||||
|
||||
_viewModel.Add(partialConnection);
|
||||
partialConnection.ZIndex = -1;
|
||||
_viewModel.Add(partialConnection);
|
||||
partialConnection.ZIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Connector sinkConnector;
|
||||
private Connector _sinkConnector;
|
||||
public Connector SinkConnector
|
||||
{
|
||||
get
|
||||
{
|
||||
return _sinkConnector;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_sinkConnector != null)
|
||||
{
|
||||
_sinkConnector.Info.DisableAttachTo = false;
|
||||
}
|
||||
if (_sinkConnector != value)
|
||||
{
|
||||
_sinkConnector = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DrawMode DrawMode
|
||||
{
|
||||
@@ -406,7 +426,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
partialConnection.SinkConnectorInfo = new PartCreatedConnectorInfo(currentPoint.X, currentPoint.Y);
|
||||
sinkConnector = HitTesting(currentPoint);
|
||||
|
||||
SinkConnector = HitTesting(currentPoint);
|
||||
if (SinkConnector?.Info?.CanAttachTo(SourceConnector?.Info) == false)
|
||||
{
|
||||
SinkConnector.Info.DisableAttachTo = true;
|
||||
}
|
||||
|
||||
if (EnableSnapping)
|
||||
{
|
||||
@@ -452,12 +477,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
Mediator.Instance.NotifyColleagues<bool>("DoneDrawingMessage", true);
|
||||
|
||||
if (sourceConnector != null)
|
||||
if (SourceConnector != null)
|
||||
{
|
||||
ConnectorInfoBase sourceDataItem = sourceConnector.Info;
|
||||
if (sinkConnector != null)
|
||||
ConnectorInfoBase sourceDataItem = SourceConnector.Info;
|
||||
if (SinkConnector != null && SinkConnector.Info?.DisableAttachTo == false)
|
||||
{
|
||||
ConnectorInfoBase sinkDataItem = sinkConnector.Info;
|
||||
ConnectorInfoBase sinkDataItem = SinkConnector.Info;
|
||||
|
||||
_viewModel.Remove(partialConnection);
|
||||
_viewModel.AddItemCommand.Execute(new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode));
|
||||
@@ -481,8 +506,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
sourceConnector = null;
|
||||
sinkConnector = null;
|
||||
SourceConnector = null;
|
||||
SinkConnector = null;
|
||||
partialConnection = null;
|
||||
|
||||
if (_service.DrawModeViewModel.GetDrawMode() != DrawMode.DirectLine)
|
||||
|
||||
Reference in New Issue
Block a user