public static void down(MouseButtonEventArgs e, InkPresenter inkCanvas) { inkCanvas.CaptureMouse(); setDrawingAttributes(); newStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(inkCanvas)); inkCanvas.Strokes.Add(newStroke); }
public static void down(MouseButtonEventArgs e, InkPresenter inkCanvas, Grid LayoutRoot) { dragStarted = true; inkCanvas.CaptureMouse(); clickedLayer = Common.hitTestLayer(e, inkCanvas); initialPos = e.GetPosition(inkCanvas); StylusPointCollection spc = new StylusPointCollection(); spc.Add(new StylusPoint(e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y)); hitCount = inkCanvas.Strokes.HitTest(spc).Count; System.Diagnostics.Debug.WriteLine("layer " + clickedLayer); if (clickedLayer != -1) { //Calculate offset of left, right, top, bottom calculateOffset(e, inkCanvas); //System.Diagnostics.Debug.WriteLine("maxLeft " + MainPage.layerList[clickedLayer].imageToBorderDist[LEFT]); //System.Diagnostics.Debug.WriteLine("offSetLeft " + offSetLeft); //System.Diagnostics.Debug.WriteLine("positionY" + e.GetPosition(inkCanvas).Y); //System.Diagnostics.Debug.WriteLine("maxTop " + MainPage.layerList[clickedLayer].imageToBorderDist[TOP]); //System.Diagnostics.Debug.WriteLine("offSetTop " + offSetTop); //if the clickedLayer's image is out of bound if (clickedLayer != -1 && MainPage.layerList[clickedLayer].imgBackup != null) { replaceMovingImgWithBackupImg(LayoutRoot); } else { //temporarly save image in image backup imageBackup = new WriteableBitmap((BitmapSource)MainPage.layerList[clickedLayer].img.Source); } } //Line clicked if (hitCount > 0) { moveInkToNewInkPresenter(inkCanvas, LayoutRoot, spc); } }