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);
                        }
                    }
                }
            }
        }
示例#2
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;
                    }
                }
            }
        }