示例#1
0
        internal string GetPdfFont(StyleInfo si)
        {
            string face = FontNameNormalize(si.FontFamily);

            if (face == "Times-Roman")
            {
                if (si.IsFontBold() && si.FontStyle == FontStyleEnum.Italic)
                {
                    face = "Times-BoldItalic";
                }
                else if (si.IsFontBold())
                {
                    face = "Times-Bold";
                }
                else if (si.FontStyle == FontStyleEnum.Italic)
                {
                    face = "Times-Italic";
                }
            }
            else if (si.IsFontBold() &&
                     si.FontStyle == FontStyleEnum.Italic)              // bold and italic?
            {
                face = face + "-BoldOblique";
            }
            else if (si.IsFontBold())                                   // just bold?
            {
                face = face + "-Bold";
            }
            else if (si.FontStyle == FontStyleEnum.Italic)
            {
                face = face + "-Oblique";
            }

            return(GetPdfFont(face));
        }
示例#2
0
        private void DoStyle(Style style, Row row)
        {
            if (style == null)
            {
                return;
            }

            StyleInfo si = style.GetStyleInfo(r, row);

//            tw.Write(@"\plain");        // reset current attributes

            // Handle the font
            if (!_Fonts.Contains(si.FontFamily))
            {
                _Fonts.Add(si.FontFamily);
            }
            int fc = _Fonts.IndexOf(si.FontFamily);

            tw.Write(@"\f{0} ", fc);

            if (si.IsFontBold())
            {
                tw.Write(@"\b");
            }
            if (si.FontStyle == FontStyleEnum.Italic)
            {
                tw.Write(@"\i");
            }
            switch (si.TextDecoration)
            {
            case TextDecorationEnum.Underline:
                tw.Write(@"\ul");
                break;

            case TextDecorationEnum.LineThrough:
                tw.Write(@"\strike");
                break;

            default:
                break;
            }

            tw.Write(@"\fs{0}", (int)Math.Round(si.FontSize * 2, 0));        // font size

            // Handle the color
            int ic;

            if (!_Colors.Contains(si.Color))
            {
                _Colors.Add(si.Color);
            }
            ic = _Colors.IndexOf(si.Color) + 1;

            tw.Write(@"\cf{0} ", ic);
        }
        int GetFontIndex(StyleInfo si)
        {
            StringBuilder sb = new StringBuilder(150);

            sb.Append("<font>");
            sb.Append(GetColor(si.Color));
            sb.AppendFormat("<sz val=\"{0}\"/> ", si.FontSize);
            sb.AppendFormat("<name val=\"{0}\"/> ", si.FontFamily);
            if (si.IsFontBold())
            {
                sb.Append("<b /> ");
            }
            if (si.FontStyle == FontStyleEnum.Italic)
            {
                sb.Append("<i /> ");
            }
            sb.Append("</font>");
            int i = _FontCache.GetIndex(sb.ToString());

            return(i);
        }
示例#4
0
        private void SelectionChanged(object sender, System.EventArgs e)
        {
            // handle edit tab first
            if (rdlEditPreview1.DesignTab == DesignTabs.Edit)
            {
                SetStatusNameAndPosition();
                return;
            }

            bSuppressChange = true;                     // don't process changes in status bar

            SetStatusNameAndPosition();
            this.EnableEditTextBox();   // handling enabling/disabling of textbox

            StyleInfo si = rdlEditPreview1.SelectedStyle;

            if (si == null)
            {
                return;
            }

            if (centerAlignToolStripButton2 != null)
            {
                centerAlignToolStripButton2.Checked = si.TextAlign == TextAlignEnum.Center ? true : false;
            }
            if (leftAlignToolStripButton2 != null)
            {
                leftAlignToolStripButton2.Checked = si.TextAlign == TextAlignEnum.Left ? true : false;
            }
            if (rightAlignToolStripButton3 != null)
            {
                rightAlignToolStripButton3.Checked = si.TextAlign == TextAlignEnum.Right ? true : false;
            }
            if (boldToolStripButton1 != null)
            {
                boldToolStripButton1.Checked = si.IsFontBold() ? true : false;
            }
            if (italiacToolStripButton1 != null)
            {
                italiacToolStripButton1.Checked = si.FontStyle == FontStyleEnum.Italic ? true : false;
            }
            if (underlineToolStripButton2 != null)
            {
                underlineToolStripButton2.Checked = si.TextDecoration == TextDecorationEnum.Underline ? true : false;
            }
            if (fontToolStripComboBox1 != null)
            {
                fontToolStripComboBox1.Text = si.FontFamily;
            }
            if (fontSizeToolStripComboBox1 != null)
            {
                string rs = string.Format(NumberFormatInfo.InvariantInfo, "{0:0.#}", si.FontSize);
                fontSizeToolStripComboBox1.Text = rs;
            }
            if (foreColorPicker1 != null)
            {
                foreColorPicker1.Text = si.Color.IsEmpty ? si.ColorText : ColorTranslator.ToHtml(si.Color);
            }
            if (backColorPicker1 != null)
            {
                backColorPicker1.Text = si.BackgroundColor.IsEmpty ? si.BackgroundColorText : ColorTranslator.ToHtml(si.BackgroundColor);
            }

            bSuppressChange = false;
        }