Ejemplo n.º 1
0
        private void DeleteBookmark_OnClick(object sender, RoutedEventArgs e)
        {
            TextBlock parent = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBlock;

            CurrentCodeFile.DeleteBookmark((int)parent.Tag);
            UpdateBookmarks();
        }
Ejemplo n.º 2
0
        public void ClearAllColorSegments()
        {
            if (CurrentCodeFile == null)
            {
                return;
            }

            CurrentCodeFile.ClearAllColorSegments();
            Redraw();
        }
Ejemplo n.º 3
0
        private void SetAllCheckboxes_Click(object sender, RoutedEventArgs e)
        {
            // Удаляем все секбоксы в текущем файле
            CurrentCodeFile.Checkboxes.Clear();

            // Поставить чекбокс в начал каждой линии
            for (int i = 1; i < CurrentCodeFile.Document.LineCount + 1; i++)
            {
                CurrentCodeFile.AddCheckbox(i);
            }

            CheckboxesPanel.UpdateView();
        }
Ejemplo n.º 4
0
        public void EraseColorSegment()
        {
            if (CurrentCodeFile == null || AvalonEditor.SelectionLength == 0)
            {
                return;
            }

            CurrentCodeFile.EraseColorSegment(AvalonEditor.SelectionStart, AvalonEditor.SelectionStart + AvalonEditor.SelectionLength);

            // Ставим каретку в начало выделения
            AvalonEditor.SelectionLength = 0;
            Redraw();
        }
Ejemplo 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();
                }
            };
        }
Ejemplo n.º 6
0
        private void AddBookmark_OnClick(object sender, RoutedEventArgs e)
        {
            bool foundFirstEmptyKey = false;
            int  key = 0;

            while (!foundFirstEmptyKey)
            {
                foundFirstEmptyKey = (CurrentCodeFile.Bookmarks.Count(b => b.Key == key) == 0);
                key++;
            }

            TextBlock parent = ((sender as MenuItem).Parent as ContextMenu).PlacementTarget as TextBlock;
            int       line   = (int)parent.Tag;

            CurrentCodeFile.AddBookmark(line, key - 1);
            codeEditor.UpdateBookmarks();
        }
Ejemplo n.º 7
0
        // ----------------------------------------------------------------------------------------
        public void AddColorSegment(SolidColorBrush color)
        {
            if (CurrentCodeFile == null || AvalonEditor.SelectionLength == 0)
            {
                return;
            }

            // Стираем все, что было на этом месте
            CurrentCodeFile.EraseColorSegment(AvalonEditor.SelectionStart, AvalonEditor.SelectionStart + AvalonEditor.SelectionLength);

            // Рисуем там же новый цвет
            CurrentCodeFile.AddColorSegment(AvalonEditor.SelectionStart, AvalonEditor.SelectionStart + AvalonEditor.SelectionLength, color);

            // Ставим каретку в начало выделения
            AvalonEditor.SelectionLength = 0;
            Redraw();
        }
Ejemplo n.º 8
0
        protected override void SetEvents(TextBlock elem)
        {
            elem.SetBinding(TextBlock.ToolTipProperty,
                            new Binding()
            {
                Source = Application.Current.Resources["LocalString"],
                Path   = new PropertyPath("Dict[Editor_BookmarkTooltip]")
            });
            ToolTipService.SetIsEnabled(elem, false);

            elem.TextAlignment = TextAlignment.Center;
            elem.ContextMenu   = _emptyContextMenu;

            elem.MouseDown += (sender, args) =>
            {
                // Double click
                if (args.ClickCount == 2)
                {
                    TextBlock b = sender as TextBlock;
                    if (b.Text != "")
                    {
                        CurrentCodeFile.DeleteBookmark((int)b.Tag);
                        UpdateView();
                    }
                    else
                    {
                        bool foundFirstEmptyKey = false;
                        int  key = 0;

                        while (!foundFirstEmptyKey)
                        {
                            foundFirstEmptyKey = (CurrentCodeFile.Bookmarks.Count(bookmark => bookmark.Key == key) == 0);
                            key++;
                        }

                        int line = (int)b.Tag;

                        CurrentCodeFile.AddBookmark(line, key - 1);
                        UpdateView();
                    }
                }
            };
        }
Ejemplo n.º 9
0
 private void OnAddBookmarkCommand(object sender, ExecutedRoutedEventArgs e)
 {
     CurrentCodeFile.AddBookmark(AvalonEditor.TextArea.Caret.Line, Convert.ToInt32(e.Parameter));
     BookmarksPanel.UpdateView();
 }