Exemplo n.º 1
0
        public CodeTextEditor()
        {
            Options = new TextEditorOptions
            {
                ConvertTabsToSpaces = true,
                AllowScrollBelowDocument = true,
                IndentationSize = 4,
                EnableEmailHyperlinks = false,
            };
            ShowLineNumbers = true;

            MouseHover += OnMouseHover;
            MouseHoverStopped += OnMouseHoverStopped;
            TextArea.TextView.VisualLinesChanged += OnVisualLinesChanged;
            TextArea.TextEntering += OnTextEntering;
            TextArea.TextEntered += OnTextEntered;
            
            ToolTipService.SetInitialShowDelay(this, 0);
            SearchReplacePanel.Install(this);

            var commandBindings = TextArea.CommandBindings;
            var deleteLineCommand = commandBindings.OfType<CommandBinding>().FirstOrDefault(x => x.Command == AvalonEditCommands.DeleteLine);
            if (deleteLineCommand != null)
            {
                commandBindings.Remove(deleteLineCommand);
            }
        }
Exemplo n.º 2
0
        public CodeTextEditor()
        {
            Options = new TextEditorOptions
            {
                ConvertTabsToSpaces      = true,
                AllowScrollBelowDocument = true,
                IndentationSize          = 4,
                EnableEmailHyperlinks    = false,
            };

            // TODO: remove this after bug fix
#if AVALONIA
            var lineMargin = new LineNumberMargin {
                Margin = new Thickness(0, 0, 10, 0)
            };
            lineMargin[~TextBlock.ForegroundProperty] = this[~LineNumbersForegroundProperty];
            TextArea.LeftMargins.Insert(0, lineMargin);
#else
            ShowLineNumbers = true;
#endif

            TextArea.TextView.VisualLinesChanged += OnVisualLinesChanged;
            TextArea.TextEntering += OnTextEntering;
            TextArea.TextEntered  += OnTextEntered;

#if AVALONIA
            PointerHover        += OnMouseHover;
            PointerHoverStopped += OnMouseHoverStopped;
#else
            MouseHover        += OnMouseHover;
            MouseHoverStopped += OnMouseHoverStopped;

            ToolTipService.SetInitialShowDelay(this, 0);
            SearchReplacePanel.Install(this);
#endif

            var commandBindings   = TextArea.CommandBindings;
            var deleteLineCommand = commandBindings.OfType <CommandBinding>().FirstOrDefault(x =>
                                                                                             x.Command == AvalonEditCommands.DeleteLine);
            if (deleteLineCommand != null)
            {
                commandBindings.Remove(deleteLineCommand);
            }

            var contextMenu = new ContextMenu();
            contextMenu.SetItems(new[]
            {
                new MenuItem {
                    Command = ApplicationCommands.Cut
                },
                new MenuItem {
                    Command = ApplicationCommands.Copy
                },
                new MenuItem {
                    Command = ApplicationCommands.Paste
                }
            });
            ContextMenu = contextMenu;
        }
        partial void Initialize()
        {
            ShowLineNumbers = true;

            MouseHover        += OnMouseHover;
            MouseHoverStopped += OnMouseHoverStopped;

            ToolTipService.SetInitialShowDelay(this, 0);
            SearchReplacePanel.Install(this);
        }