void print_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { isMove = false; IsActivity = false; //e.Handled = false; FrameworkElement element = sender as FrameworkElement; element.ReleaseMouseCapture(); if (_newLine == null) { return; } Point p = e.GetPosition(print); if (p == _newLine.StartPoint) { RemoveArrowLine(_newLine); } else { //-->如果当前的箭头,所连接的控件,与移动进去的控件不是同一控件的话。 foreach (var v in DictControls) { IActivity iact = v.Value as IActivity; if (null == iact) { continue; } //-->获取当前控件的 double top = Canvas.GetTop(v.Value); double left = Canvas.GetLeft(v.Value); //-->判断当前的箭头进入Activity控件区域 if ((p.X >= left && p.X <= (left + v.Value.Width)) && (p.Y >= top && p.Y <= (top + v.Value.Height))) { //-->判断当前的箭头是否可以连接到Activity控件上去。 if (!iact.IsConnection()) { MessageBox.Show("不能连接"); RemoveArrowLine(_newLine); continue; } //-->当前线的尾部控件与当前进入的控件相同,不进行操作 if (null != _newLine.ArrowFootControl && _newLine.ArrowFootControl.Equals(v.Value)) { continue; } IActivity arrowFoot = _newLine.ArrowFootControl as IActivity; if (arrowFoot != null && arrowFoot.CheckedArrowIsExists(iact)) { MessageBox.Show("已经存在相同的线了"); RemoveArrowLine(_newLine); continue; } string _point = string.Format("X_{0}_Y_{1}", _newLine.StartPoint.X, _newLine.StartPoint.Y); if (!iact.DictArrowFootPoint.ContainsKey(_newLine.Name)) { iact.DictArrowCapPoint.Add(_newLine.Name, _newLine); _newLine.ArrowCapControl = v.Value; } break; } } } _newLine = null; }