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

            Document.StartUndoCapture();
            //delete the current line
            Document.PushUndoBlock(UndoAction.DeleteRange, Document.GetRange(tr), tr.FirstColumn, tr.FirstRow);
            //alter the text
            Document.PushUndoBlock(UndoAction.InsertRange, text, tp.X, tp.Y);
            Text = text;
            Document.EndUndoCapture();
            Document.InvokeChange();
        }
        private Point GetTextPointPixelPos(TextPoint tp)
        {
            Row xtr = Control.Document[tp.Y];
            if (xtr.RowState == RowState.SegmentParsed)
                Control.Document.Parser.ParseLine(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);
        }
Example #3
0
 public int Contains2(TextPoint tp)
 {
     return this.Contains2(tp.X, tp.Y);
 }
Example #4
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);
            //alter the text
            this.Document.PushUndoBlock(UndoAction.InsertRange, Text, tp.X, tp.Y);
            this.Text = Text;
            this.Document.EndUndoCapture();
            this.Document.InvokeChange();
        }
Example #5
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;
 }