private void Swap(bool redraw) { // Grab the original surface ImageSurface surf = userLayer.Surface; if (userSurfaceDiff != null) { userSurfaceDiff.ApplyAndSwap(surf); PintaCore.Workspace.Invalidate(userSurfaceDiff.GetBounds()); } else { // Undo to the "old" surface userLayer.Surface = userSurface; // Store the original surface for Redo userSurface = surf; //Redraw everything since surfaces were swapped. PintaCore.Workspace.Invalidate(); } Swap(ref sEngines, ref BaseEditEngine.SEngines); //Ensure that all of the shapes that should no longer be drawn have their ReEditableLayer removed from the drawing loop. foreach (ShapeEngine se in sEngines) { //Determine if it is currently in the drawing loop and should no longer be. Note: a DrawingLayer could be both removed and then //later added in the same swap operation, but this is faster than looping through each ShapeEngine in BaseEditEngine.SEngines. if (se.DrawingLayer.InTheLoop && !BaseEditEngine.SEngines.Contains(se)) { se.DrawingLayer.TryRemoveLayer(); } } //Ensure that all of the shapes that should now be drawn have their ReEditableLayer in the drawing loop. foreach (ShapeEngine se in BaseEditEngine.SEngines) { //Determine if it is currently out of the drawing loop; if not, it should be. if (!se.DrawingLayer.InTheLoop) { se.DrawingLayer.TryAddLayer(); } } Swap(ref selectedPointIndex, ref ee.SelectedPointIndex); Swap(ref selectedShapeIndex, ref ee.SelectedShapeIndex); //Determine if the currently active tool matches the shape's corresponding tool, and if not, switch to it. if (BaseEditEngine.ActivateCorrespondingTool(ee.SelectedShapeIndex, true) != null) { //The currently active tool now matches the shape's corresponding tool. if (redraw) { ((ShapeTool)PintaCore.Tools.CurrentTool).EditEngine.DrawAllShapes(); } } }
private void Swap() { // Grab the original surface ImageSurface surf = PintaCore.Workspace.ActiveDocument.ToolLayer.Surface; // Grab the original surface surf = userLayer.Surface; if (user_surface_diff != null) { user_surface_diff.ApplyAndSwap(surf); PintaCore.Workspace.Invalidate(user_surface_diff.GetBounds()); } else { // Undo to the "old" surface userLayer.Surface = userSurface; // Store the original surface for Redo userSurface = surf; } //Redraw everything since surfaces were swapped. PintaCore.Workspace.Invalidate(); //Store the old curve data temporarily. CurveEngineCollection oldCEngine = cEngines; //Swap half of the data. cEngines = Pinta.Tools.LineCurveTool.cEngines; //Swap the other half. Pinta.Tools.LineCurveTool.cEngines = oldCEngine; //Swap the selected point data. int temp = selectedPointIndex; selectedPointIndex = Pinta.Tools.LineCurveTool.selectedPointIndex; Pinta.Tools.LineCurveTool.selectedPointIndex = temp; //Swap the selected curve data. temp = selectedPointCurveIndex; selectedPointCurveIndex = Pinta.Tools.LineCurveTool.selectedPointCurveIndex; Pinta.Tools.LineCurveTool.selectedPointCurveIndex = temp; }