Пример #1
0
 void UpdateVerticalPanels(object sender, EventArgs e)
 {
     CheckboxesPanel.UpdateGrid();
     CommentsPanel.UpdateGrid();
     ErrorMarkersPanel.UpdateGrid();
     BookmarksPanel.UpdateGrid();
 }
Пример #2
0
        private void SetNewCodeFile()
        {
            CodeFile newFile = CurrentCodeFile;

            // Отписываемся от событий предыдущего документа
            if (_lastFile != null)
            {
                _lastFile.LastCaretOffset   = AvalonEditor.TextArea.Caret.Offset;
                _lastFile.TextChanged      -= UpdateErrorsMarkers;
                _lastFile.TextChanged      -= OnCurrentFileChanged;
                _lastFile.LineCountChanged -= UpdateVerticalPanels;
                _lastFile.Compiled         -= FileOnCompiled;
            }

            // Выделять ошибки уже не надо
            _colorizeErrorForPopUp.Error = null;

            if (newFile != null)
            {
                newFile.TextChanged      += UpdateErrorsMarkers;
                newFile.TextChanged      += OnCurrentFileChanged;
                newFile.LineCountChanged += UpdateVerticalPanels; // для обновления вертикальных панелей
                newFile.Compiled         += FileOnCompiled;

                // Обновим вертикальные панели
                CheckboxesPanel.UpdateCodeFile(CurrentCodeFile);
                CheckboxesPanel.UpdateGrid();

                CommentsPanel.UpdateCodeFile(CurrentCodeFile);
                CommentsPanel.UpdateGrid();

                ErrorMarkersPanel.UpdateCodeFile(CurrentCodeFile);
                ErrorMarkersPanel.UpdateGrid();

                BookmarksPanel.UpdateCodeFile(CurrentCodeFile);
                BookmarksPanel.UpdateGrid();

                AvalonEditor.DataContext           = newFile;
                AvalonEditor.TextArea.Caret.Offset = newFile.LastCaretOffset;
            }
            else
            {
                AvalonEditor.DataContext = null;
                //Document = null;
            }

            OnCurrentFileChanged(null, null);

            // Установим видимости контролов
            // /*tabControl1.Visibility = */AvalonEditor.Visibility = (newFile == null) ? Visibility.Hidden : Visibility.Visible;

            // Set new last file
            _lastFile = newFile;
        }
Пример #3
0
 private void OnAddBookmarkCommand(object sender, ExecutedRoutedEventArgs e)
 {
     CurrentCodeFile.AddBookmark(AvalonEditor.TextArea.Caret.Line, Convert.ToInt32(e.Parameter));
     BookmarksPanel.UpdateView();
 }
Пример #4
0
        // ----------------------------------------------------------------------------------------
        public void Init(ErrorsListView errorsListView)
        {
            OnPropertyChanged("CurrentCodeFile"); // Без этого не скрывает все изначально

            _colorizeErrors        = new ColorizeErrors(this);
            _colorizeErrorForPopUp = new ColorizeErrorForPopup();

            // Tabs control
            tabControl.SelectionChanged += (sender, args) =>
            {
                SetNewCodeFile();
                OnPropertyChanged("CurrentCodeFile");
                OnActiveFileChanged();
                //Dispatcher.BeginInvoke(new Action(() => AvalonEditor.Focus())); // official hack! BAD!
            };
            tabControl.FileOpened += (sender, args) => OnFileOpened(args);
            tabControl.FileClosed += (sender, args) => OnFileClosed(args);

            tabControl.Init(this);

            // Setting view
            _errorListView = errorsListView;

            // Скроллбары
            AvalonEditor.VerticalScrollBarVisibility   = ScrollBarVisibility.Hidden;
            AvalonEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;

            IsKeyboardFocusWithinChanged += (sender, args) =>
            {
                IsEditorFocused        = IsKeyboardFocusWithin;
                _isEditorFocused.Value = IsKeyboardFocusWithin || CommentsPanel.IsKeyboardFocusWithin;
                Redraw();
                OnPropertyChanged("IsEditorFocused");
            };
            CommentsPanel.IsKeyboardFocusWithinChanged += (sender, args) =>
            {
                _isEditorFocused.Value = IsKeyboardFocusWithin || CommentsPanel.IsKeyboardFocusWithin;
                Redraw();
            };

            // Выделение цветом
            XBackgroundRenderer currentLineColorize = new XBackgroundRenderer(AvalonEditor, _isEditorFocused, CommentsPanel);

            AvalonEditor.TextArea.TextView.BackgroundRenderers.Add(currentLineColorize);
            AvalonEditor.TextArea.TextView.LineTransformers.Add(new ColorizeColorSegments(this));
            AvalonEditor.TextArea.TextView.LineTransformers.Add(_colorizeErrors);
            AvalonEditor.TextArea.TextView.LineTransformers.Add(_colorizeErrorForPopUp);


            // Отключаем drag&drop
            // Если разрешить DragDrop, выделение цветом рушится, и вообще нестабильно, ну его
            AvalonEditor.TextArea.Options.EnableTextDragDrop = false;

            AvalonEditor.Options.EnableEmailHyperlinks = false;
            AvalonEditor.Options.EnableHyperlinks      = false;


            // Изначально никакой файл не открыт
            //SetNewCodeFile();

            // Line numbers
            AvalonEditor.ShowLineNumbers       = true;
            AvalonEditor.LineNumbersForeground = new SolidColorBrush(Colors.SteelBlue);

            // Update Line and Column in the bottom
            AvalonEditor.TextArea.Caret.PositionChanged += (sender, args) =>
            {
                OnPropertyChanged("Caret");
                SelectCurrentErrorForCaret();

                if (CaretLine.Text != AvalonEditor.TextArea.Caret.Line.ToString())
                {
                    OnPropertyChanged("Line");
                    ScrollToErrorInCurrentLine();
                }
                if (CaretColumn.Text != AvalonEditor.TextArea.Caret.Column.ToString())
                {
                    OnPropertyChanged("Column");
                }

                CaretLine.Text   = AvalonEditor.TextArea.Caret.Line.ToString();
                CaretColumn.Text = AvalonEditor.TextArea.Caret.Column.ToString();
            };

            // Verical editor panels
            CheckboxesPanel.Init(this);
            CheckboxesPanel.InitCheckboxes(AvalonEditor);
            CommentsPanel.Init(this);
            CommentsPanel.InitComments(currentLineColorize, AvalonEditor);
            ErrorMarkersPanel.Init(this);
            BookmarksPanel.Init(this);
            BookmarksPanel.Init2(Resources["BookmarksContextMenu"] as ContextMenu, Resources["BookmarksEmptyContextMenu"] as ContextMenu);

            // Popups
            InitPopups();
        }
Пример #5
0
 // ----------------------------------------------------------------------------------------
 public void UpdateBookmarks()
 {
     BookmarksPanel.UpdateView();
 }