コード例 #1
0
        private void PaintElement(Graphics g, VisualStyleElement element, Rectangle rect, int state)
        {
            if (VisualStyleRenderer.IsSupported)
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element.ClassName, element.Part, state);

                renderer.DrawBackground(g, rect);
            }
            else
            {
                ButtonState buttonState = ButtonState.Normal;

                if (state == State.Disabled)
                {
                    buttonState = ButtonState.Inactive;
                }
                else if (state == State.Pressed)
                {
                    buttonState = ButtonState.Pushed;
                }

                if (element == _elementClose)
                {
                    ControlPaint.DrawCaptionButton(g, rect, CaptionButton.Close, buttonState);
                }
                else
                {
                    ControlPaint.DrawButton(g, rect, buttonState);
                }
            }
        }
コード例 #2
0
        private void DrawButtonBorder(Graphics g, TabButton button)
        {
            switch (buttonStyle)
            {
            case TabButtonStyle.Flat:
                // 平らなタブコントロール
                if (button.IsSelected)
                {
                    ControlPaint.DrawBorder3D(g, button.Bounds, Border3DStyle.Sunken);
                }

                // タブとタブの間に境界線を描画
                Size      border = SystemInformation.Border3DSize;
                Rectangle rect   = button.Bounds;
                rect.X     = rect.Right + border.Width / 2;
                rect.Width = border.Width;
                ControlPaint.DrawBorder3D(g, rect, Border3DStyle.Etched, Border3DSide.Right);
                break;

            case TabButtonStyle.Button:
                // ボタン式タブコントロール
                if (button.IsSelected)
                {
                    ControlPaint.DrawBorder3D(g, button.Bounds, Border3DStyle.Sunken);
                }
                else
                {
                    ControlPaint.DrawButton(g,
                                            button.Bounds, ButtonState.Normal);
                }
                break;
            }
        }
コード例 #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            IntPtr data = Win32.OpenThemeData2(this.Handle, "Trackbar");

            if (data != IntPtr.Zero)
            {
                IntPtr     hdc = e.Graphics.GetHdc();
                Win32.RECT rct = new Win32.RECT(
                    this.Width / 2 - 2, _tracker.Bounds.Height / 2,
                    4, this.Height - _tracker.Bounds.Height);
                Win32.DrawThemeBackground2(data, hdc, 1, 1, ref rct);
                rct = _tracker.Bounds;
                Win32.DrawThemeBackground2(data, hdc, 8, 1 + (int)_tracker.State, ref rct);
                Win32.CloseThemeData2(hdc);
                e.Graphics.ReleaseHdc(hdc);
            }
            else
            {
                ControlPaint.DrawBorder3D(e.Graphics,
                                          _tracker.Bounds.Width / 2, this.Height / 2 - 2,
                                          this.Width - _tracker.Bounds.Width, 4,
                                          Border3DStyle.SunkenOuter, Border3DSide.All);
                ControlPaint.DrawButton(e.Graphics, _tracker.Bounds, ButtonState.Normal);
            }
        }
コード例 #4
0
        /// <summary>
        /// draws a fader
        /// </summary>
        private void DrawFader(Graphics gr, double pos, Color col, bool flip, bool selected)
        {
            Rectangle fader = PosToRectangle(pos);

            Point[]    pts   = GetFaderPolygon(fader, flip);
            RectangleF field = GetFaderArea(fader, flip);

            //draw fader
            gr.FillPolygon(selected ? SystemBrushes.Highlight : SystemBrushes.Control, pts);
            //draw background
            ControlPaint.DrawButton(gr, Rectangle.Inflate(
                                        Rectangle.Ceiling(field), 1, 1), ButtonState.Flat);
            if (col.A != 255)
            {
                using (HatchBrush brs = new HatchBrush(HatchStyle.SmallCheckerBoard,
                                                       Color.Gray, Color.White))
                {
                    gr.RenderingOrigin = Point.Truncate(field.Location);
                    gr.FillRectangle(brs, field);
                }
            }
            //draw color
            using (SolidBrush brs = new SolidBrush(col))
            {
                gr.FillRectangle(brs, field);
            }
            //frame
            gr.DrawPolygon(Pens.Black, pts);
        }
コード例 #5
0
ファイル: TreeListPainter.cs プロジェクト: wolf96/renderdoc
        public virtual void DrawHeader(Graphics dc, Rectangle cellRect, TreeListColumn column, TreeList.TextFormatting format, bool isHot, bool highlight)
        {
            Rectangle textRect = AdjustRectangle(cellRect, format.Padding);

            if (!Application.RenderWithVisualStyles)
            {
                ControlPaint.DrawButton(dc, cellRect,
                                        m_owner.ViewOptions.UserRearrangeableColumns && highlight ? ButtonState.Pushed : ButtonState.Flat);
                DrawHeaderText(dc, textRect, column, format);
                return;
            }
            VisualStyleElement element = VisualStyleElement.Header.Item.Normal;

            if (isHot || highlight)
            {
                element = VisualStyleElement.Header.Item.Hot;
            }
            if (VisualStyleRenderer.IsElementDefined(element))
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(dc, cellRect);

                if (format.BackColor != Color.Transparent)
                {
                    SolidBrush brush = new SolidBrush(format.BackColor);
                    dc.FillRectangle(brush, cellRect);
                    brush.Dispose();
                }
                //dc.DrawRectangle(Pens.Black, cellRect);

                DrawHeaderText(dc, textRect, column, format);
            }
        }
コード例 #6
0
ファイル: XButton.cs プロジェクト: vkarthim/l10nsharp
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Draws the button with an image.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void DrawArrow(PaintEventArgs e)
        {
            Rectangle rc = ClientRectangle;

            // If possible, render the button with visual styles. Otherwise,
            // paint the plain Windows 2000 push button.
            VisualStyleElement element = GetCorrectVisualStyleArrowElement();

            if (PaintingHelper.CanPaintVisualStyle(element))
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawParentBackground(e.Graphics, rc, this);
                renderer.DrawBackground(e.Graphics, rc);
                return;
            }

            if (!Font.SizeInPoints.Equals(12))
            {
                Font = new Font(Font.FontFamily, 12, GraphicsUnit.Point);
            }

            ControlPaint.DrawButton(e.Graphics, rc,
                                    (m_state == PaintState.HotDown ? ButtonState.Pushed : ButtonState.Normal));

            // In the Marlette font, '3' is the left arrow and '4' is the right.
            var arrowGlyph = (m_drawLeftArrowButton ? "3" : "4");

            var clr = (Enabled ? SystemColors.ControlText : SystemColors.GrayText);

            // The 'r' in the Marlette font is the close button symbol 'X'
            TextRenderer.DrawText(e.Graphics, arrowGlyph, Font, rc, clr, fTxtFmtflags);
        }
コード例 #7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            try
            {
                Rectangle r = e.ClipRectangle;
                if (r.IsEmpty)
                {
                    return;
                }
                ControlPaint.DrawButton(e.Graphics, r, down ? ButtonState.Pushed : ButtonState.Normal);

                if (down)
                {
                    r.Offset(1, 1);
                }
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                Point p = new Point(r.X + 2, r.Y + r.Height / 2 - 2);
                for (int i = 0; i < 2; i++)
                {
                    int     w  = r.Right - p.X - 4;
                    Point[] ps = { p, new Point(p.X + w / 2, p.Y + 2), new Point(p.X + w, p.Y) };
                    e.Graphics.DrawLines(Pens.Black, ps);
                    p.Y += 3;
                }
            }
            catch { }
        }
コード例 #8
0
        private void selectionListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            if (e.Index >= 0)
            {
                var buttonBounds = e.Bounds;
                var maxIndex     = selectionListBox.Items.Count - 1;
                buttonBounds.Width  = (int)e.Graphics.MeasureString(maxIndex.ToString(), e.Font).Width;
                buttonBounds.Width += 2 * ButtonMargin + 1;
                ControlPaint.DrawButton(e.Graphics, buttonBounds, ButtonState.Inactive);

                var indexWidth = (int)e.Graphics.MeasureString(e.Index.ToString(), e.Font).Width;
                buttonBounds.X = (buttonBounds.Width - indexWidth) / 2;
                e.Graphics.DrawString(e.Index.ToString(), e.Font, Brushes.Black, buttonBounds.Location);

                var itemBounds = e.Bounds;
                itemBounds.X += buttonBounds.Width;

                var itemBrush = Brushes.Black;
                if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
                {
                    itemBrush = Brushes.White;
                }

                var itemText   = selectionListBox.Items[e.Index].ToString();
                var itemExtent = (int)e.Graphics.MeasureString(itemText, e.Font).Width + buttonBounds.Width;
                selectionListBox.HorizontalExtent = Math.Max(selectionListBox.HorizontalExtent, itemExtent);
                e.Graphics.DrawString(itemText, e.Font, itemBrush, itemBounds, StringFormat.GenericDefault);
            }
            e.DrawFocusRectangle();
        }
コード例 #9
0
ファイル: TreeListPainter.cs プロジェクト: lonelyong/NgNet
        /// <summary>
        ///
        /// </summary>
        /// <param name="dc"></param>
        /// <param name="cellRect"></param>
        /// <param name="column"></param>
        /// <param name="format"></param>
        /// <param name="isHot"></param>
        public virtual void DrawHeader(Graphics dc, Rectangle cellRect, TreeListColumn column, TextFormatting format, bool isHot)
        {
            if (!Application.RenderWithVisualStyles)
            {
                ControlPaint.DrawButton(dc, cellRect, ButtonState.Flat);
                return;
            }
            VisualStyleElement element = VisualStyleElement.Header.Item.Normal;

            if (isHot)
            {
                element = VisualStyleElement.Header.Item.Hot;
            }
            if (VisualStyleRenderer.IsElementDefined(element))
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawBackground(dc, cellRect);

                if (format.BackColor != Color.Transparent)
                {
                    SolidBrush brush = new SolidBrush(format.BackColor);
                    dc.FillRectangle(brush, cellRect);
                    brush.Dispose();
                }
                cellRect = new Rectangle(cellRect.X + format.Padding.Left, cellRect.Y + format.Padding.Top, cellRect.Width - format.Padding.Left - format.Padding.Right, cellRect.Height - format.Padding.Top - format.Padding.Bottom);
                //dc.DrawRectangle(Pens.Black, cellRect);

                Color           color = format.ForeColor;
                TextFormatFlags flags = TextFormatFlags.EndEllipsis | format.GetFormattingFlags();
                TextRenderer.DrawText(dc, column.Caption, column.Font, cellRect, color, flags);
            }
        }
コード例 #10
0
ファイル: TabPageButton.cs プロジェクト: SetCode/Fluid
        /// <summary>
        /// Draws the vertical button back onto the specified graphics.
        /// <seealso cref="Graphics"/>
        /// </summary>
        /// <param name="graphics">Button graphics object.</param>
        private void DrawVerticalButtonBack(Graphics graphics)
        {
            // Draw button border
            ButtonState buttonState = (this.pressed) ? ButtonState.Pushed : ButtonState.Normal;

            ControlPaint.DrawButton(graphics, this.ClientRectangle, buttonState);
        }
コード例 #11
0
        public override void DrawDayHeader(Graphics g, Rectangle rect, DateTime date)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            using (StringFormat format = new StringFormat())
            {
                format.Alignment     = StringAlignment.Center;
                format.FormatFlags   = StringFormatFlags.NoWrap;
                format.LineAlignment = StringAlignment.Center;

                ControlPaint.DrawButton(g, rect, ButtonState.Inactive);
                ControlPaint.DrawBorder3D(g, rect, Border3DStyle.Etched);

                g.DrawString(
                    System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek),
                    BaseFont,
                    SystemBrushes.WindowText,
                    rect,
                    format
                    );
            }
        }
コード例 #12
0
    void ButtonOnPaint(object obj, PaintEventArgs pea)
    {
        Button   btn  = (Button)obj;
        Graphics grfx = pea.Graphics;

        ControlPaint.DrawButton(grfx, 0, 0, cxBtn, cyBtn,
                                (btn == (Button)GetChildAtPoint(
                                     PointToClient(
                                         MousePosition))) &&
                                btn.Capture ? ButtonState.Pushed : ButtonState.Normal);

        GraphicsState grfxstate = grfx.Save();

        grfx.TranslateTransform((cxBtn - cxImage) / 2,
                                (cyBtn - cyImage) / 2);
        if (btn == btnLarger)
        {
            DrawLargerButton(grfx, cxImage, cyImage);
        }
        else
        {
            DrawSmallerButton(grfx, cxImage, cyImage);
        }

        grfx.Restore(grfxstate);

        if (btn.Focused)
        {
            ControlPaint.DrawFocusRectangle(grfx,
                                            new Rectangle((cxBtn - cxImage) / 2 + cxImage / 16,
                                                          (cyBtn - cyImage) / 2 + cyImage / 16,
                                                          cxImage * 14 / 16,
                                                          cyImage * 14 / 16));
        }
    }
コード例 #13
0
ファイル: ButtonCell.cs プロジェクト: zxscn/ReoGrid
        /// <summary>
        /// Draw button surface.
        /// </summary>
        /// <param name="dc">Platform independence drawing context.</param>
        /// <param name="state">Button state.</param>
        protected virtual void DrawButton(CellDrawingContext dc)
        {
#if WINFORM
            ControlPaint.DrawButton(dc.Graphics.PlatformGraphics, (System.Drawing.Rectangle)Bounds,
                                    this.IsPressed ? ButtonState.Pushed :
                                    (this.Cell.IsReadOnly ? ButtonState.Inactive : ButtonState.Normal));
#elif WPF
            var g = dc.Graphics;

            //g.TranslateTransform(20f, 00f);

            var r = this.Bounds;
            g.DrawRectangle(r, SolidColor.Dark(StaticResources.SystemColor_ControlDark));

            //var r2 = new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1);
            var r3 = new Rectangle(r.X + 1, r.Y + 1, r.Width - 2, r.Height - 2);
            g.FillRectangle(r3, StaticResources.SystemColor_Control);

            if (this.IsPressed)
            {
                //	g.DrawRectangle(r, StaticResources.SystemColor_ControlDark);

                //	r.X++; r.Y++; r.Width--; r.Height--;
                //	g.DrawRectangle(r, SolidColor.Dark(StaticResources.SystemColor_ControlDark));
                var r2 = new Rectangle(r.X + 1, r.Y + 1, r.Width - 2, r.Height - 2);
                g.DrawRectangle(r2, SolidColor.Dark(StaticResources.SystemColor_ControlDark));
            }
            else
            {
                //var r2 = new Rectangle(r.X + 1, r.Y + 1, r.Width - 1, r.Height - 1);
                //g.DrawRectangle(r2, StaticResources.SystemColor_ControlDark);
            }
#endif // WPF
        }
コード例 #14
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);
            }
        }
コード例 #15
0
        // TODO: Use VisualStyles stuff in .NET 2.0 instead
        /// <summary>
        /// Draws a button in the appropriate system theme (Aero vs. Luna vs. Classic).
        /// </summary>
        /// <remarks>
        /// Note to implementors: This may be implemented as a simple thunk to ControlPaint.DrawButton().
        /// </remarks>
        public static void DrawThemedButton(
            Control hostControl,
            Graphics g,
            int x,
            int y,
            int width,
            int height,
            UI.ButtonState state)
        {
            System.Windows.Forms.ButtonState swfState;

            switch (state)
            {
            case UI.ButtonState.Disabled:
                swfState = System.Windows.Forms.ButtonState.Inactive;
                break;

            default:
            case UI.ButtonState.Hot:
            case UI.ButtonState.Normal:
                swfState = System.Windows.Forms.ButtonState.Normal;
                break;

            case UI.ButtonState.Pressed:
                swfState = System.Windows.Forms.ButtonState.Pushed;
                break;
            }

            ControlPaint.DrawButton(g, x, y, width, height, swfState);


            GC.KeepAlive(hostControl);
        }
コード例 #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gr"></param>
        /// <param name="rect"></param>
        /// <param name="o"></param>
        /// <param name="state"></param>
        protected override void DrawThumb(Graphics gr, Rectangle rect, Orientation o, ElementState state)
        {
            if (ThemeFactory.VisualStylesEnabled && ThemeFactory.VisualStylesSupported)
            {
                ThemeFactory.DrawScrollBar(gr, rect, ElementStateToScrollBarStates(state),
                                           o == Orientation.Horizontal ? ScrollBarParts.ThumbBtnHorz : ScrollBarParts.ThumbBtnVert);

                if (FirstCoord((Point)rect.Size) > 17)
                {
                    ThemeFactory.DrawScrollBar(gr, rect, ElementStateToScrollBarStates(state),
                                               o == Orientation.Horizontal ? ScrollBarParts.GripperHorz : ScrollBarParts.GripperVert);
                }
            }
            else
            {
                if (state == ElementState.Pushed)
                {
                    ControlPaint.DrawButton(gr, rect, ButtonState.Pushed);
                }
                else
                {
                    ControlPaint.DrawButton(gr, rect, ButtonState.Normal);
                }
            }
        }
コード例 #17
0
 private void button2_Click(object sender, System.EventArgs e)
 {
     // Draws a flat button on button1.
     ControlPaint.DrawButton(
         System.Drawing.Graphics.FromHwnd(button1.Handle), 0, 0, button1.Width, button1.Height,
         ButtonState.Flat);
 }
コード例 #18
0
        /// <summary>
        /// The button look is determined in this override.
        /// </summary>
        /// <param name="e"></param>
        protected override void PaintForeground(GridPaintEventArgs e)
        {
            if ((Control.MouseButtons == MouseButtons.Left) &&
                (this.RectangleToScreen(e.ClientRectangle).Contains(Control.MousePosition)))
            {
                ControlPaint.DrawButton(e.Graphics, e.DisplayRectangle, ButtonState.Pushed);
            }
            else
            {
                ControlPaint.DrawButton(e.Graphics, e.DisplayRectangle, ButtonState.Normal);
            }

            using (SolidBrush brush = new SolidBrush(this.GetDisplayVisualStyle(VisualGridElementState.Idle).ForeColor))
            {
                Rectangle textRectangle = e.DisplayRectangle;
                textRectangle.Inflate(-2, -2);

                if ((textRectangle.Height > 0) && (textRectangle.Width > 0))
                {
                    // Paint a fixed text
                    e.Graphics.DrawString("编辑", this.Font, brush, textRectangle);

                    // For text that follows the value of the cell, you could do someting like the following :
                    // e.Graphics.DrawString( this.GetTextToPaint(), this.Font, brush, textRectangle );
                }
            }
        }
コード例 #19
0
ファイル: MainToolBar.cs プロジェクト: zhujingcheng/CP3
            /// <summary>
            /// Renders the background of toolbar buttons
            /// </summary>
            /// <param name="e">The render parameters</param>
            protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
            {
                // Perform the default actions
                // NOTE: Is this needed? If not, do we have to clear the button background?
                base.OnRenderButtonBackground(e);

                // Plus draw the button border based on the state of the button
                if (e.Item is ToolStripButton)
                {
                    ButtonState state = 0;
                    if (!e.Item.Enabled)
                    {
                        state |= ButtonState.Inactive;
                    }
                    if (((ToolStripButton)e.Item).Checked)
                    {
                        state |= ButtonState.Checked;
                    }
                    if (e.Item.Pressed)
                    {
                        state |= ButtonState.Pushed;
                    }
                    if (state == 0)
                    {
                        state = ButtonState.Normal;
                    }
                    ControlPaint.DrawButton(e.Graphics, new Rectangle(0, 0, e.Item.Width, e.Item.Height), state);
                }
            }
コード例 #20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Draws the button with an image.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void DrawArrow(PaintEventArgs e)
        {
            Rectangle rc = ClientRectangle;

            // If possible, render the button with visual styles. Otherwise,
            // paint the plain Windows 2000 push button.
            VisualStyleElement element = GetCorrectVisualStyleArrowElement();

            if (PaintingHelper.CanPaintVisualStyle(element))
            {
                VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                renderer.DrawParentBackground(e.Graphics, rc, this);
                renderer.DrawBackground(e.Graphics, rc);
                return;
            }

            if (Font.SizeInPoints != 12)
            {
                Font = new Font(Font.FontFamily, 12, GraphicsUnit.Point);
            }

            ControlPaint.DrawButton(e.Graphics, rc,
                                    (m_state == PaintState.HotDown ? ButtonState.Pushed : ButtonState.Normal));

            var arrowGlyph = Platform.IsWindows
                             // In the Marlett font, '3' is the left arrow and '4' is the right.
                                ? (m_drawLeftArrowButton ? "3" : "4")
                             // Linux doesn't have the Marlett font, so use standard Unicode dingbats here.
                                : (m_drawLeftArrowButton ? "\u25C4" : "\u25BA");

            Color clr = (Enabled ? SystemColors.ControlText : SystemColors.GrayText);

            TextRenderer.DrawText(e.Graphics, arrowGlyph, Font, rc, clr, m_txtFmtflags);
        }
コード例 #21
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Handles the Paint event of the m_parent control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
 /// ------------------------------------------------------------------------------------
 void OnParentPaint(object sender, PaintEventArgs e)
 {
     if (m_fVisible)
     {
         e.Graphics.FillRectangle(SystemBrushes.Window, e.ClipRectangle);
         ControlPaint.DrawButton(e.Graphics, m_sizingRectangle, ButtonState.Normal);
     }
 }
コード例 #22
0
        private static void PaintButton(Graphics g, Rectangle bounds, ButtonState state)
        {
            Rectangle buttonBounds = new Rectangle(bounds.X, bounds.Y, m_buttonWidth, m_buttonHeight);

            ControlPaint.DrawButton(g, buttonBounds, state);

            g.DrawImageUnscaled(m_editIcon, bounds.X, bounds.Y);
        }
コード例 #23
0
        public override void DrawButton(System.Drawing.Graphics g, System.Drawing.Rectangle rect, System.Windows.Forms.ButtonState buttonState, Syncfusion.Windows.Forms.Grid.GridStyleInfo style)
        {
            ControlPaint.DrawButton(g, rect, buttonState);

            // Icon
            rect.Inflate(-3, -3);
            Syncfusion.Drawing.BrushPaint.FillRectangle(g, rect, new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.PathEllipse, Color.Black, Color.Wheat));
        }
コード例 #24
0
        protected override void Paint(PPaintContext paintContext)
        {
            base.Paint(paintContext);

            if ((int)Width > 0)
            {
                ControlPaint.DrawButton(paintContext.Graphics, (int)X, (int)Y, (int)Width, (int)Height, ButtonState.Flat);
            }
        }
コード例 #25
0
ファイル: ListViewRenderer.cs プロジェクト: ckjbug/VisualPlus
        /// <summary>Draw column in header control.</summary>
        /// <param name="graphicsColumn">The graphics column.</param>
        /// <param name="rectColumn">The rectangle column.</param>
        /// <param name="column">The column.</param>
        /// <param name="theme">The _theme.</param>
        /// <param name="listView">The list View.</param>
        public static void DrawColumnHeader(Graphics graphicsColumn, Rectangle rectColumn, VisualListViewColumn column, IntPtr theme, VisualListViewAdvanced listView)
        {
            DebugTraceManager.WriteDebug("ListViewRenderer::DrawColumnHeader - Name: " + column.Name, DebugTraceManager.DebugOutput.TraceListener);

            if (listView.ControlStyle == LVControlStyles.SuperFlat)
            {
                SolidBrush brush = new SolidBrush(listView.SuperFlatHeaderColor);
                graphicsColumn.FillRectangle(brush, rectColumn);
                brush.Dispose();
            }
            else if ((listView.ControlStyle == LVControlStyles.XP) && listView.ThemesAvailable)
            {
                // this is really the only thing we care about for themeing right now inside the control
                IntPtr hDC = graphicsColumn.GetHdc();

                RECT colrect  = new RECT(rectColumn.X, rectColumn.Y, rectColumn.Right, rectColumn.Bottom);
                RECT cliprect = new RECT(rectColumn.X, rectColumn.Y, rectColumn.Right, rectColumn.Bottom);

                if (column.State == ColumnStates.None)
                {
                    // Debug.WriteLine( "Normal" );
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 1, ref colrect, ref cliprect);
                }
                else if (column.State == ColumnStates.Pressed)
                {
                    // Debug.WriteLine( "Pressed" );
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 3, ref colrect, ref cliprect);
                }
                else if (column.State == ColumnStates.Hot)
                {
                    // Debug.WriteLine( "Hot" );
                    Uxtheme.DrawThemeBackground(theme, hDC, 1, 2, ref colrect, ref cliprect);
                }

                graphicsColumn.ReleaseHdc(hDC);
            }
            else
            {
                // normal state
                if (column.State != ColumnStates.Pressed)
                {
                    ControlPaint.DrawButton(graphicsColumn, rectColumn, ButtonState.Normal);
                }
                else
                {
                    ControlPaint.DrawButton(graphicsColumn, rectColumn, ButtonState.Pushed);
                }
            }

            // if there is an image, this routine will RETURN with exactly the space left for everything else after the image is drawn (or not drawn due to lack of space)
            if ((column.ImageIndex > -1) && (listView.ImageListColumns != null) && (column.ImageIndex < listView.ImageListColumns.Images.Count))
            {
                rectColumn = DrawCellGraphic(graphicsColumn, rectColumn, listView.ImageListColumns.Images[column.ImageIndex], HorizontalAlignment.Left, listView.CellPaddingSize, listView);
            }

            DrawCellText(graphicsColumn, rectColumn, column.Text, listView.Font, column.TextAlignment, listView.ForeColor, false, listView);
        }
コード例 #26
0
        /// ------------------------------------------------------------------------------------
        private void PaintNonThemeButton(Graphics g, ButtonState state)
        {
            ControlPaint.DrawButton(g, _button.ClientRectangle, state);

            using (Font fnt = new Font("Marlett", 10))
            {
                TextRenderer.DrawText(g, "6", fnt, _button.ClientRectangle, SystemColors.ControlDarkDark,
                                      TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
            }
        }
コード例 #27
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);
         }
     }
 }
コード例 #28
0
            protected override void OnPaint(PaintEventArgs e)
            {
                if (VisualStyleRenderer.IsSupported &&
                    VisualStyleRenderer.IsElementDefined(VisualStyleElement.ExplorerBar.HeaderClose.Normal) &&
                    VisualStyleRenderer.IsElementDefined(VisualStyleElement.ExplorerBar.HeaderClose.Hot) &&
                    VisualStyleRenderer.IsElementDefined(VisualStyleElement.ExplorerBar.HeaderClose.Pressed))
                {
                    VisualStyleElement element;
                    if (!this.ShowGreyed && IsMouseOver(this.ClientRectangle))
                    {
                        element = IsLeftMouseButtonPressed() ? VisualStyleElement.ExplorerBar.HeaderClose.Pressed : VisualStyleElement.ExplorerBar.HeaderClose.Hot;
                    }
                    else
                    {
                        element = VisualStyleElement.ExplorerBar.HeaderClose.Normal;
                    }

                    VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                    Size size = renderer.GetPartSize(e.Graphics, this.ClientRectangle, ThemeSizeType.True);
                    using (Bitmap bmp = new Bitmap(size.Width, size.Height))
                    {
                        using (Graphics g = Graphics.FromImage(bmp))
                        {
                            renderer.DrawBackground(g, this.ClientRectangle);
                        }
                        e.Graphics.DrawImage(bmp, this.ClientRectangle);
                    }
                }
                else
                {
                    const int lineWidth = 2;

                    if (this.ShowGreyed)
                    {
                        ControlPaint.DrawButton(e.Graphics, this.ClientRectangle, ButtonState.Inactive);
                    }
                    else if (IsMouseOver(this.ClientRectangle) && IsLeftMouseButtonPressed())
                    {
                        ControlPaint.DrawButton(e.Graphics, this.ClientRectangle, ButtonState.Pushed);
                    }
                    else
                    {
                        ControlPaint.DrawButton(e.Graphics, this.ClientRectangle, ButtonState.Normal);
                    }

                    using (Pen p = new Pen(this.ShowGreyed ? SystemBrushes.GrayText : SystemBrushes.ControlText, lineWidth))
                    {
                        Rectangle crossBounds = this.ClientRectangle;
                        crossBounds.Location += new Size(2 * lineWidth, 2 * lineWidth);
                        crossBounds.Size     -= new Size(4 * lineWidth + 1, 4 * lineWidth + 1);
                        e.Graphics.DrawLine(p, crossBounds.Left, crossBounds.Top, crossBounds.Right, crossBounds.Bottom);
                        e.Graphics.DrawLine(p, crossBounds.Left, crossBounds.Bottom, crossBounds.Right, crossBounds.Top);
                    }
                }
            }
コード例 #29
0
ファイル: PackageView.cs プロジェクト: aalmada/bonsai
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            var color  = (e.State & TreeNodeStates.Selected) != 0 ? SystemColors.HighlightText : SystemColors.WindowText;
            var bounds = e.Bounds;

            bounds.Width = RightMargin - bounds.X;

            if (e.Node.Tag == null)
            {
                TextRenderer.DrawText(e.Graphics, e.Node.Text, Font, bounds, color,
                                      TextFormatFlags.WordBreak | TextFormatFlags.VerticalCenter);
            }
            else
            {
                if (e.Node.Checked)
                {
                    var checkedImageX = RightMargin - packageViewNodeCheckedImage.Width - boundsMargin;
                    var checkedImageY = bounds.Y + operationButtonBounds.Y;
                    e.Graphics.DrawImage(packageViewNodeCheckedImage, checkedImageX, checkedImageY);
                    bounds.Width -= packageViewNodeCheckedImage.Width;
                }
                else if ((e.State & TreeNodeStates.Selected) != 0)
                {
                    var font         = Font;
                    var buttonBounds = GetOperationButtonBounds(bounds);
                    bounds.Width -= buttonBounds.Width + boundsMargin * 2;

                    if (VisualStyleRenderer.IsSupported)
                    {
                        ButtonRenderer.DrawButton(e.Graphics, buttonBounds, OperationText, font, false, PushButtonState.Normal);
                    }
                    else
                    {
                        var buttonTextSize   = TextRenderer.MeasureText(OperationText, font);
                        var buttonTextOffset = new Point(
                            buttonBounds.Location.X + (buttonBounds.Size.Width - buttonTextSize.Width) / 2,
                            buttonBounds.Location.Y + (buttonBounds.Size.Height - buttonTextSize.Height) / 2);
                        ControlPaint.DrawButton(e.Graphics, buttonBounds, ButtonState.Normal);
                        TextRenderer.DrawText(e.Graphics, OperationText, font, buttonTextOffset, SystemColors.ControlText);
                    }
                }

                var lines = e.Node.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                TextRenderer.DrawText(e.Graphics, lines[0], boldFont, bounds, color, TextFormatFlags.WordEllipsis);

                if (lines.Length > 1)
                {
                    bounds.Y += TextRenderer.MeasureText(lines[0], boldFont, bounds.Size, TextFormatFlags.WordEllipsis).Height;
                    TextRenderer.DrawText(e.Graphics, lines[1], Font, bounds, color, TextFormatFlags.WordBreak);
                }
            }

            base.OnDrawNode(e);
        }
コード例 #30
0
        private void DrawButton(PaintEventArgs e, ArrowDirection direction)
        {
            Rectangle    rect  = (direction == ArrowDirection.Right) ? rightBounds : leftBounds;
            SpinnerState state = (direction == ArrowDirection.Right) ? rightState : leftState;

            // Draw Button
            ButtonState[] bs = { ButtonState.Normal, ButtonState.Pushed, ButtonState.Normal }; //style translation
            ControlPaint.DrawButton(e.Graphics, rect, bs[(int)state]);                         //translate style and draw
            // Draw Arrow and Possible Highlight
            DrawArrow(e, rect, direction, state);
        }