private void pdfOverlay1_OnModified(TikzParseItem sender, string oldtext)
        {
            // update code
            int InsertAt = sender.StartPosition();
            if (InsertAt > txtCode.Text.Length)
            {
                MainWindow.AddStatusLine("Trying to insert code \"" + sender.ToString().Replace(Environment.NewLine, "<NEWLINE>") + "\" to position " + sender.StartPosition() + " but document has only " + txtCode.Text.Length + " characters."
                + " Inserting code at end of document instead. Code does probably not compile now. Please correct or choose undo.", true);
                InsertAt = txtCode.Text.Length;
            }

            txtCode.Document.Replace(InsertAt, oldtext.Length, sender.ToString());

        }
        /// <summary>
        /// Removes a child
        /// </summary>
        /// <param name="tpi"></param>
        /// <param name="InsertAsFirst"></param>
        public void RemoveChild(TikzParseItem tpi)
        {

            int startpos = tpi.StartPosition();
            string oldtext = tpi.ToString();
            tpi.parent = null;
            Children.Remove(tpi);

            // raise event
            RaiseTextChanged(new DummyTikzParseItem(startpos), oldtext);
            RaiseParseTreeModified(new ParseTreeModifiedEventArgs() { AffectedItem = tpi, Type = ParseTreeModifiedType.Remove });
        }