Esempio n. 1
0
        /// <summary>
        /// This method executes a dialog key
        /// </summary>
        public bool ExecuteDialogKey(Keys keyData)
        {
            // try, if a dialog key processor was set to use this
            if (DoProcessDialogKey != null && DoProcessDialogKey(keyData))
            {
                return(true);
            }

            // if not (or the process was 'silent', use the standard edit actions
            IEditAction action = motherTextEditorControl.GetEditAction(keyData);

            AutoClearSelection = true;
            if (action != null)
            {
                BeginUpdate();
                try {
                    lock (Document) {
                        action.Execute(this);
                        if (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/)
                        {
                            if (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                            {
                                SelectionManager.ClearSelection();
                            }
                        }
                    }
                } finally {
                    EndUpdate();
                    Caret.UpdateCaretPosition();
                }
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// This method executes a dialog key
        /// </summary>
        public bool ExecuteDialogKey(Keys keyData)
        {
            // try, if a dialog key processor was set to use this
            if (DoProcessDialogKey != null && DoProcessDialogKey(keyData))
            {
                return(true);
            }

            if (keyData == Keys.Back || keyData == Keys.Delete || keyData == Keys.Enter)
            {
                if (TextEditorProperties.UseCustomLine == true)
                {
                    if (SelectionManager.HasSomethingSelected)
                    {
                        if (Document.CustomLineManager.IsReadOnly(SelectionManager.SelectionCollection[0], false))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        int curLineNr = Document.GetLineNumberForOffset(Caret.Offset);
                        if (Document.CustomLineManager.IsReadOnly(curLineNr, false) == true)
                        {
                            return(true);
                        }
                        if ((Caret.Column == 0) && (curLineNr - 1 >= 0) && keyData == Keys.Back &&
                            Document.CustomLineManager.IsReadOnly(curLineNr - 1, false) == true)
                        {
                            return(true);
                        }
                        if (keyData == Keys.Delete)
                        {
                            LineSegment curLine = Document.GetLineSegment(curLineNr);
                            if (curLine.Offset + curLine.Length == Caret.Offset &&
                                Document.CustomLineManager.IsReadOnly(curLineNr + 1, false) == true)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            // if not (or the process was 'silent', use the standard edit actions
            IEditAction action = motherTextEditorControl.GetEditAction(keyData);

            AutoClearSelection = true;
            if (action != null)
            {
                motherTextEditorControl.BeginUpdate();
                try {
                    lock (Document) {
                        action.Execute(this);
                        if (SelectionManager.HasSomethingSelected && AutoClearSelection /*&& caretchanged*/)
                        {
                            if (Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                            {
                                SelectionManager.ClearSelection();
                            }
                        }
                    }
                } finally {
                    motherTextEditorControl.EndUpdate();
                    Caret.UpdateCaretPosition();
                }
                return(true);
            }
            return(false);
        }