コード例 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            IntPtr data = Win32.OpenThemeData2(this.Handle, "Scrollbar");

            if (data != IntPtr.Zero)          //mit xp themes
            {
                IntPtr     hdc = e.Graphics.GetHdc();
                Win32.RECT rct = new Win32.RECT(0, 0, this.Width, this.Height);
                Win32.DrawThemeBackground2(data, hdc, 4, 4, ref rct);
                rct = base._elems[0].Bounds; rct.Top--;
                Win32.DrawThemeBackground2(data, hdc, 1, (int)base._elems[0].State + 8, ref rct);
                rct = base._elems[1].Bounds; rct.Top--;
                Win32.DrawThemeBackground2(data, hdc, 1, (int)base._elems[1].State + 12, ref rct);
                rct = base._elems[2].Bounds; rct.Top--;
                Win32.DrawThemeBackground2(data, hdc, 2, (int)base._elems[2].State, ref rct);
                e.Graphics.ReleaseHdc(hdc);
                Win32.CloseThemeData2(data);
            }
            else            //ohne xpthemes, einfache rechtecke
            {
                e.Graphics.FillRectangle(SystemBrushes.ControlLightLight, this.ClientRectangle);
                ControlPaint.DrawScrollButton(e.Graphics, base._elems[0].Bounds, ScrollButton.Left, base._elems[0].ToButtonState());
                ControlPaint.DrawScrollButton(e.Graphics, base._elems[1].Bounds, ScrollButton.Right, base._elems[1].ToButtonState());
                ControlPaint.DrawButton(e.Graphics, base._elems[2].Bounds, ButtonState.Normal);
            }
            using (StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap))
            {
                fmt.LineAlignment = fmt.Alignment = StringAlignment.Center;
                e.Graphics.DrawString(base.Value.ToString(), base.Font,
                                      this.Enabled?Brushes.Black:Brushes.Gray, base._elems[2].Bounds, fmt);
            }
        }
コード例 #2
0
        /// <summary>
        /// Draws an UpDown's up and down buttons in the specified state, on the specified
        /// graphics surface, and within the specified bounds
        /// </summary>
        /// <param name="g">The Graphics to draw on</param>
        /// <param name="upButtonRect">The Rectangle that represents the dimensions
        /// of the up button</param>
        /// <param name="upButtonClipRect">The Rectangle that represents the clipping area
        /// for the up button</param>
        /// <param name="upButtonState">An UpDownStates value that specifies the
        /// state to draw the up button in</param>
        /// <param name="downButtonRect">The Rectangle that represents the dimensions
        /// of the down button</param>
        /// <param name="downButtonClipRect">The Rectangle that represents the clipping area
        /// for the down button</param>
        /// <param name="downButtonState">An UpDownStates value that specifies the
        /// state to draw the down button in</param>
        public static void DrawUpDownButtons(Graphics g, Rectangle upButtonRect, Rectangle upButtonClipRect, UpDownStates upButtonState, Rectangle downButtonRect, Rectangle downButtonClipRect, UpDownStates downButtonState)
        {
            if (g == null)
            {
                return;
            }

            if (upButtonRect.Width > 0 && upButtonRect.Height > 0 && upButtonClipRect.Width > 0 && upButtonClipRect.Height > 0)
            {
                if (ThemeManager.VisualStylesEnabled)
                {
                    ThemeManager.DrawThemeBackground(g, ThemeClasses.UpDown, (int)UpDownParts.Up, (int)upButtonState, upButtonRect, upButtonClipRect);
                }
                else
                {
                    ControlPaint.DrawScrollButton(g, upButtonRect, ScrollButton.Up, ThemeManager.ConvertUpDownStateToButtonState(upButtonState));
                }
            }

            if (downButtonRect.Width > 0 && downButtonRect.Height > 0 && downButtonClipRect.Width > 0 && downButtonClipRect.Height > 0)
            {
                if (ThemeManager.VisualStylesEnabled)
                {
                    ThemeManager.DrawThemeBackground(g, ThemeClasses.UpDown, (int)UpDownParts.Down, (int)downButtonState, downButtonRect, downButtonClipRect);
                }
                else
                {
                    ControlPaint.DrawScrollButton(g, downButtonRect, ScrollButton.Down, ThemeManager.ConvertUpDownStateToButtonState(downButtonState));
                }
            }
        }
コード例 #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     ControlPaint.DrawScrollButton(
         System.Drawing.Graphics.FromHwnd(button1.Handle),
         0, 0,
         12, 12,
         ScrollButton.Down,
         ButtonState.Flat);
 }
コード例 #4
0
            protected override void OnPaint(PaintEventArgs e)
            {
                if (Application.RenderWithVisualStyles)
                {
                    VisualStyleRenderer vsr;

                    // ReSharper disable AssignNullToNotNullAttribute
                    if (IsUp)
                    {
                        vsr = new VisualStyleRenderer(
                            _captured
                                ? VisualStyleElement.Spin.Up.Hot
                                : VisualStyleElement.Spin.Up.Normal);

                        if (!Enabled)
                        {
                            vsr.SetParameters(VisualStyleElement.Spin.Up.Disabled);
                        }
                        else if (_pushed)
                        {
                            vsr.SetParameters(VisualStyleElement.Spin.Up.Pressed);
                        }
                    }
                    else
                    {
                        vsr = new VisualStyleRenderer(
                            _captured
                                ? VisualStyleElement.Spin.Down.Hot
                                : VisualStyleElement.Spin.Down.Normal);

                        if (!Enabled)
                        {
                            vsr.SetParameters(VisualStyleElement.Spin.Down.Disabled);
                        }
                        else if (_pushed)
                        {
                            vsr.SetParameters(VisualStyleElement.Spin.Down.Pressed);
                        }
                    }
                    // ReSharper restore AssignNullToNotNullAttribute

                    vsr.DrawBackground(e.Graphics, new Rectangle(0, 0, Width, Height));
                }
                else
                {
                    ControlPaint.DrawScrollButton(
                        e.Graphics,
                        new Rectangle(0, 0, Width, Height),
                        IsUp ? ScrollButton.Up : ScrollButton.Down,
                        _pushed
                            ? ButtonState.Pushed
                            : (Enabled
                                ? ButtonState.Normal
                                : ButtonState.Inactive));
                }
            }
コード例 #5
0
        protected override void OnPaint(PaintEventArgs args)
        {
            Graphics grfx = args.Graphics;

            ControlPaint.DrawScrollButton(grfx, ClientRectangle, scrbtn,
                                          !Enabled ? ButtonState.Inactive :
                                          (Capture & ClientRectangle.Contains(
                                               PointToClient(MousePosition))) ?
                                          ButtonState.Pushed : ButtonState.Normal);
        }
コード例 #6
0
 public override void DrawTopLayer(Graphics g)
 {
     if (Visible && ControlState == MCDU.Drawing.ControlState.Edit)
     {
         int       itemHeight = GetItemHeight(g);
         Rectangle bounds     = ClipRectangle;
         m_drop_down_bounds = new Rectangle(bounds.X,
                                            bounds.Y + bounds.Height,
                                            bounds.Width,
                                            itemHeight * Math.Max(1, Math.Min(10, m_items.Length)) + 2);
         g.FillRectangle(ForeBrush, m_drop_down_bounds);
         g.DrawRectangle(new Pen(BackColor), new Rectangle(m_drop_down_bounds.X,
                                                           m_drop_down_bounds.Y,
                                                           m_drop_down_bounds.Width - 1,
                                                           m_drop_down_bounds.Height - 1));
         for (int index = 0; index < Math.Min(10, m_items.Length); index++)
         {
             Rectangle itemBounds = new Rectangle(bounds.X,
                                                  bounds.Y + bounds.Height + index * itemHeight,
                                                  m_items.Length > 10 ? bounds.Width - buttonWidth : bounds.Width,
                                                  itemHeight);
             if (m_hightlight_index == index + m_scroll_index)
             {
                 g.FillRectangle(new SolidBrush(SystemColors.Highlight), itemBounds);
             }
             g.DrawString(m_items[index + m_scroll_index], Font, BackBrush, itemBounds, StringFormat);
         }
         if (m_items.Length > 10)
         {
             Rectangle rectangle = new Rectangle(m_drop_down_bounds.X + m_drop_down_bounds.Width - buttonWidth - 1,
                                                 m_drop_down_bounds.Y + 1,
                                                 buttonWidth,
                                                 itemHeight * 10);
             g.FillRectangle(new SolidBrush(SystemColors.ScrollBar), rectangle);
             rectangle = new Rectangle(m_drop_down_bounds.X + m_drop_down_bounds.Width - buttonWidth - 1,
                                       m_drop_down_bounds.Y + 1,
                                       buttonWidth,
                                       buttonHeight);
             ControlPaint.DrawScrollButton(g, rectangle, ScrollButton.Up, m_top_scroll_button_state);
             rectangle = new Rectangle(m_drop_down_bounds.X + m_drop_down_bounds.Width - buttonWidth - 1,
                                       m_drop_down_bounds.Y + 1 + itemHeight * 10 - buttonHeight,
                                       buttonWidth,
                                       buttonHeight);
             ControlPaint.DrawScrollButton(g, rectangle, ScrollButton.Down, m_bottom_scroll_button_state);
             int height = (int)((itemHeight * 10 - 2 * buttonHeight) * 10.0 / m_items.Length);
             int y      = m_drop_down_bounds.Y + 1 + buttonHeight +
                          (int)((itemHeight * 10 - 2 * buttonHeight) * m_scroll_index / m_items.Length);
             rectangle = new Rectangle(m_drop_down_bounds.X + m_drop_down_bounds.Width - buttonWidth - 1,
                                       y,
                                       buttonWidth,
                                       height);
             ControlPaint.DrawButton(g, rectangle, ButtonState.Normal);
         }
     }
 }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gr"></param>
        /// <param name="rect"></param>
        /// <param name="d"></param>
        /// <param name="state"></param>
        protected override void DrawArrow(Graphics gr, Rectangle rect, Direction d, ElementState state)
        {
            if (ThemeFactory.VisualStylesEnabled && ThemeFactory.VisualStylesSupported)
            {
                ThemeFactory.DrawScrollBar(gr, rect, GetArrowScrollBarStates(d, state), ScrollBarParts.ArrowBtn);
            }
            else
            {
                ScrollButton sb = DirectionToScrollButton(d);
                ButtonState  bs = ElementStateToButtonState(state);

                ControlPaint.DrawScrollButton(gr, rect, sb, bs);
            }
        }
コード例 #8
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);
            Graphics gr            = pevent.Graphics;
            bool     mouseInButton = this.Capture &&
                                     this.ClientRectangle.Contains(this.PointToClient(MousePosition));

            System.Windows.Forms.ButtonState buttonState = !this.Enabled ? ButtonState.Inactive
              : (mouseInButton ? ButtonState.Pushed
              : ButtonState.Normal);
            ControlPaint.DrawScrollButton(gr, this.ClientRectangle,
                                          scrollButton,
                                          buttonState);
        }
コード例 #9
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);   // Отправляем к базовому методу
            Graphics gr            = pevent.Graphics;
            bool     mouseInButton = this.Capture &&
                                     this.ClientRectangle.Contains(this.PointToClient(MousePosition));

            System.Windows.Forms.ButtonState buttonState =
                !this.Enabled ? ButtonState.Inactive
                : (mouseInButton ? ButtonState.Pushed
                : ButtonState.Normal);
            ControlPaint.DrawScrollButton(gr, this.ClientRectangle,
                                          scrollButton, // В какую сторону рисовать стрелку
                                          buttonState); // Каким стилем рисовать
        }
コード例 #10
0
        // Отрисовка кнопки в стиле со стрелкой
        protected override void OnPaint(PaintEventArgs pevent)
        {
            base.OnPaint(pevent);          // Отправляем к базовому методу или вообще убираем!!!
            Graphics gr = pevent.Graphics; // Извлекаем контекст устройства
                                           // Кнопка в контакте с мышью и курсор находится в области чувствительности
            bool mouseInButton = this.Capture && this.ClientRectangle.Contains(this.PointToClient(MousePosition));

            // Флаг состояния кнопки для управления ее стилем отрисовки
            System.Windows.Forms.ButtonState buttonState =
                !this.Enabled ? ButtonState.Inactive    // Если кнопка недоступна
                : (mouseInButton ? ButtonState.Pushed   // Если доступна и нажата
                : ButtonState.Normal);                  // Если доступна и отпущена
                                                        // Рисуем кнопку как кнопку со стрелкой
            ControlPaint.DrawScrollButton(gr, this.ClientRectangle,
                                          scrollButton, // В какую сторону рисовать стрелку
                                          buttonState); // Каким стилем рисовать
        }
コード例 #11
0
        private void RenderScrollControls(Graphics g, Rectangle rcBody)
        {
            var baseState = image != null && image.Bytes.Length > granularity * Width
                ? ButtonState.Flat
                : ButtonState.Flat | ButtonState.Inactive;

            ControlPaint.DrawScrollButton(g,
                                          0, (Height - CyScroll) / 2,
                                          CxScroll,
                                          CyScroll,
                                          ScrollButton.Left,
                                          (scrollButton == ScrollButton.Left ? ButtonState.Pushed : ButtonState.Normal) | baseState);
            ControlPaint.DrawScrollButton(g,
                                          Width - CxScroll,
                                          (Height - CyScroll) / 2,
                                          CxScroll,
                                          CyScroll,
                                          ScrollButton.Right,
                                          (scrollButton == ScrollButton.Left ? ButtonState.Pushed : ButtonState.Normal) | baseState);
        }
コード例 #12
0
ファイル: PaneSplitter.cs プロジェクト: yoshikixxxx/poderosa
        private void DrawMark(Graphics g, ArrowElement element, Rectangle rect)
        {
            if (VisualStyleInformation.IsEnabledByUser)
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element.VSElement); //TODO new避ける
                renderer.DrawBackground(g, rect);
                //背景がSystemColors.ControlであることをVisualStyleは想定しているらしく、枠が見えて見苦しいことがある。
                //VisualStyleRendererに背景色を指示する方法はないみたいなので手動で。

                //TODO 方向により異なる三辺を塗る必要があるようだ。めんどうくさい!

                /*Pen pen = new Pen(_target.BackColor);
                 * g.DrawRectangle(pen, rect.X, rect.Y, rect.Width-1, rect.Height-1);
                 * pen.Dispose();*/
            }
            else
            {
                ControlPaint.DrawScrollButton(g, rect, element.ScrollButton, ButtonState.Normal);
            }
        }
コード例 #13
0
        private void ControlPaintTest_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(10, 10, 50, 50), ButtonState.Checked);
            ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(70, 10, 30, 30), ButtonState.Normal);
            ControlPaint.DrawCheckBox(e.Graphics, new Rectangle(110, 10, 20, 20), ButtonState.Checked);

            ControlPaint.DrawButton(e.Graphics, new Rectangle(10, 80, 20, 20), ButtonState.Checked);
            ControlPaint.DrawButton(e.Graphics, new Rectangle(50, 80, 20, 20), ButtonState.Flat);
            ControlPaint.DrawButton(e.Graphics, new Rectangle(90, 80, 20, 20), ButtonState.Normal);
            ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(130, 80, 20, 20));

            ControlPaint.DrawGrid(e.Graphics, new Rectangle(10, 120, 250, 50), new Size(5, 5), Color.Blue);
            ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(10, 180, 20, 20), ScrollButton.Left, ButtonState.Normal);
            ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(50, 180, 20, 20), ScrollButton.Max, ButtonState.Pushed);
            ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(90, 180, 20, 20), ScrollButton.Up, ButtonState.Normal);

            ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(10, 220, 20, 20), MenuGlyph.Arrow);
            ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(50, 220, 20, 20), MenuGlyph.Checkmark);
            ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle(90, 220, 20, 20), MenuGlyph.Max);
        }
コード例 #14
0
        public override void Paint(PropertyGrid grid, PropertyGrid.Item item, Graphics g, Rectangle rect)
        {
            if (base.Editing == item)
            {
                ComboBoxState comboBoxState = ComboBoxState.Normal;
                switch (this.mState)
                {
                case PushButtonState.Hot:
                {
                    comboBoxState = ComboBoxState.Hot;
                    break;
                }

                case PushButtonState.Pressed:
                {
                    comboBoxState = ComboBoxState.Pressed;
                    break;
                }

                case PushButtonState.Disabled:
                {
                    comboBoxState = ComboBoxState.Disabled;
                    break;
                }
                }
                rect.X     = this.mButton.X;
                rect.Width = this.mButton.Width;
                if (!Application.RenderWithVisualStyles)
                {
                    ControlPaint.DrawScrollButton(g, rect, ScrollButton.Down, (comboBoxState == ComboBoxState.Pressed ? ButtonState.Pushed : ButtonState.Normal));
                }
                else
                {
                    ComboBoxRenderer.DrawDropDownButton(g, rect, comboBoxState);
                }
            }
            else
            {
                base.Paint(grid, item, g, rect);
            }
        }
コード例 #15
0
ファイル: ImageMapView.Painter.cs プロジェクト: xor2003/reko
            private void RenderScrollControls(Graphics g, ImageMapView mapView)
            {
                int cbTotal   = 0;
                var baseState = imageMap != null && cbTotal > granularity * rcClient.Width
                    ? ButtonState.Flat
                    : ButtonState.Flat | ButtonState.Inactive;

                ControlPaint.DrawScrollButton(g,
                                              0, (rcClient.Height - CyScroll) / 2,
                                              CxScroll,
                                              CyScroll,
                                              ScrollButton.Left,
                                              (mapView.scrollButton == ScrollButton.Left ? ButtonState.Pushed : ButtonState.Normal) | baseState);
                ControlPaint.DrawScrollButton(g,
                                              rcClient.Width - CxScroll,
                                              (rcClient.Height - CyScroll) / 2,
                                              CxScroll,
                                              CyScroll,
                                              ScrollButton.Right,
                                              (mapView.scrollButton == ScrollButton.Left ? ButtonState.Pushed : ButtonState.Normal) | baseState);
            }
コード例 #16
0
        private void pnlButtons_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            e.Graphics.Clear(this.BackColor);

            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;

            if (upButton)
            {
                ControlPaint.DrawScrollButton(e.Graphics, 0, 0, pnlButtons.Width, pnlButtons.Height / 2, ScrollButton.Up, ButtonState.Pushed);
            }
            else
            {
                ControlPaint.DrawScrollButton(e.Graphics, 0, 0, pnlButtons.Width, pnlButtons.Height / 2, ScrollButton.Up, ButtonState.Normal);
            }

            if (downButton)
            {
                ControlPaint.DrawScrollButton(e.Graphics, 0, pnlButtons.Height / 2, pnlButtons.Width, pnlButtons.Height / 2, ScrollButton.Down, ButtonState.Pushed);
            }
            else
            {
                ControlPaint.DrawScrollButton(e.Graphics, 0, pnlButtons.Height / 2, pnlButtons.Width, pnlButtons.Height / 2, ScrollButton.Down, ButtonState.Normal);
            }
        }
コード例 #17
0
ファイル: SpinControl.cs プロジェクト: windygu/sycorax
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Graphics  g  = e.Graphics;
            Rectangle rc = Rectangle.Inflate(ClientRectangle, -1, -1);

            g.FillRectangle((Enabled == true) ? SystemBrushes.Window : SystemBrushes.Control,
                            ClientRectangle);

            if (Rectangle.Empty == m_rcUpArrow)
            {
                m_rcUpArrow = new Rectangle(rc.X, rc.Y, rc.Width, (rc.Height - 1) / 2);
            }

            if (Rectangle.Empty == m_rcDownArrow)
            {
                m_rcDownArrow = new Rectangle(rc.X, rc.Y + (rc.Height - 1) / 2 + 1, rc.Width, (rc.Height - 1) / 2);
            }

            ControlPaint.DrawScrollButton(g, m_rcUpArrow, ScrollButton.Up,
                                          (Enabled) ? m_stateUp : ButtonState.Inactive | ButtonState.Flat);

            ControlPaint.DrawScrollButton(g, m_rcDownArrow, ScrollButton.Down,
                                          (Enabled) ? m_stateDown : ButtonState.Inactive | ButtonState.Flat);
        }
コード例 #18
0
ファイル: TabControlPainter.cs プロジェクト: raj581/Marvin
 protected virtual void DrawScrollButton(Graphics dc, Rectangle bounds, Rectangle clippingArea, ScrollButton button, PushButtonState state)
 {
     ControlPaint.DrawScrollButton(dc, bounds, button, GetButtonState(state));
 }
コード例 #19
0
ファイル: PropInPlaceUpDown.cs プロジェクト: 15831944/Test3-1
        protected override void OnPaint(PaintEventArgs e)
        {
            // Draw the background

            _ownerPropertyEnum.Property.ParentGrid.DrawManager.DrawPropertyValueBackground(e.Graphics,
                                                                                           ClientRectangle, _ownerPropertyEnum);

            // Draw the arrows

            if (!ReadOnly)
            {
                int halfHeight  = (int)Math.Round(ClientSize.Height / 2.0);
                int buttonWidth = SystemInformation.VerticalScrollBarWidth;
                int leftSide    = ClientSize.Width - buttonWidth;

                if (ThemeRenderer.Enabled)
                {
                    int state = (_pushed == ButtonID.Up ? ThemeSpin.Pressed :
                                 (_mouseOver == ButtonID.Up ? ThemeSpin.Hot : ThemeSpin.Normal));
                    ThemeSpin.Up.Draw(e.Graphics, state, new Rectangle(leftSide, 0, buttonWidth, halfHeight));

                    state = (_pushed == ButtonID.Down ? ThemeSpin.Pressed :
                             (_mouseOver == ButtonID.Down ? ThemeSpin.Hot : ThemeSpin.Normal));
                    ThemeSpin.Down.Draw(e.Graphics, state, new Rectangle(leftSide, halfHeight, buttonWidth, halfHeight));
                }
                else
                {
                    ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(leftSide, 0, buttonWidth, halfHeight), ScrollButton.Up, (_pushed == ButtonID.Up) ? ButtonState.Pushed : ButtonState.Normal);
                    ControlPaint.DrawScrollButton(e.Graphics, new Rectangle(leftSide, halfHeight, buttonWidth, halfHeight), ScrollButton.Down, (_pushed == ButtonID.Down) ? ButtonState.Pushed : ButtonState.Normal);
                }
            }

            // Draw the text

            if (_edit == null)
            {
                // Draw the value
                Rectangle valueRect = ClientRectangle;
                if (!ReadOnly)
                {
                    valueRect.Width -= SystemInformation.VerticalScrollBarWidth + 1;
                }

                if (Focused)
                {
                    Rectangle fillRect = valueRect;
                    fillRect.X++;
                    fillRect.Width--;
                    fillRect.Height--;
                    e.Graphics.FillRectangle(SystemBrushes.FromSystemColor(SystemColors.Highlight), fillRect);
                    ControlPaint.DrawFocusRectangle(e.Graphics, fillRect);
                }

                Color valueColor;
                if (_ownerPropertyEnum.Property.Enabled == false)
                {
                    valueColor = SystemColors.GrayText;
                }
                else
                {
                    if (Focused)
                    {
                        valueColor = SystemColors.HighlightText;
                    }
                    else
                    {
                        valueColor = _ownerPropertyEnum.Property.Value.ForeColor;
                    }
                }

                _ownerPropertyEnum.Property.Value.DrawValue(e.Graphics, valueRect, valueColor, _ownerPropertyEnum, Text);
            }

            base.OnPaint(e);
        }
コード例 #20
0
    /// <summary>
    /// Paints the drop-down, including all items within the scrolled region
    /// and, if appropriate, the scrollbar.
    /// </summary>
    /// <param name="e"></param>
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);

        if (_scrollBarVisible)
        {
            Rectangle upper = new Rectangle(_scrollBar.DisplayRectangle.Left, _scrollBar.DisplayRectangle.Top, _scrollBar.DisplayRectangle.Width, _scrollBar.Thumb.Top - _scrollBar.DisplayRectangle.Top);
            Rectangle lower = new Rectangle(_scrollBar.DisplayRectangle.Left, _scrollBar.Thumb.Bottom, _scrollBar.DisplayRectangle.Width, _scrollBar.DisplayRectangle.Bottom - _scrollBar.Thumb.Bottom);

            if (_sourceControl.DrawWithVisualStyles && ScrollBarRenderer.IsSupported)
            {
                ScrollBarRenderer.DrawUpperVerticalTrack(e.Graphics, upper, GetScrollBarState(upper));
                ScrollBarRenderer.DrawLowerVerticalTrack(e.Graphics, lower, GetScrollBarState(lower));
                ScrollBarRenderer.DrawArrowButton(e.Graphics, _scrollBar.UpArrow, GetScrollBarStateUp());
                ScrollBarRenderer.DrawArrowButton(e.Graphics, _scrollBar.DownArrow, GetScrollBarStateDown());
                ScrollBarRenderer.DrawVerticalThumb(e.Graphics, _scrollBar.Thumb, GetScrollBarThumbState());
                ScrollBarRenderer.DrawVerticalThumbGrip(e.Graphics, _scrollBar.Thumb, GetScrollBarThumbState());
            }
            else
            {
                Rectangle bounds = _scrollBar.DisplayRectangle;
                bounds.Offset(1, 0);
                Rectangle up = _scrollBar.UpArrow;
                up.Offset(1, 0);
                Rectangle down = _scrollBar.DownArrow;
                down.Offset(1, 0);
                Rectangle thumb = _scrollBar.Thumb;
                thumb.Offset(1, 0);

                using (HatchBrush brush = new HatchBrush(HatchStyle.Percent50, SystemColors.ControlLightLight, SystemColors.Control)) {
                    e.Graphics.FillRectangle(brush, bounds);
                }

                ControlPaint.DrawScrollButton(e.Graphics, up, ScrollButton.Up, GetButtonState(_scrollBar.UpArrow));
                ControlPaint.DrawScrollButton(e.Graphics, down, ScrollButton.Down, GetButtonState(_scrollBar.DownArrow));
                ControlPaint.DrawButton(e.Graphics, thumb, ButtonState.Normal);
            }
        }

        for (int i = _scrollOffset; i < (_scrollOffset + _numItemsDisplayed); i++)
        {
            bool     highlighted = ((_highlightedItemIndex == i) && !_sourceControl.ShowCheckBoxes);
            NodeInfo item        = _visibleItems[i];

            // background
            if (highlighted)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, item.DisplayRectangle);
            }

            // image and glyphs
            if (item.Image != null)
            {
                Rectangle imgBounds = new Rectangle(item.DisplayRectangle.Location, item.Image.Size);
                e.Graphics.DrawImage(item.Image, imgBounds);

                if (_sourceControl.ShowCheckBoxes)
                {
                    CheckBoxState state   = GetCheckBoxState(item.Node.CheckState, item.CheckRectangle);
                    Size          chkSize = CheckBoxRenderer.GetGlyphSize(e.Graphics, state);
                    CheckBoxRenderer.DrawCheckBox(e.Graphics, Point.Add(item.CheckRectangle.Location, new Size((item.CheckRectangle.Width - chkSize.Width) / 2, (item.CheckRectangle.Height - chkSize.Height) / 2)), state);
                }
            }

            Rectangle textBounds = new Rectangle(item.DisplayRectangle.X + item.Image.Width + 2, item.DisplayRectangle.Y, item.DisplayRectangle.Width - item.Image.Width - 4, _itemHeight);

            using (Font font = new Font(Font, _visibleItems[i].Node.FontStyle)) {
                TextRenderer.DrawText(e.Graphics, item.Node.Text, font, textBounds, highlighted ? SystemColors.HighlightText : ForeColor, TEXT_FORMAT_FLAGS);
            }

            if (highlighted && _sourceControl.Focused && _sourceControl.ShowsFocusCues)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, item.DisplayRectangle);
            }
        }
    }
コード例 #21
0
        protected override void OnPaint(PaintEventArgs p)
        {
            if (locked)
            {
                return;
            }

            var g    = p.Graphics;
            var rect = Mode.GetTitleRectangle();

            if (Width != 0 && Height != 0)
            {
                #region Fill Title
                g.FillRectangle(Brushes.White, rect);
                #endregion

                #region Paint tab pages
                int count               = 0;
                int sumWidth            = 0;
                int countInvisiblePages = 0;
                foreach (StiTabulatorPage tb in Controls)
                {
                    if (!tb.Invisible)
                    {
                        count++;
                    }
                    if (!tb.Invisible)
                    {
                        sumWidth += tb.TitleSize.Width;
                    }
                    else
                    {
                        countInvisiblePages++;
                    }
                }

                #region ScrollButton
                if (tabTitlePosition == StiTabTitlePosition.TopHorizontal)
                {
                    if (sumWidth < this.Width && countInvisiblePages > 0)
                    {
                        VisibleRightScrollButton = false;
                        VisibleLeftScrollButton  = true;
                        mode.startPosTitle       = 18;
                        ScrollButtonVisible      = true;
                        ResizeScrollButton();
                    }
                    else
                    {
                        if (sumWidth > this.Width && countInvisiblePages == 0)
                        {
                            VisibleRightScrollButton = true;
                            VisibleLeftScrollButton  = false;
                            mode.startPosTitle       = 8;
                            ScrollButtonVisible      = true;
                            ResizeScrollButton();
                        }
                        else
                        {
                            if (sumWidth < this.Width)
                            {
                                mode.startPosTitle  = 8;
                                ScrollButtonVisible = false;
                                VisiblePage();
                            }
                            else
                            {
                                VisibleRightScrollButton = true;
                                VisibleLeftScrollButton  = true;
                                mode.startPosTitle       = 18;
                                ScrollButtonVisible      = true;
                                ResizeScrollButton();
                            }
                        }
                    }
                }
                #endregion

                if (DesignMode)
                {
                    count = Controls.Count;
                }

                if (count > 0)
                {
                    if (selectedTab == null)
                    {
                        this.SelectedTab = this.Controls[0] as StiTabulatorPage;
                    }

                    for (int index = Controls.Count - 1; index >= 0; index--)
                    {
                        var page = (StiTabulatorPage)Controls[index];
                        if (page != this.selectedTab && ((!page.Invisible) || DesignMode))
                        {
                            DrawPageTitle(g, page);
                        }
                    }

                    DrawPageTitle(g, this.selectedTab);
                }
                #endregion
            }

            #region Paint scroll button
            if (tabTitlePosition == StiTabTitlePosition.TopHorizontal)
            {
                if (ScrollButtonVisible)
                {
                    if (VisibleRightScrollButton)
                    {
                        if (stateRight)
                        {
                            ControlPaint.DrawScrollButton(g, RightRect, ScrollButton.Right, ButtonState.Checked);
                        }
                        else
                        {
                            ControlPaint.DrawScrollButton(g, RightRect, ScrollButton.Right, ButtonState.Normal);
                        }
                    }

                    if (VisibleLeftScrollButton)
                    {
                        if (stateLeft)
                        {
                            ControlPaint.DrawScrollButton(g, LeftRect, ScrollButton.Left, ButtonState.Checked);
                        }
                        else
                        {
                            ControlPaint.DrawScrollButton(g, LeftRect, ScrollButton.Left, ButtonState.Normal);
                        }
                    }
                }
            }
            #endregion
        }
コード例 #22
0
        //-------------------------------------------------------------------
        void PaintTabs(Graphics G)
        {
            // Paint Header
            if (Children.Count == 0)
            {
                return;
            }
            if (Children.Count == 1 && !ShowHeaderWhenOnlyOne)
            {
                return;
            }

            _HeaderVisible = true;

            int indexCurrent = Children.IndexOf(Current);

            if (indexCurrent == -1)
            {
                return;
            }

            int[] wChild = new int[Children.Count];
            int   wTotal = 0;

            for (int i = 0; i < Children.Count; i++)
            {
                TaxonControlInfo info = FactoryOfTaxonControl.TaxonControlInfoFromType(Children[i].GetType());
                info.CurrentTaxonControl = Children[i];

                int w = (int)G.MeasureString(info.DisplayName, Font).Width + 1;
                w += 2 * Theme.Current.TabHeader_Margin;
                w += Theme.Current.TabHeader_IconSize + Theme.Current.TabHeader_GapBetweenIconAndText;

                wChild[i] = w;
                wTotal   += w;
            }

            int[] X = new int[Children.Count + 1];
            int   x = 0;

            if (wTotal < Width)
            {
                for (int i = 0; i < Children.Count; i++)
                {
                    X[i] = x;
                    x   += wChild[i];
                }
                X[Children.Count] = x;
            }
            else if (Children.Count == 1)
            {
                X[1] = Width;
            }
            else
            {
                int[] newW = new int[Children.Count];
                newW[indexCurrent] = wChild[indexCurrent];
                int wLeft       = Width - wChild[indexCurrent];
                int wLeftTab    = (Children.Count - 1);
                int wLeftPerTab = wLeft / wLeftTab;

                if (wLeftPerTab < 24)
                {
                    if (indexCurrent > 0)
                    {
                        _PrevButtonVisible = true;
                        _PrevButtonRect    = new Rectangle(0, (Theme.Current.TabHeader_Height - 16) / 2, 16, 16);
                        x = 20;
                    }
                    newW[indexCurrent] = Width - x;
                    if (indexCurrent < Children.Count - 1)
                    {
                        _NextButtonVisible  = true;
                        _NextButtonRect     = new Rectangle(Width - 16, (Theme.Current.TabHeader_Height - 16) / 2, 16, 16);
                        newW[indexCurrent] -= 20;
                    }
                }
                else
                {
                    bool ended = false;
                    while (!ended)
                    {
                        ended = true;
                        for (int i = 0; i < Children.Count; i++)
                        {
                            if (newW[i] == 0 && wChild[i] < wLeftPerTab)
                            {
                                newW[i] = wChild[i];
                                wLeft  -= wChild[i];
                                wLeftTab--;
                                wLeftPerTab = wLeft / wLeftTab;
                                ended       = false;
                            }
                        }
                    }

                    for (int i = 0; i < Children.Count; i++)
                    {
                        if (newW[i] == 0)
                        {
                            newW[i] = wLeftPerTab;
                        }
                    }
                }

                for (int i = 0; i < Children.Count; i++)
                {
                    X[i] = x;
                    x   += newW[i];
                }
                X[Children.Count] = x;
            }

            _ChildrenRect.Clear();

            for (int i = 0; i < Children.Count; i++)
            {
                Rectangle R = Rectangle.FromLTRB(X[i], 0, X[i + 1], Theme.Current.TabHeader_Height);
                _ChildrenRect.Add(R);
                if (R.Width == 0)
                {
                    continue;
                }
                if (indexCurrent == i)
                {
                    continue;
                }

                TaxonControlInfo info = FactoryOfTaxonControl.TaxonControlInfoFromType(Children[i].GetType());
                Draw.IconAndText(G, R, info.DisplayName, Font, info.Icon, Theme.Current.TabHeaderParams);
            }

            if (_PrevButtonVisible)
            {
                ControlPaint.DrawScrollButton(G, _PrevButtonRect, ScrollButton.Left, ButtonState.Normal);
            }
            if (_NextButtonVisible)
            {
                ControlPaint.DrawScrollButton(G, _NextButtonRect, ScrollButton.Right, ButtonState.Normal);
            }

            // draw at last selected tab
            {
                TaxonControlInfo info = FactoryOfTaxonControl.TaxonControlInfoFromType(Children[indexCurrent].GetType());
                Rectangle        R    = _ChildrenRect[indexCurrent];
                G.FillRectangle(Theme.Current.TabHeader_SelectedBackground, R);
                if (R.Right < ClientRectangle.Right)
                {
                    G.DrawLine(Theme.Current.TabHeader_DarkShadow, R.Right, R.Top, R.Right, R.Bottom - 2);
                }
                if (R.Left > 0)
                {
                    G.DrawLine(Theme.Current.TabHeader_LightShadow, R.Left, R.Bottom, R.Left, R.Top);
                }
                G.DrawLine(Theme.Current.TabHeader_LightShadow, R.Left, R.Top, R.Right, R.Top);
                Draw.IconAndText(G, R, info.DisplayName, Font, info.Icon, Theme.Current.SelectedTabHeaderParams);
            }
        }
コード例 #23
0
 protected override void RenderControl(Graphics g, ButtonState buttonState, CheckState checkState)
 {
     //ControlPaint.DrawScrollButton(g, ClientRectangle, ScrollButton.Up,buttonState);
     ControlPaint.DrawScrollButton(g, ClientRectangle, sButton, buttonState);
 }
コード例 #24
0
        /// <summary>
        /// Paints the combo on the canvas
        /// </summary>
        /// <param name="g"></param>
        public override void Paint(Graphics g)
        {
            if (resize)
            {
                SizeF s = new SizeF(g.MeasureString(mText, mFont));
                s.Width  += mHeight + 20;
                s.Height += 2;
                if (OnResize != null)
                {
                    OnResize(s);
                }
                mWidth  = (int)s.Width;
                mHeight = (int)s.Height;
                resize  = false;
            }
            ControlPaint.DrawComboButton(g, mLocation.X, mLocation.Y, mHeight, mHeight, ButtonState.Flat);
            if (mExpanded)
            {
                if (recalc)
                {
                    RecalcSize(g);
                }

                StringBuilder sb = new StringBuilder();

                for (int k = startIndex; k < Math.Min(mListItems.Count, startIndex + 5); k++)
                {
                    sb.Append(mListItems[k].ToString());
                    sb.Append(Environment.NewLine);
                }

                float step = ((float)expandedHeight) / (5F);
                if (((mListItems.Count > 5) && (startIndex + 5) < mListItems.Count) || startIndex > 0)
                {
                    g.FillRectangle(Brushes.WhiteSmoke, new Rectangle(mLocation.X + mHeight, mLocation.Y, expandedWidth + 10, expandedHeight));
                    //this is the scroller
                    g.FillRectangle(Brushes.LightGray, mLocation.X + mHeight + expandedWidth, mLocation.Y, 10, expandedHeight);
                    //down scroller
                    if ((mListItems.Count > 5) && (startIndex + 5) < mListItems.Count)
                    {
                        ControlPaint.DrawScrollButton(g, mLocation.X + mHeight + expandedWidth, mLocation.Y + expandedHeight - 10, 10, 10, ScrollButton.Down, ButtonState.Flat);
                    }

                    //ControlPaint.DrawScrollButton(g,mLocation.X+mHeight+expandedSize.Width,mLocation.Y+expandedSize.Height,10,10);
                    if (startIndex > 0)
                    {
                        //up scroller
                        ControlPaint.DrawScrollButton(g, mLocation.X + mHeight + expandedWidth, mLocation.Y, 10, 10, ScrollButton.Up, ButtonState.Flat);
                    }
                }
                else
                {
                    g.FillRectangle(Brushes.WhiteSmoke, new Rectangle(mLocation.X + mHeight, mLocation.Y, expandedWidth + 10, expandedHeight + 10));
                }

                g.DrawString(sb.ToString(), mFont, Brushes.Black, new Point(mLocation.X + mHeight, mLocation.Y));
                ControlPaint.DrawBorder(g, new Rectangle(mLocation.X + mHeight, mLocation.Y, expandedWidth + 10, expandedHeight), Color.DarkGray, ButtonBorderStyle.Solid);
            }
            else
            {
                ControlPaint.DrawBorder(g, new Rectangle(mLocation.X + mHeight, mLocation.Y, mWidth - mHeight, mHeight), Color.DarkGray, ButtonBorderStyle.Solid);
                g.DrawString(mText, mFont, Brushes.Black, mLocation.X + mHeight + 2, mLocation.Y + 1);
            }
        }
コード例 #25
0
        // draws all elements
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.Clear(SystemColors.Control);
            if (this.Height < 24 || this.Width < 24)
            {
                return;
            }
            IntPtr data = Win32.OpenThemeData2(this.Handle, "Combobox");

            if (data != IntPtr.Zero)             //draw with winxp themes
            {
                IntPtr hdc = e.Graphics.GetHdc();

                #region background, dropdown button

                Win32.RECT rct = new Win32.RECT(0, 0, this.Width, 22);
                Win32.DrawThemeBackground2(data, hdc, 0, _mouseentered ? 2 : 1, ref rct);
                rct.Left    = rct.Right - 15;
                rct.Top    += 2;
                rct.Bottom -= 2;
                rct.Right  -= 2;
                Win32.DrawThemeBackground2(data, hdc, 1, (int)_elements[0].State, ref rct);
                Win32.CloseThemeData2(data);

                #endregion

                #region spin buttons

                data = Win32.OpenThemeData2(this.Handle, "Spin");
                if (data == IntPtr.Zero)
                {
                    goto final;
                }
                rct.Left -= 13;
                rct.Width = 13;
                rct.Top--;
                rct.Height = 10;
                Win32.DrawThemeBackground2(data, hdc, 1, (int)_elements[1].State, ref rct);
                rct.Top    += 10;
                rct.Bottom += 10;
                Win32.DrawThemeBackground2(data, hdc, 2, (int)_elements[2].State, ref rct);
                Win32.CloseThemeData2(data);

                #endregion

                #region progress bar

                data = Win32.OpenThemeData2(this.Handle, "Progress");
                if (data == IntPtr.Zero)
                {
                    goto final;
                }
                rct.Bottom = this.Height;
                rct.Top    = rct.Bottom - 3;
                rct.Left   = 0;
                rct.Right  = GetPercentage(this.Width);
                Win32.DrawThemeBackground2(data, hdc, 3, 1, ref rct);
                Win32.CloseThemeData2(data);

                #endregion

final:
                e.Graphics.ReleaseHdc(hdc);
            }
            else             //draw without winxp themes
            {
                #region background, dropdown button

                Rectangle rct = new Rectangle(0, 0, this.Width, 22);
                e.Graphics.FillRectangle(Brushes.White, rct);
                e.Graphics.DrawRectangle(_mouseentered ? SystemPens.Highlight : SystemPens.ControlDark,
                                         rct.X, rct.Y, rct.Width - 1, rct.Height - 1);
                rct.X       = this.Width - 15;
                rct.Y       = 1;
                rct.Height -= 2;
                rct.Width   = 15;
                ControlPaint.DrawComboButton(e.Graphics, rct, _elements[0].ToButtonState());

                #endregion

                #region spin button

                rct.X     -= 13;
                rct.Width  = 13;
                rct.Height = 10;
                ControlPaint.DrawScrollButton(e.Graphics, rct, ScrollButton.Up, _elements[1].ToButtonState());
                rct.Y += 10;
                ControlPaint.DrawScrollButton(e.Graphics, rct, ScrollButton.Down, _elements[2].ToButtonState());

                #endregion

                #region progress bar

                rct.Y      = this.Height - 3;
                rct.Height = 3;
                rct.X      = 0;
                rct.Width  = GetPercentage(this.Width);
                e.Graphics.FillRectangle(SystemBrushes.Highlight, rct);

                #endregion
            }
        }
コード例 #26
0
        private SafeHandleGDI GetBufferArrow2()
        {
            SafeHandleGDI target;

            if (this._arrow2Down)
            {
                target = this._hbitmapArrow2Pressed;
            }
            else if (this._arrow2Hover)
            {
                target = this._hbitmapArrow2Hot;
            }
            else
            {
                target = this._hbitmapArrow2;
            }

            if (target != null)
            {
                return(target);
            }

            if (this.arrow2.Width <= 0 || this.arrow2.Height <= 0)
            {
                return(null);
            }

            using (var bmp = new Bitmap(this.arrow2.Width, this.arrow2.Height))
            {
                using (var g = Graphics.FromImage(bmp))
                {
                    if (ScrollBarRenderer.IsSupported)
                    {
                        if (this.Horizontal)
                        {
                            var s4 = this._arrow2Down
                                ? ScrollBarArrowButtonState.RightPressed
                                : this._arrow2Hover
                                    ? ScrollBarArrowButtonState.RightHot
                                    : ScrollBarArrowButtonState.RightNormal;
                            ScrollBarRenderer.DrawArrowButton(g, new Rectangle(0, 0, this.arrow2.Width, this.arrow2.Height), s4);
                        }
                        else
                        {
                            var s4 = this._arrow2Down
                                ? ScrollBarArrowButtonState.DownPressed
                                : this._arrow2Hover
                                    ? ScrollBarArrowButtonState.DownHot
                                    : ScrollBarArrowButtonState.DownNormal;
                            ScrollBarRenderer.DrawArrowButton(g, new Rectangle(0, 0, this.arrow2.Width, this.arrow2.Height), s4);
                        }
                    }
                    else
                    {
                        ControlPaint.DrawScrollButton(
                            g,
                            new Rectangle(0, 0, this.arrow2.Width, this.arrow2.Height),
                            this.Horizontal ? ScrollButton.Right : ScrollButton.Down,
                            this._arrow2Down
                                ? ButtonState.Pushed
                                : ButtonState.Normal);
                    }
                }

                target = new SafeHandleGDI(bmp.GetHbitmap());
            }

            if (this._arrow2Down)
            {
                return(this._hbitmapArrow2Pressed = target);
            }

            if (this._arrow2Hover)
            {
                return(this._hbitmapArrow2Hot = target);
            }

            return(this._hbitmapArrow2 = target);
        }
コード例 #27
0
        internal void Draw(Graphics e)
        {
            StringFormat textFormat = new StringFormat();
            Brush        textBrush  = new SolidBrush(TextColor);
            Brush        bgBrush    = new SolidBrush(BackColor);
            string       minMonth;
            string       maxMonth;
            string       currentMonth;


            string month;

            textFormat.LineAlignment = StringAlignment.Center;
            switch (m_align)
            {
            case mcTextAlign.Center:
            {
                textFormat.Alignment = StringAlignment.Center;
                break;
            }

            case mcTextAlign.Left:
            {
                textFormat.Alignment = StringAlignment.Near;
                break;
            }

            case mcTextAlign.Right:
            {
                textFormat.Alignment = StringAlignment.Far;
                break;
            }
            }

            e.FillRectangle(bgBrush, m_rect);

            if (m_monthSelector)
            {
                currentMonth = m_calendar.Month.SelectedMonth.Year.ToString() + "-" + m_calendar.Month.SelectedMonth.Month.ToString();

                minMonth = m_calendar.MinDate.Year.ToString() + "-" + m_calendar.MinDate.Month.ToString();
                maxMonth = m_calendar.MaxDate.Year.ToString() + "-" + m_calendar.MaxDate.Month.ToString();

                if ((minMonth == currentMonth) && (m_leftBtnState != ButtonState.Pushed))
                {
                    m_leftBtnState = ButtonState.Inactive;
                }
                else if (m_leftBtnState != ButtonState.Pushed)
                {
                    m_leftBtnState = ButtonState.Normal;
                }

                if ((maxMonth == currentMonth) && (m_rightBtnState != ButtonState.Pushed))
                {
                    m_rightBtnState = ButtonState.Inactive;
                }
                else if (m_rightBtnState != ButtonState.Pushed)
                {
                    m_rightBtnState = ButtonState.Normal;
                }
            }
            if (m_yearSelector)
            {
                currentMonth = m_calendar.Month.SelectedMonth.Year.ToString() + "-" + m_calendar.Month.SelectedMonth.Month.ToString() + "-01";

                DateTime currentDate = DateTime.Parse(currentMonth);
                int      days        = DateTime.DaysInMonth(m_calendar.MinDate.Year, m_calendar.MinDate.Month);
                DateTime minDate     = DateTime.Parse(m_calendar.MinDate.Year.ToString() + "-" + m_calendar.MinDate.Month.ToString() + "-" + days.ToString());
                days = DateTime.DaysInMonth(m_calendar.MaxDate.Year, m_calendar.MaxDate.Month);
                DateTime maxDate = DateTime.Parse(m_calendar.MaxDate.Year.ToString() + "-" + m_calendar.MaxDate.Month.ToString() + "-" + days.ToString());

                if ((DateTime.Compare(currentDate.AddYears(-1), minDate) < 0) && (m_leftYearBtnState != ButtonState.Pushed))
                {
                    m_leftYearBtnState = ButtonState.Inactive;
                }
                else if (m_leftYearBtnState != ButtonState.Pushed)
                {
                    m_leftYearBtnState = ButtonState.Normal;
                }

                if ((DateTime.Compare(currentDate.AddYears(1), maxDate) > 0) && (m_rightYearBtnState != ButtonState.Pushed))
                {
                    m_rightYearBtnState = ButtonState.Inactive;
                }
                else if (m_rightYearBtnState != ButtonState.Pushed)
                {
                    m_rightYearBtnState = ButtonState.Normal;
                }
            }


            if (m_calendar.Enabled)
            {
                if (m_monthSelector)
                {
                    ControlPaint.DrawScrollButton(e, m_leftBtnRect, ScrollButton.Left, m_leftBtnState);
                    ControlPaint.DrawScrollButton(e, m_rightBtnRect, ScrollButton.Right, m_rightBtnState);
                }
                if (m_yearSelector)
                {
                    int corr = 0;
                    ControlPaint.DrawButton(e, m_leftYearBtnRect, m_leftYearBtnState);
                    if (m_leftYearBtnState == ButtonState.Pushed)
                    {
                        corr = 1;
                    }
                    if (m_leftYearBtnState != ButtonState.Inactive)
                    {
                        e.DrawImage(m_prevYear, new Point(m_leftYearBtnRect.Left, m_leftYearBtnRect.Top + 2 + corr));
                    }
                    else
                    {
                        e.DrawImage(m_prevYearDisabled, new Point(m_leftYearBtnRect.Left, m_leftYearBtnRect.Top + 2));
                    }

                    ControlPaint.DrawButton(e, m_rightYearBtnRect, m_rightYearBtnState);
                    corr = 0;

                    if (m_rightYearBtnState == ButtonState.Pushed)
                    {
                        corr = 1;
                    }
                    if (m_rightYearBtnState != ButtonState.Inactive)
                    {
                        e.DrawImage(m_nextYear, new Point(m_rightYearBtnRect.Left + 3, m_rightYearBtnRect.Top + 2 + corr));
                    }
                    else
                    {
                        e.DrawImage(m_nextYearDisabled, new Point(m_rightYearBtnRect.Left + 3, m_rightYearBtnRect.Top + 2));
                    }
                }
            }
            else
            {
                //IGOR:
//				ControlPaint.DrawScrollButton(e,m_leftBtnRect,ScrollButton.Left,ButtonState.Inactive);
//				ControlPaint.DrawScrollButton(e,m_rightBtnRect,ScrollButton.Right,ButtonState.Inactive);
//				ControlPaint.DrawButton(e,m_leftYearBtnRect,ButtonState.Inactive);
//				ControlPaint.DrawButton(e,m_rightYearBtnRect,ButtonState.Inactive);
                if (m_monthSelector)
                {
                    ControlPaint.DrawScrollButton(e, m_leftBtnRect, ScrollButton.Left, ButtonState.Inactive);
                    ControlPaint.DrawScrollButton(e, m_rightBtnRect, ScrollButton.Right, ButtonState.Inactive);
                }
                if (m_yearSelector)
                {
                    ControlPaint.DrawButton(e, m_leftYearBtnRect, ButtonState.Inactive);
                    ControlPaint.DrawButton(e, m_rightYearBtnRect, ButtonState.Inactive);
                }
                //IGOR: end
            }


            month = m_calendar.m_dateTimeFormat.GetMonthName(m_calendar.Month.SelectedMonth.Month) + " " + m_calendar.Month.SelectedMonth.Year.ToString();
            if (ShowMonth)
            {
                e.DrawString(month, Font, textBrush, m_textRect, textFormat);
            }
            else
            {
                e.DrawString(m_text, Font, textBrush, m_textRect, textFormat);
            }

            textBrush.Dispose();
            bgBrush.Dispose();
        }
コード例 #28
0
        /// <summary>
        /// Paints the drop-down, including all items within the scrolled region
        /// and, if appropriate, the scrollbar.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (scrollBarVisible)
            {
                Rectangle upper = new Rectangle(scrollBar.DisplayRectangle.Left, scrollBar.DisplayRectangle.Top, scrollBar.DisplayRectangle.Width, scrollBar.Thumb.Top - scrollBar.DisplayRectangle.Top);
                Rectangle lower = new Rectangle(scrollBar.DisplayRectangle.Left, scrollBar.Thumb.Bottom, scrollBar.DisplayRectangle.Width, scrollBar.DisplayRectangle.Bottom - scrollBar.Thumb.Bottom);

                if (sourceControl.DrawWithVisualStyles && ScrollBarRenderer.IsSupported)
                {
                    ScrollBarRenderer.DrawUpperVerticalTrack(e.Graphics, upper, GetScrollBarState(upper));
                    ScrollBarRenderer.DrawLowerVerticalTrack(e.Graphics, lower, GetScrollBarState(lower));
                    ScrollBarRenderer.DrawArrowButton(e.Graphics, scrollBar.UpArrow, GetScrollBarStateUp());
                    ScrollBarRenderer.DrawArrowButton(e.Graphics, scrollBar.DownArrow, GetScrollBarStateDown());
                    ScrollBarRenderer.DrawVerticalThumb(e.Graphics, scrollBar.Thumb, GetScrollBarThumbState());
                    ScrollBarRenderer.DrawVerticalThumbGrip(e.Graphics, scrollBar.Thumb, GetScrollBarThumbState());
                }
                else
                {
                    Rectangle bounds = scrollBar.DisplayRectangle;
                    bounds.Offset(1, 0);
                    Rectangle up = scrollBar.UpArrow;
                    up.Offset(1, 0);
                    Rectangle down = scrollBar.DownArrow;
                    down.Offset(1, 0);
                    Rectangle thumb = scrollBar.Thumb;
                    thumb.Offset(1, 0);

                    System.Drawing.Drawing2D.HatchBrush brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent50, SystemColors.ControlLightLight, SystemColors.Control);

                    e.Graphics.FillRectangle(brush, bounds);
                    ControlPaint.DrawScrollButton(e.Graphics, up, ScrollButton.Up, GetButtonState(scrollBar.UpArrow));
                    ControlPaint.DrawScrollButton(e.Graphics, down, ScrollButton.Down, GetButtonState(scrollBar.DownArrow));
                    ControlPaint.DrawButton(e.Graphics, thumb, ButtonState.Normal);
                }
            }

            for (int i = scrollOffset; i < (scrollOffset + numItemsDisplayed); i++)
            {
                bool     highlighted = (highlightedItemIndex == i);
                NodeInfo item        = visibleItems[i];

                // background
                if (highlighted)
                {
                    e.Graphics.FillRectangle(SystemBrushes.Highlight, item.DisplayRectangle);
                }

                // image and glyphs
                if (item.Image != null)
                {
                    e.Graphics.DrawImage(item.Image, new Rectangle(item.DisplayRectangle.Location, item.Image.Size));
                }

                Font font = new Font(Font, visibleItems[i].Node.FontStyle);

                Rectangle textBounds = new Rectangle(item.DisplayRectangle.X + item.Image.Width + 2, item.DisplayRectangle.Y, item.DisplayRectangle.Width - item.Image.Width - 4, itemHeight);
                TextRenderer.DrawText(e.Graphics, item.Node.Text, font, textBounds, highlighted ? SystemColors.HighlightText : ForeColor, TEXT_FORMAT_FLAGS);
            }
        }
コード例 #29
0
ファイル: Header.cs プロジェクト: menglou/winformyunche
        private void DrawButton(Graphics e, mcButtonState state, mcHeaderButtons button, Rectangle rect)
        {
            Bitmap image = null;
            int    x     = 0;
            int    y     = 0;
            int    corr  = 0;

            if (Application.RenderWithVisualStyles)
            {
                VisualStyleElement element = VisualStyleElement.Button.PushButton.Normal;

                if (m_calendar.Enabled)
                {
                    if (state == mcButtonState.Hot)
                    {
                        element = VisualStyleElement.Button.PushButton.Hot;
                    }
                    else if (state == mcButtonState.Inactive)
                    {
                        element = VisualStyleElement.Button.PushButton.Disabled;
                    }
                    else if (state == mcButtonState.Pushed)
                    {
                        element = VisualStyleElement.Button.PushButton.Pressed;
                    }
                }
                else
                {
                    element = VisualStyleElement.Button.PushButton.Disabled;
                }

                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(e, rect);
                switch (button)
                {
                case mcHeaderButtons.PreviousMonth:
                {
                    image = m_prevMonthVs;
                    x     = rect.Left + 5;
                    y     = rect.Top + 5;
                    break;
                }

                case mcHeaderButtons.PreviousYear:
                {
                    image = m_prevYearVs;
                    x     = rect.Left + 4;
                    y     = rect.Top + 5;
                    break;
                }

                case mcHeaderButtons.NextMonth:
                {
                    image = m_nextMonthVs;
                    x     = rect.Right - 13;
                    y     = rect.Top + 5;
                    break;
                }

                case mcHeaderButtons.NextYear:
                {
                    image = m_nextYearVs;
                    x     = rect.Right - 16;
                    y     = rect.Top + 5;
                    break;
                }
                }

                if ((m_calendar.Enabled) && (state != mcButtonState.Inactive))
                {
                    e.DrawImageUnscaled(image, new Point(x, y));
                }
                else
                {
                    ControlPaint.DrawImageDisabled(e, image, x, y, Color.Transparent);
                }
            }
            else
            {
                ButtonState btnState = ButtonState.Normal;
                if (m_calendar.Enabled)
                {
                    if (state == mcButtonState.Hot)
                    {
                        btnState = ButtonState.Normal;
                    }
                    else if (state == mcButtonState.Inactive)
                    {
                        btnState = ButtonState.Inactive;
                    }
                    else if (state == mcButtonState.Pushed)
                    {
                        btnState = ButtonState.Pushed;
                    }
                }
                else
                {
                    btnState = ButtonState.Inactive;
                }

                switch (button)
                {
                case mcHeaderButtons.PreviousMonth:
                {
                    ControlPaint.DrawScrollButton(e, rect, ScrollButton.Left, btnState);
                    break;
                }

                case mcHeaderButtons.NextMonth:
                {
                    ControlPaint.DrawScrollButton(e, rect, ScrollButton.Right, btnState);
                    break;
                }

                case mcHeaderButtons.NextYear:
                {
                    ControlPaint.DrawButton(e, rect, btnState);
                    if (state == mcButtonState.Pushed)
                    {
                        corr = 1;
                    }
                    if ((m_calendar.Enabled) && (m_nextYearBtnState != mcButtonState.Inactive))
                    {
                        e.DrawImage(m_nextYear, new Point(rect.Left + 3, rect.Top + 2 + corr));
                    }
                    else
                    {
                        e.DrawImage(m_nextYearDisabled, new Point(rect.Left + 3, rect.Top + 2 + corr));
                    }

                    break;
                }

                case mcHeaderButtons.PreviousYear:
                {
                    ControlPaint.DrawButton(e, rect, btnState);
                    if (state == mcButtonState.Pushed)
                    {
                        corr = 1;
                    }
                    if ((m_calendar.Enabled) && (m_prevYearBtnState != mcButtonState.Inactive))
                    {
                        e.DrawImage(m_prevYear, new Point(rect.Left, rect.Top + 2 + corr));
                    }
                    else
                    {
                        e.DrawImage(m_prevYearDisabled, new Point(rect.Left, rect.Top + 2 + corr));
                    }

                    break;
                }
                }
            }
        }
コード例 #30
0
ファイル: ThemeManager.cs プロジェクト: zeroyou/XPTable
        /// <summary>
        /// Draws an UpDown's up and down buttons in the specified state, on the specified
        /// graphics surface, and within the specified bounds
        /// </summary>
        /// <param name="g">The Graphics to draw on</param>
        /// <param name="upButtonRect">The Rectangle that represents the dimensions
        /// of the up button</param>
        /// <param name="upButtonClipRect">The Rectangle that represents the clipping area
        /// for the up button</param>
        /// <param name="upButtonState">An UpDownState value that specifies the
        /// state to draw the up button in</param>
        /// <param name="downButtonRect">The Rectangle that represents the dimensions
        /// of the down button</param>
        /// <param name="downButtonClipRect">The Rectangle that represents the clipping area
        /// for the down button</param>
        /// <param name="downButtonState">An UpDownState value that specifies the
        /// state to draw the down button in</param>
        public static void DrawUpDownButtons(Graphics g, Rectangle upButtonRect, Rectangle upButtonClipRect, UpDownState upButtonState, Rectangle downButtonRect, Rectangle downButtonClipRect, UpDownState downButtonState)
        {
            if (g == null)
            {
                return;
            }

            if (upButtonRect.Width > 0 && upButtonRect.Height > 0 && upButtonClipRect.Width > 0 && upButtonClipRect.Height > 0)
            {
                if (ThemeManager.VisualStylesEnabled)
                {
                    //ThemeManager.DrawThemeBackground(g, ThemeClasses.UpDown, (int) UpDownParts.Up, (int) upButtonState, upButtonRect, upButtonClipRect);
                    VisualStyleRenderer renderer;
                    switch (upButtonState)
                    {
                    case UpDownState.Disabled:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Disabled);
                        break;

                    case UpDownState.Hot:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Hot);
                        break;

                    case UpDownState.Pressed:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Pressed);
                        break;

                    case UpDownState.Normal:
                    default:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Normal);
                        break;
                    }
                    renderer.DrawBackground(g, upButtonRect, upButtonClipRect);
                }
                else
                {
                    ControlPaint.DrawScrollButton(g, upButtonRect, ScrollButton.Up, ThemeManager.ConvertUpDownStateToButtonState(upButtonState));
                }
            }

            if (downButtonRect.Width > 0 && downButtonRect.Height > 0 && downButtonClipRect.Width > 0 && downButtonClipRect.Height > 0)
            {
                if (ThemeManager.VisualStylesEnabled)
                {
                    //ThemeManager.DrawThemeBackground(g, ThemeClasses.UpDown, (int) UpDownParts.Down, (int) downButtonState, downButtonRect, downButtonClipRect);
                    VisualStyleRenderer renderer;
                    switch (downButtonState)
                    {
                    case UpDownState.Disabled:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Disabled);
                        break;

                    case UpDownState.Hot:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Hot);
                        break;

                    case UpDownState.Pressed:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Pressed);
                        break;

                    case UpDownState.Normal:
                    default:
                        renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Normal);
                        break;
                    }
                    renderer.DrawBackground(g, downButtonRect, downButtonClipRect);
                }
                else
                {
                    ControlPaint.DrawScrollButton(g, downButtonRect, ScrollButton.Down, ThemeManager.ConvertUpDownStateToButtonState(downButtonState));
                }
            }
        }