mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-07 09:46:37 +08:00
整理一下项目文件
This commit is contained in:
40
AIStudio.Wpf.DiagramDesigner/Controls/Connector.cs
Normal file
40
AIStudio.Wpf.DiagramDesigner/Controls/Connector.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class Connector : Control
|
||||
{
|
||||
|
||||
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseLeftButtonDown(e);
|
||||
DesignerCanvas canvas = GetDesignerCanvas(this);
|
||||
if (canvas != null)
|
||||
{
|
||||
canvas.SourceConnector = this;
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectorOrientation Orientation { get; set; }
|
||||
|
||||
// iterate through visual tree to get parent DesignerCanvas
|
||||
private DesignerCanvas GetDesignerCanvas(DependencyObject element)
|
||||
{
|
||||
while (element != null && !(element is DesignerCanvas))
|
||||
element = VisualTreeHelper.GetParent(element);
|
||||
|
||||
return element as DesignerCanvas;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user