private Media.FontFamily TransformFontFamily(Styles.FontFamily fontFamily) { if (fontFamily == Styles.FontFamily.GenericMonospace) return new Media.FontFamily("Courier New"); else if (fontFamily == Styles.FontFamily.GenericSansSerif) return new Media.FontFamily("Arial"); else if (fontFamily == Styles.FontFamily.GenericSerif) return new Media.FontFamily("Times New Roman"); else return new Media.FontFamily(fontFamily.Name); }
private Drawing.FontStyle TransformFontStyle(Styles.FontStyle fontStyle) { switch (fontStyle) { case Styles.FontStyle.Normal: return Drawing.FontStyle.Regular; case Styles.FontStyle.Italic: return Drawing.FontStyle.Italic; default: throw new ArgumentException("fontStyle"); } }
private Windows.TextDecorationCollection TransformTextDecoration(Styles.TextDecoration textDecoration) { if (textDecoration == TextDecoration.Baseline) return null; // no pair for this -> return the default style else if (textDecoration == TextDecoration.OverLine) return null; // no pair for this -> return the default style else if (textDecoration == TextDecoration.Strikethrough) return null; // no pair for this -> return the default style else if (textDecoration == TextDecoration.Underline) return Windows.TextDecorations.Underline; else { switch (textDecoration.Location) { case Styles.TextDecorationLocation.Baseline: return null; // no pair for this -> return the default style case Styles.TextDecorationLocation.OverLine: return null; // no pair for this -> return the default style case Styles.TextDecorationLocation.Strikethrough: return null; // no pair for this -> return the default style case Styles.TextDecorationLocation.Underline: return Windows.TextDecorations.Underline; default: throw new ArgumentException("textDecoration"); } } }
private Media.Color TransformColor(Styles.Color color) { return Media.Color.FromArgb(color.A(), color.R(), color.G(), color.B()); }
private Windows.TextDecorationLocation TransformTextDecorationLocation(Styles.TextDecorationLocation textDecorationLocation) { switch (textDecorationLocation) { case Styles.TextDecorationLocation.Baseline: return Windows.TextDecorationLocation.Baseline; case Styles.TextDecorationLocation.OverLine: return Windows.TextDecorationLocation.OverLine; case Styles.TextDecorationLocation.Strikethrough: return Windows.TextDecorationLocation.Strikethrough; case Styles.TextDecorationLocation.Underline: return Windows.TextDecorationLocation.Underline; default: throw new ArgumentException("textDecoration"); } }
private Windows.FontWeight TransformFontWeight(Styles.FontWeight fontWeight) { switch (fontWeight) { case Styles.FontWeight.Normal: return Windows.FontWeights.Normal; case Styles.FontWeight.Bold: return Windows.FontWeights.Bold; case Styles.FontWeight.Thin: return Windows.FontWeights.Thin; default: throw new ArgumentException("fontWeight"); } }
private Graphics.Color TransformColor(Styles.Color color) { return Graphics.Color.Argb(color.A(), color.R(), color.G(), color.B()); }
private Drawing.Color TransformColor(Styles.Color color) { return Drawing.Color.FromArgb(color.A(), color.R(), color.G(), color.B()); }
private Graphics.TypefaceStyle TransformFontStyle(Styles.FontStyle fontStyle) { switch (fontStyle) { case Styles.FontStyle.Normal: return Graphics.TypefaceStyle.Normal; case Styles.FontStyle.Italic: return Graphics.TypefaceStyle.Italic; default: throw new ArgumentException("fontStyle"); } }
private Graphics.TypefaceStyle TransformFontWeight(Styles.FontWeight fontWeight) { switch (fontWeight) { case Styles.FontWeight.Normal: return Graphics.TypefaceStyle.Normal; case Styles.FontWeight.Bold: return Graphics.TypefaceStyle.Bold; case Styles.FontWeight.Thin: return Graphics.TypefaceStyle.Normal; // no pair for this -> return the default style default: throw new ArgumentException("fontWeight"); } }
private Graphics.Typeface TransformFontFamilyToTypefaceFamily(Styles.FontFamily fontFamily) { if (fontFamily == Styles.FontFamily.GenericMonospace) return Graphics.Typeface.Monospace; else if (fontFamily == Styles.FontFamily.GenericSansSerif) return Graphics.Typeface.SansSerif; else if (fontFamily == Styles.FontFamily.GenericSerif) return Graphics.Typeface.Serif; else return Graphics.Typeface.Create(fontFamily.Name, Graphics.TypefaceStyle.Normal); }
private Windows.BaselineAlignment TransformBaselineAlignment(Styles.BaselineAlignment baselineAlignment) { switch (baselineAlignment) { case Styles.BaselineAlignment.Baseline: return Windows.BaselineAlignment.Baseline; case Styles.BaselineAlignment.Bottom: return Windows.BaselineAlignment.Bottom; case Styles.BaselineAlignment.Center: return Windows.BaselineAlignment.Center; case Styles.BaselineAlignment.Subscript: return Windows.BaselineAlignment.Subscript; case Styles.BaselineAlignment.Superscript: return Windows.BaselineAlignment.Superscript; case Styles.BaselineAlignment.TextBottom: return Windows.BaselineAlignment.TextBottom; case Styles.BaselineAlignment.TextTop: return Windows.BaselineAlignment.TextTop; case Styles.BaselineAlignment.Top: return Windows.BaselineAlignment.Top; default: throw new ArgumentException("baselineAlignment"); } }
private Media.Pen TransformPen(Styles.Pen pen) { return new Media.Pen(new Media.SolidColorBrush(TransformColor(pen.Color)), pen.Thickness); }
private Drawing.FontStyle TransformFontWeight(Styles.FontWeight fontWeight) { switch (fontWeight) { case Styles.FontWeight.Normal: return Drawing.FontStyle.Regular; case Styles.FontWeight.Bold: return Drawing.FontStyle.Bold; case Styles.FontWeight.Thin: return Drawing.FontStyle.Regular; // no pair for this -> return the default style default: throw new ArgumentException("fontWeight"); } }
private Windows.FontStretch TransformFontStretch(Styles.FontStretch fontStretch) { switch (fontStretch) { case Styles.FontStretch.Normal: return Windows.FontStretches.Normal; case Styles.FontStretch.Condensed: return Windows.FontStretches.Condensed; case Styles.FontStretch.Expanded: return Windows.FontStretches.Expanded; default: throw new ArgumentException("fontStretch"); } }
private Drawing.FontStyle TransformTextDecoration(Styles.TextDecoration textDecoration) { if (textDecoration == TextDecoration.Baseline) return Drawing.FontStyle.Regular; // no pair for this -> return the default style else if (textDecoration == TextDecoration.OverLine) return Drawing.FontStyle.Regular; // no pair for this -> return the default style else if (textDecoration == TextDecoration.Strikethrough) return Drawing.FontStyle.Strikeout; else if (textDecoration == TextDecoration.Underline) return Drawing.FontStyle.Underline; else { switch (textDecoration.Location) { case Styles.TextDecorationLocation.Baseline: return Drawing.FontStyle.Regular; // no pair for this -> return the default style case Styles.TextDecorationLocation.OverLine: return Drawing.FontStyle.Regular; // no pair for this -> return the default style case Styles.TextDecorationLocation.Strikethrough: return Drawing.FontStyle.Strikeout; case Styles.TextDecorationLocation.Underline: return Drawing.FontStyle.Underline; default: throw new ArgumentException("textDecoration"); } } }
private Windows.FontStyle TransformFontStyle(Styles.FontStyle fontStyle) { switch (fontStyle) { case Styles.FontStyle.Normal: return Windows.FontStyles.Normal; case Styles.FontStyle.Italic: return Windows.FontStyles.Italic; default: throw new ArgumentException("fontStyle"); } }
private Drawing.FontFamily TransformFontFamily(Styles.FontFamily fontFamily) { if (fontFamily == Styles.FontFamily.GenericMonospace) return Drawing.FontFamily.GenericMonospace; else if (fontFamily == Styles.FontFamily.GenericSansSerif) return Drawing.FontFamily.GenericSansSerif; else if (fontFamily == Styles.FontFamily.GenericSerif) return Drawing.FontFamily.GenericSerif; else return new Drawing.FontFamily(fontFamily.Name); }
private Windows.TextDecorationCollection TransformTextDecoration(Styles.TextDecoration textDecoration) { if (textDecoration == TextDecoration.Baseline) return Windows.TextDecorations.Baseline; else if (textDecoration == TextDecoration.OverLine) return Windows.TextDecorations.OverLine; else if (textDecoration == TextDecoration.Strikethrough) return Windows.TextDecorations.Strikethrough; else if (textDecoration == TextDecoration.Underline) return Windows.TextDecorations.Underline; else { return new Windows.TextDecorationCollection( new[] { new Windows.TextDecoration( TransformTextDecorationLocation(textDecoration.Location), TransformPen(textDecoration.Pen), textDecoration.PenOffset, Windows.TextDecorationUnit.FontRecommended, Windows.TextDecorationUnit.FontRecommended ) } ); } }