Ejemplo n.º 1
0
        private void RenderText(Graphics g)
        {
            using (TextRenderingHintGraphics textRenderGraphics
                = new TextRenderingHintGraphics(g))
            {
                PointF point = CalculateRenderTextStartPoint(g);
                Color fc = ForeColor;
                Color bc = BorderColor;
                if (ForeColorSuit)
                {
                    bool Base = SkinTools.ColorSlantsDarkOrBright(this.Parent.BackColor);
                    if (Base)
                    {
                        fc = Color.White;
                        bc = Color.Black;
                    }
                    else
                    {
                        fc = Color.Black;
                        bc = Color.White;

                    }
                }
                switch (_artTextStyle)
                {
                    case ArtTextStyle.Border:
                        RenderBordText(g, point, fc, bc);
                        break;
                    case ArtTextStyle.Relievo:
                        RenderRelievoText(g, point, fc, bc);
                        break;
                    case ArtTextStyle.Forme:
                        RenderFormeText(g, point, fc, bc);
                        break;
                    case ArtTextStyle.Anamorphosis:
                        RenderAnamorphosisText(g, point, fc, bc);
                        break;
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnRenderImageMargin(

            ToolStripRenderEventArgs e)

        {

            ToolStrip toolStrip = e.ToolStrip;

            Graphics g = e.Graphics;

            Rectangle bounds = e.AffectedBounds;



            if (toolStrip is ToolStripDropDown)

            {

                bool bDrawLogo = NeedDrawLogo(toolStrip);

                bool bRightToLeft = toolStrip.RightToLeft == RightToLeft.Yes;



                Rectangle imageBackRect = bounds;

                imageBackRect.Width = OffsetMargin;



                if (bDrawLogo)

                {

                    Rectangle logoRect = bounds;

                    logoRect.Width = OffsetMargin;

                    if (bRightToLeft)

                    {

                        logoRect.X -= 2;

                        imageBackRect.X = logoRect.X - OffsetMargin;

                    }

                    else

                    {

                        logoRect.X += 2;

                        imageBackRect.X = logoRect.Right;

                    }

                    logoRect.Y += 1;

                    logoRect.Height -= 2;



                    using (LinearGradientBrush brush = new LinearGradientBrush(

                        logoRect,

                        ColorTable.BackHover,

                        ColorTable.BackNormal,

                        90f))

                    {

                        Blend blend = new Blend();

                        blend.Positions = new float[] { 0f, .2f, 1f };

                        blend.Factors = new float[] { 0f, 0.1f, .9f };

                        brush.Blend = blend;

                        logoRect.Y += 1;

                        logoRect.Height -= 2;

                        using (GraphicsPath path =

                            GraphicsPathHelper.CreatePath(logoRect, 8, RoundStyle.All, false))

                        {

                            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))

                            {

                                g.FillPath(brush, path);

                            }

                        }

                    }



                    StringFormat sf = new StringFormat(StringFormatFlags.NoWrap);

                    Font font = new Font(

                        toolStrip.Font.FontFamily, 11, FontStyle.Bold);

                    sf.Alignment = StringAlignment.Near;

                    sf.LineAlignment = StringAlignment.Center;

                    sf.Trimming = StringTrimming.EllipsisCharacter;



                    g.TranslateTransform(logoRect.X, logoRect.Bottom);

                    g.RotateTransform(270f);



                    if (!string.IsNullOrEmpty(MenuLogoString))

                    {

                        Rectangle newRect = new Rectangle(

                            0, 0, logoRect.Height, logoRect.Width);



                        using (Brush brush = new SolidBrush(ColorTable.Fore))

                        {

                            using (TextRenderingHintGraphics tg =

                                new TextRenderingHintGraphics(g))

                            {

                                g.DrawString(

                                    MenuLogoString,

                                    font,

                                    brush,

                                    newRect,

                                    sf);

                            }

                        }

                    }



                    g.ResetTransform();

                }

                else

                {

                    if (bRightToLeft)

                    {

                        imageBackRect.X -= 3;

                    }

                    else

                    {

                        imageBackRect.X += 3;

                    }

                }



                imageBackRect.Y += 2;

                imageBackRect.Height -= 4;

                using (SolidBrush brush = new SolidBrush(ColorTable.DropDownImageBack))

                {

                    g.FillRectangle(brush, imageBackRect);

                }



                Point ponitStart;

                Point pointEnd;

                if (bRightToLeft)

                {

                    ponitStart = new Point(imageBackRect.X, imageBackRect.Y);

                    pointEnd = new Point(imageBackRect.X, imageBackRect.Bottom);

                }

                else

                {

                    ponitStart = new Point(imageBackRect.Right - 1, imageBackRect.Y);

                    pointEnd = new Point(imageBackRect.Right - 1, imageBackRect.Bottom);

                }



                using (Pen pen = new Pen(ColorTable.DropDownImageSeparator))

                {

                    g.DrawLine(pen, ponitStart, pointEnd);

                }

            }

            else

            {

                base.OnRenderImageMargin(e);

            }

        }