【发布时间】: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