Ejemplo n.º 1
0
 /// <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);
 }
Ejemplo n.º 2
0
        /// <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);
              }
        }
Ejemplo n.º 3
0
        public void OnMouseDragEnd(MouseDragEventArgs mouseDragEventArgs)
        {
            var startPoint = _guiToRelativeCoordinateTransformer.TransformToRelative(mouseDragEventArgs.StartPosition);
            var endPoint   = _guiToRelativeCoordinateTransformer.TransformToRelative(mouseDragEventArgs.EndPosition);

            Camera.CommitRotation(startPoint, endPoint);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Dragedイベントを発生させる
 /// </summary>
 /// <param name="e">マウスドラッグイベントデータ</param>
 protected void OnDraged(MouseDragEventArgs e)
 {
     if (this.Draged != null)
     {
         this.Draged(this, e);
     }
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 private void OnMouseDrag(object sender, MouseDragEventArgs mouse)
 {
     foreach (UIElement child in Children)
     {
         if (child.OnMouseDrag(mouse) != null)
         {
             break;
         }
     }
 }
Ejemplo n.º 8
0
 /// <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);
 }
Ejemplo n.º 9
0
 /// <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);
 }
Ejemplo n.º 10
0
 /// <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);
     }
 }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
 /// <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();
 }
Ejemplo n.º 13
0
        public override UIElement OnMouseDrag(MouseDragEventArgs mouse)
        {
            if (mouse.Button == MouseButton.Left)
            {
                if (BodyCaught)
                {
                    MoveBy(mouse.CurrentPosition - mouse.PreviousPosition);
                    return(this);
                }
            }

            return(base.OnMouseDrag(mouse));
        }
Ejemplo n.º 14
0
        /// <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);
        }
Ejemplo n.º 15
0
        /// <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);
        }
Ejemplo n.º 16
0
        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;
            }
        }
Ejemplo n.º 17
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);
            }
        }
Ejemplo n.º 18
0
        /// <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);
        }
Ejemplo n.º 19
0
        /// <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);
            }
        }
Ejemplo n.º 20
0
        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;
            }
        }
Ejemplo n.º 21
0
 public override UIElement OnMouseDrag(MouseDragEventArgs mouse)
 {
     return(CheckIntercept(mouse.StartPosition));
 }
Ejemplo n.º 22
0
        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));
        }
Ejemplo n.º 23
0
 private void OnMouseDrag(object sender, MouseDragEventArgs args)
 {
     Camera -= (args.PreviousPosition - args.CurrentPosition).ToVector2();
 }
Ejemplo n.º 24
0
 /// <summary>
 /// ドラッグ中に実行される処理
 /// </summary>
 /// <param name="e">マウスドラッグイベントデータ</param>
 public override void Drag(MouseDragEventArgs e)
 {
     this.OnDraged(e);
 }
Ejemplo n.º 25
0
 /// <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);
 }
Ejemplo n.º 26
0
 public void OnMouseDrag(MouseDragEventArgs mouse)
 {
 }
Ejemplo n.º 27
0
 /// <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();
 }
Ejemplo n.º 28
0
 /// <summary>
 /// ドラッグ中に実行される処理
 /// </summary>
 /// <param name="e">マウスドラッグイベントデータ</param>
 public abstract void Drag(MouseDragEventArgs e);
Ejemplo n.º 29
0
 public abstract UIElement OnMouseDrag(MouseDragEventArgs mouse);
Ejemplo n.º 30
0
 /// <summary>
 /// ドラッグ中に実行される処理
 /// </summary>
 /// <param name="e">マウスドラッグイベントデータ</param>
 public override void Drag(MouseDragEventArgs e)
 {
     this.OnDraged(e);
 }
Ejemplo n.º 31
0
 public void OnMouseDrag(MouseDragEventArgs mouse)
 {
     Camera.MoveBy(mouse.PreviousPosition - mouse.CurrentPosition);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Dragedイベントを発生させる
 /// </summary>
 /// <param name="e">マウスドラッグイベントデータ</param>
 protected void OnDraged(MouseDragEventArgs e)
 {
     if (this.Draged != null)
     this.Draged(this, e);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// ドラッグ中に実行される処理
 /// </summary>
 /// <param name="e">マウスドラッグイベントデータ</param>
 public abstract void Drag(MouseDragEventArgs e);
Ejemplo n.º 34
0
 public override UIElement OnMouseDrag(MouseDragEventArgs mouse)
 {
     return(null);
 }