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); } }
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); }
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); }
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); } }
public override void AddAttribute (object backend, TextAttribute attribute) { }
public void AddAttribute(TextAttribute attribute) { Attributes.Add (attribute.Clone ()); handler.AddAttribute (Backend, attribute); }
public abstract void AddAttribute (object backend, TextAttribute attribute);
public void AddAttribute(TextAttribute attribute) { if (attributes == null) attributes = new List<TextAttribute>(); attributes.Add(attribute); if (formattedText != null) ApplyAttribute(attribute); }
public override bool Equals(TextAttribute t) { var ot = t as FontWeightTextAttribute; return ot != null && Weight.Equals (ot.Weight) && base.Equals (t); }
public override void AddAttribute(object backend, TextAttribute attribute) { var tl = (PangoBackend) backend; tl.Attributes.AddAttribute (tl.TextIndexer, attribute); }
public override bool Equals(TextAttribute t) { var ot = t as UnderlineTextAttribute; return ot != null && base.Equals (t); }
public virtual bool Equals(TextAttribute t) { return t.StartIndex == StartIndex && t.Count == Count; }
public override bool Equals(TextAttribute t) { var ot = t as StrikethroughTextAttribute; return ot != null && base.Equals (t); }
public override bool Equals(TextAttribute t) { var ot = t as ForegroundTextAttribute; return ot != null && Color.Equals (ot.Color) && base.Equals (t); }
public void AddAttribute(TextAttribute attribute) { Attributes.Add(attribute.Clone()); handler.AddAttribute(Backend, attribute); }
public override void AddAttribute (object backend, TextAttribute attribute) { var t = (TextLayoutBackend)backend; t.AddAttribute(attribute); }
public override bool Equals(TextAttribute t) { var ot = t as FontStyleTextAttribute; return ot != null && Style.Equals (ot.Style) && base.Equals (t); }