[12503] | 1 | using System.Collections.Generic;
|
---|
| 2 | using System.Windows;
|
---|
| 3 | using System;
|
---|
| 4 | using Microsoft.Research.DynamicDataDisplay.Common;
|
---|
| 5 |
|
---|
| 6 | namespace Microsoft.Research.DynamicDataDisplay
|
---|
| 7 | {
|
---|
| 8 | public static class CoordinateUtilities
|
---|
| 9 | {
|
---|
| 10 | public static Rect RectZoom(Rect rect, double ratio)
|
---|
| 11 | {
|
---|
| 12 | return RectZoom(rect, rect.GetCenter(), ratio);
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | public static Rect RectZoom(Rect rect, double horizontalRatio, double verticalRatio)
|
---|
| 16 | {
|
---|
| 17 | return RectZoom(rect, rect.GetCenter(), horizontalRatio, verticalRatio);
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public static Rect RectZoom(Rect rect, Point zoomCenter, double ratio)
|
---|
| 21 | {
|
---|
| 22 | return RectZoom(rect, zoomCenter, ratio, ratio);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public static Rect RectZoom(Rect rect, Point zoomCenter, double horizontalRatio, double verticalRatio)
|
---|
| 26 | {
|
---|
| 27 | Rect res = new Rect();
|
---|
| 28 | res.X = zoomCenter.X - (zoomCenter.X - rect.X) * horizontalRatio;
|
---|
| 29 | res.Y = zoomCenter.Y - (zoomCenter.Y - rect.Y) * verticalRatio;
|
---|
| 30 | res.Width = rect.Width * horizontalRatio;
|
---|
| 31 | res.Height = rect.Height * verticalRatio;
|
---|
| 32 | return res;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public static DataRect RectZoom(DataRect rect, double ratio)
|
---|
| 36 | {
|
---|
| 37 | return RectZoom(rect, rect.GetCenter(), ratio);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | public static DataRect RectZoom(DataRect rect, double horizontalRatio, double verticalRatio)
|
---|
| 41 | {
|
---|
| 42 | return RectZoom(rect, rect.GetCenter(), horizontalRatio, verticalRatio);
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | public static DataRect RectZoom(DataRect rect, Point zoomCenter, double ratio)
|
---|
| 46 | {
|
---|
| 47 | return RectZoom(rect, zoomCenter, ratio, ratio);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | public static DataRect RectZoom(DataRect rect, Point zoomCenter, double horizontalRatio, double verticalRatio)
|
---|
| 51 | {
|
---|
| 52 | DataRect res = new DataRect();
|
---|
| 53 | res.XMin = zoomCenter.X - (zoomCenter.X - rect.XMin) * horizontalRatio;
|
---|
| 54 | res.YMin = zoomCenter.Y - (zoomCenter.Y - rect.YMin) * verticalRatio;
|
---|
| 55 | res.Width = rect.Width * horizontalRatio;
|
---|
| 56 | res.Height = rect.Height * verticalRatio;
|
---|
| 57 | return res;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | public static DataRect RectZoomX(DataRect rect, Point zoomCenter, double ratio)
|
---|
| 61 | {
|
---|
| 62 | DataRect res = rect;
|
---|
| 63 | res.XMin = zoomCenter.X - (zoomCenter.X - rect.XMin) * ratio;
|
---|
| 64 | res.Width = rect.Width * ratio;
|
---|
| 65 | return res;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | public static DataRect RectZoomY(DataRect rect, Point zoomCenter, double ratio)
|
---|
| 69 | {
|
---|
| 70 | DataRect res = rect;
|
---|
| 71 | res.YMin = zoomCenter.Y - (zoomCenter.Y - rect.YMin) * ratio;
|
---|
| 72 | res.Height = rect.Height * ratio;
|
---|
| 73 | return res;
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | }
|
---|