コード例 #1
0
        internal override bool HandleUserInput(WindowMouseEvent e)
        {
            if (UserInput.IsMouseLeftButtonDown)
            {
                Client.Position.Height = Client.CurrentTop;
                if (e.MouseDownPosition.X > Position.Right - TextHeight)
                {
                    var thumbOffset = (int)((float)(Position.Height - 3 * TextHeight) * (float)ScrollPosition / (float)ScrollSize);

                    // Mouse down occured within the scrollbar.
                    if (e.MouseDownPosition.Y < Position.Top + TextHeight)
                    {
                        // Mouse down occured on top button.
                        SetScrollPosition(ScrollPosition - 10);
                    }
                    else if (e.MouseDownPosition.Y < Position.Top + TextHeight + thumbOffset)
                    {
                        // Mouse down occured on top gutter.
                        SetScrollPosition(ScrollPosition - 100);
                    }
                    else if (e.MouseDownPosition.Y > Position.Bottom - TextHeight)
                    {
                        // Mouse down occured on bottom button.
                        SetScrollPosition(ScrollPosition + 10);
                    }
                    else if (e.MouseDownPosition.Y > Position.Top + 2 * TextHeight + thumbOffset)
                    {
                        // Mouse down occured on bottom gutter.
                        SetScrollPosition(ScrollPosition + 100);
                    }
                    return(true);
                }
            }
            return(base.HandleUserInput(e));
        }
コード例 #2
0
 internal override bool HandleUserInput(WindowMouseEvent e)
 {
     if (base.HandleUserInput(e))
     {
         return(true);
     }
     return(true);
 }
コード例 #3
0
        internal override bool HandleMouseUp(WindowMouseEvent e)
        {
            if (Dragging)
            {
                Dragging = false;
            }

            return(base.HandleMouseUp(e));
        }
コード例 #4
0
ファイル: Window.cs プロジェクト: nfsprodriver/openrails
 internal override bool HandleMouseDown(WindowMouseEvent e)
 {
     DragWindowOffset = DragInvalid;
     if (base.HandleMouseDown(e))
     {
         return(true);
     }
     DragWindowOffset = new Point(e.MouseDownScreenPosition.X - Window.Location.X, e.MouseDownScreenPosition.Y - Window.Location.Y);
     return(true);
 }
コード例 #5
0
 internal override bool HandleUserInput(WindowMouseEvent e)
 {
     foreach (var control in controls.Where(c => c.Position.Contains(e.MouseDownPosition)))
     {
         if (control.HandleUserInput(e))
         {
             return(true);
         }
     }
     return(base.HandleUserInput(e));
 }
コード例 #6
0
        internal override bool HandleMouseMove(WindowMouseEvent e)
        {
            if (UserInput.IsMouseLeftButtonDown && Dragging && UserInput.MouseMovedUp)
            {
                SetScrollPosition(ScrollPosition - (int)(DragThumbOffset * UserInput.MouseSpeedY));
            }

            if (UserInput.IsMouseLeftButtonDown && Dragging && UserInput.MouseMovedDown)
            {
                SetScrollPosition(ScrollPosition + (int)(DragThumbOffset * UserInput.MouseSpeedY));
            }

            return(base.HandleMouseMove(e));
        }
コード例 #7
0
 internal override bool HandleMouseMove(WindowMouseEvent e)
 {
     if (base.HandleMouseMove(e))
     {
         return(true);
     }
     if (UserInput.IsMouseLeftButtonDown && !Dragging && (DragWindowOffset != DragInvalid) && ((MathHelper.Distance(e.MouseScreenPosition.X, e.MouseDownScreenPosition.X) > WindowManager.DragMinimumDistance) || (MathHelper.Distance(e.MouseScreenPosition.Y, e.MouseDownScreenPosition.Y) > WindowManager.DragMinimumDistance)))
     {
         Dragging = true;
     }
     else if (UserInput.IsMouseLeftButtonDown && Dragging)
     {
         Window.MoveTo(e.MouseScreenPosition.X - DragWindowOffset.X, e.MouseScreenPosition.Y - DragWindowOffset.Y);
     }
     return(true);
 }
コード例 #8
0
        internal override bool HandleUserInput(WindowMouseEvent e)
        {
            if (UserInput.IsMouseLeftButtonDown)
            {
                Client.Position.Width = Client.CurrentLeft;
                if (e.MouseDownPosition.Y > Position.Bottom - TextHeight)
                {
                    var thumbOffset = (int)((float)(Position.Width - 3 * TextHeight) * (float)ScrollPosition / (float)ScrollSize);

                    // Mouse down occured within the scrollbar.
                    if (!Dragging && e.MouseDownPosition.X < Position.Left + TextHeight)
                    {
                        // Mouse down occured on left button.
                        SetScrollPosition(ScrollPosition - 10);
                    }
                    else if (!Dragging && e.MouseDownPosition.X < Position.Left + TextHeight + thumbOffset)
                    {
                        // Mouse down occured on left gutter.
                        SetScrollPosition(ScrollPosition - 100);
                    }
                    else if (!Dragging && e.MouseDownPosition.X > Position.Right - TextHeight)
                    {
                        // Mouse down occured on right button.
                        SetScrollPosition(ScrollPosition + 10);
                    }
                    else if (!Dragging && e.MouseDownPosition.X > Position.Left + 2 * TextHeight + thumbOffset)
                    {
                        // Mouse down occured on right gutter.
                        SetScrollPosition(ScrollPosition + 100);
                    }
                    else if (e.MouseDownPosition.X > Position.Left + TextHeight + thumbOffset && e.MouseDownPosition.X < Position.Left + 2 * TextHeight + thumbOffset && !Dragging)
                    {
                        // Mouse down occured on the thumb
                        Dragging        = true;
                        DragThumbOffset = e.MousePosition.X - (Position.Left + TextHeight + thumbOffset);
                    }

                    return(true);
                }
            }
            return(base.HandleUserInput(e));
        }
コード例 #9
0
        internal override bool HandleMouseDown(WindowMouseEvent e)
        {
            DragWindowOffset = DragInvalid;

            if (base.HandleMouseDown(e))
            {
                return(true);
            }

            // prevent from dragging when clicking on vertical scrollbar
            if (MathHelper.Distance(base.RemainingWidth, e.MousePosition.X) < 20)
            {
                return(false);
            }

            // prevent from dragging when clicking on horizontal scrollbar
            if (MathHelper.Distance(base.RemainingHeight, e.MousePosition.Y) < 20)
            {
                return(false);
            }

            DragWindowOffset = new Point(e.MouseDownScreenPosition.X - Window.Location.X, e.MouseDownScreenPosition.Y - Window.Location.Y);
            return(true);
        }
コード例 #10
0
 internal virtual void MouseClick(WindowMouseEvent e)
 {
     OnClick(new Point(e.MouseDownPosition.X - Position.X, e.MouseDownPosition.Y - Position.Y));
 }
コード例 #11
0
 internal virtual bool HandleUserInput(WindowMouseEvent e)
 {
     return(false);
 }
コード例 #12
0
 internal virtual bool HandleMouseMove(WindowMouseEvent e)
 {
     return(false);
 }
コード例 #13
0
 internal virtual bool HandleMouseUp(WindowMouseEvent e)
 {
     MouseClick(e);
     return(false);
 }