/// <summary> /// ドラッグ中に実行される処理 /// </summary> /// <param name="e">マウスドラッグイベントデータ</param> public override void Drag(MouseDragEventArgs e) { this.IsDragging = true; Bounds = new Rectangle( e.StartLocation, (Size)e.Location - (Size)e.StartLocation); }
/// <summary> /// ドラッグ /// </summary> /// <param name="e">マウスドラッグイベント引数</param> public void Drag(MouseDragEventArgs e) { var act = Active as Shape; ResizeHandle activeHandle = null; if (act != null) activeHandle = act.ActiveHandle; if (activeHandle == null) { foreach (IDraggable draggable in this.Items) draggable.Drag(e); return; } var actAnchor = activeHandle.GetAnchor(); foreach (IDraggable draggable in this.Items) { var shape = draggable as Shape; if (shape == null) { continue; } shape.ActiveateHandle(activeHandle.Alignment); var anchor = shape.ActiveHandle.GetAnchor(); var delta = (Size)(anchor - (Size)actAnchor); var args = new MouseDragEventArgs(e.StartLocation + delta, e.LastLocation + delta, e.Location + delta); shape.Drag(args); } }
public void OnMouseDragEnd(MouseDragEventArgs mouseDragEventArgs) { var startPoint = _guiToRelativeCoordinateTransformer.TransformToRelative(mouseDragEventArgs.StartPosition); var endPoint = _guiToRelativeCoordinateTransformer.TransformToRelative(mouseDragEventArgs.EndPosition); Camera.CommitRotation(startPoint, endPoint); }
/// <summary> /// Dragedイベントを発生させる /// </summary> /// <param name="e">マウスドラッグイベントデータ</param> protected void OnDraged(MouseDragEventArgs e) { if (this.Draged != null) { this.Draged(this, e); } }
public override UIElement OnMouseDrag(MouseDragEventArgs mouse) { UIElement intercept; foreach (UIElement child in Children) if ((intercept = child.OnMouseDrag(mouse)) != null) return intercept; return base.OnMouseDrag(mouse); }
private void OnMouseDrag(object sender, MouseDragEventArgs mouse) { foreach (UIElement child in Children) { if (child.OnMouseDrag(mouse) != null) { break; } } }
/// <summary> /// ドラッグ処理 /// </summary> /// <param name="e">マウスドラッグイベントデータ</param> public override void Drag(MouseDragEventArgs e) { this.IsDragging = true; if (this.ActiveHandle != null) { this.ActiveHandle.Drag(e); return; } this.SetBounds(Bounds.Location + (Size)e.Location - (Size)e.LastLocation, Bounds.Size); }
/// <summary> /// Performs the mouse drag event. /// If the <see cref="Line"/> <see cref="Shape"/> is previously created, update the destination /// <see cref="Pseudo.Port"/> to the position of mouse; else, do nothing. /// </summary> /// <param name="sender">The <seealso cref="object"/> which triggers the event.</param> /// <param name="e">The <seealso cref="EventArgs"/> containing information of mouse.</param> /// <seealso cref="Mode.OnMouseDrag"/> public override void OnMouseDrag(object sender, MouseDragEventArgs e) { if (Shape != null) { int ofx = e.OffsetX; //Store displacements int ofy = e.OffsetY; TargetPort.Move(ofx, ofy); //Update target port to current position of mouse Shape.SetPort(1, TargetPort); base.OnMouseDrag(sender, e); } }
public override UIElement OnMouseDrag(MouseDragEventArgs mouse) { UIElement intercept = base.OnMouseDrag(mouse); if (intercept == this) { View.OnMouseDrag(new MouseDragEventArgs(mouse.Button, mouse.CurrentPosition - Position, mouse.PreviousPosition - Position, mouse.StartPosition - Position, mouse.HeldKeys)); } return(intercept); }
/// <summary> /// Creates a <see cref="Canvas"/> instance. /// </summary> private Canvas() { Dock = DockStyle.Fill; BackColor = Color.Black; BorderStyle = BorderStyle.None; DoubleBuffered = true; Paint += Repaint; _currentMode = null; _dragEventArgs = null; _pressed = false; _shapes = new List <Shape>(); InitializeMouseEvents(); }
public override UIElement OnMouseDrag(MouseDragEventArgs mouse) { if (mouse.Button == MouseButton.Left) { if (BodyCaught) { MoveBy(mouse.CurrentPosition - mouse.PreviousPosition); return(this); } } return(base.OnMouseDrag(mouse)); }
/// <summary> /// Handles the mouse down event and triggers the corresponding <see cref="Mode"/>. /// </summary> /// <param name="sender">The <seealso cref="object"/> which triggers the event.</param> /// <param name="e">The <seealso cref="EventArgs"/> containing information of mouse.</param> /// <remarks>Also initializes the customized mouse drag event.</remarks> public void OnMouseDown(object sender, MouseEventArgs e) { if (e.Button.Equals(MouseButtons.Right)) { return; } // Customized mouse drag event. _dragEventArgs = new MouseDragEventArgs(e.Button, e.Clicks, e.X, e.Y, 0, 0, e.Delta); _pressed = true; Debug.Assert(_currentMode != null); _currentMode.OnMouseDown(sender, e); }
/// <summary> /// Handles the mouse up event and triggers the corresponding <see cref="Mode"/>. /// </summary> /// <param name="sender">The <seealso cref="object"/> which triggers the event.</param> /// <param name="e">The <seealso cref="EventArgs"/> containing information of mouse.</param> /// <remarks>Also finishes the mouse drag event.</remarks> public void OnMouseUp(object sender, MouseEventArgs e) { // Customized mouse drag event. _pressed = false; _dragEventArgs = null; Debug.Assert(_currentMode != null); if (e.Button.Equals(MouseButtons.Right)) { return; } _currentMode.OnMouseUp(sender, e); }
public void OnMouseDrag(MouseDragEventArgs mouse) { if (mouse.Button == MouseButton.Right) { Camera += mouse.DeltaToPrevious.ToVector2() / Zoom; } if (Camera.X < 0) { Camera.X = 0; } if (Camera.Y < 0) { Camera.Y = 0; } }
/// <summary> /// Handles the mouse move event and triggers the corresponding <see cref="Mode"/>. /// </summary> /// <param name="sender">The <seealso cref="object"/> which triggers the event.</param> /// <param name="e">The <seealso cref="EventArgs"/> containing information of mouse.</param> /// <remarks> /// If the <see cref="_pressed"/> is <code>true</code>, customized <see cref="OnMouseDrag"/> /// event handler will be fired, customized <see cref="MouseEventArgs"/> containing mouse /// drag information will be generated and passed to the <see cref="OnMouseDrag"/> handler. /// </remarks> public void OnMouseMove(object sender, MouseEventArgs e) { Debug.Assert(_currentMode != null); if (_pressed) { // Customized mouse drag event. int offsetX = e.X - _dragEventArgs.X; int offsetY = e.Y - _dragEventArgs.Y; _dragEventArgs = new MouseDragEventArgs(e.Button, e.Clicks, e.X, e.Y, offsetX, offsetY, e.Delta); _currentMode.OnMouseDrag(sender, _dragEventArgs); } else { _currentMode.OnMouseMove(sender, e); } }
/// <summary> /// Performs the mouse drag event. /// If there is any selected <see cref="Shape"/>, move selected <see cref="Shape"/> by /// the offset information provided in the <see cref="MouseDragEventArgs"/>; otherwise, /// Updates the location and size of created <see cref="SelectedArea"/>. /// </summary> /// <remarks>Also updates the position of <see cref="_currentMousePoint"/>.</remarks> /// <param name="sender">The <seealso cref="object"/> which triggers the event.</param> /// <param name="e">The <seealso cref="EventArgs"/> containing information of mouse.</param> /// <seealso cref="Mode.OnMouseDrag"/> public override void OnMouseDrag(object sender, MouseDragEventArgs e) { if (_hasSelectArea) { //No shape selected means formed a selected area _currentMousePoint.X = e.X; _currentMousePoint.Y = e.Y; UpdateSelectedArea(Shape); } else { foreach (Shape shape in Canvas.SelectedShapes) { shape.Move(e.OffsetX, e.OffsetY); } } base.OnMouseDrag(sender, e); }
/// <summary> /// ドラッグ /// </summary> /// <param name="e">マウスドラッグイベント引数</param> public void Drag(MouseDragEventArgs e) { var act = Active as Shape; ResizeHandle activeHandle = null; if (act != null) { activeHandle = act.ActiveHandle; } if (activeHandle == null) { foreach (IDraggable draggable in this.Items) { draggable.Drag(e); } return; } var actAnchor = activeHandle.GetAnchor(); foreach (IDraggable draggable in this.Items) { var shape = draggable as Shape; if (shape == null) { continue; } shape.ActiveateHandle(activeHandle.Alignment); var anchor = shape.ActiveHandle.GetAnchor(); var delta = (Size)(anchor - (Size)actAnchor); var args = new MouseDragEventArgs(e.StartLocation + delta, e.LastLocation + delta, e.Location + delta); shape.Drag(args); } }
public void OnMouseDrag(MouseDragEventArgs mouse) { switch (mouse.Button) { case MouseButton.Left: if (Map.ActiveMode == ShipDesignerMap.Mode.Build) { Ship.AddModule(SelectedModule, GridPosition, Map.ModuleRotation); } break; case MouseButton.Right: if (Map.ActiveMode == ShipDesignerMap.Mode.Build) { Ship.RemoveModule(GridPosition); } //Camera.MoveBy(mouse.DeltaToStart.ToVector2() / 16f); break; case MouseButton.Middle: //Camera.MoveBy(mouse.DeltaFromPrevious.ToVector2()); break; } }
public override UIElement OnMouseDrag(MouseDragEventArgs mouse) { return(CheckIntercept(mouse.StartPosition)); }
public override UIElement OnMouseDrag(MouseDragEventArgs mouse) { if (mouse.Button == MouseButton.Left) { switch (EdgeCaught) { /*case Edge.Body: * { * MoveBy(mousePosition - previousPosition); * break; * }*/ case Edge.TopLeft: { int bottomY = Y + Height; int newY = Math.Min(mouse.CurrentPosition.Y, bottomY - Sprite.MinimumHeight); int newHeight = bottomY - newY; int rightX = X + Width; int newX = Math.Min(mouse.CurrentPosition.X, rightX - Sprite.MinimumWidth); int newWidth = rightX - newX; ResizeTo(newX, newY, newWidth, newHeight); break; } case Edge.Top: { int bottomY = Y + Height; int newY = Math.Min(mouse.CurrentPosition.Y, bottomY - Sprite.MinimumHeight); int newHeight = bottomY - newY; ResizeTo(X, newY, Width, newHeight); break; } case Edge.TopRight: { int bottomX = Y + Height; int newY = Math.Min(mouse.CurrentPosition.Y, bottomX - Sprite.MinimumHeight); int newHeight = bottomX - newY; int newWidth = Math.Max(mouse.CurrentPosition.X - X, Sprite.MinimumWidth); ResizeTo(X, newY, newWidth, newHeight); break; } case Edge.Left: { int rightX = X + Width; int newX = Math.Min(mouse.CurrentPosition.X, rightX - Sprite.MinimumWidth); int newWidth = rightX - newX; ResizeTo(newX, Y, newWidth, Height); break; } case Edge.Right: { int newWidth = Math.Max(mouse.CurrentPosition.X - X, Sprite.MinimumWidth); ResizeTo(X, Y, newWidth, Height); break; } case Edge.BottomLeft: { int rightX = X + Width; int newX = Math.Min(mouse.CurrentPosition.X, rightX - Sprite.MinimumWidth); int newWidth = rightX - newX; int newHeight = Math.Max(mouse.CurrentPosition.Y - Y, Sprite.MinimumHeight); ResizeTo(newX, Y, newWidth, newHeight); break; } case Edge.Bottom: { int newHeight = Math.Max(mouse.CurrentPosition.Y - Y, Sprite.MinimumHeight); ResizeTo(X, Y, Width, newHeight); break; } case Edge.BottomRight: { int newWidth = Math.Max(mouse.CurrentPosition.X - X, Sprite.MinimumWidth); int newHeight = Math.Max(mouse.CurrentPosition.Y - Y, Sprite.MinimumHeight); ResizeTo(X, Y, newWidth, newHeight); break; } } if (EdgeCaught != Edge.None) { return(this); } } return(base.OnMouseDrag(mouse)); }
private void OnMouseDrag(object sender, MouseDragEventArgs args) { Camera -= (args.PreviousPosition - args.CurrentPosition).ToVector2(); }
/// <summary> /// ドラッグ中に実行される処理 /// </summary> /// <param name="e">マウスドラッグイベントデータ</param> public override void Drag(MouseDragEventArgs e) { this.OnDraged(e); }
/// <summary> /// Handles the mouse drag event and triggers the corresponding <see cref="Mode"/>. /// </summary> /// <param name="sender">The <seealso cref="object"/> which triggers the event.</param> /// <param name="e">The <seealso cref="EventArgs"/> containing information of mouse.</param> /// <remarks>Customized mouse drag event.</remarks> public void OnMouseDrag(object sender, MouseDragEventArgs e) { _currentMode.OnMouseDrag(sender, e); }
public void OnMouseDrag(MouseDragEventArgs mouse) { }
/// <summary> /// Performs the mouse drag event. /// </summary> /// <param name="sender">The <seealso cref="object"/> which triggers the event.</param> /// <param name="e">The <seealso cref="EventArgs"/> containing information of mouse.</param> /// <remarks>Base handler.</remarks> public virtual void OnMouseDrag(object sender, MouseDragEventArgs e) { Canvas.Invalidate(); }
/// <summary> /// ドラッグ中に実行される処理 /// </summary> /// <param name="e">マウスドラッグイベントデータ</param> public abstract void Drag(MouseDragEventArgs e);
public abstract UIElement OnMouseDrag(MouseDragEventArgs mouse);
public void OnMouseDrag(MouseDragEventArgs mouse) { Camera.MoveBy(mouse.PreviousPosition - mouse.CurrentPosition); }
/// <summary> /// Dragedイベントを発生させる /// </summary> /// <param name="e">マウスドラッグイベントデータ</param> protected void OnDraged(MouseDragEventArgs e) { if (this.Draged != null) this.Draged(this, e); }
public override UIElement OnMouseDrag(MouseDragEventArgs mouse) { return(null); }