Пример #1
0
        internal CodeEditor(IWpfTextView textView, IWpfTextViewHost textViewHost, IEditorOperations editorCommands, ITextBufferUndoManager undoService, IFindLogic findLogic, IClassificationTypeRegistry classificationRegistry, IClassificationFormatMap classificationFormatMap, ISquiggleProvider squiggleProvider, ICompletionBroker completionBroker, CodeOptionsModel codeOptionsModel, IMessageDisplayService messageDisplayService, ICodeAidProvider codeAidProvider, IEnvironment environment)
        {
            this.textView                = textView;
            this.textViewHost            = textViewHost;
            this.findLogic               = findLogic;
            this.classificationRegistry  = classificationRegistry;
            this.classificationFormatMap = classificationFormatMap;
            this.editorCommands          = editorCommands;
            this.undoService             = undoService;
            this.squiggleProvider        = squiggleProvider;
            this.environment             = environment;
            this.messageDisplayService   = messageDisplayService;
            this.codeEditorOperations    = new CodeEditorOperations(this, completionBroker, codeAidProvider);
            FrameworkElement element1 = this.Element;

            element1.PreviewLostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Editor_LostFocus);
            element1.LostFocus += new RoutedEventHandler(this.Editor_LostFocus);
            element1.GotFocus  += new RoutedEventHandler(this.Editor_GotFocus);
            this.textView.Caret.PositionChanged   += new EventHandler <CaretPositionChangedEventArgs>(this.Caret_PositionChanged);
            this.textView.Background               = (Brush)Brushes.White;
            this.textView.Selection.UnfocusedBrush = (Brush)Brushes.LightGray;
            this.verticalScollBar = (IWpfTextViewMargin)this.textViewHost.GetTextViewMargin("Wpf Vertical Scrollbar");
            UIElement element2 = ((IWpfTextViewMargin)this.textViewHost.GetTextViewMargin("Wpf Horizontal Scrollbar")).VisualElement.Parent as UIElement;

            if (element2 != null)
            {
                Grid.SetColumn(element2, 0);
                Grid.SetColumnSpan(element2, 2);
            }
            this.lineNumberMargin = (IWpfLineNumberMargin)this.textViewHost.GetTextViewMargin("Wpf Line Number Margin");
            this.lineNumberMargin.BackgroundBrush = (Brush) new SolidColorBrush(Colors.White);
            Border border = this.textViewHost.GetTextViewMargin("Spacer Margin") as Border;

            if (border != null)
            {
                border.BorderBrush     = (Brush) new SolidColorBrush(Color.FromRgb((byte)204, (byte)204, (byte)204));
                border.Margin          = new Thickness(2.0, 0.0, 0.0, 0.0);
                border.BorderThickness = new Thickness(1.0, 0.0, 0.0, 0.0);
            }
            this.textViewHost.BottomRightMarginCorner = (UIElement) new CodeEditorCorner();
            this.codeOptionsModel = codeOptionsModel;
            this.codeOptionsModel.PropertyChanged           += new PropertyChangedEventHandler(this.CodeOptionsModel_PropertyChanged);
            this.editorSpecificOptionsModel                  = this.codeOptionsModel.GetEditorModel(this.codeOptionsModel.GetEditorType(this.TextBuffer));
            this.editorSpecificOptionsModel.PropertyChanged += new PropertyChangedEventHandler(this.CodeOptionsModel_PropertyChanged);
            this.UpdateOptions();
        }
Пример #2
0
        internal CodeEditor CreateCodeEditor(Microsoft.VisualStudio.Text.ITextBuffer textBuffer)
        {
            EditingService.DefaultEnvironment defaultEnvironment = new EditingService.DefaultEnvironment();
            IWpfTextViewHost textViewHost = this.textEditorFactoryProvider.CreateTextViewHost(textBuffer, (IEnvironment)defaultEnvironment, false);

            defaultEnvironment.SetTextViewHost(textViewHost);
            IWpfTextView                textView              = textViewHost.TextView;
            IEditorOperations           editorOperations      = this.editorCommandsProvider.GetEditorOperations((ITextView)textView);
            ITextBufferUndoManager      bufferUndoManager     = this.undoManagerProvider.GetTextBufferUndoManager(textBuffer);
            IFindLogic                  service1              = this.loader.GetService <IFindLogic>();
            IClassificationTypeRegistry service2              = this.loader.GetService <IClassificationTypeRegistry>();
            IClassificationFormatMap    service3              = this.loader.GetService <IClassificationFormatMap>();
            ISquiggleProvider           squiggleProvider      = this.squiggleProviderFactory.GetSquiggleProvider((ITextView)textView);
            ICompletionBroker           brokerForTextView     = this.completionBrokerMap.GetBrokerForTextView((ITextView)textView);
            IMessageDisplayService      messageDisplayService = (IMessageDisplayService)this.serviceProvider.GetService(typeof(IMessageDisplayService));
            ICodeAidProvider            codeAidProvider       = this.GetCodeAidProvider();

            return(new CodeEditor(textView, textViewHost, editorOperations, bufferUndoManager, service1, service2, service3, squiggleProvider, brokerForTextView, this.codeOptionsModel, messageDisplayService, codeAidProvider, (IEnvironment)defaultEnvironment));
        }
Пример #3
0
            // boilerplate
            void OnBufferViewEditorInitialized(object sender, EventArgs e)
            {
                this.bufferView.EditorInitialized -= OnBufferViewEditorInitialized;
                this.squiggleProvider = this.squiggleProviderFactory.GetSquiggleProvider(this.bufferView.TextEditor.TextView);

                // start looking for errors
                this.reparseTimer.Change(100, 100);
            }