示例#1
0
        internal CodeEditor(
            ICommandManager commandManager
            , IEditorView editorView
            , IEditorViewHost editorViewHost
            , IEditorCommands editorCommands
            , IUndoManager undoManager
            , IFindLogic findLogic
            , CodeOptionsModel codeOptionsModel
            )
        {
            this.commandManager = commandManager;
            this.editorView     = editorView;
            this.editorViewHost = editorViewHost;
            this.findLogic      = findLogic;
            this.editorCommands = editorCommands;
            this.undoManager    = undoManager;
            FrameworkElement element = this.Element;

            element.PreviewLostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Editor_LostFocus);
            element.LostFocus += new RoutedEventHandler(this.Editor_LostFocus);
            if (this.commandManager != null)
            {
                this.commandManager.CommandExecuting += new CommandExecutionEventHandler(this.Editor_LostFocus);
            }
            this.editorView.Background = Brushes.White;
            TextFormattingRunProperties.DefaultProperties.SetTypeface(new Typeface(FontName));
            TextFormattingRunProperties.DefaultProperties.SetFontRenderingEmSize(FontSize);
            this.editorViewHost.LineNumberGutterForegroundColor = Colors.Black;
            this.editorViewHost.LineNumberGutterTypeface        = new Typeface(FontName);
            this.editorViewHost.LineNumberGutterFontSize        = FontSize;
            this.editorView.Invalidate();
            this.codeOptionsModel = codeOptionsModel;
            this.codeOptionsModel.PropertyChanged += new PropertyChangedEventHandler(this.CodeOptionsModel_PropertyChanged);
            this.UpdateOptions();
        }
示例#2
0
		internal CodeEditor(
			ICommandManager commandManager
			, IEditorView editorView
			, IEditorViewHost editorViewHost
			, IEditorCommands editorCommands
			, IUndoManager undoManager
			, IFindLogic findLogic
			, CodeOptionsModel codeOptionsModel
			)
		{
			this.commandManager = commandManager;
			this.editorView = editorView;
			this.editorViewHost = editorViewHost;
			this.findLogic = findLogic;
			this.editorCommands = editorCommands;
			this.undoManager = undoManager;
			FrameworkElement element = this.Element;
			element.PreviewLostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.Editor_LostFocus);
			element.LostFocus += new RoutedEventHandler(this.Editor_LostFocus);
			if (this.commandManager != null)
			{
				this.commandManager.CommandExecuting += new CommandExecutionEventHandler(this.Editor_LostFocus);
			}
			this.editorView.Background = Brushes.White;
			TextFormattingRunProperties.DefaultProperties.SetTypeface(new Typeface(FontName));
			TextFormattingRunProperties.DefaultProperties.SetFontRenderingEmSize(FontSize);
			this.editorViewHost.LineNumberGutterForegroundColor = Colors.Black;
			this.editorViewHost.LineNumberGutterTypeface = new Typeface(FontName);
			this.editorViewHost.LineNumberGutterFontSize = FontSize;
			this.editorView.Invalidate();
			this.codeOptionsModel = codeOptionsModel;
			this.codeOptionsModel.PropertyChanged += new PropertyChangedEventHandler(this.CodeOptionsModel_PropertyChanged);
			this.UpdateOptions();
		}
示例#3
0
        public static IFindLogic GetFindLogic()
        {
            if (_findLogic == null)
            {
                _findLogic = new FindLogic(GetTextStructureNavigatorFactory());
            }

            return(_findLogic);
        }
示例#4
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();
        }
示例#5
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));
        }