Beispiel #1
0
 private void splitter_MouseDown(object sender, MouseEventArgs e)
 {
     if (SplitterVisible && !ButtonRectangle.Contains(e.Location) && !Collapsed && !IsSplitterFixed)
     {
         m_trackingMouse = true;
     }
 }
Beispiel #2
0
 public override void Update()
 {
     if (ButtonRectangle.Contains(Input.MousePosition.ToPoint()) && Input.WasLeftMouseClicked())
     {
         ZombieGame.SetQuit = true;
     }
 }
Beispiel #3
0
        public virtual void OnMouseMove(MouseEventArgs e)
        {
            bool hover = ButtonRectangle.Contains(e.X, e.Y);

            if (hover != isHover)
            {
                isHover = hover;
                this.Invalidate(ButtonRectangle);
            }
            else if (isDrag)
            {
                Point oldPt = dragPt;
                dragPt = e.Location;
                Rectangle rc = this.Bounds;
                Point     pt = this.Location;

                pt.X += dragPt.X - oldPt.X;
                pt.Y += dragPt.Y - oldPt.Y;

                Rectangle invalidRect = Rectangle.Union(this.bounds_, rc);

                this.Location = pt;

                this.Invalidate(invalidRect);
            }
        }
Beispiel #4
0
 public override void Update()
 {
     if (ButtonRectangle.Contains(Input.MousePosition.ToPoint()) && Input.WasLeftMouseClicked())
     {
         Console.WriteLine("Triggered");
     }
 }
Beispiel #5
0
 private bool IsMouseOverExpandCollapseRegion(Point mouseLocation)
 {
     if (!ButtonRectangle.Contains(mouseLocation) && !Collapsed)
     {
         return(IsSplitterFixed);
     }
     return(true);
 }
Beispiel #6
0
        public virtual void OnMouseUp(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (isPushed && ButtonRectangle.Contains(e.X, e.Y))
                {
                    IsCollapsed = !IsCollapsed;
                }

                isDrag   = false;
                isPushed = false;
            }
        }
        /// <summary>
        /// Updates the button's colour based on the cursor's position.
        /// </summary>
        /// <param name="mState">
        /// The MouseState variable whose input is to be queried.
        /// </param>
        /// /// <param name="prevMState">
        /// The previous mouse state. Used to query for single clicks.
        /// </param>
        /// mState used as a parameter because it is not needed elsewhere in the
        ///		class. This can then be passed in within Game1, and other
        ///		classes which use Buttons then don't need to handle mouse input.
        public void Update(MouseState mState, MouseState prevMState)
        {
            // Button colour FSM
            // Uses if-statements because multiple conditions are checked for.
            // Contains can either lead to hovering or clicking...
            if (ButtonRectangle.Contains(mState.Position))
            {
                // ...so nested ifs are used to address all conditions

                // Click and hold: click colour is shown ONLY.
                if (mState.LeftButton == ButtonState.Pressed)
                {
                    CurrentButtonColour = ClickButtonColour;
                }
                // Release after click: button registers as clicked.
                else if (mState.LeftButton == ButtonState.Released &&
                         prevMState.LeftButton == ButtonState.Pressed)
                {
                    IsClicked = true;
                }
                // If neither of the above take place, then the user is hovering.
                else
                {
                    CurrentButtonColour = HoverButtonColour;
                    IsClicked           = false;
                }

                // Above was written as a single conditional, and not broken up
                //		into multiple ones because events are mutually exclusive.
                // Therefore, only split conditionals into multiple if's when
                //		events are NOT mututally exclusive i.e. they can occur
                //		simultaneously.
            }
            // If Contains returns false, the user is neither hovering or
            //		clicking on the button
            else
            {
                CurrentButtonColour = DefaultButtonColour;
                IsClicked           = false;
            }
        }
Beispiel #8
0
 public virtual void OnMouseDown(MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         isPushed = ButtonRectangle.Contains(e.X, e.Y);
         if (!isPushed && e.Clicks == 2 && CaptionRectangle.Contains(e.X, e.Y))
         {
             // ダブルクリックで閉じる
             IsCollapsed = !IsCollapsed;
         }
         else if (this.CaptionRectangle.Contains(e.Location))
         {
             dragPt = e.Location;
             isDrag = true;
         }
     }
     else
     {
         isPushed = false;
     }
 }