12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Controls;
- using System.Windows.Media.Effects;
- using System.Windows.Media;
- using System.Windows.Shapes;
- using System.Windows;
- namespace FlowChartModule.绘制模块
- {
- public class Connection_Point
- {
- Canvas _canvas;
- public Point _point;
- public static bool _isMouseDown=false;
- public bool isMouseDown=false;
- public List<Connection_Line> _connection_Lines ;
- public Ellipse ellipse = new Ellipse();
- public Connection_Point(Point point, Canvas canvas, List<Connection_Line> connection_Lines)
- {
- _connection_Lines = connection_Lines;
- _canvas=canvas;
- // 创建一个 Ellipse 元素
-
- ellipse.Width = 12;
- ellipse.Height = 12;
- ellipse.Fill = Brushes.Transparent;
- ellipse.StrokeThickness = 2;
- ellipse.Stroke= Brushes.Transparent;
- ellipse.MouseLeftButtonDown += Ellipse_MouseLeftButtonDown;
- ellipse.MouseLeftButtonUp += Ellipse_MouseLeftButtonUp;
- ellipse.MouseEnter += Ellipse_MouseEnter;
- ellipse.MouseLeave += Ellipse_MouseLeave;
- // 设置 Ellipse 元素在 Canvas 中的位置
- Canvas.SetLeft(ellipse, point.X);
- Canvas.SetTop(ellipse, point.Y);
- // 将 Ellipse 元素添加到 Canvas 中
- canvas.Children.Add(ellipse);
- }
- private void Ellipse_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
- {
- _canvas.Children.Remove(ellipse);
- ellipse.Stroke = Brushes.Transparent;
- _canvas.Children.Add(ellipse);
- }
- private void Ellipse_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
- {
- _canvas.Children.Remove(ellipse);
- ellipse.Fill = Brushes.Green;
- ellipse.Stroke = Brushes.White;
- _canvas.Children.Add(ellipse);
-
- }
- private void Ellipse_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
-
- isMouseDown = false;
- // ((Ellipse) sender).ReleaseMouseCapture();
- }
- private void Ellipse_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- _isMouseDown = true;
- isMouseDown = true;
- //( ( Ellipse ) sender ).CaptureMouse();
- }
- }
- }
|