/// <summary> /// from physical to visual /// </summary> /// <param name="size"></param> /// <returns></returns> public static Size Physic2Visual(Size size) { double wPixel = VisualCommon.Convert2PixelXUnit(size.Width); double hPixel = VisualCommon.Convert2PixelYUnit(size.Height); return(new Size(wPixel, hPixel)); }
/// <summary> /// from physical to visual /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="size"></param> /// <returns></returns> public static Rect Physic2Visual(double x, double y, Size size) { double xPixel = VisualCommon.Convert2PixelXUnit(x); double yPixel = VisualCommon.Convert2PixelYUnit(y); xPixel += GetXShift(); yPixel += GetYShift(); double wPixel = VisualCommon.Convert2PixelXUnit(size.Width); double hPixel = VisualCommon.Convert2PixelYUnit(size.Height); return(new Rect(new Point(xPixel, yPixel), new Size(wPixel, hPixel))); }
/// <summary> /// draw circle /// </summary> /// <param name="position"></param> /// <param name="radius"></param> /// <param name="drawingContext"></param> /// <param name="color"></param> public static void DrawCircle(Point position, double radius, DrawingContext drawingContext, Color color, bool fill = false) { double xPixel = VisualCommon.Convert2PixelXUnit(position.X); double yPixel = VisualCommon.Convert2PixelYUnit(position.Y); xPixel += GetXShift(); yPixel += GetYShift(); double rXPixel = VisualCommon.Convert2PixelXUnit(radius); double rYPixel = VisualCommon.Convert2PixelYUnit(radius); Brush brush = new SolidColorBrush(color); Brush fillBrush = fill ? brush : null; drawingContext.DrawEllipse(fillBrush, new Pen(new SolidColorBrush(color), 1), new Point(xPixel, yPixel), rXPixel, rYPixel); }
internal static void DrawText(Point pt, string text, DrawingContext drawingContext) { double xPixel = VisualCommon.Convert2PixelXUnit(pt.X) + GetXShift(); double yPixel = VisualCommon.Convert2PixelYUnit(pt.Y) + GetYShift(); Point ptVisual = new Point(xPixel, yPixel); double fontSize = 10 * containerSize.Height / 400; var formattedText = new FormattedText(text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), fontSize, System.Windows.Media.Brushes.DarkBlue); drawingContext.DrawText(formattedText, ptVisual); }