/// <summary>
        /// try to delete some word from an existing textbox
        /// </summary>
        /// <param name="shape"></param>
        private void deleteWordIfTextbox(PowerPoint.Shape shape)
        {
            TextBox box = new TextBox();

            box.Text  = shape.TextFrame.TextRange.Text;
            box.Font  = new System.Drawing.Font(shape.TextFrame.TextRange.Font.Name, shape.TextFrame.TextRange.Font.Size, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            box.Width = (int)shape.TextFrame.TextRange.BoundWidth + 10;
            shape.TextFrame.TextRange.Text = deleteWholeWord(box, shape.Left);
            shape.Width = shape.TextFrame.TextRange.BoundWidth + 10;
            ShapeAttributes clone1 = new ShapeAttributes(shape);

            undoStack.Push(clone1);
            undoStack.Push("deleteWord");
            setFeedback("Word deleted");
            basicOverlay.Ink.DeleteStrokes();
            Panel.Invalidate();
            if (shape.TextFrame.TextRange.Text.Length == 0)
            {
                DialogResult dr = System.Windows.Forms.MessageBox.Show(
                    "Textbox is now empty. Do you wish to delete it?",
                    "PowerPoint",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Exclamation);
                if (dr == DialogResult.OK) // only go ahead and delete if OK button is pressed
                {
                    deleteChosenObject(shape);
                }
            }
        }
        }//deleteAllStrokes()

        #endregion


        #region Copy/Cut/Paste
        // note that these functions are SEPARATE from normal windows clipboard
        // functions -- invoking them will not change the clipboard.

        /// <summary>
        /// Copy all the selected objects
        /// </summary>
        private void copySelection()
        {
            try
            {
                PowerPoint.Selection selection;
                setFeedback("test");
                if (fillCurrentSelection(out selection))
                {
                    cutAllShapes = new List <ShapeAttributes>();
                    // save all currently selected shapes into cutPasteShapes object
                    cutPasteShapes = selection.HasChildShapeRange ? selection.ChildShapeRange : selection.ShapeRange;
                    foreach (PowerPoint.Shape s in cutPasteShapes)
                    {
                        ShapeAttributes sa = new ShapeAttributes(s);
                        cutAllShapes.Add(sa);
                    }
                    setFeedback("All selected objects copied");
                }
                else
                {
                    setFeedback("Selection empty - nothing was copied");
                }
            }
            catch (Exception ex)
            {
                debugExceptionMessage("copySelection", ex);
            }
        }//copySelection()
        private void stackOrderChange(PowerPoint.Shape shape, string order)
        {
            ShapeAttributes clone = new ShapeAttributes(shape);

            undoStack.Push("");
            undoStack.Push(order);
            undoStack.Push(clone);
            undoStack.Push("ChangeOrder");
        }
        private void stackDeleteTextbox(PowerPoint.Shape shape, ListBox lb)
        {
            ShapeAttributes clone = new ShapeAttributes(shape);

            undoStack.Push("");
            undoStack.Push(lb);
            undoStack.Push(clone);
            undoStack.Push("DeleteTextBox");
        }
        private void stackDeleteShape(PowerPoint.Shape shape)
        {
            ShapeAttributes clone = new ShapeAttributes(shape);

            undoStack.Push("");
            undoStack.Push("");
            undoStack.Push(clone);
            undoStack.Push("DeleteObject");
        }
        private void stackAddShape(PowerPoint.Shape s)
        {
            ShapeAttributes clone = new ShapeAttributes(s);

            undoStack.Push("");          // placeholder
            undoStack.Push("");          // placeholder
            undoStack.Push(clone);       // object to be added
            undoStack.Push("AddObject"); // action
        }
        private void stackMoveEnd(PowerPoint.ShapeRange totalShapes)
        {
            List <ShapeAttributes> clones = new List <ShapeAttributes>();

            foreach (PowerPoint.Shape s in totalShapes)
            {
                ShapeAttributes sa = new ShapeAttributes(s);
                clones.Add(sa);
            }
            undoStack.Push(clones);
            undoStack.Push("Move");
        }
        private void stackDeleteShapes(List <PowerPoint.Shape> allShapes)
        {
            List <ShapeAttributes> clones = new List <ShapeAttributes>();

            foreach (PowerPoint.Shape shape in allShapes)
            {
                ShapeAttributes clone = new ShapeAttributes(shape);
                clones.Add(clone);
            }
            undoStack.Push("");
            undoStack.Push("");
            undoStack.Push(clones);
            undoStack.Push("DeleteAllShapes");
        }
        private void stackChangeRotation(List <float> angle, List <PowerPoint.Shape> rotated)
        {
            List <ShapeAttributes> clones = new List <ShapeAttributes>();
            ShapeAttributes        clone;

            foreach (PowerPoint.Shape s in rotated)
            {
                clone = new ShapeAttributes(s);
                clones.Add(clone);
            }
            undoStack.Push("");
            undoStack.Push(angle);
            undoStack.Push(clones);
            undoStack.Push("ChangeRotation");
        }
 /// <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");
 }
        /// <summary>
        /// try to insert new text into an existing textbox
        /// </summary>
        /// <param name="shape"></param>
        private void insertIfTextbox(PowerPoint.Shape shape)
        {
            shape.TextFrame.WordWrap = MsoTriState.msoFalse;
            TextBox box = new TextBox(); // need some functions withint TextBox class

            box.Text  = shape.TextFrame.TextRange.Text;
            box.Font  = new System.Drawing.Font(shape.TextFrame.TextRange.Font.Name, shape.TextFrame.TextRange.Font.Size, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            box.Width = (int)shape.TextFrame.TextRange.BoundWidth + 10;
            shape.TextFrame.TextRange.Text = insertText(box, shape.Left);
            shape.Width = shape.TextFrame.TextRange.BoundWidth + buttonForm.BOUND; // adjust width accordingly
            ShapeAttributes clone = new ShapeAttributes(shape);

            undoStack.Push(clone); // keep track of name so for undo's sake
            undoStack.Push("insert");
            setFeedback("Text inserted");
            basicOverlay.Ink.DeleteStrokes();
            Panel.Invalidate();
        }
        /// <summary>
        /// called by the selectedIndexChanged event handler when the user selects an alternative
        /// in any of the listboxes. It then replace the text in the original textbox with the
        /// selected alternative.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void lb_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox lb = (ListBox)sender;

            PowerPoint.Shape shapeToChange = findTextboxFromListbox(lb.Name);
            string           original      = shapeToChange.TextFrame.TextRange.Text;

            shapeToChange.TextFrame.TextRange.Text = lb.SelectedItem.ToString();
            shapeToChange.Width = shapeToChange.TextFrame.TextRange.BoundWidth + 10;
            ShapeAttributes sa = new ShapeAttributes(shapeToChange);

            updateButton(shapeToChange);
            lb.Hide();

            undoStack.Push("");
            undoStack.Push(original);
            undoStack.Push(sa);
            undoStack.Push("SelectedIndexChanged");
        }