/// <summary> /// Selects the passed shape. If clearSelection is true, clears the current selection first, else adds the shape to current selection. /// /// </summary> /// <param name="shape">Shape to select; if null, will just not select it.</param> /// <param name="clearSelection">true = clear the current selection first; false = leave it be</param> internal void selectShape(PowerPoint.Shape shape, bool clearSelection) { if (clearSelection) { PowerPoint.Selection selection = pptController.pptApp.ActiveWindow.Selection; selection.Unselect(); } if (shape != null) { shape.Select(Microsoft.Office.Core.MsoTriState.msoTrue); } }//selectShape
/// <summary> /// rightClick is only called when a right click is recognized AND when there is a current /// selection on the slide. /// </summary> /// <param name="shapes">a collection of shapes</param> internal void rightClick(PowerPoint.ShapeRange shapes) { PowerPoint.Shape clickedShape = null; try { clickedShape = pptController.findShape(X, Y); } catch (Exception e) { debugExceptionMessage("right click", e); return; } // If the click wasn't on any shape, just return if (clickedShape == null) { PowerPoint.Selection selection = pptController.pptApp.ActiveWindow.Selection; selection.Unselect(); return; } // Then, if it falls on an unselected shape, select that and return //if(shapes. bool inRange = false; // first assume the cursor is NOT in range of any of the shapes try { foreach (PowerPoint.Shape shape in shapes) { // if the cursor falls within the range of ANY of the shape selected if (clickedShape.Equals(shape)) { inRange = true; } } if (inRange == false) // if the cursor does not fall within the range of any shapes currently selected { // then try to see if it falls on top of a shape that is not currently selected, // if so, select that one PowerPoint.Shape shape = pptController.findShape(X, Y); shape.Select(Microsoft.Office.Core.MsoTriState.msoTrue); } } catch (Exception e) { // this exception should only be thrown when the right click does NOT fall on top of any // shapes, so the select method complains. In that case, this does not need to do anything // However, it's now checked for above so we should know when it happens debugExceptionMessage("rightclick", e); } }
/// <summary> /// cutAll "cuts" all the selected shapes on the current slide and store those /// shapes in a global ShapeRange object to be accessed later. /// </summary> /// <param name="selection">the selection of shapes on the current slide</param> internal void cutAll(PowerPoint.Selection selection) { cutAllShapes = new List <ShapeAttributes>(); selection = pptController.pptApp.ActiveWindow.Selection; cutPasteShapes = selection.HasChildShapeRange ? selection.ChildShapeRange : selection.ShapeRange; foreach (PowerPoint.Shape s in cutPasteShapes) { ShapeAttributes clone = new ShapeAttributes(s); cutAllShapes.Add(clone); s.Delete(); } selection.Unselect(); undoStack.Push(""); undoStack.Push(""); undoStack.Push(cutAllShapes); undoStack.Push("CutAll"); }