private void DrawSlider(Graphics Gfx)
        {
            //Smoothing Mode
            Gfx.SmoothingMode     = SmoothingMode.AntiAlias;
            Gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

            //Slider Bounds
            Rectangle SliderBounds = GetSliderBounds(GetSliderPosition());

            //Check Palette
            if (_palette != null)
            {
                //Get the renderer associated with this palette
                IRenderer Renderer = _palette.GetRenderer();

                //Create the rendering context that is passed into all renderer calls
                using (RenderContext RenderContext = new RenderContext(this, Gfx, SliderBounds, Renderer))
                {
                    // We want to draw the background of the entire control over the entire client area.
                    using (GraphicsPath Path = GetSliderPath(GetSliderPosition()))
                    {
                        // Set the style we want picked up from the base palette
                        m_paletteBack.Style = PaletteBackStyle.HeaderPrimary;

                        // Ask renderer to draw the background
                        m_mementoBack1 = Renderer.RenderStandardBack.DrawBack(RenderContext, SliderBounds, Path, m_paletteBack, VisualOrientation.Top, (this.Enabled ? PaletteState.Normal : PaletteState.Disabled), m_mementoBack1);
                    }

                    //We want the inner part of the control to act like a button, so
                    //we need to find the correct palette state based on if the mouse
                    //is over the control if the mouse button is pressed down or not.
                    PaletteState ButtonState = GetSliderState();

                    //Set the style of button we want to draw
                    m_paletteBack.Style    = PaletteBackStyle.ButtonStandalone;
                    m_paletteBorder.Style  = PaletteBorderStyle.ButtonStandalone;
                    m_paletteContent.Style = PaletteContentStyle.ButtonStandalone;

                    //Do we need to draw the background?
                    if (m_paletteBack.GetBackDraw(ButtonState) == InheritBool.True)
                    {
                        //BackGround Path
                        using (GraphicsPath Path = GetSliderPath(GetSliderPosition()))
                        {
                            // Ask renderer to draw the background
                            m_mementoBack2 = Renderer.RenderStandardBack.DrawBack(RenderContext, SliderBounds, Path, m_paletteBack, VisualOrientation.Top, ButtonState, m_mementoBack2);
                            Gfx.DrawPath(new Pen(m_paletteBorder.GetBorderColor2(ButtonState)), Path);
                            Gfx.DrawLine(new Pen(m_paletteBorder.GetBorderColor2(ButtonState)), (int)SliderBounds.X + (SliderBounds.Width / 2) + 1, SliderBounds.Y + 4, (int)SliderBounds.X + (SliderBounds.Width / 2) + 1, SliderBounds.Y + 8);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (_palette != null)
            {
                // Get the renderer associated with this palette
                IRenderer renderer = _palette.GetRenderer();

                // Create the rendering context that is passed into all renderer calls
                using (RenderContext renderContext = new RenderContext(this, e.Graphics, e.ClipRectangle, renderer))
                {
                    /////////////////////////////////////////////////////////////////////////////////
                    // We want to draw the background of the entire control over the entire client //
                    // area. In this example we are using a background style of HeaderPrimary      //
                    /////////////////////////////////////////////////////////////////////////////////
                    using (GraphicsPath path = CreateRectGraphicsPath(ClientRectangle))
                    {
                        // Set the style we want picked up from the base palette
                        _paletteBack.Style = PaletteBackStyle.HeaderPrimary;

                        // Ask renderer to draw the background
                        _mementoBack1 = renderer.RenderStandardBack.DrawBack(renderContext, ClientRectangle, path, _paletteBack, Orientation,
                                                                             Enabled ? PaletteState.Normal : PaletteState.Disabled, _mementoBack1);
                    }

                    // We want the inner part of the control to act like a button, so
                    // we need to find the correct palette state based on if the mouse
                    // is over the control if the mouse button is pressed down or not.
                    PaletteState buttonState = GetButtonState();

                    // Create a rectangle inset, this is where we will draw a button
                    Rectangle innerRect = ClientRectangle;
                    innerRect.Inflate(-20, -20);

                    // Set the style of button we want to draw
                    _paletteBack.Style    = PaletteBackStyle.ButtonStandalone;
                    _paletteBorder.Style  = PaletteBorderStyle.ButtonStandalone;
                    _paletteContent.Style = PaletteContentStyle.ButtonStandalone;

                    // Do we need to draw the background?
                    if (_paletteBack.GetBackDraw(buttonState) == InheritBool.True)
                    {
                        //////////////////////////////////////////////////////////////////////////////////
                        // In case the border has a rounded effect we need to get the background path   //
                        // to draw from the border part of the renderer. It will return a path that is  //
                        // appropriate for use drawing within the border settings.                      //
                        //////////////////////////////////////////////////////////////////////////////////
                        using (GraphicsPath path = renderer.RenderStandardBorder.GetBackPath(renderContext,
                                                                                             innerRect,
                                                                                             _paletteBorder,
                                                                                             Orientation,
                                                                                             buttonState))
                        {
                            // Ask renderer to draw the background
                            _mementoBack2 = renderer.RenderStandardBack.DrawBack(renderContext, innerRect, path, _paletteBack,
                                                                                 Orientation, buttonState, _mementoBack2);
                        }
                    }

                    // Do we need to draw the border?
                    if (_paletteBorder.GetBorderDraw(buttonState) == InheritBool.True)
                    {
                        // Now we draw the border of the inner area, also in ButtonStandalone style
                        renderer.RenderStandardBorder.DrawBorder(renderContext, innerRect, _paletteBorder, Orientation, buttonState);
                    }

                    // Do we need to draw the content?
                    if (_paletteContent.GetContentDraw(buttonState) == InheritBool.True)
                    {
                        // Last of all we draw the content over the top of the border and background
                        renderer.RenderStandardContent.DrawContent(renderContext, innerRect,
                                                                   _paletteContent, _mementoContent,
                                                                   Orientation, buttonState, false, true);
                    }
                }
            }

            base.OnPaint(e);
        }
Exemplo n.º 3
0
        //ComponentFactory Palette Painting
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            //Define Bounds
            Rectangle  ButtonBounds       = new Rectangle(0, 0, 16, 16);
            RectangleF ButtonCircleBounds = new RectangleF((float)0, (float)0, (float)15.1, (float)15.1);

            //Smoothing Mode
            e.Graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

            //Paint Base
            base.OnPaint(e);

            if (_palette != null)
            {
                //Get the renderer associated with this palette
                IRenderer Renderer = _palette.GetRenderer();

                //Create the rendering context that is passed into all renderer calls
                using (RenderContext RenderContext = new RenderContext(this, e.Graphics, ButtonBounds, Renderer))
                {
                    // Set the style we want picked up from the base palette
                    m_paletteBack.Style = PaletteBackStyle.HeaderPrimary;


                    //Fill The Space
                    using (GraphicsPath Path = GetButtonPath(ButtonBounds))
                    {
                        // Ask renderer to draw the background
                        m_mementoBack1 = Renderer.RenderStandardBack.DrawBack(RenderContext, ButtonBounds, Path, m_paletteBack, m_orientation, (this.Enabled ? PaletteState.Normal : PaletteState.Disabled), m_mementoBack1);
                    }

                    // We want the inner part of the control to act like a button, so
                    // we need to find the correct palette state based on if the mouse
                    // is over the control if the mouse button is pressed down or not.
                    PaletteState ButtonState = GetButtonState();

                    // Set the style of button we want to draw
                    m_paletteBack.Style    = m_visuallook;
                    m_paletteBorder.Style  = (PaletteBorderStyle)m_visuallook;
                    m_paletteContent.Style = (PaletteContentStyle)m_visuallook;

                    // Do we need to draw the background?
                    if (m_paletteBack.GetBackDraw(ButtonState) == InheritBool.True)
                    {
                        using (GraphicsPath Path = GetRoundedSquarePath(ButtonCircleBounds))
                        {
                            // Ask renderer to draw the background
                            m_mementoBack2 = Renderer.RenderStandardBack.DrawBack(RenderContext, ButtonBounds, Path, m_paletteBack, m_orientation, ButtonState, m_mementoBack2);
                        }
                    }

                    // Do we need to draw the border?
                    if (m_paletteBorder.GetBorderDraw(ButtonState) == InheritBool.True)
                    {
                        // Now we draw the border of the inner area, also in ButtonStandalone style
                        e.Graphics.DrawEllipse(new Pen(m_paletteBorder.GetBorderColor2(ButtonState)), ButtonCircleBounds);
                    }

                    e.Graphics.SmoothingMode = SmoothingMode.None;

                    //Draw Magnifying Sign
                    switch (m_buttonstyle)
                    {
                    case ButtonStyles.MinusButton:
                        Rectangle MinusOuterBounds = new Rectangle(3, (this.Height / 2) - 2, 10, 4);
                        Rectangle MinusInnerBounds = new Rectangle(4, (this.Height / 2) - 1, 8, 2);

                        e.Graphics.FillRectangle(new SolidBrush(m_outerColor), MinusOuterBounds);
                        e.Graphics.FillRectangle(new SolidBrush(m_innerColor), MinusInnerBounds);

                        break;

                    case ButtonStyles.PlusButton:
                        DrawPlusOuter(e.Graphics, m_outerColor);
                        DrawPlusInner(e.Graphics, m_innerColor);
                        break;
                    }
                }
            }
        }
        private void PaintTab(int index, RenderContext renderContext)
        {
            bool Selected = (SelectedIndex == index);

            Rectangle tabRect = GetTabRect(index);

            if ((Appearance & TabAppearance.Normal) == TabAppearance.Normal)
            {
                tabRect.Inflate(0, Selected ? 2 : 1);
                tabRect.X += 1;
            }

            PaletteState State = default(PaletteState);

            if (Selected)
            {
                State = PaletteState.Pressed;
            }
            else
            {
                State = tabRect.Contains(PointToClient(MousePosition)) ? PaletteState.Tracking : PaletteState.Normal;
            }

            VisualOrientation visualOrientation = (VisualOrientation)Alignment;

            if (m_PaletteTabButtonBackground.GetBackDraw(State) == InheritBool.True)
            {
                using (GraphicsPath BackPath = m_Renderer.RenderStandardBorder.GetBackPath(renderContext, tabRect, m_PaletteTabButtonBorder, visualOrientation, State))
                {
                    m_MementoTabButtonBackground = m_Renderer.RenderStandardBack.DrawBack(renderContext, tabRect, BackPath, m_PaletteTabButtonBackground, visualOrientation, State, m_MementoTabButtonBackground);
                }
            }

            if (m_PaletteTabButtonBorder.GetBorderDraw(State) == InheritBool.True)
            {
                m_Renderer.RenderStandardBorder.DrawBorder(renderContext, tabRect, m_PaletteTabButtonBorder, visualOrientation, State);
            }
            else if (Selected)
            {
                using (Pen PBorder = new Pen(m_PaletteTabPageBorder.GetBorderColor1(PaletteState.Normal)))
                {
                    Rectangle RBorder = tabRect;
                    RBorder.Width -= 1;

                    renderContext.Graphics.DrawRectangle(PBorder, RBorder);
                }
            }

            // (TODO: adjust rendering for other Appearance settings)

            if (ImageList != null)
            {
                Image tabImage = null;

                if (TabPages[index].ImageIndex != -1)
                {
                    int imageIndex = TabPages[index].ImageIndex;
                    tabImage = ImageList.Images[imageIndex];
                }
                else if (TabPages[index].ImageKey != null)
                {
                    string imageKey = TabPages[index].ImageKey;
                    tabImage = ImageList.Images[imageKey];
                }

                if (tabImage != null)
                {
                    int x = tabRect.X + (tabImage.Width / 2);
                    int y = tabRect.Y + (tabRect.Height - tabImage.Height) / 2;

                    renderContext.Graphics.DrawImage(tabImage, x, y);

                    tabRect.X     += tabImage.Width;
                    tabRect.Width -= tabImage.Width;
                }
            }

            if (m_TabFont == null || (!object.ReferenceEquals(m_TabFont, g_TabFontBold) & !object.ReferenceEquals(m_TabFont, g_TabFontRegular)))
            {
                if (renderContext.Graphics.MeasureString(TabPages[index].Text, g_TabFontBold, tabRect.X, g_StringFormat).Width <= tabRect.Width)
                {
                    m_TabFont = g_TabFontBold;
                }
                else
                {
                    m_TabFont = g_TabFontRegular;
                }
            }

            renderContext.Graphics.DrawString(TabPages[index].Text, m_TabFont, m_TabBrush, tabRect, g_StringFormat);
        }
        /// <summary>
        /// Overrides the paint event
        /// </summary>
        /// <param name="e">PaintEventArgs</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            int num2 = 5;

            if (_palette != null)
            {
                // (3) Get the renderer associated with this palette
                IRenderer renderer = _palette.GetRenderer();

                // (4) Create the rendering context that is passed into all renderer calls
                using (RenderContext renderContext = new RenderContext(this, e.Graphics, e.ClipRectangle, renderer))
                {
                    _paletteBack.Style   = PaletteBackStyle.PanelClient;
                    _paletteBorder.Style = PaletteBorderStyle.HeaderPrimary;
                    using (GraphicsPath path = renderer.RenderStandardBorder.GetBackPath(renderContext, e.ClipRectangle, _paletteBorder, VisualOrientation.Top, PaletteState.Normal))
                    {
                        _mementoBack = renderer.RenderStandardBack.DrawBack(renderContext,
                                                                            ClientRectangle,
                                                                            path,
                                                                            _paletteBack,
                                                                            VisualOrientation.Top,
                                                                            PaletteState.Normal,
                                                                            _mementoBack);
                    }
                    renderer.RenderStandardBorder.DrawBorder(renderContext, ClientRectangle, _border, VisualOrientation.Top, PaletteState.Normal);

                    //If no grouped columns, draw to the indicating text
                    if (columnsList.Count == 0)
                    {
                        TextRenderer.DrawText(e.Graphics, "DRAGCOLUMNTOGROUP", _palette.GetContentShortTextFont(PaletteContentStyle.LabelNormalPanel, PaletteState.Normal), e.ClipRectangle, _palette.GetContentShortTextColor1(PaletteContentStyle.LabelNormalPanel, PaletteState.Normal),
                                              TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);
                    }

                    PaletteState state;
                    _paletteBack.Style   = PaletteBackStyle.GridHeaderColumnList;
                    _paletteBorder.Style = PaletteBorderStyle.GridHeaderColumnList;
                    // PaintGroupBox(e.Graphics, e.ClipRectangle, this.Font, "Drag a column here to group", columnsList.Count > 0);

                    //Draw the column boxes
                    foreach (OutlookGridGroupBoxColumn current in this.columnsList)
                    {
                        Rectangle rectangle = default(Rectangle);
                        rectangle.Width  = 100;
                        rectangle.X      = num2;
                        rectangle.Y      = (e.ClipRectangle.Height - 25) / 2;
                        rectangle.Height = 25;
                        num2            += 105;
                        current.Rect     = rectangle;

                        if (current.IsHovered)
                        {
                            state = PaletteState.Tracking;
                        }
                        else if (current.Pressed)
                        {
                            state = PaletteState.Pressed;
                        }
                        else
                        {
                            state = PaletteState.Normal;
                        }
                        // Do we need to draw the background?
                        if (_paletteBack.GetBackDraw(PaletteState.Normal) == InheritBool.True)
                        {
                            //Back
                            using (GraphicsPath path = renderer.RenderStandardBorder.GetBackPath(renderContext, rectangle, _paletteBorder, VisualOrientation.Top, PaletteState.Normal))
                            {
                                _mementoBack = renderer.RenderStandardBack.DrawBack(renderContext,
                                                                                    rectangle,
                                                                                    path,
                                                                                    _paletteBack,
                                                                                    VisualOrientation.Top,
                                                                                    state,
                                                                                    _mementoBack);
                            }

                            //Border
                            renderer.RenderStandardBorder.DrawBorder(renderContext, rectangle, _paletteBorder, VisualOrientation.Top, state);

                            //Text
                            TextRenderer.DrawText(e.Graphics, current.Text, _palette.GetContentShortTextFont(PaletteContentStyle.GridHeaderColumnList, state), rectangle, _palette.GetContentShortTextColor1(PaletteContentStyle.GridHeaderColumnList, state),
                                                  TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);

                            //Sort Glyph
                            renderer.RenderGlyph.DrawGridSortGlyph(renderContext, current.SortOrder, rectangle, _paletteDataGridViewAll.HeaderColumn.Content, state, false);
                        }

                        //Draw the column box while it is moving
                        if (current.IsMoving)
                        {
                            Rectangle rectangle1 = new Rectangle(_mouse.X, _mouse.Y, current.Rect.Width, current.Rect.Height);
                            //this.Renderer.PaintMovingColumn(graphics, this.currentDragColumn, rectangle1);
                            using (SolidBrush solidBrush = new SolidBrush(Color.FromArgb(70, Color.Gray)))
                            {
                                e.Graphics.FillRectangle(solidBrush, rectangle1);
                            }

                            TextRenderer.DrawText(e.Graphics, current.Text, _palette.GetContentShortTextFont(PaletteContentStyle.GridHeaderColumnList, PaletteState.Disabled), rectangle1, _palette.GetContentShortTextColor1(PaletteContentStyle.GridHeaderColumnList, PaletteState.Disabled),
                                                  TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);
                        }
                    }
                }
            }

            base.OnPaint(e);
        }