Ejemplo n.º 1
0
 /// <summary>
 /// Raises the ButtonDragRectangle event.
 /// </summary>
 /// <param name="e">An ButtonDragRectangleEventArgs containing the event args.</param>
 protected virtual void OnButtonDragRectangle(ButtonDragRectangleEventArgs e)
 {
     if (ButtonDragRectangle != null)
     {
         ButtonDragRectangle(this, e);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Mouse button has been pressed in the view.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="pt">Mouse position relative to control.</param>
        /// <param name="button">Mouse button pressed down.</param>
        /// <returns>True if capturing input; otherwise false.</returns>
        public virtual bool MouseDown(Control c, Point pt, MouseButtons button)
        {
            // Is the controller allowed to track/click
            if (IsOperating)
            {
                // Only interested in left mouse pressing down
                if (button == MouseButtons.Left)
                {
                    // Capturing mouse input
                    _captured        = true;
                    _draggingAttempt = false;

                    // Use event to discover the rectangle that causes dragging to begin
                    ButtonDragRectangleEventArgs args = new ButtonDragRectangleEventArgs(pt);
                    OnButtonDragRectangle(args);
                    _dragRect      = args.DragRect;
                    _preDragOffset = args.PreDragOffset;

                    if (!_fixedPressed)
                    {
                        // Update the visual state
                        UpdateTargetState(pt);

                        // Do we become fixed in the pressed state until RemoveFixed is called?
                        if (BecomesFixed)
                        {
                            _fixedPressed = true;
                        }

                        // Indicate that the mouse wants to select the elment
                        OnMouseSelect(new MouseEventArgs(MouseButtons.Left, 1, pt.X, pt.Y, 0));

                        // Generate a click event if we generate click on mouse down
                        if (ClickOnDown)
                        {
                            OnClick(new MouseEventArgs(MouseButtons.Left, 1, pt.X, pt.Y, 0));

                            // If we need to perform click repeats then use a timer...
                            if (Repeat)
                            {
                                _repeatTimer          = new Timer();
                                _repeatTimer.Interval = SystemInformation.DoubleClickTime;
                                _repeatTimer.Tick    += new EventHandler(OnRepeatTimer);
                                _repeatTimer.Start();
                            }
                        }
                    }
                }
                else if (button == MouseButtons.Right)
                {
                    if (!_fixedPressed)
                    {
                        // Do we become fixed in the pressed state until RemoveFixed is called?
                        if (BecomesRightFixed)
                        {
                            _fixedPressed = true;
                        }

                        // Indicate the right mouse was used on the button
                        OnRightClick(new MouseEventArgs(MouseButtons.Right, 1, pt.X, pt.Y, 0));
                    }
                }
            }

            return(_captured);
        }