Beispiel #1
0
        /// <summary>
        /// Assigns a new text to the row.
        /// </summary>
        /// <param name="text"></param>
        public void SetText(string Text)
        {
            this.Document.StartUndoCapture();
            TextPoint tp = new TextPoint(0, this.Index);
            TextRange tr = new TextRange();
            tr.FirstColumn = 0;
            tr.FirstRow = tp.Y;
            tr.LastColumn = this.Text.Length;
            tr.LastRow = tp.Y;

            this.Document.StartUndoCapture();
            //delete the current line
            this.Document.PushUndoBlock(UndoAction.DeleteRange, this.Document.GetRange(tr), tr.FirstColumn, tr.FirstRow, this.RevisionMark);
            //alter the text
            this.Document.PushUndoBlock(UndoAction.InsertRange, Text, tp.X, tp.Y, this.RevisionMark);
            this.Text = Text;
            this.Document.EndUndoCapture();
            this.Document.InvokeChange();
        }
Beispiel #2
0
 /// <summary>
 /// Caret constructor
 /// </summary>
 /// <param name="control">The control that will use the caret</param>
 public Caret(EditViewControl control)
 {
     Position = new TextPoint(0, 0);
     Control = control;
 }
Beispiel #3
0
        public Point GetTextPointPixelPos(TextPoint tp)
        {
            Row xtr = Control.Document[tp.Y];
            if (xtr.RowState == RowState.SpanParsed)
                Control.Document.Parser.ParseRow(xtr.Index, true);

            Row r = xtr.IsCollapsedEndPart ? xtr.Expansion_StartRow : xtr;

            int index = r.VisibleIndex;
            int yPos = (index - Control.View.FirstVisibleRow);
            if (yPos < 0 || yPos > Control.View.VisibleRowCount)
                return new Point(-1, -1);

            yPos *= Control.View.RowHeight;

            bool Collapsed = (xtr.IsCollapsedEndPart);
            int pos = MeasureRow(xtr, tp.X).Width + 1;

            if (Collapsed) {
                pos += xtr.Expansion_PixelStart;
                pos -= MeasureRow(xtr, xtr.Expansion_StartChar).Width;
            }

            int xPos = pos + Control.View.TextMargin - Control.View.ClientAreaStart;

            if (xPos < Control.View.TextMargin || xPos > Control.View.ClientAreaWidth + Control.View.TextMargin)
                return new Point(-1, -1);

            return new Point(xPos, yPos);
        }