2011-01-13 107 views
0

我使用名爲「drawCanvas」的畫布來顯示畫布中包含的名爲「CanvasContainInkCanvas」的圖像和inkcanvas。我可以通過使用MatrixTransform縮小。如何在inkcanvas外部顯示圖像

//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; 

如果我縮小,我可以看到畫布外的圖像。 alt text

我想複製圖像從畫布到inkcanvas使用選擇。 我的問題是,圖像無法顯示在inkcanvas之外。

alt text

如何顯示外inkcanvas圖像?

感謝

更新:我如何使用選擇外inkcanvas?

回答

2

InkCanvas上設置ClipToBounds="False"。默認情況下,它設置爲True

+0

好吧,我現在可以顯示圖像,但我有新問題。如何使用inkcanvas外部的選擇? – 2011-01-13 09:01:23