Esempio n. 1
0
 private void CodeEditor_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (!AvalonEditor.IsFocused)
     {
         AvalonEditor.Focus();
     }
 }
Esempio n. 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)));
        }
Esempio n. 3
0
        // ----------------------------------------------------------------------------------------
        public void SetCaretTo(CodeFile file, int offset)
        {
            OpenTab(file, false);

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

            SelectCurrentErrorForCaret();
        }
Esempio n. 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();
            }
        }
Esempio n. 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();
                }
            };
        }
Esempio n. 6
0
 public void ForceFocus()
 {
     Dispatcher.BeginInvoke(new Action(() => AvalonEditor.Focus())); // official hack! BAD!
     AvalonEditor.Focus();
 }