【问题标题】:Zoom in at touch point在接触点放大
【发布时间】:2014-11-08 22:09:34
【问题描述】:

我有一个大约 4048x8096 的画布,当我尝试放大时,它不会在手势点放大,它总是朝着画布的位置 Point(0,0) 移动,这是代码我正在使用: 当达到缩放限制时,它也会闪烁。

private void GraphSurface_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
{
    var matrix = ((MatrixTransform)this.RenderTransform).Matrix;

    Point center = new Point(this.ActualWidth / 2, this.ActualHeight / 2);

    center = matrix.Transform(center);

        if (Scale <= ZoomInLimit && Scale >= ZoomOutLimit)
        {
            matrix.ScaleAt(e.DeltaManipulation.Scale.X, e.DeltaManipulation.Scale.Y, center.X, center.Y);
        }

        if (Scale > ZoomInLimit)
        {
            matrix.M11 -= 0.001;
            matrix.M22 -= 0.001;
        }
        else if (Scale < ZoomOutLimit)
        {
            matrix.M11 = ZoomOutLimit + 0.001;
            matrix.M22 = ZoomOutLimit + 0.001;
        }

    ((MatrixTransform)this.RenderTransform).Matrix = matrix;

    e.Handled = true;
}

【问题讨论】:

标签: c# wpf canvas matrix zooming


【解决方案1】:

这是一个缩放手势点的演示。使用底部的示例。代码是 JS,而不是 Java,但它应该可以转换。将 awesome_tiger.svg 替换为您的画布对象。也许这会给你一个你自己的代码所需的样本。希望有帮助。

http://timmywil.github.io/jquery.panzoom/demo/

【讨论】:

    猜你喜欢
    • 2014-03-20
    • 2015-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多