protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) { this.rubberbandSelectionStartPoint = null; } // ... but if mouse button is pressed and start // point value is set we do have one if (this.rubberbandSelectionStartPoint.HasValue) { // create rubberband adorner AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, rubberbandSelectionStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } } e.Handled = true; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) this.rubberbandSelectionStartPoint = null; // ... but if mouse button is pressed and start // point value is set we do have one if (this.rubberbandSelectionStartPoint.HasValue) { // create rubberband adorner AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, rubberbandSelectionStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } } e.Handled = true; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) { this._rubberbandSelectionStartPoint = null; } if (this._rubberbandSelectionStartPoint.HasValue) { // create rubberband adorner AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, _rubberbandSelectionStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } } if (e.MiddleButton != MouseButtonState.Pressed) { this._canvasDraggingStartPoint = null; } if (this._canvasDraggingStartPoint.HasValue) { Point mousePosition = Mouse.GetPosition(parent); double newVerticalOffset = parent.VerticalOffset + (_canvasDraggingStartPoint.Value.Y - mousePosition.Y); double newHorizontalOffset = parent.HorizontalOffset + (_canvasDraggingStartPoint.Value.X - mousePosition.X); _canvasDraggingStartPoint = Mouse.GetPosition(parent); parent.ScrollToHorizontalOffset(newHorizontalOffset); parent.ScrollToVerticalOffset(newVerticalOffset); } e.Handled = true; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (SourceConnector != null) { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPoint = e.GetPosition(this); partialConnection.SinkConnectorInfo = new PartCreatedConnectionInfo(currentPoint); HitTesting(currentPoint); } } else { // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) { rubberbandSelectionStartPoint = null; } // ... but if mouse button is pressed and start // point value is set we do have one if (this.rubberbandSelectionStartPoint.HasValue) { // create rubberband adorner AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, rubberbandSelectionStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } } } e.Handled = true; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.LeftButton != MouseButtonState.Pressed) { this.dragStartPoint = null; } if (this.dragStartPoint.HasValue) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, this.dragStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } e.Handled = true; } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (SourceConnector != null) { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPoint = e.GetPosition(this); partialConnection.SinkConnectorInfo = new PartCreatedConnectionInfo(currentPoint); HitTesting(currentPoint); } } else { // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) { rubberbandSelectionStartPoint = null; initialDragPoint = null; } if (this.initialDragPoint.HasValue && this.DataContext is DesignerItemViewModelBase) { Mouse.SetCursor(Cursors.SizeAll); DesignerItemViewModelBase item = (DesignerItemViewModelBase)this.DataContext; double minLeft = double.MaxValue; double minTop = double.MaxValue; Point currentPoint = e.GetPosition(this); IDiagramViewModel designerCanvas = item.Parent as IDiagramViewModel; Rect rekt = PointHelper.GetBoundingRectangle(designerCanvas.Items, 10); double left = item.Left; double top = item.Top; minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft); minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop); double deltaHorizontal = Math.Max(-minLeft, currentPoint.X - initialDragPoint.Value.X); double deltaVertical = Math.Max(-minTop, currentPoint.Y - initialDragPoint.Value.Y); item.Left += deltaHorizontal; item.Top += deltaVertical; if (item.Parent is IDiagramViewModel && item.Parent is DesignerItemViewModelBase) { DesignerItemViewModelBase groupItem = (DesignerItemViewModelBase)item.Parent; if (item.Left + item.ItemWidth >= groupItem.ItemWidth) { item.Left = groupItem.ItemWidth - item.ItemWidth; } if (item.Top + item.ItemHeight >= groupItem.ItemHeight) { item.Top = groupItem.ItemHeight - item.ItemHeight; } } e.Handled = true; } else { // ... but if mouse button is pressed and start // point value is set we do have one if (this.rubberbandSelectionStartPoint.HasValue) { // create rubberband adorner AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, rubberbandSelectionStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } } } } e.Handled = true; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if(SourceConnector != null) { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPoint = e.GetPosition(this); partialConnection.SinkConnectorInfo = new PartCreatedConnectionInfo(currentPoint); HitTesting(currentPoint); } } else { // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) rubberbandSelectionStartPoint = null; // ... but if mouse button is pressed and start // point value is set we do have one if (this.rubberbandSelectionStartPoint.HasValue) { // create rubberband adorner AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { RubberbandAdorner adorner = new RubberbandAdorner(this, rubberbandSelectionStartPoint); if (adorner != null) { adornerLayer.Add(adorner); } } } } e.Handled = true; }