Esempio n. 1
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));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Start the selection at the given point.
        /// </summary>
        public void Start(PointF pt, bool clearSelection)
        {
            selStart  = pt;
            selEnd    = pt;
            selecting = true;

            if (clearSelection)
            {
                // Clear selection
                container.SelectedItems.Clear();
            }

            // Record current selection
            startSelection = new List <VCItemPlacement>(container.SelectedItems);

            // Select appropriate items
            UpdateSelection(SelectionBounds);
            container.Invalidate();
        }
        /// <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));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public SelectionManager(IVCItemContainer container, Predicate <VCItemPlacement> canSelect)
 {
     this.container = container;
     this.canSelect = canSelect;
     container.SelectedItems.Changed += (s, e) => container.Invalidate();
 }