public static void ApplyTextStyle(this TextSelection selection, ITextStyle style)
 {
     if (selection == null || selection.Start == selection.End)
         return;
     selection.ApplyPropertyValue(TextElement.FontFamilyProperty, style.FontFamily);
     selection.ApplyPropertyValue(TextElement.FontSizeProperty, style.FontSize * 96d / 72d);
     selection.ApplyPropertyValue(TextElement.FontStyleProperty, style.FontStyle);
     selection.ApplyPropertyValue(TextElement.FontWeightProperty, style.FontWeight);
     selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(style.FontColor));
     FlowDocumentHelper.SetStyleName(selection.Start.Parent, style.Name);
 }
示例#2
0
		public static FontFamily SetEtoFamily(this swd.TextRange control, FontFamily fontFamily)
		{
			if (control == null) return fontFamily;
			if (fontFamily != null)
			{
				((FontFamilyHandler)fontFamily.Handler).Apply(control);
			}
			else
			{
				control.ApplyPropertyValue(swd.TextElement.FontFamilyProperty, swc.Control.FontFamilyProperty.DefaultMetadata.DefaultValue);
			}
			return fontFamily;
		}
示例#3
0
		public static Font SetEtoFont(this swd.TextRange control, Font font)
		{
			if (control == null) return font;
			if (font != null)
			{
				((FontHandler)font.Handler).Apply(control);
			}
			else
			{
				control.ApplyPropertyValue(swd.TextElement.FontFamilyProperty, swc.Control.FontFamilyProperty.DefaultMetadata.DefaultValue);
				control.ApplyPropertyValue(swd.TextElement.FontStyleProperty, swc.Control.FontStyleProperty.DefaultMetadata.DefaultValue);
				control.ApplyPropertyValue(swd.TextElement.FontWeightProperty, swc.Control.FontWeightProperty.DefaultMetadata.DefaultValue);
				control.ApplyPropertyValue(swd.TextElement.FontSizeProperty, swc.Control.FontSizeProperty.DefaultMetadata.DefaultValue);
				control.ApplyPropertyValue(swd.Inline.TextDecorationsProperty, new sw.TextDecorationCollection());
			}
			return font;
		}