/// <summary> /// when shapes are stacked in layers, it's difficult to access the shapes hidden under the /// first item. SelectNext enables the user to access those objects with a single tap - it /// cycles through all the shapes that fall under this mouseDown. /// TODO FIXME: right now, if other gestures -- for example, moving or deleting shapes -- happen between /// calls to this method, we may try to access shapes that are no longer under the cursor or perhaps /// now nonexistant. /// </summary> /// <param name="x">x coordinate</param> /// <param name="y">y coordinate</param> /// <returns>the Shape to be selected</returns> internal PowerPoint.Shape selectNext(fPoint p, bool doSelect) { // if we tapped on the same point the last time we tapped (with small margin), just go through the list and select the next thing //TODO FIXME - don't hardcode the margin in if (p.isNear(lastSelectedPoint, 2)) { // if it's empty, clear selection if (shapesAtCurrentPoint.Count == 0) { if (doSelect) { selectShape(null, true); } return(null); } //then, if we've decremented past the end of layeredShapeCounter, loop around if (layeredShapeCounter < 0) { layeredShapeCounter = shapesAtCurrentPoint.Count - 1; } // then, select the shape at the counter and decrement for next time if (doSelect) { selectShape(shapesAtCurrentPoint[layeredShapeCounter], false); } layeredShapeCounter--; return(shapesAtCurrentPoint[layeredShapeCounter]); } // remember what point we just tapped at lastSelectedPoint = p; // Reset the list of shapes at the tapped point shapesAtCurrentPoint.Clear(); // get all the shapes List <PowerPoint.Shape> totalShapes = pptController.allShapes(); // List<PowerPoint.Shape> choices = new List<PowerPoint.Shape>(); // to store possible candidates // go through each shape and add it to the list if it's there foreach (PowerPoint.Shape currentShape in totalShapes) { if (pptController.pointOnShape(p, currentShape)) { shapesAtCurrentPoint.Add(currentShape); } } layeredShapeCounter = shapesAtCurrentPoint.Count - 1; // # of Shapes: 0 = clear selection // : 1 = add it to selection // : >1= add (last added) to selection and move counter to previous one PowerPoint.Shape shape; if (layeredShapeCounter == -1) { shape = null; if (doSelect) { selectShape(null, true); } setFeedback("No object selected - please tap on top of a valid object"); } else { shape = shapesAtCurrentPoint[layeredShapeCounter]; if (doSelect) { selectShape(shape, false); } layeredShapeCounter--; //and decrement the counter // DEBUG FEEDBACK FIXME // setFeedback("Object selected; w=" + shape.Width.ToString() + " h=" + shape.Height.ToString() + " r=" + shape.Rotation.ToString() + // " hf=" + shape.HorizontalFlip.ToString() + " vf=" + shape.VerticalFlip.ToString() + layeredShapeCounter); } // call up an button to display recognition alternatives of that particular textbox // set up such that regardless of input doSelect, a textbox will be selected if clicked if (shape.Type == MsoShapeType.msoTextBox) { displayButton(shape); } return(shape); }