示例#1
0
        private void UpdateView()
        {
            var context = new RtfContext();

            context.AddFont(defaultFont.Name);
            var rtfBody = textBlock.ToRtf(context);

            rtbText.Rtf = $@"{context.RtfHeader}{{\pard {rtfBody}\par}}}}";
        }
        public override string ToRtf(RtfContext context)
        {
            if (BackColor == null)
            {
                return(DecoratedTextBlock.ToRtf(context));
            }
            var cnumber = context.AddColor(BackColor);

            return($@"\highlight{cnumber} {DecoratedTextBlock.ToRtf(context)}");
        }
示例#3
0
        public override string ToRtf(RtfContext context)
        {
            if (Font == null)
            {
                return(DecoratedTextBlock.ToRtf(context));
            }
            var strikeThroughCmd = Font.Strikeout ? "strike" : "strike0";
            var twips            = Math.Floor(Font.SizeInPoints * 2);
            var fnumber          = context.AddFont(Font.Name);

            return($@"\f{fnumber}\fs{twips}\{strikeThroughCmd} {DecoratedTextBlock.ToRtf(context)}");
        }
示例#4
0
        public override string ToRtf(RtfContext context)
        {
            var underlineCmd = "ul";

            switch (Underline)
            {
            case UnderlineType.None:
                underlineCmd = "ulnone";
                break;

            case UnderlineType.Single:
                underlineCmd = "ul";
                break;

            case UnderlineType.Double:
                underlineCmd = "uldb";
                break;
            }
            return($@"\{underlineCmd} {DecoratedTextBlock.ToRtf(context)}");
        }
示例#5
0
        public override string ToRtf(RtfContext context)
        {
            var text  = DecoratedTextBlock.RawText;
            var match = numericListRegex.Match(text);

            if (match.Success)
            {
                context.ListStyle         = match.Groups[2].Value;
                context.LastListNumbering = match.Groups[1].Value;
                return(DecoratedTextBlock.ToRtf(context));
            }
            var lastNumbering = context.LastListNumbering ?? "0";
            var sections      = lastNumbering.Split('.').Select(d => int.Parse(d)).ToList();

            sections[sections.Count - 1]++;
            var numbering = String.Join(".", sections);

            context.LastListNumbering = numbering;
            context.ListStyle         = context.ListStyle ?? ".";
            return($@"{numbering}{context.ListStyle}{DecoratedTextBlock.ToRtf(context)}");
        }
示例#6
0
 public override string ToRtf(RtfContext context)
 {
     return($@"\b {DecoratedTextBlock.ToRtf(context)}");
 }
示例#7
0
        public override string ToRtf(RtfContext context)
        {
            var cmd = (Indent == IndentType.Left ? "li" : "ri");

            return($@"\{cmd}720 {DecoratedTextBlock.ToRtf(context)}");
        }
示例#8
0
 public override string ToRtf(RtfContext context)
 {
     return(context.Escape(Text ?? ""));
 }