Beispiel #1
0
        private void LabelModeCombo_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            NFunnelSeries funnel = (NFunnelSeries)nChartControl1.Charts[0].Series[0];

            funnel.LabelMode = (FunnelLabelMode)LabelModeCombo.SelectedIndex;

            HorzAlign ha = HorzAlign.Center;

            switch (funnel.LabelMode)
            {
            case FunnelLabelMode.Left:
            case FunnelLabelMode.LeftAligned:
                ha = HorzAlign.Right;
                break;

            case FunnelLabelMode.Right:
            case FunnelLabelMode.RightAligned:
                ha = HorzAlign.Left;
                break;
            }

            funnel.DataLabelStyle.TextStyle.StringFormatStyle.HorzAlign = ha;

            nChartControl1.Refresh();
        }
Beispiel #2
0
        private void DrawRotatedText(string text, Graphics g, Font font, Brush brush, RectangleF rect,
                                     StringFormat format, HorzAlign horzAlign, float fontWidthRatio, float lineHeight, int angle,
                                     bool wysiwyg, bool forceJustify)
        {
            GraphicsState state    = g.Save();
            Region        saveClip = g.Clip;

            g.SetClip(rect, CombineMode.Intersect);
            g.TranslateTransform(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
            g.RotateTransform(angle);
            rect.X = -rect.Width / 2;
            rect.Y = -rect.Height / 2;

            if ((angle >= 90 && angle < 180) || (angle >= 270 && angle < 360))
            {
                rect = new RectangleF(rect.Y, rect.X, rect.Height, rect.Width);
            }

            g.ScaleTransform(fontWidthRatio, 1);
            rect.X     /= fontWidthRatio;
            rect.Width /= fontWidthRatio;

            if ((angle == 0 || angle == 90 || angle == 180 || angle == 270) &&
                (horzAlign == HorzAlign.Justify || wysiwyg || lineHeight != 0))
            {
                DrawBlockAlign(text, g, font, brush, rect, format, horzAlign, lineHeight, forceJustify);
            }
            else
            {
                g.DrawString(text, font, brush, rect, format);
            }

            g.Restore(state);
            g.SetClip(saveClip, CombineMode.Replace);
        }
Beispiel #3
0
 private void HTMLAlign(StringBuilder sb, HorzAlign horzAlign, VertAlign vertAlign)
 {
     sb.Append("text-align:");
     if (horzAlign == HorzAlign.Left)
     {
         sb.Append("Left");
     }
     else if (horzAlign == HorzAlign.Right)
     {
         sb.Append("Right");
     }
     else if (horzAlign == HorzAlign.Center)
     {
         sb.Append("Center");
     }
     else if (horzAlign == HorzAlign.Justify)
     {
         sb.Append("Justify");
     }
     sb.Append(";vertical-align:");
     if (vertAlign == VertAlign.Top)
     {
         sb.Append("Top");
     }
     else if (vertAlign == VertAlign.Bottom)
     {
         sb.Append("Bottom");
     }
     else if (vertAlign == VertAlign.Center)
     {
         sb.Append("Middle");
     }
     sb.Append(";word-wrap:break-word");
     sb.Append(";");
 }
        private string GetStyle(Font Font, Color TextColor, Color FillColor,
                                bool RTL, HorzAlign HAlign, Border Border, bool WordWrap, float LineHeight, float Width, float Height, bool Clip)
        {
            FastString style = new FastString(256);

            if (Font != null)
            {
                if (Zoom != 1)
                {
                    using (Font newFont = new Font(Font.FontFamily, Font.Size * Zoom, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont))
                        HTMLFontStyle(style, newFont, LineHeight);
                }
                else
                {
                    HTMLFontStyle(style, Font, LineHeight);
                }
            }
            style.Append("text-align:");
            if (HAlign == HorzAlign.Left)
            {
                style.Append(RTL ? "right" : "left");
            }
            else if (HAlign == HorzAlign.Right)
            {
                style.Append(RTL ? "left" : "right");
            }
            else if (HAlign == HorzAlign.Center)
            {
                style.Append("center");
            }
            else
            {
                style.Append("justify");
            }
            style.Append(";");

            if (WordWrap)
            {
                style.Append("word-wrap:break-word;");
            }

            if (Clip)
            {
                style.Append("overflow:hidden;");
            }

            style.Append("position:absolute;color:").
            Append(ExportUtils.HTMLColor(TextColor)).
            Append(";background-color:").
            Append(FillColor.A == 0 ? "transparent" : ExportUtils.HTMLColor(FillColor)).
            Append(";").Append(RTL ? "direction:rtl;" : String.Empty);

            Border newBorder = Border;

            HTMLBorder(style, newBorder);
            style.Append("width:").Append(Px(Width * Zoom)).Append("height:").Append(Px(Height * Zoom));
            return(style.ToString());
        }
Beispiel #5
0
 /// <summary>
 /// Sets the horizontal text alignment for tthe selected objects.
 /// </summary>
 /// <param name="align">Alignment to set.</param>
 public void SetHAlign(HorzAlign align)
 {
     foreach (TextObject text in ModifyList)
     {
         text.HorzAlign = align;
     }
     FDesigner.LastFormatting.HorzAlign = align;
     FDesigner.SetModified();
 }
Beispiel #6
0
 /// <summary>
 /// Draws a string.
 /// </summary>
 /// <param name="text">String to draw.</param>
 /// <param name="g"><b>Graphics</b> object to draw on.</param>
 /// <param name="font">Font that used to draw text.</param>
 /// <param name="brush">Brush that determines the color and texture of the drawn text. </param>
 /// <param name="rect"><b>RectangleF</b> structure that specifies the location of the drawn text.</param>
 /// <param name="format">StringFormat that specifies formatting attributes, such as line spacing and alignment, that are applied to the drawn text.</param>
 /// <param name="horzAlign">Horizontal alignment of the text.</param>
 /// <param name="fontWidthRatio">Width ratio of the font used to draw a string.</param>
 /// <param name="lineHeight">Line height, in pixels.</param>
 /// <param name="angle">Angle of the text, in degrees.</param>
 /// <param name="wysiwyg">Indicates whther to draw string close to the printout.</param>
 /// <param name="forceJustify">Force justify for the last line.</param>
 public void Draw(string text, Graphics g, Font font, Brush brush, RectangleF rect, StringFormat format,
                  HorzAlign horzAlign, float fontWidthRatio, float lineHeight, int angle, bool wysiwyg, bool forceJustify)
 {
     angle %= 360;
     if (angle == 0)
     {
         DrawNormalText(text, g, font, brush, rect, format, horzAlign, fontWidthRatio, lineHeight, wysiwyg, forceJustify);
     }
     else
     {
         DrawRotatedText(text, g, font, brush, rect, format, horzAlign, fontWidthRatio, lineHeight, angle, wysiwyg, forceJustify);
     }
 }
Beispiel #7
0
 private StringBuilder AlignStr(string s, HorzAlign align, int width)
 {
     if (align == HorzAlign.Right)
     {
         return(RightStr(s, width - 1));
     }
     else if (align == HorzAlign.Center)
     {
         return(CenterStr(s, width - 1));
     }
     else
     {
         return(LeftStr(s, width - 1));
     }
 }
Beispiel #8
0
        private string GetRTFHAlignment(HorzAlign HAlign)
        {
            switch (HAlign)
            {
            case HorzAlign.Right:
                return("\\qr");

            case HorzAlign.Center:
                return("\\qc");

            case HorzAlign.Justify:
                return("\\qj");

            default:
                return("\\ql");
            }
        }
Beispiel #9
0
        private void DrawBlockAlign(string text, Graphics g, Font font, Brush textBrush,
                                    RectangleF textRect, StringFormat format, HorzAlign horzAlign, float lineHeight, bool forceJustify)
        {
            bool wordWrap = (format.FormatFlags & StringFormatFlags.NoWrap) == 0;
            StringFormatFlags saveFlags = format.FormatFlags;

            format.FormatFlags |= StringFormatFlags.NoWrap;

            if (lineHeight == 0)
            {
                lineHeight = font.GetHeight(g);
            }

            // wrap words
            int   charactersFitted;
            float height = CalcHeight(text, g, font, textRect.Width, textRect.Height, horzAlign,
                                      lineHeight, forceJustify, (format.FormatFlags & StringFormatFlags.DirectionRightToLeft) > 0,
                                      wordWrap, format.Trimming, out charactersFitted);

            // calculate offset if line alignment is not Near
            float offsetY = textRect.Top;

            if (format.LineAlignment == StringAlignment.Center)
            {
                offsetY = textRect.Top + (textRect.Height - height) / 2;
            }
            else if (format.LineAlignment == StringAlignment.Far)
            {
                offsetY = textRect.Top + (textRect.Height - height) - 1;
            }

            // set clip. needed if amount of text greather than textRect.Height
            Region saveClip = g.Clip;

            g.SetClip(textRect, CombineMode.Intersect);

            // draw each paragraph
            foreach (Paragraph paragraph in FParagraphs)
            {
                paragraph.Draw(g, font, textBrush, textRect.Left, offsetY, textRect.Width, textRect.Height, format);
            }

            g.SetClip(saveClip, CombineMode.Replace);
            format.FormatFlags = saveFlags;
        }
        /// <summary>
        /// Converts List and Label text Align.
        /// </summary>
        /// <param name="str">The List and Label text Align value as string.</param>
        /// <returns>A HorzAlign value.</returns>
        public static HorzAlign ConvertTextAlign(string str)
        {
            HorzAlign align = HorzAlign.Left;

            switch (str)
            {
            case "1":
                align = HorzAlign.Center;
                break;

            case "2":
                align = HorzAlign.Right;
                break;

            default:
                align = HorzAlign.Left;
                break;
            }
            return(align);
        }
        private void SetLabelMode(NFunnelSeries funnel)
        {
            funnel.LabelMode = (FunnelLabelMode)FunnelLabelModeDropDownList.SelectedIndex;

            HorzAlign ha = HorzAlign.Center;

            switch (funnel.LabelMode)
            {
            case FunnelLabelMode.Left:
            case FunnelLabelMode.LeftAligned:
                ha = HorzAlign.Right;
                break;

            case FunnelLabelMode.Right:
            case FunnelLabelMode.RightAligned:
                ha = HorzAlign.Left;
                break;
            }

            funnel.DataLabelStyle.TextStyle.StringFormatStyle.HorzAlign = ha;
        }
Beispiel #12
0
        private void DrawNormalText(string text, Graphics g, Font font, Brush brush, RectangleF rect,
                                    StringFormat format, HorzAlign horzAlign, float fontWidthRatio, float lineHeight,
                                    bool wysiwyg, bool forceJustify)
        {
            GraphicsState state = g.Save();

            g.ScaleTransform(fontWidthRatio, 1);
            rect.X     /= fontWidthRatio;
            rect.Width /= fontWidthRatio;

            if (horzAlign == HorzAlign.Justify || wysiwyg || lineHeight != 0)
            {
                DrawBlockAlign(text, g, font, brush, rect, format, horzAlign, lineHeight, forceJustify);
            }
            else
            {
                g.DrawString(text, font, brush, rect, format);
            }

            g.Restore(state);
        }
Beispiel #13
0
 private void HTMLAlign(FastString sb, HorzAlign horzAlign, VertAlign vertAlign, bool wordWrap)
 {
     sb.Append("text-align:");
     if (horzAlign == HorzAlign.Left)
     {
         sb.Append("Left");
     }
     else if (horzAlign == HorzAlign.Right)
     {
         sb.Append("Right");
     }
     else if (horzAlign == HorzAlign.Center)
     {
         sb.Append("Center");
     }
     else if (horzAlign == HorzAlign.Justify)
     {
         sb.Append("Justify");
     }
     sb.Append(";vertical-align:");
     if (vertAlign == VertAlign.Top)
     {
         sb.Append("Top");
     }
     else if (vertAlign == VertAlign.Bottom)
     {
         sb.Append("Bottom");
     }
     else if (vertAlign == VertAlign.Center)
     {
         sb.Append("Middle");
     }
     if (wordWrap)
     {
         sb.Append(";word-wrap:break-word");
     }
     sb.Append(";overflow:hidden;");
 }
Beispiel #14
0
        private void AlignLine(int startWord, int count, float width, HorzAlign horzAlign)
        {
            if (count == 0)
            {
                return;
            }
            int   lastWordIndex = startWord + count - 1;
            float lineWidth     = FWords[lastWordIndex].Right;

            if (horzAlign == HorzAlign.Justify)
            {
                float delta    = (width - lineWidth) / (count - 1);
                float curDelta = delta;
                for (int i = 1; i < count; i++)
                {
                    FWords[i + startWord].Left += curDelta;
                    curDelta += delta;
                }
            }
            else
            {
                float delta = 0;
                if (horzAlign == HorzAlign.Center)
                {
                    delta = (width - lineWidth) / 2;
                }
                else if (horzAlign == HorzAlign.Right)
                {
                    delta = width - lineWidth;
                }
                for (int i = 0; i < count; i++)
                {
                    FWords[i + startWord].Left += delta;
                }
            }
        }
Beispiel #15
0
 private void HTMLGetStyle(FastString style, Font Font, Color TextColor, Color FillColor, HorzAlign HAlign, VertAlign VAlign,
                           Border Border, Padding Padding, bool RTL, bool wordWrap, float LineHeight, float ParagraphOffset)
 {
     HTMLFontStyle(style, Font, LineHeight);
     style.Append("color:").Append(ExportUtils.HTMLColor(TextColor)).Append(";");
     style.Append("background-color:");
     style.Append(FillColor.A == 0 ? "transparent" : ExportUtils.HTMLColor(FillColor)).Append(";");
     HTMLAlign(style, HAlign, VAlign, wordWrap);
     HTMLBorder(style, Border);
     HTMLPadding(style, Padding, ParagraphOffset);
     HTMLRtl(style, RTL);
     style.AppendLine("}");
 }
 /// <summary>
 /// Align report title content horizontal left, right, center, justify
 /// </summary>
 /// <param name="horzAlign"></param>
 /// <returns></returns>
 public ReportTitleBuilder <T> HorzAlign(HorzAlign horzAlign)
 {
     _report._reportTitle.HorzAlign = horzAlign;
     return(this);
 }
Beispiel #17
0
        private string XmlAlign(HorzAlign horzAlign, VertAlign vertAlign, int angle)
        {
            string Fh = "Left", Fv = "Top";

            if (angle == 0 || angle == 180)
            {
                if (horzAlign == HorzAlign.Left)
                {
                    Fh = "Left";
                }
                else if (horzAlign == HorzAlign.Right)
                {
                    Fh = "Right";
                }
                else if (horzAlign == HorzAlign.Center)
                {
                    Fh = "Center";
                }
                else if (horzAlign == HorzAlign.Justify)
                {
                    Fh = "Justify";
                }
                if (vertAlign == VertAlign.Top)
                {
                    Fv = "Top";
                }
                else if (vertAlign == VertAlign.Bottom)
                {
                    Fv = "Bottom";
                }
                else if (vertAlign == VertAlign.Center)
                {
                    Fv = "Center";
                }
            }
            else if (angle == 90)
            {
                if (horzAlign == HorzAlign.Left)
                {
                    Fv = "Top";
                }
                else if (horzAlign == HorzAlign.Right)
                {
                    Fv = "Bottom";
                }
                else if (horzAlign == HorzAlign.Center)
                {
                    Fv = "Center";
                }
                if (vertAlign == VertAlign.Top)
                {
                    Fh = "Right";
                }
                else if (vertAlign == VertAlign.Bottom)
                {
                    Fh = "Left";
                }
                else if (vertAlign == VertAlign.Center)
                {
                    Fh = "Center";
                }
            }
            else
            {
                if (horzAlign == HorzAlign.Left)
                {
                    Fv = "Bottom";
                }
                else if (horzAlign == HorzAlign.Right)
                {
                    Fv = "Top";
                }
                else if (horzAlign == HorzAlign.Center)
                {
                    Fv = "Center";
                }
                if (vertAlign == VertAlign.Top)
                {
                    Fh = "Right";
                }
                else if (vertAlign == VertAlign.Bottom)
                {
                    Fh = "Left";
                }
                else if (vertAlign == VertAlign.Center)
                {
                    Fh = "Center";
                }
            }
            return("ss:Horizontal=\"" + Fh + "\" ss:Vertical=\"" + Fv + "\"");
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Funnel Chart");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            title.ContentAlignment           = ContentAlignment.BottomRight;
            title.Location = new NPointL(
                new NLength(2, NRelativeUnit.ParentPercentage),
                new NLength(2, NRelativeUnit.ParentPercentage));

            NLegend legend = nChartControl1.Legends[0];

            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom);
            legend.Data.ExpandMode = LegendExpandMode.RowsFixed;
            legend.Data.RowCount   = 2;

            NFunnelChart chart = new NFunnelChart();

            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(
                new NLength(10, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(80, NRelativeUnit.ParentPercentage),
                new NLength(68, NRelativeUnit.ParentPercentage));

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(chart);

            NFunnelSeries funnel = (NFunnelSeries)chart.Series.Add(SeriesType.Funnel);

            funnel.BorderStyle.Color      = Color.LemonChiffon;
            funnel.Legend.DisplayOnLegend = legend;
            funnel.Legend.Format          = "<percent>";
            funnel.Legend.Mode            = SeriesLegendMode.DataPoints;
            funnel.DataLabelStyle.Format  = "<value> [<xsize>]";
            funnel.UseXSizes             = true;
            funnel.Values.ValueFormatter = new NNumericValueFormatter("0.00");
            funnel.XSizes.ValueFormatter = new NNumericValueFormatter("0.00");

            GenerateData(funnel);

            if (!IsPostBack)
            {
                // init form controls
                WebExamplesUtilities.FillComboWithEnumValues(FunnelLabelModeDropDownList, typeof(FunnelLabelMode));
                FunnelLabelModeDropDownList.SelectedIndex = (int)FunnelLabelMode.RightAligned;

                WebExamplesUtilities.FillComboWithValues(FunnelPointGapDropDownList, 0, 15, 1);
                FunnelPointGapDropDownList.SelectedIndex = 6;

                WebExamplesUtilities.FillComboWithValues(FunnelRadiusDropDownList, 0, 100, 10);
                FunnelRadiusDropDownList.SelectedIndex = (int)(chart.Width / 10.0f);

                WebExamplesUtilities.FillComboWithValues(FunnelArrowLengthDropDownList, 0, 10, 1);
                FunnelArrowLengthDropDownList.SelectedIndex = 1;
            }

            // init funnel label mode
            funnel.LabelMode = (FunnelLabelMode)FunnelLabelModeDropDownList.SelectedIndex;

            HorzAlign ha = HorzAlign.Center;

            switch (funnel.LabelMode)
            {
            case FunnelLabelMode.Left:
            case FunnelLabelMode.LeftAligned:
                ha = HorzAlign.Right;
                break;

            case FunnelLabelMode.Right:
            case FunnelLabelMode.RightAligned:
                ha = HorzAlign.Left;
                break;
            }

            funnel.DataLabelStyle.TextStyle.StringFormatStyle.HorzAlign = ha;

            // arrow length
            funnel.DataLabelStyle.ArrowLength = new NLength((float)FunnelArrowLengthDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage);

            // funnel radius
            chart.Width = FunnelRadiusDropDownList.SelectedIndex * 10;

            funnel.FunnelPointGap = FunnelPointGapDropDownList.SelectedIndex / 10.0f;
        }
Beispiel #19
0
        // Wraps the text and calculates its height, in pixels.
        public float CalcHeight(string text, Graphics g, Font font, float width, float height, HorzAlign horzAlign,
                                float lineHeight, bool forceJustify, bool rightToLeft, bool wordWrap, StringTrimming trimming,
                                out int charactersFit)
        {
            if (lineHeight == 0)
            {
                lineHeight = font.GetHeight(g);
            }

            // make paragraphs
            SplitToParagraphs(text);
            charactersFit = -1;

            // wrap words in each paragraph
            float top = 0;

            foreach (Paragraph paragraph in FParagraphs)
            {
                int charsFit = -1;
                top = paragraph.Wrap(g, font, top, (int)Math.Round(width), height, horzAlign, lineHeight, forceJustify,
                                     wordWrap, trimming, out charsFit);
                if (rightToLeft)
                {
                    paragraph.ApplyRTL((int)width);
                }
                if (charsFit != -1 && charactersFit == -1)
                {
                    charactersFit = charsFit;
                }
            }

            // height of the text
            if (charactersFit == -1)
            {
                charactersFit = text.Length;
            }
            return(top);
        }
Beispiel #20
0
        public float Wrap(Graphics g, Font font, float top, float width, float height, HorzAlign horzAlign,
                          float lineHeight, bool forceJustify, bool wordWrap, StringTrimming trimming, out int charactersFit)
        {
            float  left             = 0;
            int    startWord        = 0;
            float  actualLineHeight = font.GetHeight(g);
            string text             = "";

            charactersFit = -1;

            int i = 0;

            while (i < FWords.Count)
            {
                Word word = FWords[i];
                text += word.Text;
                float textWidth = g.MeasureString(text, font).Width;
                word.Left  = left;
                word.Top   = top;
                word.Width = textWidth - left;

                // check line fit
                if (top + actualLineHeight > height + 0.1f)
                {
                    charactersFit = word.OriginalTextIndex;
                }

                // word does not fit
                if (word.Right > width)
                {
                    int wordsFit = i - startWord;
                    if (wordWrap)
                    {
                        text = "";
                        left = 0;

                        if (wordsFit == 0)
                        {
                            if (word.Text.Length == 1)
                            {
                                // it's one-char word, we can't do anything more
                                startWord = i + 1;
                                top      += lineHeight;
                            }
                            else
                            {
                                // there is only one word in the line, we need to break it
                                WrapWord(g, font, width, i);
                                // continue with the first word
                                i--;
                            }
                        }
                        else
                        {
                            // align the line
                            AlignLine(startWord, wordsFit, width, horzAlign);

                            // make it first word in the line and continue with it
                            startWord = i;
                            top      += lineHeight;
                            i--;
                        }
                    }
                    else
                    {
                        switch (trimming)
                        {
                        case StringTrimming.None:
                        case StringTrimming.Character:
                            WrapWord(g, font, width - word.Left, i);
                            if (i < FWords.Count)
                            {
                                FWords[i + 1].Visible = false;
                            }
                            break;

                        case StringTrimming.Word:
                            word.Visible = false;
                            break;

                        case StringTrimming.EllipsisWord:
                            if (wordsFit > 0)
                            {
                                FWords[i - 1].Text += "...";
                            }
                            word.Visible = false;
                            break;

                        case StringTrimming.EllipsisCharacter:
                            WrapWord(g, font, width - word.Left - g.MeasureString("..", font).Width, i);
                            FWords[i].Text += "...";
                            if (i < FWords.Count)
                            {
                                FWords[i + 1].Visible = false;
                            }
                            break;
                        }

                        break;
                    }
                }
                else
                {
                    text += " ";
                    left  = textWidth;
                }

                i++;
            }

            // align the rest
            AlignLine(startWord, i - startWord, width,
                      horzAlign == HorzAlign.Justify && !forceJustify ? HorzAlign.Left : horzAlign);

            // adjust starting position for the next paragraph
            top += lineHeight;
            return(top);
        }
Beispiel #21
0
 /// <summary>
 /// Align column content horizontal left, right, center, justify
 /// </summary>
 /// <param name="horzAlign"></param>
 /// <returns></returns>
 public DataBuilder <T> HorzAlign(HorzAlign horzAlign)
 {
     _column.HorzAlign = horzAlign;
     return(this);
 }
Beispiel #22
0
 private void HTMLGetStyle(StringBuilder style, Font Font, Color TextColor, Color FillColor, HorzAlign HAlign, VertAlign VAlign,
                           Border Border, System.Windows.Forms.Padding Padding, bool RTL)
 {
     HTMLFontStyle(style, Font);
     style.Append("color:").Append(ExportUtils.HTMLColor(TextColor)).Append(";");
     style.Append("background-color:");
     style.Append(FillColor == Color.Transparent ? "transparent" : ExportUtils.HTMLColor(FillColor)).Append(";");
     HTMLAlign(style, HAlign, VAlign);
     HTMLBorder(style, Border);
     HTMLPadding(style, Padding);
     HTMLRtl(style, RTL);
     style.AppendLine("}");
 }
Beispiel #23
0
        private string GetStyle(Font Font, Color TextColor, Color FillColor, bool RTL, HorzAlign HAlign, Border Border)
        {
            StringBuilder style = new StringBuilder(512);

            if (Font != null)
            {
                if (Zoom != 1)
                {
                    Font newFont = new Font(Font.FontFamily, Font.Size * Zoom, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont);
                    HTMLFontStyle(style, newFont);
                }
                else
                {
                    HTMLFontStyle(style, Font);
                }
            }

            style.Append("text-align:");
            if (HAlign == HorzAlign.Left)
            {
                style.Append(RTL ? "right" : "left");
            }
            else if (HAlign == HorzAlign.Right)
            {
                style.Append(RTL ? "left" : "right");
            }
            else if (HAlign == HorzAlign.Center)
            {
                style.Append("center");
            }
            else
            {
                style.Append("justify");
            }
            style.Append(";");

            style.Append(
                String.Join(String.Empty, new String[] {
                "position:absolute;overflow:hidden;color:",
                ExportUtils.HTMLColor(TextColor),
                ";background-color:",
                FillColor == Color.Transparent ? "transparent" : ExportUtils.HTMLColor(FillColor), ";",
                RTL ? "direction:rtl;" : String.Empty
            }));

            Border newBorder = Border; //.Clone();

            newBorder.LeftLine.Width *= Zoom;
            if (newBorder.LeftLine.Width > 0 && newBorder.LeftLine.Width < 1)
            {
                newBorder.LeftLine.Width = 1;
            }

            newBorder.RightLine.Width *= Zoom;
            if (newBorder.RightLine.Width > 0 && newBorder.RightLine.Width < 1)
            {
                newBorder.RightLine.Width = 1;
            }

            newBorder.TopLine.Width *= Zoom;
            if (newBorder.TopLine.Width > 0 && newBorder.TopLine.Width < 1)
            {
                newBorder.TopLine.Width = 1;
            }

            newBorder.BottomLine.Width *= Zoom;
            if (newBorder.BottomLine.Width > 0 && newBorder.BottomLine.Width < 1)
            {
                newBorder.BottomLine.Width = 1;
            }

            HTMLBorder(style, newBorder);

            return(style.ToString());
        }
Beispiel #24
0
        // Wraps the text and calculates its height, in pixels.
        public float CalcHeight(string text, Graphics g, Font font, float width, float height, HorzAlign horzAlign,
                                float lineHeight, bool forceJustify, bool rightToLeft, bool wordWrap, StringTrimming trimming)
        {
            int charactersFit;

            return(CalcHeight(text, g, font, width, height, horzAlign, lineHeight, forceJustify, rightToLeft,
                              wordWrap, trimming, out charactersFit));
        }