コード例 #1
0
        /// <summary>
        /// Pass mouse move to appropriate item
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseMove(VCItem sender, ItemMouseEventArgs e)
        {
            if (enabled || IsSelecting)
            {
                e.Cursor = Cursors.Cross;

                if (IsSelecting)
                {
                    // Record position
                    selEnd = SnapPoint(LimitMoveToPosition(e.Location));

                    // Redraw selection box
                    container.Invalidate();
                }
                else
                {
                    // Record position
                    selStart = selEnd = SnapPoint(LimitMoveToPosition(e.Location));

                    // Redraw selection box
                    container.Invalidate();
                }

                return(true);
            }
            else
            {
                return(base.OnMouseMove(sender, e));
            }
        }
コード例 #2
0
        /// <summary>
        /// End of selection
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseUp(VCItem sender, ItemMouseEventArgs e)
        {
            if (enabled || IsSelecting)
            {
                if (IsSelecting)
                {
                    IsSelecting = false;
                    container.Invalidate();

                    if (RectangleSelected != null)
                    {
                        var bounds = SelectionBounds;
                        if (!bounds.IsEmpty)
                        {
                            RectangleSelected(this, new RectangleEventArgs(bounds.Round()));
                        }
                    }
                }

                return(true);
            }
            else
            {
                return(base.OnMouseUp(sender, e));
            }
        }
コード例 #3
0
        /// <summary>
        /// Pass mouse up to appropriate item
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseUp(VCItem sender, ItemMouseEventArgs e)
        {
            var pt = e.Location;

            if (mouseDownPlacement != null)
            {
                try
                {
                    var localPt = mouseDownPlacement.ToLocal(pt);
                    return(mouseDownPlacement.Item.OnMouseUp(new ItemMouseEventArgs(e, localPt.X, localPt.Y)));
                }
                finally
                {
                    mouseDownPlacement = null;
                }
            }
            else
            {
                VCItemPlacement placement = null;
                while ((placement = container.Items.Find(pt, placement)) != null)
                {
                    var localPt = placement.ToLocal(pt);
                    if (placement.Item.OnMouseUp(new ItemMouseEventArgs(e, localPt.X, localPt.Y)))
                    {
                        return(true);
                    }
                }
                return(base.OnMouseUp(sender, e));
            }
        }
コード例 #4
0
 /// <summary>
 /// Mouse move within this item
 /// </summary>
 /// <param name="e"></param>
 /// <returns>True if the event was handled, false otherwise.</returns>
 public virtual bool OnMouseMove(VCItem sender, ItemMouseEventArgs e)
 {
     if (next != null)
     {
         return(next.OnMouseMove(sender, e));
     }
     return(false);
 }
コード例 #5
0
 /// <summary>
 /// End of selection
 /// </summary>
 public override bool OnMouseUp(VCItem sender, ItemMouseEventArgs e)
 {
     if (manager.IsSelecting)
     {
         manager.Stop();
         return(true);
     }
     return(base.OnMouseUp(sender, e));
 }
コード例 #6
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public ItemMouseEventArgs(ItemMouseEventArgs source, float x, float y)
 {
     Button           = source.Button;
     Clicks           = source.Clicks;
     Delta            = source.Delta;
     X                = x;
     Y                = y;
     cursorController = source.cursorController;
 }
コード例 #7
0
ファイル: VCItem.cs プロジェクト: michaeloed/BinkyRailways
        /// <summary>
        /// Mouse move within this item
        /// </summary>
        /// <param name="e"></param>
        internal bool OnMouseMove(Handlers.ItemMouseEventArgs e)
        {
            bool result = false;

            if (mouseHandler != null)
            {
                result |= mouseHandler.OnMouseMove(this, e);
            }
            return(result);
        }
コード例 #8
0
 /// <summary>
 /// End of resize
 /// </summary>
 /// <param name="e"></param>
 public override bool OnMouseUp(VCItem sender, ItemMouseEventArgs e)
 {
     if (resizing)
     {
         resizing = false;
         return(true);
     }
     else
     {
         return(base.OnMouseUp(sender, e));
     }
 }
コード例 #9
0
        /// <summary>
        /// Mouse button up
        /// </summary>
        public override bool OnMouseUp(VCItem sender, ItemMouseEventArgs e)
        {
            if (zooming)
            {
                zooming = false;
                var location = ZoomLayer.Local2Global(e.Location);
                ContainsMouse = zoomArea.Contains(location);
                ZoomLayer.Invalidate();
                return(true);
            }

            return(base.OnMouseUp(sender, e));
        }
コード例 #10
0
        /// <summary>
        /// Handle mouse moves
        /// </summary>
        public override bool OnMouseMove(VCItem sender, ItemMouseEventArgs e)
        {
            var location = ZoomLayer.Local2Global(e.Location);

            if (zooming)
            {
                ZoomLayer.ZoomFactor = GetZoomFactor(zoomArea, location);
                return(true);
            }

            ContainsMouse = zoomArea.Contains(location);
            return(base.OnMouseMove(sender, e));
        }
コード例 #11
0
        /// <summary>
        /// Pass mouse down to appropriate item
        /// </summary>
        public override bool OnMouseDown(VCItem sender, ItemMouseEventArgs e)
        {
            var location = ZoomLayer.Local2Global(e.Location);

            if ((e.Button == MouseButtons.Left) && (zoomArea.Contains(location)))
            {
                zooming              = true;
                ContainsMouse        = true;
                ZoomLayer.ZoomFactor = GetZoomFactor(zoomArea, location);
                return(true);
            }
            return(base.OnMouseDown(sender, e));
        }
コード例 #12
0
        /// <summary>
        /// Pass mouse down to appropriate item
        /// </summary>
        public override bool OnMouseDown(VCItem sender, ItemMouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                // Pass event on
                return(base.OnMouseDown(sender, e));
            }

            var pt             = e.Location;
            var clearSelection = (Control.ModifierKeys == Keys.None);

            manager.Start(pt, clearSelection);
            return(true);
        }
コード例 #13
0
        /// <summary>
        /// Pass mouse move to appropriate item
        /// </summary>
        public override bool OnMouseMove(VCItem sender, ItemMouseEventArgs e)
        {
            if (!manager.IsSelecting || (e.Button != MouseButtons.Left))
            {
                return(base.OnMouseMove(sender, e));
            }

            // Record position
            var pt = e.Location;

            manager.Extend(pt);

            return(true);
        }
コード例 #14
0
        /// <summary>
        /// Pass mouse move to appropriate item
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseMove(VCItem sender, ItemMouseEventArgs e)
        {
            var pt = e.Location;

            if (mouseDownPlacement != null)
            {
                // Mouse button down, always send events to same placement
                var localPt = mouseDownPlacement.ToLocal(pt);
                return(mouseDownPlacement.Item.OnMouseMove(new ItemMouseEventArgs(e, localPt.X, localPt.Y)));
            }
            else
            {
                VCItemPlacement placement = container.Items.Find(pt, null);

                // Handle mouse leave
                if ((mouseOverPlacement != null) && (mouseOverPlacement != placement))
                {
                    mouseOverPlacement.Item.OnMouseLeave(EventArgs.Empty);
                    mouseOverPlacement = null;
                }

                while (placement != null)
                {
                    // Convert point to local
                    var localPt = placement.ToLocal(pt);

                    // Handle mouse enter
                    if (mouseOverPlacement == null)
                    {
                        mouseOverPlacement = placement;
                        mouseOverPlacement.Item.OnMouseEnter(EventArgs.Empty);
                    }

                    // Send mouse move
                    mouseOverPlacement = placement;
                    if (placement.Item.OnMouseMove(new ItemMouseEventArgs(e, localPt.X, localPt.Y)))
                    {
                        return(true);
                    }

                    placement = container.Items.Find(pt, placement);
                    if ((placement != mouseOverPlacement) && (placement != null))
                    {
                        mouseOverPlacement.Item.OnMouseLeave(EventArgs.Empty);
                        mouseOverPlacement = null;
                    }
                }
                return(base.OnMouseMove(sender, e));
            }
        }
コード例 #15
0
        /// <summary>
        /// End of move
        /// </summary>
        public override bool OnMouseUp(VCItem sender, ItemMouseEventArgs e)
        {
            if (movingPlacements == null)
            {
                return(base.OnMouseUp(sender, e));
            }

            foreach (var mPlacement in movingPlacements)
            {
                mPlacement.Commit(this);
            }
            movingPlacements = null;
            container.Invalidate();
            return(true);
        }
コード例 #16
0
        /// <summary>
        /// Pass mouse double click to appropriate item
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseDoubleClick(VCItem sender, ItemMouseEventArgs e)
        {
            var             pt        = e.Location;
            VCItemPlacement placement = null;

            while ((placement = container.Items.Find(pt, placement)) != null)
            {
                var localPt = placement.ToLocal(pt);
                if (placement.Item.OnMouseDoubleClick(new ItemMouseEventArgs(e, localPt.X, localPt.Y)))
                {
                    return(true);
                }
            }
            return(base.OnMouseDoubleClick(sender, e));
        }
コード例 #17
0
        /// <summary>
        /// Pass mouse move to appropriate item
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseMove(VCItem sender, ItemMouseEventArgs e)
        {
            var pt = e.Location;

            if (resizing)
            {
                var rect = CalcResizedBounds(startBounds, startMousePt, LimitMoveToPosition(pt), startSide);
                Resize(activePlacement, rect);
                container.Invalidate();
                return(true);
            }
            else if (e.Button == MouseButtons.None)
            {
                VCItemPlacement placement = Find(pt, null);

                // Can placement be resized?
                if ((placement != null) && (placement != activePlacement) && !CanResize(placement))
                {
                    // No, it cannot be resized
                    placement = null;
                }

                HitSide hitSide = HitSide.None;
                if ((placement != null) || (activePlacement != null))
                {
                    hitSide = CalcHitSide(placement, pt);
                    if (hitSide != HitSide.None)
                    {
                        e.Cursor = GetCursor(hitSide);
                    }
                }

                if (activePlacement != placement)
                {
                    activePlacement = placement;
                    container.Invalidate();
                }

                if (hitSide != HitSide.None)
                {
                    return(true);
                }
            }

            return(base.OnMouseMove(sender, e));
        }
コード例 #18
0
        /// <summary>
        /// Pass mouse down to appropriate item
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseDown(VCItem sender, ItemMouseEventArgs e)
        {
            var pt        = e.Location;
            var placement = Find(pt, null);

            // Can placement be resized?
            if ((placement != null) && (placement != activePlacement) && !CanResize(placement))
            {
                // No, it cannot be resized
                placement = null;
            }

            HitSide side = HitSide.None;

            if (placement != null)
            {
                side = CalcHitSide(placement, pt);
                if (side == HitSide.None)
                {
                    placement = null;
                }
            }

            if (placement != null)
            {
                activePlacement = placement;
                startBounds     = placement.Bounds;
                startMousePt    = pt;
                startSide       = side;
                resizing        = true;
                container.Invalidate();
                return(true);
            }
            else
            {
                // Pass event on
                return(base.OnMouseDown(sender, e));
            }
        }
コード例 #19
0
        /// <summary>
        /// Pass mouse move to appropriate item
        /// </summary>
        public override bool OnMouseMove(VCItem sender, ItemMouseEventArgs e)
        {
            if (movingPlacements == null)
            {
                return(base.OnMouseMove(sender, e));
            }

            var pt = e.Location;
            var dx = pt.X - startMousePt.X;
            var dy = pt.Y - startMousePt.Y;

            foreach (var mPlacement in movingPlacements)
            {
                mPlacement.Move(dx, dy, this);
                if (moveContents)
                {
                    mPlacement.Commit(this);
                }
            }
            container.Invalidate();
            return(true);
        }
コード例 #20
0
        /// <summary>
        /// Pass mouse down to appropriate item
        /// </summary>
        public override bool OnMouseDown(VCItem sender, ItemMouseEventArgs e)
        {
            if (IsValidMoveButton(e.Button))
            {
                var pt = e.Location;
                startMousePt     = pt;
                movingPlacements = null;

                if (container.SelectedItems.Find(pt, CanMove) != null)
                {
                    // Move all selected items
                    movingPlacements = container.SelectedItems.Where(CanMove).Select(x => new MovingPlacement(x)).ToList();
                }
                else
                {
                    movingPlacements = null;
                    var placement = container.Items.Find(pt, null, CanMove);
                    if (placement != null)
                    {
                        // Move only 1 items
                        movingPlacements = new List <MovingPlacement> {
                            new MovingPlacement(placement)
                        };
                    }
                }
                if ((movingPlacements != null) && (movingPlacements.Count > 0))
                {
                    // Begin of the move
                    return(true);
                }

                // Nothing to move
                movingPlacements = null;
            }

            return(base.OnMouseDown(sender, e));
        }
コード例 #21
0
        /// <summary>
        /// Pass mouse down to appropriate item
        /// </summary>
        /// <param name="e"></param>
        public override bool OnMouseDown(VCItem sender, ItemMouseEventArgs e)
        {
            if (enabled || IsSelecting)
            {
                e.Cursor = Cursors.Cross;
            }
            if (enabled)
            {
                if (e.Button == MouseButtons.Left)
                {
                    var pt = SnapPoint(LimitMoveToPosition(e.Location));
                    selStart    = pt;
                    selEnd      = pt;
                    IsSelecting = true;
                }

                return(true);
            }
            else
            {
                // Pass event on
                return(base.OnMouseDown(sender, e));
            }
        }