如何在inkcanvas之外显示图像
我有一个名为“drawCanvas”的画布,用于显示名为“CanvasContainInkCanvas”的画布中包含的图像和 inkcanvas。我可以使用 MatrixTransform 进行缩小。
//Get the image that's being manipulation.
Canvas element = (Canvas)e.Source;
//Ues the matrix of the transform to manipulation the element's appearance.
Matrix matrix = ((MatrixTransform)drawCanvas.RenderTransform).Matrix;
//Get the ManipulationDelta object.
ManipulationDelta deltaManipulation = e.DeltaManipulation;
//Find the old center, and apply any previous manipulations.
Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
//Apply new move manipulation (if it exists).
center = matrix.Transform(center);
//Apply new zoom manipulation (if it exists).
matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y);
//Translation (pan)
matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y);
//Set the final matrix.
((MatrixTransform)drawCanvas.RenderTransform).Matrix = matrix;
// set the matrix of canvas that contain inkcanvas
((MatrixTransform)CanvasContainInkCanvas.RenderTransform).Matrix = matrix;
如果缩小,我可以看到画布外的图像。
我想将图像从画布复制到 inkcanvas 以使用选择。 我的问题是图像无法在 inkcanvas 之外显示。
如何在 inkcanvas 之外显示图像?
谢谢
更新:我如何在 inkcanvas 之外使用选择?
I have canvas called "drawCanvas" to show images and inkcanvas that is contained in the canvas called "CanvasContainInkCanvas". I can zoom out by using MatrixTransform.
//Get the image that's being manipulation.
Canvas element = (Canvas)e.Source;
//Ues the matrix of the transform to manipulation the element's appearance.
Matrix matrix = ((MatrixTransform)drawCanvas.RenderTransform).Matrix;
//Get the ManipulationDelta object.
ManipulationDelta deltaManipulation = e.DeltaManipulation;
//Find the old center, and apply any previous manipulations.
Point center = new Point(element.ActualWidth / 2, element.ActualHeight / 2);
//Apply new move manipulation (if it exists).
center = matrix.Transform(center);
//Apply new zoom manipulation (if it exists).
matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y);
//Translation (pan)
matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y);
//Set the final matrix.
((MatrixTransform)drawCanvas.RenderTransform).Matrix = matrix;
// set the matrix of canvas that contain inkcanvas
((MatrixTransform)CanvasContainInkCanvas.RenderTransform).Matrix = matrix;
If I zoom out, I can see images outside canvas.
I want to copy images from canvas to inkcanvas to use selection.
My problem is that the images cannot be shown outside inkcanvas.
How do I show images outside inkcanvas?
Thanks
Update: How do I use selection outside inkcanvas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在该
InkCanvas
上设置ClipToBounds="False"
。默认情况下,它设置为True
。Set
ClipToBounds="False"
on thatInkCanvas
. By default it's set toTrue
.