Esempio n. 1
0
        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());
        }
Esempio n. 2
0
 void IPdfOverlayView.JumpToSourceDoIt(OverlayShapeVM o)
 {
     if (JumpToSource != null)
     {
         TikzParseItem tpi = o.item;
         if (tpi != null)
         {
             JumpToSource(this, new JumpToSourceEventArgs()
             {
                 JumpToPos = tpi.StartPosition(), SelectionLength = tpi.Length
             });
         }
     }
 }
Esempio n. 3
0
        private void pdfOverlay1_JumpToSource(object sender)
        {
            TikzParseItem tpi  = sender as TikzParseItem;
            int           spos = tpi.StartPosition();

            if (spos > txtCode.Text.Length)
            {
                MainWindow.AddStatusLine("Trying to jump to position " + spos + " but document only has " + txtCode.Text.Length + " characters. Please correct any parser errors or restart TikzEdt.", true);
                return;
            }
            txtCode.SelectionLength = 0; //deselect first
            txtCode.CaretOffset     = spos;
            txtCode.SelectionStart  = spos;
            txtCode.SelectionLength = tpi.ToString().Length;
            txtCode.ScrollToLine(txtCode.Document.GetLineByOffset(spos).LineNumber);
            txtCode.Focus();
        }