}//end paste() #endregion #region Misc /// <summary> /// add the object on which the gesture started to the current selection /// </summary> /// <param name="allShapes">a list of all shapes on the current slide</param> private void multiSelect(List <PowerPoint.Shape> allShapes) { PowerPoint.Shape shape = pptController.findShape(X, Y); if (shape.Equals(null)) { setFeedback("No shape selected - nothing added to selection"); return; } PowerPoint.Selection selection; try { // if the selection is empty, add the shape anyways if (!fillCurrentSelection(out selection)) { shape.Select(MsoTriState.msoTrue); setFeedback("Added object to previously empty selection"); } else { //else, get the selected shapes. I don't know what's the deal with ChildShapeRange. selection = pptController.pptApp.ActiveWindow.Selection; PowerPoint.ShapeRange shapes = selection.HasChildShapeRange ? selection.ChildShapeRange : selection.ShapeRange; //allShapes = selection.HasChildShapeRange ? selection.ChildShapeRange : selection.ShapeRange; // TODO: FIX: why do we need to reselect everything? Figure out why and replace if possible foreach (PowerPoint.Shape s in shapes) { s.Select(MsoTriState.msoFalse); // why does FALSE actually select the object?!? } shape.Select(MsoTriState.msoFalse); setFeedback("New object added to selection"); } } catch (Exception ex) { debugExceptionMessage("case right, for removing exception", ex); shape.Select(MsoTriState.msoFalse); setFeedback("Added object to previously empty selection"); // setFeedback("No currently selection, please select at least one object first"); } }//multiSelect()
/// <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); } }