예제 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Pen      p = null;

            // draw control border
            if (FShowBorder)
            {
                using (p = new Pen(Color.FromArgb(127, 157, 185)))
                {
                    g.DrawRectangle(p, 0, 0, Width - 1, Height - 1);
                }
            }

            g.SmoothingMode = SmoothingMode.AntiAlias;
            // draw ticks
            int size   = Math.Min(Width, Height - 30);
            int cx     = size / 2;
            int cy     = cx;
            int radius = size / 2 - 10;

            p           = new Pen(Color.Silver);
            p.DashStyle = DashStyle.Dot;
            g.DrawEllipse(p, 10, 10, size - 20, size - 20);
            p.Dispose();
            for (int i = 0; i < 360; i += 45)
            {
                Rectangle rect = new Rectangle(cx + (int)(Math.Cos(Math.PI / 180 * i) * radius) - 2,
                                               cy + (int)(Math.Sin(Math.PI / 180 * i) * radius) - 2, 4, 4);
                g.FillEllipse(i == FAngle ? Brushes.DarkOrange : SystemBrushes.Window, rect);
                g.DrawEllipse(i == FAngle ? Pens.DarkOrange : Pens.Black, rect);
            }

            // draw sample
            using (StringFormat sf = new StringFormat())
            {
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                StandardTextRenderer.Draw(Res.Get("Misc,Sample"), g, Font, SystemBrushes.WindowText,
                                          new RectangleF(cx - radius + 1, cy - radius + 1, radius * 2, radius * 2),
                                          sf, FAngle, 1);
            }
        }
예제 #2
0
        /// <summary>
        /// Draws a text.
        /// </summary>
        /// <param name="e">Paint event data.</param>
        public void DrawText(FRPaintEventArgs e)
        {
            if (!String.IsNullOrEmpty(Text))
            {
                Graphics   g        = e.Graphics;
                RectangleF textRect = new RectangleF(
                    (AbsLeft + Padding.Left) * e.ScaleX,
                    (AbsTop + Padding.Top) * e.ScaleY,
                    (Width - Padding.Horizontal) * e.ScaleX,
                    (Height - Padding.Vertical) * e.ScaleY);

                StringFormat format = GetStringFormat(e.Cache, 0);

                Font font = e.Cache.GetFont(Font.Name,
                                            IsPrinting ? Font.Size : Font.Size * e.ScaleX * 96f / DrawUtils.ScreenDpi,
                                            Font.Style);

                Brush textBrush = null;
                if (TextFill is SolidFill)
                {
                    textBrush = e.Cache.GetBrush((TextFill as SolidFill).Color);
                }
                else
                {
                    textBrush = TextFill.CreateBrush(textRect);
                }

                Report report = Report;
                if (report != null && report.TextQuality != TextQuality.Default)
                {
                    g.TextRenderingHint = GetTextQuality(report.TextQuality);
                }

                if (textRect.Width > 0 && textRect.Height > 0)
                {
                    if (LineHeight == 0 && HorzAlign != HorzAlign.Justify && !Wysiwyg && !HtmlTags)
                    {
                        // use simple rendering
                        if (Angle == 0 && FontWidthRatio == 1)
                        {
                            g.DrawString(Text, font, textBrush, textRect, format);
                        }
                        else
                        {
                            StandardTextRenderer.Draw(Text, g, font, textBrush, textRect, format, Angle, FontWidthRatio);
                        }
                    }
                    else
                    {
                        // use advanced rendering
                        AdvancedTextRenderer renderer = new AdvancedTextRenderer(Text, g, font, textBrush,
                                                                                 textRect, format, HorzAlign, VertAlign, LineHeight * e.ScaleY, Angle, FontWidthRatio,
                                                                                 ForceJustify, Wysiwyg, HtmlTags, false);
                        renderer.Draw();
                    }
                }

                if (!(TextFill is SolidFill))
                {
                    textBrush.Dispose();
                }
                if (report != null && report.TextQuality != TextQuality.Default)
                {
                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }

            DrawUnderlines(e);
        }