|
@@ -13,8 +13,11 @@ public class IconImage : IImage
|
|
public SolidColorBrush Foreground { get; }
|
|
public SolidColorBrush Foreground { get; }
|
|
public Size Size { get; }
|
|
public Size Size { get; }
|
|
|
|
|
|
|
|
+ public double RotationAngle { get; }
|
|
|
|
+
|
|
private Typeface _typeface;
|
|
private Typeface _typeface;
|
|
|
|
|
|
|
|
+
|
|
public IconImage(string icon, FontFamily fontFamily, double fontSize, Color foreground)
|
|
public IconImage(string icon, FontFamily fontFamily, double fontSize, Color foreground)
|
|
{
|
|
{
|
|
Icon = icon;
|
|
Icon = icon;
|
|
@@ -24,9 +27,28 @@ public class IconImage : IImage
|
|
_typeface = new Typeface(FontFamily);
|
|
_typeface = new Typeface(FontFamily);
|
|
Size = new Size(FontSize, FontSize);
|
|
Size = new Size(FontSize, FontSize);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ public IconImage(string unicode, FontFamily fontFamily, double fontSize, Color foreground, double rotationAngle)
|
|
|
|
+ {
|
|
|
|
+ Icon = unicode;
|
|
|
|
+ FontFamily = fontFamily;
|
|
|
|
+ FontSize = fontSize;
|
|
|
|
+ Foreground = new SolidColorBrush(foreground);
|
|
|
|
+ _typeface = new Typeface(FontFamily);
|
|
|
|
+ Size = new Size(FontSize, FontSize);
|
|
|
|
+ RotationAngle = rotationAngle;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void Draw(DrawingContext context, Rect sourceRect, Rect destRect)
|
|
public void Draw(DrawingContext context, Rect sourceRect, Rect destRect)
|
|
{
|
|
{
|
|
|
|
+ if (RotationAngle != 0)
|
|
|
|
+ {
|
|
|
|
+ double radians = RotationAngle * Math.PI / 180;
|
|
|
|
+ context.PushTransform(Matrix.CreateTranslation(destRect.Width, destRect.Height));
|
|
|
|
+ context.PushTransform(Matrix.CreateRotation(radians));
|
|
|
|
+ context.PushTransform(Matrix.CreateTranslation(destRect.Width / 4f, destRect.Height / 4f));
|
|
|
|
+ }
|
|
|
|
+
|
|
context.DrawText(
|
|
context.DrawText(
|
|
new FormattedText(Icon, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, _typeface, FontSize, Foreground),
|
|
new FormattedText(Icon, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, _typeface, FontSize, Foreground),
|
|
destRect.TopLeft);
|
|
destRect.TopLeft);
|