private void UserControl_MouseMove(object sender, MouseEventArgs e) { if (trackingMouseMove) { FrameworkElement element = sender as FrameworkElement; FlowNodePictureContainer fn = sender as FlowNodePictureContainer; try { OrdinaryNode sn = fn.currentPic as OrdinaryNode; if (sn != null && sn.picRect.Cursor == Cursors.SizeNWSE) { sn.picRect.Width += 1; sn.picRect.Height += 1; } else { element.Cursor = Cursors.Hand; if (e.GetPosition(null) == mousePosition) { return; } hadActualMove = true; double deltaV = e.GetPosition(null).Y - mousePosition.Y; double deltaH = e.GetPosition(null).X - mousePosition.X; double newTop = deltaV + Position.Y; double newLeft = deltaH + Position.X; double containerWidth = (double)this.Parent.GetValue(Canvas.WidthProperty); double containerHeight = (double)this.Parent.GetValue(Canvas.HeightProperty); if ((CenterPoint.X - sdPicture.PictureWidth / 2 < 2 && deltaH < 0) || (CenterPoint.Y - sdPicture.PictureHeight / 2 < 2 && deltaV < 0) ) { //超过流程容器的范围 } else { positionIsChange = true; this.SetValue(Canvas.TopProperty, newTop); this.SetValue(Canvas.LeftProperty, newLeft); Move(this, e); mousePosition = e.GetPosition(null); _container.MoveControlCollectionByDisplacement(deltaH, deltaV, this); _container.IsNeedSave = true; } } } catch { } } }
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { e.Handled = true; hadActualMove = false; if (_doubleClickTimer != null) { if (_doubleClickTimer.IsEnabled) { _doubleClickTimer.Stop(); _container.ShowFlowNodeSetting(this); } else { _doubleClickTimer.Start(); this.SetValue(Canvas.ZIndexProperty, _container.NextMaxIndex); FrameworkElement element = sender as FrameworkElement; FlowNodePictureContainer fn = sender as FlowNodePictureContainer; OrdinaryNode sn = fn.currentPic as OrdinaryNode; mousePosition = e.GetPosition(null); trackingMouseMove = true; if (null != element) { element.CaptureMouse(); if (sn != null && sn.picRect.Cursor == Cursors.SizeNWSE) { } else { element.Cursor = Cursors.Hand; } } } } }