コード例 #1
0
        /// <summary>
        /// Ekrana renkli metin yazdırır.
        /// </summary>
        /// <param name="g">Çizim kaynağı</param>
        /// <param name="text">Metin</param>
        /// <param name="font">Varsayılan Font</param>
        /// <param name="foreGroundColor">Varsayılan Renk</param>
        /// <param name="rectangle">Çizim Alanı</param>
        /// <param name="xOfs">Satır başlarındaki girinti</param>
        /// <param name="alignment">Yazdırılacak metin konumu</param>
        public static void DrawColoredText(Graphics g, string text, Font font, Color foreGroundColor, RectangleF rectangle,
                                           ContentAlignment alignment = ContentAlignment.TopLeft)
        {
            var evulator = GetEvulator(text);

            //Content Aligment derğindeki Yatay alanı alıyoruz.
            System.Windows.Forms.VisualStyles.HorizontalAlign halign = Utils.ContentAligmentToHorizontalAlign(alignment);
            //Content Aligment derğindeki Dfkey alanı alıyoruz.
            System.Windows.Forms.VisualStyles.VerticalAlignment valign = Utils.ContentAligmentToVerticalAlign(alignment);

            //Dikey ve Yatay olarak sol üst konumda ise bu alana girmez.
            if (halign != System.Windows.Forms.VisualStyles.HorizontalAlign.Left || valign != System.Windows.Forms.VisualStyles.VerticalAlignment.Top)
            {
                //Metin içerisindeki konumu hesaplattıroyurz.
                var result = MeasureColoredText(g, text, font, rectangle);
                switch (halign)
                {
                case System.Windows.Forms.VisualStyles.HorizontalAlign.Center:
                    //Metin sarma işlemi uygulandıysa bu alana girmez.
                    if (!result.IsOverlayed)
                    {
                        rectangle.X += rectangle.Width / 2 - result.Size.Width / 2;
                    }
                    break;

                case System.Windows.Forms.VisualStyles.HorizontalAlign.Right:
                    if (!result.IsOverlayed && result.Size.Width <= rectangle.Width)
                    {
                        rectangle.X = rectangle.X + rectangle.Width - result.Size.Width - 1;
                    }
                    break;
                }
                //Metin boyutu, çizim alanından büyük ise girmez.
                if (result.Size.Height < rectangle.Height)
                {
                    switch (valign)
                    {
                    case System.Windows.Forms.VisualStyles.VerticalAlignment.Center:
                        rectangle.Y += rectangle.Height / 2 - result.Size.Height / 2;
                        break;

                    case System.Windows.Forms.VisualStyles.VerticalAlignment.Bottom:
                        rectangle.Y = rectangle.Y + rectangle.Height - result.Size.Height;
                        break;
                    }
                }
            }
            ColoredInfo info = new ColoredInfo()
            {
                Font            = font,
                ForeGroundColor = foreGroundColor,
                PointX          = rectangle.X,
                PointY          = rectangle.Y,
                Graphics        = g,
                DrawRectangle   = rectangle
            };

            evulator.CustomDataSingle = info;
            evulator.Elements.EvulateValue();
        }
コード例 #2
0
 public static CVerticalAlign ToVerticalAlign(System.Windows.Forms.VisualStyles.VerticalAlignment winVerticalAlignment)
 {
     return(new CVerticalAlign((ReportExporters.Common.Model.Style.VerticalAlign)(int) winVerticalAlignment));
 }