MyTransform.cs 1015 B

12345678910111213141516171819202122232425262728293031323334
  1. namespace AIDiagnosisDemo.Infrastucture
  2. {
  3. public class MyTransform
  4. {
  5. public double Scale { get; set; }
  6. public double OffsetX { get; set; }
  7. public double OffsetY { get; set; }
  8. public MyTransform(double scale, double offsetX, double offsetY)
  9. {
  10. Scale = scale;
  11. OffsetX = offsetX;
  12. OffsetY = offsetY;
  13. }
  14. public System.Windows.Point Transform(System.Windows.Point point)
  15. {
  16. double x = OffsetX + Scale * point.X;
  17. double y = OffsetY + Scale * point.Y;
  18. return new System.Windows.Point(x, y);
  19. }
  20. public System.Windows.Rect Transform(System.Windows.Rect rect)
  21. {
  22. double left = OffsetX + Scale * rect.Left;
  23. double top = OffsetY + Scale * rect.Top;
  24. double width = Scale * rect.Width;
  25. double height = Scale * rect.Height;
  26. return new System.Windows.Rect(left, top, width, height);
  27. }
  28. }
  29. }