public SourceEditor()

in tools/Explorer/Views/SourceEditor.cs [141:250]


        public SourceEditor()
        {
            this.TextArea.Caret.PositionChanged += (object sender, EventArgs a) =>
            {
                var caret = sender as ICSharpCode.AvalonEdit.Editing.Caret;
                Model.CaretPositionString = string.Format(CultureInfo.CurrentCulture, "Line: {0} Column: {1}", caret.Line, caret.Column);
            };

            // Install the search panel that appears in the upper left corner.
            ICSharpCode.AvalonEdit.Search.SearchPanel.Install(this.TextArea);

            this.PreviewMouseWheel += MouseWheelHandler;
            this.IsReadOnly = true;

            var fontFamilyBinding = new Binding("SourceFont")
            {
                Source = Properties.Settings.Default
            };
            this.SetBinding(FontFamilyProperty, fontFamilyBinding);

            var fontSizeBinding = new Binding("SourceFontSize")
            {
                Source = Properties.Settings.Default
            };
            this.SetBinding(FontSizeProperty, fontSizeBinding);

            var showLineNumbersBinding = new Binding("ShowLineNumbers")
            {
                Source = Properties.Settings.Default
            };
            this.SetBinding(ShowLineNumbersProperty, showLineNumbersBinding);

            this.Options = new TextEditorOptions
            {
                ConvertTabsToSpaces = true,
                IndentationSize = 4,
            };

            var textMarkerService = new TextMarkerService(this.Document);
            this.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
            this.TextArea.TextView.LineTransformers.Add(textMarkerService);
            IServiceContainer services = (IServiceContainer)this.Document.ServiceProvider.GetService(typeof(IServiceContainer));
            if (services != null)
            {
                services.AddService(typeof(ITextMarkerService), textMarkerService);
            }

            this.TextMarkerService = textMarkerService;

            this.ContextMenu = new ContextMenu
            {
                ItemsSource = new[]
                {
                    new MenuItem {
                        Command = ApplicationCommands.Cut,
                        Icon = new Image {
                            Source = new BitmapImage(new Uri("images/Cut_16x.png", UriKind.Relative))
                        }},
                    new MenuItem {
                        Command = ApplicationCommands.Copy,
                        Icon = new Image {
                                Source = new BitmapImage(new Uri("images/Copy_16x.png", UriKind.Relative))
                            }},
                    new MenuItem {
                        Command = ApplicationCommands.Paste,
                        Icon = new Image {
                                Source = new BitmapImage(new Uri("images/Paste_16x.png", UriKind.Relative))
                        }},
                    new MenuItem {
                        Command = ApplicationCommands.Delete,
                        Icon = new Image {
                                Source = new BitmapImage(new Uri("images/Cancel_16x.png", UriKind.Relative))
                        }},
                    new MenuItem()
                    {
                        Header = "Undo",
                        ToolTip = "Undo",
                        Icon = new Image
                        {
                            Source = new BitmapImage(new Uri("images/undo_16x.png", UriKind.Relative))
                        },
                        InputGestureText = "Ctrl+Z",
                        Command = new RelayCommand(
                            p => { this.Undo(); },
                            p => { return this.CanUndo; })
                    },

                    new MenuItem() {
                        Header = "Redo",
                        ToolTip = "Redo",
                        Icon = new Image
                        {
                            Source = new BitmapImage(new Uri("images/redo_16x.png", UriKind.Relative))
                        },
                        InputGestureText = "Ctrl+Y",
                        Command = new RelayCommand(
                            p => { this.Redo(); },
                            p => { return this.CanRedo; })
                    },
                    new MenuItem {
                        Command = ApplicationCommands.SelectAll,
                        Icon = new Image
                        {
                            Source = new BitmapImage(new Uri("images/SelectAll_16x.png", UriKind.Relative))
                        }
                    }

                }
            };
        }