예제 #1
0
        /// <summary>
        /// Raises the Paint event.
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            SmoothingMode cachSmothingMode = e.Graphics.SmoothingMode;

            e.Graphics.SmoothingMode     = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            ControlShapeInternal(e);

            EnhanceGroupBoxState state = Enabled ? EnhanceGroupBoxState.Normal : EnhanceGroupBoxState.Disabled;

            _controlElements.BackColor         = BackColor;
            _controlElements.Bounds            = this.ClientRectangle;
            _controlElements.DisabledTextColor = DisabledTextColor;
            _controlElements.Font          = Font;
            _controlElements.ForeColor     = ForeColor;
            _controlElements.Graphics      = e.Graphics;
            _controlElements.GroupBoxStyle = GroupBoxStyle;
            _controlElements.Text          = Text;

            EnhanceGroupBoxRenderer.DrawEnhanceGroupBox(_controlElements, _borderElements, HeaderElements, InsideBorderElements, _dirty, state);

            e.Graphics.SmoothingMode = cachSmothingMode;

            // pass to base last to raise paint event
            base.OnPaint(e);
        }
예제 #2
0
        /// <summary>
        /// Draws a group box control in the specified state and bounds, with the specified group-box, graphics and state.
        /// </summary>
        /// <param name="ecb">GroupBox object</param>
        /// <param name="g">The Graphics used to draw the group box.</param>
        /// <param name="bounds">The Rectangle that specifies the bounds of the group box.</param>
        /// <param name="state">One of the EnhanceGroupBoxState values that specifies the visual state of the group box.</param>
        public static void DrawEnhanceGroupBox(GroupBox ecb, Graphics g, Rectangle bounds, EnhanceGroupBoxState state)
        {
            _eGroupBox       = ecb;
            _clientRectangle = bounds;
            _state           = state;

            // Check if dirty bit is flipped if not return previously drawn image.
            if (_eGroupBox.RenderingDirty == false)
            {
                Graphics.FromImage(_bitmap);
                g.DrawImage(_bitmap, 0, 0, _bitmap.Width, _bitmap.Height);
                return;
            }

            // dirty bit is flipped and we have to redraw everything
            _bitmap      = new Bitmap(_clientRectangle.Width, _clientRectangle.Height, PixelFormat.Format32bppArgb);
            _graphicsObj = Graphics.FromImage(_bitmap);
            _graphicsObj.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            _graphicsObj.Clear(Color.Transparent);

            SetTextbounds(g);
            DrawElements(g);

            g.DrawImage(_bitmap, 0, 0, _bitmap.Width, _bitmap.Height);
            _graphicsObj.Dispose();
        }
        /// <summary>
        /// Draws a group box control in the specified state and bounds, with the specified group-box, graphics and state.
        /// </summary>
        /// <param name="ce">IControlElements implementation class used for drawing user defined group box control.</param>
        /// <param name="be">IBorderElements implemented class used for drawing user defined boarder elements.</param>
        /// <param name="he">IHeaderElements implemented class used for drawing user defined header elements.</param>
        /// <param name="ie">IInsideBorderElements implemented class used for drawing user defined inside boarder elements.</param>
        /// <param name="isDirty">Boolean value specifies one of the graphical element has changed and control rendering needs updating.</param>
        /// <param name="state">One of the EnhanceGroupBoxState values that specifies the visual state of the group box.</param>
        public static void DrawEnhanceGroupBox(IControlElements ce, IBorderElements be, IHeaderElements he, IInsideBorderElements ie, bool isDirty, EnhanceGroupBoxState state)
        {
            _clientRectangle      = ce.Bounds;
            _state                = state;
            _style                = ce.GroupBoxStyle;
            _borderElements       = be;
            _headerElements       = he;
            _insideBorderElements = ie;
            _text              = ce.Text;
            _font              = ce.Font;
            _foreColor         = ce.ForeColor;
            _backColor         = ce.BackColor;
            _disabledTextColor = ce.DisabledTextColor;

            // Check if dirty bit is flipped if not return previously drawn image.
            if (isDirty == false)
            {
                Graphics.FromImage(_bitmap);
                ce.Graphics.DrawImage(_bitmap, 0, 0, _bitmap.Width, _bitmap.Height);
                return;
            }

            // dirty bit is flipped and we have to redraw everything
            _bitmap      = new Bitmap(_clientRectangle.Width, _clientRectangle.Height, PixelFormat.Format32bppArgb);
            _graphicsObj = Graphics.FromImage(_bitmap);
            _graphicsObj.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            _graphicsObj.Clear(Color.Transparent);

            SetTextbounds(ce.Graphics);
            DrawElements();

            ce.Graphics.DrawImage(_bitmap, 0, 0, _bitmap.Width, _bitmap.Height);
            _graphicsObj.Dispose();
        }
예제 #4
0
        /// <summary>
        /// Raises the Paint event.
        /// </summary>
        /// <param name="e">A PaintEventArgs that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            SmoothingMode cachSmothingMode = e.Graphics.SmoothingMode;

            e.Graphics.SmoothingMode     = SmoothingMode.HighQuality;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            ControlShape(e);

            EnhanceGroupBoxState state = Enabled ? EnhanceGroupBoxState.Normal : EnhanceGroupBoxState.Disabled;

            GroupBoxRenderer.DrawEnhanceGroupBox(this, e.Graphics, ClientRectangle, state);

            e.Graphics.SmoothingMode = cachSmothingMode;

            // pass to base last to raise paint event
            base.OnPaint(e);
        }