Ejemplo n.º 1
0
        /// <remarks>
        /// Executes this edit action
        /// </remarks>
        /// <param name="editor">The <see cref="Ieditor"/> which is used for callback purposes</param>
        public override void Execute(TextBoxControl editor)
        {
            int curLineNr           = editor.Caret.Line;
            int iPageLines          = editor.ClientSize.Height / editor.FontHeight;
            int requestedLineNumber = Math.Max((curLineNr - iPageLines), 1);

            if (curLineNr != requestedLineNumber)
            {
                int lineWidth = editor.GetLineWidth(requestedLineNumber);
                if (editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X) > lineWidth)
                {
                    if (editor.Caret.Position.Y > 1)
                    {
                        editor.Caret.Position = new TextLocation(editor.CalColumnNumber(requestedLineNumber, lineWidth), requestedLineNumber);
                        editor.Caret.UpdateCaretPosition();
                    }
                }
                else
                {
                    int oldLocation = editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X);
                    int location    = oldLocation > 0 ? oldLocation : 0;
                    editor.Caret.Position = new TextLocation(editor.CalColumnNumber(requestedLineNumber, location), requestedLineNumber);
                    editor.Caret.UpdateCaretPosition();
                }
                if (editor.VerticalScroll.Visible)
                {
                    editor.VerticalScroll.Value = Math.Max(0, editor.VerticalScroll.Value - iPageLines * editor.FontHeight);
                    editor.PerformLayout();
                }
            }
        }
Ejemplo n.º 2
0
        public override void Execute(TextBoxControl editor)
        {
            if (editor.Caret.Position.Y == editor.LineCount)
            {
                return;
            }
            int lineWidth = editor.GetLineWidth(editor.Caret.Position.Y + 1);

            if (editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X) > lineWidth)
            {
                editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y + 1, lineWidth), editor.Caret.Position.Y + 1);
                editor.Caret.UpdateCaretPosition();
            }
            else
            {
                int oldLocation = editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X);
                int location    = oldLocation > 0 ? oldLocation : 0;
                editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y + 1, location), editor.Caret.Position.Y + 1);
                editor.Caret.UpdateCaretPosition();
            }
            if (editor.VerticalScroll.Visible && editor.VerticalScroll.Value + editor.DrawRectangle.Height < (editor.Caret.Line - 1) * editor.FontHeight)
            {
                editor.VerticalScroll.Value = Math.Min(editor.VerticalScroll.Maximum, editor.VerticalScroll.Value + editor.FontHeight);
                editor.PerformLayout();
            }
        }
Ejemplo n.º 3
0
        public override void Execute(TextBoxControl editor)
        {
            int lineWidth = editor.GetLineWidth(editor.Caret.Position.Y);

            if (lineWidth <= editor.CalColumnLocation(editor.Caret.Position.Y, editor.Caret.Position.X) && editor.Caret.Position.Y != editor.LineCount)
            {
                if (editor.HorizontalScroll.Value != 0 && editor.HorizontalScroll.Visible)
                {
                    editor.HorizontalScroll.Value = 0;
                }
                if ((editor.Caret.Position.Y + 1) * editor.FontHeight > editor.DrawRectangle.Height && editor.VerticalScroll.Visible)
                {
                    editor.VerticalScroll.Value = Math.Min(editor.VerticalScroll.Maximum, editor.VerticalScroll.Value + editor.FontHeight);
                }
                editor.PerformLayout();
                editor.Caret.Position = new TextLocation(0, editor.Caret.Position.Y + 1);
                editor.Caret.UpdateCaretPosition();
            }
            else
            {
                int location = editor.GetMovePositionByKey(false);
                if (location > editor.DrawRectangle.Width && location > editor.HorizontalScroll.Value + editor.DrawRectangle.Width && editor.HorizontalScroll.Visible)
                {
                    editor.HorizontalScroll.Value = Math.Min(editor.VerticalScroll.Maximum, editor.HorizontalScroll.Value + editor.DrawRectangle.Width);
                }
                editor.PerformLayout();
                editor.Caret.Position = new TextLocation(editor.CalColumnNumber(editor.Caret.Position.Y, location), editor.Caret.Position.Y);
                editor.Caret.UpdateCaretPosition();
            }
        }