public void ScaleContent(Point scalePoint, bool zoomIn, double amount) { if (child != null) { var st = GetScaleTransform(); var tt = GetTranslateTransform(); double zoom = zoomIn ? .2 * amount : -.2 * amount; if (!zoomIn && (st.ScaleX < .4 || st.ScaleY < .4)) { return; } double absoluteX; double absoluteY; absoluteX = scalePoint.X * st.ScaleX + tt.X; absoluteY = scalePoint.Y * st.ScaleY + tt.Y; if ((st.ScaleY + zoom <= maxZoom) && (st.ScaleY + zoom >= minZoom)) { st.ScaleX += zoom; st.ScaleY += zoom; tt.X = absoluteX - scalePoint.X * st.ScaleX; tt.Y = absoluteY - scalePoint.Y * st.ScaleY; OnUpdateTransform?.Invoke(this); } } }
public void TranslateContent(Vector translateVector) { if (child != null) { var st = GetScaleTransform(); var tt = GetTranslateTransform(); tt.X = origin.X - translateVector.X; tt.Y = origin.Y - translateVector.Y; OnUpdateTransform?.Invoke(this); } }