/// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        internal static NParagraph GetTitleParagraphNoBorder(string text, int level)
        {
            double      fontSize  = 10;
            ENFontStyle fontStyle = ENFontStyle.Regular;

            switch (level)
            {
            case 1:
                fontSize  = 16;
                fontStyle = ENFontStyle.Bold;
                break;

            case 2:
                fontSize  = 10;
                fontStyle = ENFontStyle.Bold;
                break;
            }

            NParagraph paragraph = new NParagraph();

            paragraph.HorizontalAlignment = ENAlign.Left;
            paragraph.FontSize            = fontSize;
            paragraph.FontStyle           = fontStyle;

            NTextInline textInline = new NTextInline(text);

            textInline.FontStyle = fontStyle;
            textInline.FontSize  = fontSize;

            paragraph.Inlines.Add(textInline);

            return(paragraph);
        }
示例#2
0
        private void OnFontStyleChanged(NValueChangeEventArgs args)
        {
            string fontFamily = (m_FontFamiliesComboBox.SelectedItem.Content as NLabel).Text;
            int    fontSize   = Int32.Parse((m_FontSizeComboBox.SelectedItem.Content as NLabel).Text);

            ENFontStyle fontStyle = ENFontStyle.Regular;

            if (m_BoldCheckBox.Checked)
            {
                fontStyle |= ENFontStyle.Bold;
            }

            if (m_ItalicCheckBox.Checked)
            {
                fontStyle |= ENFontStyle.Italic;
            }

            if (m_UnderlineCheckBox.Checked)
            {
                fontStyle |= ENFontStyle.Underline;
            }

            if (m_StrikeThroughCheckBox.Checked)
            {
                fontStyle |= ENFontStyle.Strikethrough;
            }

            m_Label.Font = new NFont(fontFamily, fontSize, fontStyle, ENFontRasterizationMode.Antialiased);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor paintVisitor = args.PaintVisitor;

            NRectangle contentEge = canvas.GetContentEdge();

            // create the text bounds
            double width  = contentEge.Width * 0.5;
            double height = contentEge.Height * 0.5;
            NPoint center = contentEge.Center;

            NRectangle textBounds = new NRectangle(center.X - width / 2.0, center.Y - height / 2.0, width, height);

            // create the settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.SingleLine = false;
            settings.WrapMode   = ENTextWrapMode.WordWrap;
            settings.HorzAlign  = ENTextHorzAlign.Center;
            settings.VertAlign  = ENTextVertAlign.Center;

            // create the text
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("This text is displayed using Liberation Fonts!");
            builder.AppendLine("distributed under the SIL Open Font License (OFL)");

            // paint the bounding box
            paintVisitor.ClearStyles();
            paintVisitor.SetFill(NColor.LightBlue);
            paintVisitor.PaintRectangle(textBounds);

            // init font and fill
            paintVisitor.SetFill(NColor.Black);
            ENFontStyle fontStyle = NFontFaceDescriptor.FontVariantToFontStyle(m_FontDescriptor.FontVariant);

            paintVisitor.SetFont(new NFont(m_FontDescriptor.FamilyName, 10, fontStyle));

            // paint the text
            paintVisitor.PaintString(textBounds, builder.ToString(), ref settings);
        }