예제 #1
0
 private void CodeEditor_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (!AvalonEditor.IsFocused)
     {
         AvalonEditor.Focus();
     }
 }
예제 #2
0
        public void ScrollTo(CodeFile file, int offset)
        {
            OpenTab(file, false);

            TextLocation location = file.Document.GetLocation(offset);

            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => AvalonEditor.ScrollToLine(location.Line)));
            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => AvalonEditor.ScrollTo(location.Line, location.Column)));
        }
예제 #3
0
        // ----------------------------------------------------------------------------------------
        public void SetCaretTo(CodeFile file, int offset)
        {
            OpenTab(file, false);

            AvalonEditor.CaretOffset = offset;
            AvalonEditor.Focus();
            ScrollTo(file, offset);

            SelectCurrentErrorForCaret();
        }
예제 #4
0
        private void FocusTabOnFile(CodeFile file, bool setFocus)
        {
            tabControl.FocusOn(file);

            if (setFocus)
            {
                Dispatcher.BeginInvoke(new Action(() => AvalonEditor.Focus())); // official hack! BAD!
                AvalonEditor.Focus();
            }
        }
예제 #5
0
        private void InitPopups()
        {
            AvalonEditor.MouseHover += (sender, args) =>
            {
                if (CurrentCodeFile == null)
                {
                    return;     // Текущего файла нет совсем
                }
                TextViewPosition?pos = AvalonEditor.GetPositionFromPoint(Mouse.GetPosition(AvalonEditor.TextArea));
                if (!pos.HasValue)
                {
                    return;     // Не в области редактора
                }
                int          offset = AvalonEditor.Document.GetOffset(pos.Value.Location);
                CompileError error  = CurrentCodeFile.GetErrorByOffset(offset);

                if (error == null)
                {
                    return;     // Ошибки в этом месте нет
                }
                _errorPopup                    = new InsightWindow(AvalonEditor.TextArea);
                _errorPopup.StartOffset        = offset + 1;
                _errorPopup.EndOffset          = offset + 1;
                _errorPopup.Padding            = new Thickness(10, 0, 10, 0);
                _errorPopup.Content            = error.GetDiagnostic();
                _errorPopup.CloseAutomatically = false;

                _colorizeErrorForPopUp.Error = error;       // Выделить цветом ошибку, над которой аэростат
                Redraw();
                AvalonEditor.TextArea.Cursor             = Cursors.Hand;
                AvalonEditor.PreviewMouseLeftButtonDown += GoToMouseError;

                //_errorListView.SelectError(error, false);

                _errorPopup.Show();
            };

            AvalonEditor.MouseHoverStopped += (sender, args) =>
            {
                if (_errorPopup != null)
                {
                    AvalonEditor.PreviewMouseLeftButtonDown -= GoToMouseError;
                    _colorizeErrorForPopUp.Error             = null;
                    AvalonEditor.TextArea.Cursor             = null;
                    Redraw();

                    _errorPopup.Close();
                }
            };
        }
예제 #6
0
 public void ForceFocus()
 {
     Dispatcher.BeginInvoke(new Action(() => AvalonEditor.Focus())); // official hack! BAD!
     AvalonEditor.Focus();
 }