コード例 #1
0
 /// <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
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
 /// <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");
 }
コード例 #4
0
 /// <summary>
 /// fillCurrentSelection sets the passed selection as the current selection in powerpoint.
 /// it returns true if this selection is nonempty.
 /// </summary>
 /// <param name="selection"> the variable to be filled with the current selection</param>
 /// <returns>Returns true if the selection is nonempty, false otherwise</returns>
 private bool fillCurrentSelection(out PowerPoint.Selection selection)
 {
     selection = null;
     //try
     // {
     // TODO FIXME:
     // if there is no active window (this happens when the presentation is running)
     // this will throw an exception. Need to figure out how to handle this!
     selection = pptController.pptApp.ActiveWindow.Selection;
     if (selection.Type == PowerPoint.PpSelectionType.ppSelectionNone)
     {
         return(false);
     }
     return(true);
     //}
     //catch (Exception e)
     //{
     //     debugExceptionMessage("fillCurrentSelection", e);
     //}
     // return false;
 }//fillSelection()