Exemplo n.º 1
0
        private void PaintX(Graphics g)
        {
            // Fill backround
            g.FillRectangle(new SolidBrush(Color.FromArgb(242, 242, 242)), 0, 0, this.Width, this.Height);
            g.DrawRectangle(new Pen(Color.FromArgb(212, 208, 200)), 0, 0, this.Width - 1, this.Height - 1);

            // Draw scroll pane
            g.FillRectangle(new SolidBrush(m_ViewStyle.GetButtonColor(ScrollPaneRect.Contains(m_MousePos) || m_Dragging, Control.MouseButtons == MouseButtons.Left)), m_pScrollPaneRect.X, m_pScrollPaneRect.Y, m_pScrollPaneRect.Width, m_pScrollPaneRect.Height);
            g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(ScrollPaneRect.Contains(m_MousePos) || m_Dragging)), m_pScrollPaneRect.X, m_pScrollPaneRect.Y, m_pScrollPaneRect.Width, m_pScrollPaneRect.Height);

            // Draw decrease button
            g.FillRectangle(new SolidBrush(m_ViewStyle.GetButtonColor(DecreaseButtonRect.Contains(m_MousePos) && !m_Dragging, Control.MouseButtons == MouseButtons.Left)), DecreaseButtonRect);
            if (m_Vertical)
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(DecreaseButtonRect), Direction.Up);
            }
            else
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(DecreaseButtonRect), Direction.Left);
            }
            g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(DecreaseButtonRect.Contains(m_MousePos) && !m_Dragging)), DecreaseButtonRect);

            // Draw increase button
            g.FillRectangle(new SolidBrush(m_ViewStyle.GetButtonColor(IncreaseButtonRect.Contains(m_MousePos) && !m_Dragging, Control.MouseButtons == MouseButtons.Left)), IncreaseButtonRect);
            if (m_Vertical)
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(IncreaseButtonRect), Direction.Down);
            }
            else
            {
                LumiSoft.UI.Controls.Paint.DrawTriangle(g, Color.Black, GetTriangleRect(IncreaseButtonRect), Direction.Right);
            }
            g.DrawRectangle(new Pen(m_ViewStyle.GetBorderColor(IncreaseButtonRect.Contains(m_MousePos) && !m_Dragging)), IncreaseButtonRect);
        }
Exemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (ScrollPaneRect.Contains(new Point(e.X, e.Y)))
            {
                // See if we may begin dragging
                if (RaiseMayChangePosition())
                {
                    m_Dragging = true;
                }
            }

            Invalidate();
        }
Exemplo n.º 3
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            // Begin dragging
            if (!m_Dragging && e.Button == MouseButtons.Left)
            {
                m_Dragging = true;
            }

            // There is active drag operation
            if (m_Dragging)
            {
                int position = m_Position;

                if (m_Vertical)
                {
                    int y = (e.Y - m_MousePos.Y);
                    if (m_pScrollPaneRect.Y + y >= DecreaseButtonRect.Bottom + 1 && m_pScrollPaneRect.Bottom + y + 1 <= IncreaseButtonRect.Y)
                    {
                        m_pScrollPaneRect = new Rectangle(m_pScrollPaneRect.X, m_pScrollPaneRect.Y + y, m_pScrollPaneRect.Width, m_pScrollPaneRect.Height);

                        if (m_pScrollPaneRect.Bottom >= this.Height - 19)
                        {
                            m_Position = this.Maximum;
                        }
                        else
                        {
                            int   scrollArea = Bounds.Height - ScrollPaneRect.Height - 34;
                            float pos        = (float)(m_pScrollPaneRect.Y - 17) / scrollArea;
                            m_Position = (int)(this.Maximum * pos);
                        }

                        if (position != m_Position)
                        {
                            OnPositionChanged();
                        }

                        this.Invalidate();
                    }
                }
                else
                {
                    int x = (e.X - m_MousePos.X);
                    if (m_pScrollPaneRect.X + x >= DecreaseButtonRect.Right + 1 && m_pScrollPaneRect.Right + x + 1 <= IncreaseButtonRect.X)
                    {
                        m_pScrollPaneRect = new Rectangle(m_pScrollPaneRect.X + x, m_pScrollPaneRect.Y, m_pScrollPaneRect.Width, m_pScrollPaneRect.Height);

                        if (m_pScrollPaneRect.Right >= this.Width - 19)
                        {
                            m_Position = this.Maximum;
                        }
                        else
                        {
                            int   scrollArea = Bounds.Width - ScrollPaneRect.Width - 34;
                            float pos        = (float)(m_pScrollPaneRect.X - 17) / (float)scrollArea;
                            m_Position = (int)(this.Maximum * pos);
                        }

                        if (position != m_Position)
                        {
                            OnPositionChanged();
                        }

                        this.Invalidate();
                    }
                }
            }
            // Handle normal mouse move
            else
            {
                m_MousePos = new Point(e.X, e.Y);

                String hittedObject = "";
                if (this.DecreaseButtonRect.Contains(m_MousePos))
                {
                    hittedObject = "DecreaseButton";
                }
                else if (this.IncreaseButtonRect.Contains(m_MousePos))
                {
                    hittedObject = "IncreaseButton";
                }
                else if (ScrollPaneRect.Contains(m_MousePos))
                {
                    hittedObject = "ScrollPane";
                }

                if (!m_HittedObject.Equals(hittedObject))
                {
                    m_HittedObject = hittedObject;

                    this.Invalidate();
                }
            }

            m_MousePos = new Point(e.X, e.Y);
        }