示例#1
0
 public override void AddAttribute(object backend, TextAttribute attribute)
 {
     var t = (TextLayoutBackend)backend;
     if (attribute is FontStyleTextAttribute) {
         var xa = (FontStyleTextAttribute)attribute;
         t.FormattedText.SetFontStyle (xa.Style.ToWpfFontStyle (), xa.StartIndex, xa.Count);
     }
     else if (attribute is FontWeightTextAttribute) {
         var xa = (FontWeightTextAttribute)attribute;
         t.FormattedText.SetFontWeight (xa.Weight.ToWpfFontWeight (), xa.StartIndex, xa.Count);
     }
     else if (attribute is ColorTextAttribute) {
         var xa = (ColorTextAttribute)attribute;
         t.FormattedText.SetForegroundBrush (new SolidColorBrush (xa.Color.ToWpfColor ()), xa.StartIndex, xa.Count);
     }
     else if (attribute is StrikethroughTextAttribute) {
         var xa = (StrikethroughTextAttribute)attribute;
         var dec = new TextDecoration (TextDecorationLocation.Strikethrough, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
         TextDecorationCollection col = new TextDecorationCollection ();
         col.Add (dec);
         t.FormattedText.SetTextDecorations (col, xa.StartIndex, xa.Count);
     }
     else if (attribute is UnderlineTextAttribute) {
         var xa = (UnderlineTextAttribute)attribute;
         var dec = new TextDecoration (TextDecorationLocation.Underline, null, 0, TextDecorationUnit.FontRecommended, TextDecorationUnit.FontRecommended);
         TextDecorationCollection col = new TextDecorationCollection ();
         col.Add (dec);
         t.FormattedText.SetTextDecorations (col, xa.StartIndex, xa.Count);
     }
 }
示例#2
0
        public void SetAttribute(XD.TextAttribute a)
        {
            var rtfHelper = new LRTF.RTFHelper();

            var visit = new TextAttributeVisitor {
                FontTextAttribute = attribute => {
                    if (!string.IsNullOrEmpty(attribute.Font.Family))
                    {
                        Controller.SetFontFamiliy(attribute.Font.Family);
                    }
                    if (attribute.Font.Size > 0)
                    {
                        Controller.SetFontSize((int)attribute.Font.Size);
                    }
                },

                FontDataAttribute = attribute => {
                    if (!string.IsNullOrEmpty(attribute.FontFamily))
                    {
                        Controller.SetFontFamiliy(attribute.FontFamily);
                    }
                    if (attribute.FontSize > 0)
                    {
                        Controller.SetFontSize((int)attribute.FontSize);
                    }
                },

                FontWeightTextAttribute = attribute =>
                                          Controller.SetEditorSelectedRTF(
                    source => rtfHelper.SetAttributes(source, Convert(attribute.Weight))),

                FontStyleTextAttribute = attribute =>
                                         Controller.SetEditorSelectedRTF(
                    source => rtfHelper.SetAttributes(source, Convert(attribute.Style))),

                StrikethroughTextAttribute = attribute => {
                    if (attribute.Strikethrough)
                    {
                        Controller.SetEditorSelectedRTF(
                            source => rtfHelper.SetAttributes(source, LRTF.FontStyle.Strikeout));
                    }
                },

                UnderlineTextAttribute = attribute => {
                    if (attribute.Underline)
                    {
                        Controller.SetEditorSelectedRTF(
                            source => rtfHelper.SetAttributes(source, LRTF.FontStyle.Underline));
                    }
                },
                BackgroundTextAttribute = attribute => { },
                ColorTextAttribute      = attribute => {}
            };

            visit.Visit(a);
        }
示例#3
0
        public void SetAttribute(XD.TextAttribute a)
        {
            var range = new TextRange(TextBox.Selection.Start, TextBox.Selection.End);

            var visit = new TextAttributeVisitor {
                FontTextAttribute = attribute => {
                    if (!string.IsNullOrEmpty(attribute.Font.Family))
                    {
                        range.ApplyPropertyValue(FlowDocument.FontFamilyProperty, attribute.Font.Family);
                    }
                    if (attribute.Font.Size > 0)
                    {
                        range.ApplyPropertyValue(FlowDocument.FontSizeProperty, attribute.Font.Size);
                    }
                },

                FontDataAttribute = attribute => {
                    if (!string.IsNullOrEmpty(attribute.FontFamily))
                    {
                        range.ApplyPropertyValue(FlowDocument.FontFamilyProperty, attribute.FontFamily);
                    }
                    if (attribute.FontSize > 0)
                    {
                        range.ApplyPropertyValue(FlowDocument.FontSizeProperty, attribute.FontSize);
                    }
                },
                FontWeightTextAttribute = attribute =>
                                          range.ApplyPropertyValue(FlowDocument.FontWeightProperty, attribute.Weight.ToWpfFontWeight()),

                FontStyleTextAttribute = attribute =>
                                         range.ApplyPropertyValue(FlowDocument.FontStyleProperty, attribute.Style.ToWpfFontStyle()),

                StrikethroughTextAttribute = attribute =>
                                             TextDecoration(range, SW.TextDecorations.Strikethrough, attribute.Strikethrough),

                UnderlineTextAttribute = attribute =>
                                         TextDecoration(range, SW.TextDecorations.Underline, attribute.Underline),

                BackgroundTextAttribute = attribute =>
                                          range.ApplyPropertyValue(FlowDocument.BackgroundProperty, new SWM.SolidColorBrush(attribute.Color.ToWpfColor())),

                ColorTextAttribute = attribute =>
                                     range.ApplyPropertyValue(FlowDocument.ForegroundProperty, new SWM.SolidColorBrush(attribute.Color.ToWpfColor())),
            };

            visit.Visit(a);
        }
示例#4
0
		public void AddAttribute (TextIndexer indexer, TextAttribute attr)
		{
			var start = (uint) indexer.IndexToByteIndex (attr.StartIndex);
			var end = (uint) indexer.IndexToByteIndex (attr.StartIndex + attr.Count);

			if (attr is BackgroundTextAttribute) {
				var xa = (BackgroundTextAttribute)attr;
				AddBackgroundAttribute (xa.Color.ToGtkValue (), start, end);
			}
			else if (attr is ColorTextAttribute) {
				var xa = (ColorTextAttribute)attr;
				AddForegroundAttribute (xa.Color.ToGtkValue (), start, end);
			}
			else if (attr is FontWeightTextAttribute) {
				var xa = (FontWeightTextAttribute)attr;
				AddWeightAttribute ((Pango.Weight)(int)xa.Weight, start, end);
			}
			else if (attr is FontStyleTextAttribute) {
				var xa = (FontStyleTextAttribute)attr;
				AddStyleAttribute ((Pango.Style)(int)xa.Style, start, end);
			}
			else if (attr is UnderlineTextAttribute) {
				var xa = (UnderlineTextAttribute)attr;
				AddUnderlineAttribute (xa.Underline ? Pango.Underline.Single : Pango.Underline.None, start, end);
			}
			else if (attr is StrikethroughTextAttribute) {
				var xa = (StrikethroughTextAttribute)attr;
				AddStrikethroughAttribute (xa.Strikethrough, start, end);
			}
			else if (attr is FontTextAttribute) {
				var xa = (FontTextAttribute)attr;
				AddFontAttribute ((Pango.FontDescription)Toolkit.GetBackend (xa.Font), start, end);
			}
			else if (attr is LinkTextAttribute) {
				AddUnderlineAttribute (Pango.Underline.Single, start, end);
				AddForegroundAttribute (Colors.Blue.ToGtkValue (), start, end);
			}
		}
示例#5
0
		public override void AddAttribute (object backend, TextAttribute attribute)
		{
		}
示例#6
0
文件: TextLayout.cs 项目: Sinien/xwt
 public void AddAttribute(TextAttribute attribute)
 {
     Attributes.Add (attribute.Clone ());
     handler.AddAttribute (Backend, attribute);
 }
示例#7
0
		public abstract void AddAttribute (object backend, TextAttribute attribute);
示例#8
0
		public void AddAttribute(TextAttribute attribute)
		{
			if (attributes == null)
				attributes = new List<TextAttribute>();
			attributes.Add(attribute);
			if (formattedText != null)
				ApplyAttribute(attribute);
		}
示例#9
0
 public override bool Equals(TextAttribute t)
 {
     var ot = t as FontWeightTextAttribute;
     return ot != null && Weight.Equals (ot.Weight) && base.Equals (t);
 }
示例#10
0
 public override void AddAttribute(object backend, TextAttribute attribute)
 {
     var tl = (PangoBackend) backend;
     tl.Attributes.AddAttribute (tl.TextIndexer, attribute);
 }
示例#11
0
 public override bool Equals(TextAttribute t)
 {
     var ot = t as UnderlineTextAttribute;
     return ot != null && base.Equals (t);
 }
示例#12
0
 public virtual bool Equals(TextAttribute t)
 {
     return t.StartIndex == StartIndex && t.Count == Count;
 }
示例#13
0
 public override bool Equals(TextAttribute t)
 {
     var ot = t as StrikethroughTextAttribute;
     return ot != null && base.Equals (t);
 }
示例#14
0
 public override bool Equals(TextAttribute t)
 {
     var ot = t as ForegroundTextAttribute;
     return ot != null && Color.Equals (ot.Color) && base.Equals (t);
 }
示例#15
0
 public void AddAttribute(TextAttribute attribute)
 {
     Attributes.Add(attribute.Clone());
     handler.AddAttribute(Backend, attribute);
 }
示例#16
0
		public override void AddAttribute (object backend, TextAttribute attribute)
		{
			var t = (TextLayoutBackend)backend;
			t.AddAttribute(attribute);
		}
示例#17
0
 public override bool Equals(TextAttribute t)
 {
     var ot = t as FontStyleTextAttribute;
     return ot != null && Style.Equals (ot.Style) && base.Equals (t);
 }