Пример #1
0
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public GochiusaIDE(IWpfTextView view)
        {
            _view = view;

            InitImages();

            eyeClosed = false;
            cRandom = new Random();

            building = false;
            buildDone = false;
            clean = false;

            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("GochiusaIDE");
            _adornmentBackgroundLayer = view.GetAdornmentLayer("GochiusaIDE_Background");
            _adornmentBuildLayer = view.GetAdornmentLayer("GochiusaIDE_Build");

            _adornmentBackgroundLayer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, _backgroundImage, null);

            faceTimer = new DispatcherTimer(DispatcherPriority.Normal);
            faceTimer.Interval = new TimeSpan(30000000);
            faceTimer.Tick += new EventHandler(faceTimer_Tick);
            faceTimer.Start();

            buildTimer = new DispatcherTimer(DispatcherPriority.Normal);
            buildTimer.Interval = new TimeSpan(5000000);
            buildTimer.Tick += new EventHandler(buildTimer_Tick);
            buildTimer.Start();

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged += delegate { this.onSizeChange(); };
        }
        public AchievementAdornments(IWpfTextView view)
        {
            this.view = view;
            this.layer = view.GetAdornmentLayer("AchievementAdornments");
            this.descriptionLayer = view.GetAdornmentLayer("AchievementAdornmentsDescription");

            view.LayoutChanged += OnLayoutChanged;

            Brush brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff));
            brush.Freeze();

            Brush penBrush = new SolidColorBrush(Colors.Red);
            penBrush.Freeze();

            Pen pen = new Pen(penBrush, 0.5);
            pen.Freeze();

            this.brush = brush;
            this.pen = pen;

            AchievementUIContext.AchievementClicked += (sender, e) =>
            {
                Reset();

                var filePath = GetFilePath(view);
                if (e.AchievementDescriptor.CodeOrigin.FileName != filePath)
                    return;

                codeOrigin = e.AchievementDescriptor.CodeOrigin;
                achievementUiElement = (UIElement)e.UIElement;

                CreateAdornment();
            };
        }
        public BackgroundTextViewWorker(IWpfTextView textView)
        {
            if (textView == null)
                throw new ArgumentException("textView is null");
            _backgroundView = textView;

            EventHandler onSizeChangedEventHandler = (object sender, EventArgs args) => OnSizeChanged();
            try
            {
                _configurationDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (_configurationDirectory == null || string.IsNullOrEmpty(_configurationDirectory))
                    throw new ArgumentException("_configurationDirectory is null or empty");

                _configurationDataPath = Path.Combine(_configurationDirectory, CONFIGURATION_FILE_NAME);

                if (_configurationDataPath != null)
                {
                    _settings = new BackgroundImageSettings(new Uri(_configurationDataPath));
                }
                _adornmentLayer = textView.GetAdornmentLayer("BackgroundTextViewWorker");

                IWpfTextView newTextView = _backgroundView;
                newTextView.ViewportWidthChanged += onSizeChangedEventHandler;
                newTextView.ViewportHeightChanged += onSizeChangedEventHandler;

                // Set the environment background
                EnvBackgroundManager.ApplyEnvironmentBackground(_settings);
            }
            catch (Exception e)
            {
                // todo: better logging
            }
        }
        internal ImageAdornmentManager(IServiceProvider serviceProvider, IWpfTextView view, IEditorFormatMap editorFormatMap)
        {
            View = view;
            this.serviceProvider = serviceProvider;
            AdornmentLayer = View.GetAdornmentLayer(ImageAdornmentLayerName);

            ImagesAdornmentsRepository = new ImageAdornmentRepositoryService(view.TextBuffer);

            // Create the highlight line adornment
            HighlightLineAdornment = new HighlightLineAdornment(view, editorFormatMap);
            AdornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, HighlightLineAdornment,
                                        HighlightLineAdornment.VisualElement, null);

            // Create the preview image adornment
            PreviewImageAdornment = new PreviewImageAdornment();
            AdornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, this,
                                        PreviewImageAdornment.VisualElement, null);

            // Attach to the view events
            View.LayoutChanged += OnLayoutChanged;
            View.TextBuffer.Changed += OnBufferChanged;
            View.Closed += OnViewClosed;

            // Load and initialize the image adornments repository
            ImagesAdornmentsRepository.Load();
            ImagesAdornmentsRepository.Images.ToList().ForEach(image => InitializeImageAdornment(image));
        }
Пример #5
0
        public CodeAdornment(IWpfTextView view)
        {
            _view = view;
            _sourceFilePath = GetSourceFilePath();
            _adornmentLayer = view.GetAdornmentLayer("CodeAdornment");

            _adornmentLayer.RemoveAllAdornments();
            containingUnitView = ContainingUnitView.GetContainingUnitViewByName(_sourceFilePath);

            if (containingUnitView.Parent != null)
            {
                var adornmentLayer = (IAdornmentLayer)containingUnitView.Parent;
                adornmentLayer.RemoveAdornment(containingUnitView);
            }

            //TODO Some how anchor the adornment layer to prevent random moving.
            Canvas.SetTop(containingUnitView, 0);
            _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, containingUnitView, null);

            // _view.ViewportWidthChanged += delegate { Initialize(); };
            //_view.ViewportHeightChanged += delegate { Initialize(); };
            //    _view.LayoutChanged += delegate { Initialize(); };
            //   _view.ViewportLeftChanged += delegate { Initialize(); };
            //   _view.ZoomLevelChanged += delegate { Initialize(); };
            // _view.VisualElement.SizeChanged +=delegate { Initialize(); };
        }
        public RoslynCodeAnalysisHelper(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte, SVsServiceProvider serviceProvider, IVsActivityLog log)
        {
            _view = view;
            _document = document;
            _text = new Adornment();
            _tasks = tasks;
            _serviceProvider = serviceProvider;
            _log = log;
            _dispatcher = Dispatcher.CurrentDispatcher;

            _adornmentLayer = view.GetAdornmentLayer(RoslynCodeAnalysisFactory.LayerName);

            _view.ViewportHeightChanged += SetAdornmentLocation;
            _view.ViewportWidthChanged += SetAdornmentLocation;

            _text.MouseUp += (s, e) => dte.ExecuteCommand("View.ErrorList");

            _timer = new Timer(750);
            _timer.Elapsed += (s, e) =>
            {
                _timer.Stop();
                System.Threading.Tasks.Task.Run(() =>
                {
                    _dispatcher.Invoke(new Action(() => Update(false)), DispatcherPriority.ApplicationIdle, null);
                });
            };
            _timer.Start();
        }
Пример #7
0
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        /// <param name="imageProvider">The <see cref="IImageProvider"/> which provides bitmaps to draw</param>
        /// <param name="setting">The <see cref="Setting"/> contains user image preferences</param>
        public ClaudiaIDE(IWpfTextView view, List<IImageProvider> imageProvider, Setting setting)
		{
		    try
		    {
		        _dispacher = Dispatcher.CurrentDispatcher;
                _imageProviders = imageProvider;
                _imageProvider = imageProvider.FirstOrDefault(x=>x.ProviderType == setting.ImageBackgroundType);
                _setting = setting;
                if (_imageProvider == null)
                {
                    _imageProvider = new SingleImageProvider(_setting);
                }
                _view = view;
                _image = new Image
                {
                    Opacity = setting.Opacity,
                    IsHitTestVisible = false
                };
                _adornmentLayer = view.GetAdornmentLayer("ClaudiaIDE");
				_view.ViewportHeightChanged += delegate { RepositionImage(); };
				_view.ViewportWidthChanged += delegate { RepositionImage(); };     
                _view.ViewportLeftChanged += delegate { RepositionImage(); };
                _setting.OnChanged += delegate { ReloadSettings(); };

                _imageProviders.ForEach(x => x.NewImageAvaliable += delegate { InvokeChangeImage(); });

                ChangeImage();
            }
			catch
			{
			}
		}
Пример #8
0
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public LyricalEditor(IWpfTextView view, IEnumerable<Detail> details)
        {
            this.view = view;
            var doc =
                view.TextDataModel.DocumentBuffer.Properties.GetProperty<ITextDocument>(typeof(ITextDocument));
            var file = doc.FilePath;

            detail = details.FirstOrDefault(d => Regex.IsMatch(file, d.RuleRegex));
            imageFile = SelectFile(detail, 0);

            //Grab a reference to the adornment layer that this adornment should be added to
            this.adornmentLayer = view.GetAdornmentLayer("LyricalEditor");

            view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            view.ViewportWidthChanged += delegate { this.onSizeChange(); };

            if (detail.IsSlideShow)
            {
                timer.Interval = TimeSpan.FromSeconds((double)detail.SlideShowTiming);
                timer.Tick += delegate
                {
                    crntImageIndex++;
                    if (crntImageIndex >= detail.Images.Count)
                        crntImageIndex = 0;
                    imageFile = SelectFile(detail, crntImageIndex);
                    SetImage();
                };
                timer.Start();
            }
            view.Closed += delegate { timer.Stop(); };
            view.GotAggregateFocus += delegate { if (detail.IsSlideShow) timer.Start(); };
            view.LostAggregateFocus += delegate { if (detail.IsSlideShow) timer.Stop(); };
        }
Пример #9
0
        public ErrorHighlighter(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte)
        {
            _view = view;
            _document = document;
            _text = new Adornment();
            _tasks = tasks;
            _dispatcher = Dispatcher.CurrentDispatcher;

            _adornmentLayer = view.GetAdornmentLayer(ErrorHighlighterFactory.LayerName);

            _view.ViewportHeightChanged += SetAdornmentLocation;
            _view.ViewportWidthChanged += SetAdornmentLocation;

            _text.MouseUp += (s, e) => { dte.ExecuteCommand("View.ErrorList"); };

            _timer = new Timer(750);
            _timer.Elapsed += (s, e) =>
            {
                _timer.Stop();
                Task.Run(() =>
                {
                    _dispatcher.Invoke(new Action(() =>
                    {
                        Update(false);
                    }), DispatcherPriority.ApplicationIdle, null);
                });
            };
            _timer.Start();
        }
Пример #10
0
        public Dashboard(
            DashboardViewModel model,
            IWpfTextView textView)
        {
            _model = model;
            InitializeComponent();

            _tabNavigableChildren = new UIElement[] { this.OverloadsCheckbox, this.CommentsCheckbox, this.StringsCheckbox, this.PreviewChangesCheckbox, this.ApplyButton, this.CloseButton }.ToList();

            _textView = textView;
            this.DataContext = model;

            this.Visibility = textView.HasAggregateFocus ? Visibility.Visible : Visibility.Collapsed;

            _textView.GotAggregateFocus += OnTextViewGotAggregateFocus;
            _textView.LostAggregateFocus += OnTextViewLostAggregateFocus;
            _textView.VisualElement.SizeChanged += OnElementSizeChanged;
            this.SizeChanged += OnElementSizeChanged;

            PresentationSource.AddSourceChangedHandler(this, OnPresentationSourceChanged);

            try
            {
                _findAdornmentLayer = textView.GetAdornmentLayer("FindUIAdornmentLayer");
                ((UIElement)_findAdornmentLayer).LayoutUpdated += FindAdornmentCanvas_LayoutUpdated;
            }
            catch (ArgumentOutOfRangeException)
            {
                // Find UI doesn't exist in ETA.
            }

            this.Focus();
            textView.Caret.IsHidden = false;
            ShouldReceiveKeyboardNavigation = false;
        }
Пример #11
0
 private MiddleClickScroll(IWpfTextView view, MiddleClickScrollFactory factory)
 {
     this._view = view;
     this._layer = view.GetAdornmentLayer("MiddleClickScrollLayer");
     this._view.Closed += new EventHandler(this.OnClosed);
     this._view.VisualElement.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.OnIsVisibleChanged);
 }
Пример #12
0
 /// <summary>
 /// Creates a square image and attaches an event handler to the layout changed event that
 /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
 /// </summary>
 /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
 /// <param name="imageProvider">The <see cref="IImageProvider"/> which provides bitmaps to draw</param>
 /// <param name="setting">The <see cref="Setting"/> contains user image preferences</param>
 public ClaudiaIDE(IWpfTextView view, IImageProvider imageProvider, Setting setting)
 {
     try
     {
         _dispacher = Dispatcher.CurrentDispatcher;
         _imageProvider = imageProvider;
         _view = view;
         _positionHorizon = setting.PositionHorizon;
         _positionVertical = setting.PositionVertical;
         _imageOpacity = setting.Opacity;
         _fadeTime = setting.ImageFadeAnimationInterval;
         _image = new Image
         {
             Opacity = setting.Opacity,
             IsHitTestVisible = false
         };
         _adornmentLayer = view.GetAdornmentLayer("ClaudiaIDE");
         _view.ViewportHeightChanged += delegate { RepositionImage(); };
         _view.ViewportWidthChanged += delegate { RepositionImage(); };
         _view.ViewportLeftChanged += delegate { RepositionImage(); };
         _imageProvider.NewImageAvaliable += delegate { _dispacher.Invoke(ChangeImage); };
         ChangeImage();
     }
     catch (Exception)
     {
     }
 }
Пример #13
0
        public CurrentColumnAdornment(
            IWpfTextView view, IClassificationFormatMap formatMap,
            IClassificationType formatType, IVsfSettings settings)
        {
            this.view = view;
              this.formatMap = formatMap;
              this.formatType = formatType;
              this.settings = settings;
              this.columnRect = new Rectangle();
              layer = view.GetAdornmentLayer(Constants.COLUMN_HIGHLIGHT);

              view.Caret.PositionChanged += OnCaretPositionChanged;
              view.ViewportWidthChanged += OnViewportChanged;
              view.ViewportHeightChanged += OnViewportChanged;
              view.LayoutChanged += OnViewLayoutChanged;
              view.TextViewModel.EditBuffer.PostChanged += OnBufferPostChanged;
              view.Closed += OnViewClosed;
              view.Options.OptionChanged += OnSettingsChanged;

              this.settings.SettingsChanged += OnSettingsChanged;
              formatMap.ClassificationFormatMappingChanged +=
             OnClassificationFormatMappingChanged;

              CreateDrawingObjects();
        }
Пример #14
0
		public InstantVisualStudio (IWpfTextView view, ITextDocumentFactoryService textDocumentFactoryService)
		{
			this.view = view;
			this.layer = view.GetAdornmentLayer("Instant.VisualStudio");

			//Listen to any event that changes the layout (text changes, scrolling, etc)
			this.view.LayoutChanged += OnLayoutChanged;

			this.dispatcher = Dispatcher.CurrentDispatcher;

			this.evaluator.EvaluationCompleted += OnEvaluationCompleted;
			this.evaluator.Start();

			this.dte.Events.BuildEvents.OnBuildProjConfigDone += OnBuildProjeConfigDone;
			this.dte.Events.BuildEvents.OnBuildDone += OnBuildDone;
			this.dte.Events.BuildEvents.OnBuildBegin += OnBuildBegin;

			this.statusbar = (IVsStatusbar)this.serviceProvider.GetService (typeof (IVsStatusbar));

			ITextDocument textDocument;
			if (!textDocumentFactoryService.TryGetTextDocument (view.TextBuffer, out textDocument))
				throw new InvalidOperationException();

			this.document = this.dte.Documents.OfType<EnvDTE.Document>().FirstOrDefault (d => d.FullName == textDocument.FilePath);

			InstantTagToggleAction.Toggled += OnInstantToggled;
		}
        public VmsViewportAdornment(IWpfTextView view, SVsServiceProvider serviceProvider)
        {
            var service = (DTE)serviceProvider.GetService(typeof(DTE));
            var properties = service.Properties["Visual Method Separators", "Global"];

            var colorProperty = properties.Item("Color");
            var color = UIntToColor(colorProperty.Value);

            var dashStyleProperty = properties.Item("PenDashStyle");
            var dashStyle = DashStyleFromInt(dashStyleProperty.Value);

            var thicknessProperty = properties.Item("Thickness");
            var thickness = (double) thicknessProperty.Value;

            _view = view;
            _view.LayoutChanged += OnLayoutChanged;

            _layer = view.GetAdornmentLayer("VmsViewportAdornment");

            _pen = new Pen(new SolidColorBrush(color), thickness)
                {
                    DashStyle = dashStyle,
                    DashCap = PenLineCap.Flat,
                };

            _pen.Freeze();
        }
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public TranslationAdornment(IWpfTextView view)
        {
            _view = view;

            Brush brush = new SolidColorBrush(Colors.BlueViolet);
            brush.Freeze();
            Brush penBrush = new SolidColorBrush(Colors.Red);
            penBrush.Freeze();
            Pen pen = new Pen(penBrush, 0.5);
            pen.Freeze();

            //draw a square with the created brush and pen
            System.Windows.Rect r = new System.Windows.Rect(0, 0, 30, 30);
            Geometry g = new RectangleGeometry(r);
            GeometryDrawing drawing = new GeometryDrawing(brush, pen, g);
            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            _image = new Image();
            _image.Source = drawingImage;

            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("TranslationAdornment");

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged += delegate { this.onSizeChange(); };
        }
        public BackgroundColorVisualManager(IWpfTextView view, ITagAggregator<IClassificationTag> aggregator, IClassificationFormatMap formatMap,
                                            IVsFontsAndColorsInformationService fcService, IVsEditorAdaptersFactoryService adaptersService)
        {
            _view = view;
            _layer = view.GetAdornmentLayer("BackgroundColorFix");
            _aggregator = aggregator;
            _formatMap = formatMap;

            _fcService = fcService;
            _adaptersService = adaptersService;

            _view.LayoutChanged += OnLayoutChanged;

            // Here are the hacks for making the normal classification background go away:

            _formatMap.ClassificationFormatMappingChanged += (sender, args) =>
                {
                    if (!_inUpdate && _view != null && !_view.IsClosed)
                    {
                        _view.VisualElement.Dispatcher.BeginInvoke(new Action(FixFormatMap));
                    }
                };

            _view.VisualElement.Dispatcher.BeginInvoke(new Action(FixFormatMap));
        }
        /// <summary>
        /// Inizializza una nuova istanza della classe ViewportAdornment1 Creates a square image and attaches an event handler to the layout changed event that.
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer.
        /// </summary>
        /// <param name="theView">
        /// Puntatore alla vista di Visual Studio da Factory.
        /// </param>
        public ViewportAdornment1(IWpfTextView theView)
        {
            view = theView;

            // Brush brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff));
            // brush.Freeze();

            // Brush penBrush = new SolidColorBrush(Colors.Red);
            // penBrush.Freeze();
            // Pen pen = new Pen(penBrush, 0.5);
            // pen.Freeze();

            //// draw a square with the created brush and pen
            // System.Windows.Rect r = new System.Windows.Rect(0, 0, 5, 5);
            // Geometry g = new RectangleGeometry(r);
            // GeometryDrawing drawing = new GeometryDrawing(brush, pen, g);
            // drawing.Freeze();

            // image = new DrawingImage(drawing);
            // image.Freeze();
            SetColor();

            // Grab a reference to the adornment layer that this adornment should be added to
            adornmentLayer = view.GetAdornmentLayer("ViewportAdornment1");

            view.ViewportHeightChanged += delegate { OnSizeChange(); };
            view.ViewportWidthChanged += delegate { OnSizeChange(); };
        }
Пример #19
0
        public ColourForColour(IWpfTextView view)
        {
            _view = view;
            _layer = view.GetAdornmentLayer("ColourForColour");

            _view.MouseHover += OnMouseHover;
            _view.LayoutChanged += OnLayoutChanged;
        }
Пример #20
0
        public CodeTagsEditorAdornment(IWpfTextView view)
        {
            _view = view;
            _layer = view.GetAdornmentLayer("Usus.net.EditorAdornment");
            _view.LayoutChanged += OnLayoutChanged;

            Initialize();
        }
Пример #21
0
		public ColorAdornment(IWpfTextView view)
		{
			this.view = view;
			layer = view.GetAdornmentLayer("Eto.ColorAdornment");

			//Listen to any event that changes the layout (text changes, scrolling, etc)
			view.LayoutChanged += OnLayoutChanged;
		}
Пример #22
0
 public MultiPointEditCommandFilter(IWpfTextView tv)
 {
     m_textView = tv;
     m_adornmentLayer = tv.GetAdornmentLayer("MultiEditLayer");
     m_trackList = new List<ITrackingPoint>();
     lastCaretPosition = m_textView.Caret.Position;
     m_textView.LayoutChanged += m_textView_LayoutChanged;
     m_dte = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
 }
        GoToDefinitionAdorner(IWpfTextView textTextView, IComponentModel componentModel) {
            _textView = textTextView;

            _classicationFormatMapService = componentModel.GetService<IClassificationFormatMapService>();
            _classifier                   = componentModel.GetService<IViewClassifierAggregatorService>().GetClassifier(textTextView);            
            _adornmentLayer               = textTextView.GetAdornmentLayer(AdornerName);

            _textView.Closed += OnTextViewClosed;
        }
        private TranslationAdornmentManager(IWpfTextView view)
        {
            _view = view;
            _view.LayoutChanged += OnLayoutChanged;
            _view.Closed += OnClosed;
            _buffer = _view.TextBuffer;
            _buffer.Changed += OnBufferChanged;

            _layer = view.GetAdornmentLayer("TranslationAdornmentLayer");
        }
Пример #25
0
 public RainbowHighlight(
     IWpfTextView textView,
     IClassificationFormatMap map,
     IClassificationType[] rainbowTags)
 {
     this.view = textView;
       this.formatMap = map;
       this.rainbowTags = rainbowTags;
       layer = view.GetAdornmentLayer(LAYER);
 }
        private PostAdornmentManager(IWpfTextView view)
        {
            this.view = view;
            this.view.LayoutChanged += OnLayoutChanged;
            this.view.Closed += OnClosed;

            this.layer = view.GetAdornmentLayer("PostAdornmentLayer");

            this.provider = PostAdornmentProvider.Create(view);
            this.provider.PostsChanged += OnPostsChanged;
        }
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the  square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public AlternatingLineColorAdornment(IWpfTextView textView)
        {
            this.brush = new SolidColorBrush(Color.FromArgb(160, 194, 252, 233));
            //this.brush = new SolidColorBrush(Color.FromArgb(160, 40, 80, 60));
            this.brush.Freeze();
            this.alternatingLineColorLayer = textView.GetAdornmentLayer(AlternatingLineColorFactory.LayerName);

            textView.LayoutChanged += OnLayoutChanged;
            textView.ViewportWidthChanged += OnViewportWidthChanged;
            textView.ViewportLeftChanged += OnViewportLeftChanged;
        }
Пример #28
0
        /// <summary>
        /// Inizializza una nuova istanza della classe HighLighter Inizializza una nuova istanza della classe TextAdornment1.
        /// </summary>
        /// <param name="view">
        /// Parametro passato da factory.
        /// </param>
        public HighLighter(IWpfTextView view)
        {
            this.view = view;
            this.layer = view.GetAdornmentLayer("TextAdornment1");

            // Listen to any event that changes the layout (text changes, scrolling, etc)
            this.view.LayoutChanged += this.OnLayoutChanged;
            this.view.TextBuffer.Changed += new EventHandler<TextContentChangedEventArgs>(this.TextBuffer_Changed);

            this.SetColor();
        }
        internal ViewportAdornment1(IWpfTextView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            textView = view;
            adornmentLayer = view.GetAdornmentLayer("ViewportAdornment1");
            ((UIElement)view).KeyDown += KeyDown;
        }
Пример #30
0
        // Constructor
        private MacroAdornmentManager(IWpfTextView view)
        {
            this.view = view;
            this.layer = view.GetAdornmentLayer("CommentAdornmentLayer");

            // Reposition the visual when the editor is resized
            this.view.LayoutChanged += (s, e) =>
            {
                PositionVisual();
            };
        }
Пример #31
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private void Initialize()
        {
            Container = RootContainer.CreateChildContainer();

            var textViewWrapper = new TextViewWrapper(_textView);

            Container.RegisterInstance <IQualityTextView>(textViewWrapper);
            Container.RegisterInstance(_textView);
            Container.RegisterInstance(_textView.GetAdornmentLayer(nameof(CodeStructureAdorner)));

            var outliningManagerService = RootContainer.Resolve <IOutliningManagerService>();

            Container.RegisterInstance(outliningManagerService);

            Container.RegisterType <IAdornmentSpaceReservation, CodeStructureSpaceReservation>(new ContainerControlledLifetimeManager());
            Container.RegisterType <IDocumentAnalyzerService, DocumentAnalyzerService>(new ContainerControlledLifetimeManager());
            Container.RegisterType <ISyntaxWalkerProvider, SyntaxWalkerProvider>(new ContainerControlledLifetimeManager());
            Container.RegisterType <CodeStructureAdorner>(new ContainerControlledLifetimeManager());
            Container.RegisterType <CodeStructureViewModel>(new ContainerControlledLifetimeManager());
            Container.RegisterType <DiagnosticInfosViewModel>(new ContainerControlledLifetimeManager());

            Container.RegisterType <DiagnosticInfoAdorner>(new ContainerControlledLifetimeManager());
        }
Пример #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextAdornment2"/> class.
        /// </summary>
        /// <param name="view">Text view to create the adornment for</param>
        public TextAdornment2(IWpfTextView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            this.layer = view.GetAdornmentLayer("TextAdornment2");

            this.view = view;
            this.view.LayoutChanged         += this.OnLayoutChanged;
            this.view.Caret.PositionChanged += this.OnPositionChanged;

            // Create the pen and brush to color the box behind the a's
            this.brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff));
            this.brush.Freeze();

            var penBrush = new SolidColorBrush(Colors.Red);

            penBrush.Freeze();
            this.pen = new Pen(penBrush, 0.5);
            this.pen.Freeze();
        }
Пример #33
0
        public RainbowLines(IWpfTextView textView, RainbowLinesProvider provider)
        {
            this.view          = textView;
            this.provider      = provider;
            this.formatMap     = provider.GetFormatMap(textView);
            this.rainbowColors = GetRainbowColors(provider.GetRainbowTags());
            this.layer         = textView.GetAdornmentLayer(LAYER);
            this.dispatcher    = Dispatcher.CurrentDispatcher;

            this.provider.Settings.SettingsChanged += OnSettingsChanged;
            this.view.Caret.PositionChanged        += OnCaretPositionChanged;
            this.view.Options.OptionChanged        += OnOptionsChanged;
            this.view.LayoutChanged         += OnLayoutChanged;
            this.view.ViewportLeftChanged   += OnViewportLeftChanged;
            this.view.ViewportWidthChanged  += OnViewportWidthChanged;
            this.view.ViewportHeightChanged += OnViewportHeightChanged;
            this.view.Closed += OnViewClosed;

            this.formatMap.ClassificationFormatMappingChanged += OnClassificationFormatMappingChanged;

            // pre-allocate buffers
            this.slbuffer = new LinePoint[2];
        }
Пример #34
0
        public TodoArdornment(IWpfTextView view, ITagAggregator <TodoGlyphTag> aggregrator)
        {
            _view  = view;
            _layer = view.GetAdornmentLayer("TodoArdornment");
            _createTagAggregator = aggregrator;

            //Listen to any event that changes the layout (text changes, scrolling, etc)
            _view.LayoutChanged += OnLayoutChanged;

            //Create the pen and brush to color the box behind the a's
            Brush brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff));

            brush.Freeze();
            Brush penBrush = new SolidColorBrush(Colors.Red);

            penBrush.Freeze();
            Pen pen = new Pen(penBrush, 0.5);

            pen.Freeze();

            _brush = brush;
            _pen   = pen;
        }
Пример #35
0
        public TextAdornment(IWpfTextView view)
        {
            SourceControlRepo = TeamCodingPackage.Current.SourceControlRepo;
            OpenFilesFilter   = of => of.Repository.Equals(RepoDocument.RepoUrl, StringComparison.OrdinalIgnoreCase) &&
                                of.RelativePath.Equals(RepoDocument.RelativePath, StringComparison.OrdinalIgnoreCase) &&
                                (TeamCodingPackage.Current.Settings.UserSettings.ShowAllBranches || of.RepositoryBranch == RepoDocument.RepoBranch) &&
                                of.CaretPositionInfo != null;

            View = view ?? throw new ArgumentNullException(nameof(view));

            Layer        = view.GetAdornmentLayer("TextAdornment");
            RepoDocument = SourceControlRepo.GetRepoDocInfo(View.TextBuffer.GetTextDocumentFilePath());

            TeamCodingPackage.Current.RemoteModelChangeManager.RemoteModelReceived += RefreshAdornmentsAsync;
            TeamCodingPackage.Current.Settings.UserSettings.UserCodeDisplayChanged += UserSettings_UserCodeDisplayChangedAsync;
            View.LayoutChanged += OnLayoutChanged;

            var penBrush = new SolidColorBrush(Colors.Red);

            penBrush.Freeze();
            CaretPen = new Pen(penBrush, 1);
            CaretPen.Freeze();
        }
Пример #36
0
        public void ShowAdornment(IWpfTextView view)
        {
            IAdornmentLayer adornmentLayer = view.GetAdornmentLayer(FindUIAdornmentLayer);

            // Make sure anti-aliasing doesn't cause trouble
            ((UIElement)adornmentLayer).SnapsToDevicePixels = true;

            currentTextView = view;

            if (adornmentLayer.Elements.Count == 0)
            {
                adornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, this, this, null);
            }

            Position();

            Visibility = Visibility.Visible;

            view.VisualElement.SizeChanged += OnViewSizeChanged;
            view.Closed += OnViewClosed;

            FocusFindBox();
        }
Пример #37
0
 GlyphTextViewMarkerService(IGlyphTextMarkerServiceImpl glyphTextMarkerServiceImpl, IWpfTextView wpfTextView)
 {
     onRemovedDelegate = OnRemoved;
     this.glyphTextMarkerServiceImpl = glyphTextMarkerServiceImpl ?? throw new ArgumentNullException(nameof(glyphTextMarkerServiceImpl));
     TextView                                              = wpfTextView ?? throw new ArgumentNullException(nameof(wpfTextView));
     markerLayer                                           = wpfTextView.GetAdornmentLayer(PredefinedDsAdornmentLayers.GlyphTextMarker);
     markerAndSpanCollection                               = new MarkerAndSpanCollection(this);
     markerElements                                        = new List <MarkerElement>();
     editorFormatMap                                       = glyphTextMarkerServiceImpl.EditorFormatMapService.GetEditorFormatMap(wpfTextView);
     glyphTextViewMarkerGlyphTagTagger                     = GlyphTextViewMarkerGlyphTagger.GetOrCreate(this);
     glyphTextViewMarkerGlyphTextMarkerTagTagger           = GlyphTextViewMarkerGlyphTextMarkerTagger.GetOrCreate(this);
     glyphTextViewMarkerClassificationTagTagger            = GlyphTextViewMarkerClassificationTagger.GetOrCreate(this);
     useReducedOpacityForHighContrast                      = wpfTextView.Options.GetOptionValue(DefaultWpfViewOptions.UseReducedOpacityForHighContrastOptionId);
     isInContrastMode                                      = wpfTextView.Options.IsInContrastMode();
     wpfTextView.Closed                                   += WpfTextView_Closed;
     wpfTextView.LayoutChanged                            += WpfTextView_LayoutChanged;
     wpfTextView.Options.OptionChanged                    += Options_OptionChanged;
     glyphTextMarkerServiceImpl.MarkerAdded               += GlyphTextMarkerServiceImpl_MarkerAdded;
     glyphTextMarkerServiceImpl.MarkerRemoved             += GlyphTextMarkerServiceImpl_MarkerRemoved;
     glyphTextMarkerServiceImpl.MarkersRemoved            += GlyphTextMarkerServiceImpl_MarkersRemoved;
     glyphTextMarkerServiceImpl.GetGlyphTextMarkerAndSpan += GlyphTextMarkerServiceImpl_GetGlyphTextMarkerAndSpan;
     editorFormatMap.FormatMappingChanged                 += EditorFormatMap_FormatMappingChanged;
 }
Пример #38
0
        public void HideAdornment()
        {
            IWpfTextView textView = currentTextView;

            // Send the focus back to the editor.
            if (textView != null && !textView.IsClosed)
            {
                textView.VisualElement.Focus();
            }

            // Hide the adornment (Note that this calls DetachFromView on us)
            // This has to be done after the focus transfer because the FindAdornmentManager
            // needs to respond to the focus transfer before it disconnects itself from the view.
            Visibility = Visibility.Collapsed;

            if (textView != null)
            {
                if (this.IsKeyboardFocusWithin)
                {
                    // This method will remove the Find UI adornment from the visual tree but that on its own
                    // won't move the focus from the Find UI. WPF would later get around to restoring a valid focus.
                    // There is a problematic case when the adornment is being hidden while doing a FindNext to
                    // a document in a different top-level floating window frame because when we do try to focus
                    // the other top-level window frame, WPF will detect that focus is still "disconnected"
                    // and will restore focus to this editor instead of moving it as we request.
                    // By manually moving focus here, it will not get into this "disconnected" state.
                    textView.VisualElement.Focus();
                }

                currentTextView = null;

                textView.GetAdornmentLayer(FindUIAdornmentLayer).RemoveAllAdornments();
                textView.VisualElement.SizeChanged -= OnViewSizeChanged;
                textView.Closed -= OnViewClosed;
                textView         = null;
            }
        }
Пример #39
0
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public ViewportAdornment1(IWpfTextView view, TextViewExtensions tve)
        {
            _wpfTextView = view;
            _textView    = view;
            _tve         = tve;

            Brush brush = new SolidColorBrush(Colors.Red);

            brush.Freeze();
            Brush penBrush = new SolidColorBrush(Colors.Red);

            penBrush.Freeze();
            Pen pen = new Pen(penBrush, 0.5);

            pen.Freeze();

            //draw a square with the created brush and pen
            System.Windows.Rect r       = new System.Windows.Rect(0, 0, 30, 30);
            Geometry            g       = new RectangleGeometry(r);
            GeometryDrawing     drawing = new GeometryDrawing(brush, pen, g);

            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);

            drawingImage.Freeze();

            _image        = new Image();
            _image.Source = drawingImage;

            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("ViewportAdornment1");

            _wpfTextView.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _wpfTextView.ViewportWidthChanged  += delegate { this.onSizeChange(); };
            _wpfTextView.MouseHover            += _view_MouseHover;
        }
        internal AdornmentManager(
            IWpfTextView textView,
            IViewTagAggregatorFactoryService tagAggregatorFactoryService,
            IAsynchronousOperationListener asyncListener,
            string adornmentLayerName)
        {
            Contract.ThrowIfNull(textView);
            Contract.ThrowIfNull(tagAggregatorFactoryService);
            Contract.ThrowIfNull(adornmentLayerName);
            Contract.ThrowIfNull(asyncListener);

            _textView               = textView;
            _adornmentLayer         = textView.GetAdornmentLayer(adornmentLayerName);
            textView.LayoutChanged += OnLayoutChanged;
            _asyncListener          = asyncListener;

            // If we are not on the UI thread, we are at race with Close, but we should be on UI thread
            Contract.ThrowIfFalse(textView.VisualElement.Dispatcher.CheckAccess());
            textView.Closed += OnTextViewClosed;

            _tagAggregator = tagAggregatorFactoryService.CreateTagAggregator <T>(textView);

            _tagAggregator.TagsChanged += OnTagsChanged;
        }
Пример #41
0
 public CSharpBar(IWpfTextView textView)
 {
     _View            = textView;
     _Adornment       = _View.GetAdornmentLayer(nameof(CSharpBar));
     _SemanticContext = textView.Properties.GetOrCreateSingletonProperty(() => new SemanticContext(textView));
     this.SetBackgroundForCrispImage(ThemeHelper.TitleBackgroundColor);
     textView.Properties.AddProperty(nameof(NaviBar), this);
     Name      = nameof(CSharpBar);
     Resources = SharedDictionaryManager.Menu;
     SetResourceReference(BackgroundProperty, VsBrushes.CommandBarMenuBackgroundGradientKey);
     SetResourceReference(ForegroundProperty, VsBrushes.CommandBarTextInactiveKey);
     Items.Add(_RootItem = new RootItem(this));
     _View.Selection.SelectionChanged += Update;
     _View.Closed += ViewClosed;
     Update(this, EventArgs.Empty);
     foreach (var m in _SemanticContext.Compilation.Members)
     {
         if (m.IsKind(SyntaxKind.NamespaceDeclaration))
         {
             _RootItem.SetText(m.GetDeclarationSignature());
             break;
         }
     }
 }
Пример #42
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MethodTooLongTextAdornment"/> class.
        /// </summary>
        /// <param name="view">Text view to create the adornment for</param>
        ///
        /// !!! Missing parameter documentation !!!
        ///
        public MethodTooLongTextAdornment(IWpfTextView view, IVsEditorAdaptersFactoryService adapterService)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            if (adapterService == null)
            {
                throw new ArgumentNullException(nameof(adapterService));
            }

            _lastCaretBufferPosition = 0;
            _numberOfKeystrokes      = 0;
            _longMethodOccurrences   = new List <LongMethodOccurrence>();

            _layer = view.GetAdornmentLayer("MethodTooLongTextAdornment");

            _view = view;
            _view.LayoutChanged      += OnLayoutChanged;
            _view.TextBuffer.Changed += OnTextBufferChanged;

            _adapterService = adapterService;
        }
Пример #43
0
        public SelectionAdornment(IWpfTextView view)
        {
            _view = view;
            _root = new SelectionControl();

            // Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("SelectionAdornment");

            // Reposition the adornment whenever the editor window is resized
            _view.ViewportHeightChanged += delegate { OnSizeChange(); };
            _view.ViewportWidthChanged  += delegate { OnSizeChange(); };

            _view.Selection.SelectionChanged += delegate(object sender, EventArgs args)
            {
                var content = new StringBuilder();

                foreach (var selectedSpan in view.Selection.SelectedSpans)
                {
                    content.AppendLine($"{selectedSpan.Start.Position}:{selectedSpan.End.Position}");
                }

                _root.DisplayedSelection.Content = content.ToString().TrimEnd();
            };
        }
        public WhitespaceMarker(IWpfTextView view, WhitespaceProvider wsProvider)
        {
            _textView                = view;
            _layer                   = view.GetAdornmentLayer("TrailingWhiteSpaceMarker");
            _wsProvider              = wsProvider;
            _textView.LayoutChanged += OnLayoutChanged;
            // set color of image to contrast to background
            _backgroundColor = (view.Background as SolidColorBrush).Color;

            _visualBrush = new VisualBrush();
            using (var s = System.IO.File.OpenRead(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "images", "trollface.xaml"))) {
                _visualBrush.Visual = XamlReader.Load(s) as Page;
            }

            Brush penBrush = new SolidColorBrush(Colors.Red);

            penBrush.Freeze();
            Pen pen = new Pen(penBrush, 0.5);

            pen.Freeze();

            _brush = _visualBrush;
            _pen   = pen;
        }
Пример #45
0
        public CurrentLineAdornment(
            IWpfTextView view, IClassificationFormatMap formatMap,
            IClassificationType formatType, IVsfSettings settings)
        {
            this.view       = view;
            this.formatMap  = formatMap;
            this.formatType = formatType;
            this.settings   = settings;
            this.layer      = view.GetAdornmentLayer(Constants.LINE_HIGHLIGHT);
            this.lineRect   = new Rectangle();

            view.Caret.PositionChanged += OnCaretPositionChanged;
            view.ViewportWidthChanged  += OnViewportWidthChanged;
            view.LayoutChanged         += OnLayoutChanged;
            view.ViewportLeftChanged   += OnViewportLeftChanged;
            view.Closed += OnViewClosed;
            view.Options.OptionChanged += OnSettingsChanged;

            this.settings.SettingsChanged += OnSettingsChanged;
            formatMap.ClassificationFormatMappingChanged +=
                OnClassificationFormatMappingChanged;

            CreateDrawingObjects();
        }
        public LinkViewerTextAdornment(IWpfTextView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            view.VisualElement.MouseMove += VisualElementOnMouseMove;

            this.layer = view.GetAdornmentLayer("LinkViewerTextAdornment");

            this.view = view;
            this.view.LayoutChanged += this.OnLayoutChanged;

            // Create the pen and brush to color the box behind the a's
            this.brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff));
            this.brush.Freeze();

            var penBrush = new SolidColorBrush(Colors.Red);

            penBrush.Freeze();
            this.pen = new Pen(penBrush, 0.5);
            this.pen.Freeze();
        }
Пример #47
0
        public IndentGuide(IWpfTextView textView, IDocumentAnalysis documentAnalysis, GeneralOptionProvider generalOptionProvider)
        {
            _textView         = textView ?? throw new NullReferenceException();
            _generalOption    = generalOptionProvider ?? throw new NullReferenceException();
            _documentAnalysis = documentAnalysis ?? throw new NullReferenceException();

            _currentAdornments = new List <Line>();
            _canvas            = new Canvas
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch
            };

            _layer = _textView.GetAdornmentLayer(Constants.IndentGuideAdornmentLayerName) ?? throw new NullReferenceException();
            _layer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, _canvas, CanvasRemoved);
            _textView.LayoutChanged += LayoutChanged;

            _documentAnalysis.AnalysisUpdated += AnalysisUpdated;
            _generalOption.OptionsUpdated     += IndentGuideGeneralOptionUpdated;
            _textView.Options.OptionChanged   += TabSizeOptionsChanged;

            _tabSize = textView.Options.GetOptionValue(DefaultOptions.TabSizeOptionId);
            IndentGuideGeneralOptionUpdated(_generalOption);
        }
Пример #48
0
        public CodeBackgroundTextAdornment(
            IWpfTextView view,
            IClassificationFormatMapService classificationFormatMapService,
            IClassificationTypeRegistryService classificationTypeRegistry) {

            _view = view;
            _layer = view.GetAdornmentLayer("CodeBackgroundTextAdornment");

            _classificationTypeRegistry = classificationTypeRegistry;
            _classificationFormatMap = classificationFormatMapService.GetClassificationFormatMap(view);

            // Advise to events
            _classificationFormatMap.ClassificationFormatMappingChanged += OnClassificationFormatMappingChanged;
            _view.LayoutChanged += OnLayoutChanged;
            _view.Closed += OnClosed;

            var projectionBufferManager = ProjectionBufferManager.FromTextBuffer(view.TextBuffer);
            if (projectionBufferManager != null) {
                projectionBufferManager.MappingsChanged += OnMappingsChanged;
                _contanedLanguageHandler = projectionBufferManager.DiskBuffer.GetService<IContainedLanguageHandler>();
            }

            FetchColors();
        }
Пример #49
0
        //---------------------------------------------------------------------
        List <Tuple <string, Brush> > GetLinesWithCoverageTag(IWpfTextView wpfTextView)
        {
            var lines = new List <Tuple <string, Brush> >();

            // AdornmentLayer is filled asynchronously by an event.
            // Wait here to be sure adornmentLayer.Elements is not empty.
            System.Threading.Thread.Sleep(1000);
            RunInUIhread(() =>
            {
                var adornmentLayer = wpfTextView.GetAdornmentLayer(CoverageViewManager.HighlightLinesAdornment);
                var elements       = adornmentLayer.Elements.Where(e => e.Tag == CoverageViewManager.CoverageTag);

                foreach (var element in elements)
                {
                    var adornment = (Rectangle)element.Adornment;
                    var line      = wpfTextView.GetTextViewLineContainingBufferPosition(element.VisualSpan.Value.Start);
                    var text      = line.Extent.GetText();

                    lines.Add(Tuple.Create(text, adornment.Fill));
                }
            });

            return(lines);
        }
        public InheritanceAdornment(IWpfTextView view, ITextDocument doc)
        {
            _adornmentLayer = view.GetAdornmentLayer(InheritanceAdornmentLayer.LayerName);
            _document       = EditorConfigDocument.FromTextBuffer(view.TextBuffer);

            Visibility = System.Windows.Visibility.Hidden;

            Loaded += (s, e) =>
            {
                Dispatcher.VerifyAccess();

                CreateImage();
                doc.FileActionOccurred += FileActionOccurred;
                Updated += InheritanceUpdated;

                view.ViewportHeightChanged += SetAdornmentLocation;
                view.ViewportWidthChanged  += SetAdornmentLocation;
            };

            if (_adornmentLayer.IsEmpty)
            {
                _adornmentLayer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, this, null);
            }
        }
Пример #51
0
        public PowerModeAdornment(IWpfTextView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            this.view      = view;
            adornmentLayer = view.GetAdornmentLayer("PowerModeAdornment");

            streakCounterAdornment = new StreakCounterAdornment();
            screenShakeAdornment   = new ScreenShakeAdornment();
            particlesAdornment     = new ParticlesAdornment();

            generalSettings   = SettingsService.GetGeneralSettings();
            comboModeSettings = SettingsService.GetComboModeSettings();

            this.view.TextBuffer.Changed    += TextBuffer_Changed;
            this.view.ViewportHeightChanged += View_ViewportSizeChanged;
            this.view.ViewportWidthChanged  += View_ViewportSizeChanged;

            PropertyChangedEventManager.AddHandler(generalSettings, GeneralSettingModelPropertyChanged, "");
            PropertyChangedEventManager.AddHandler(comboModeSettings, ComboModeSettingsModelPropertyChanged, "");
        }
Пример #52
0
        public ConflictTextAdornment(IWpfTextView view, IEditorFormatMap editorFormatMap)
        {
            _view  = view;
            _layer = view.GetAdornmentLayer("ConflictTextAdornment");

            //Listen to any event that changes the layout (text changes, scrolling, etc)
            _view.LayoutChanged += OnLayoutChanged;

            SolidColorBrush b = (SolidColorBrush)editorFormatMap.GetProperties(ConflictRegionFormatDefinition.Name)[EditorFormatDefinition.BackgroundBrushId];;

            _brush = new SolidColorBrush(Color.FromArgb((byte)(Opacity * 255), b.Color.R, b.Color.G, b.Color.B));
            Brush penBrush = (SolidColorBrush)editorFormatMap.GetProperties(ConflictRegionFormatDefinition.Name)[EditorFormatDefinition.ForegroundBrushId];;

            penBrush.Freeze();
            _pen = new Pen(penBrush, 1);

            string filePath = _view.GetDocumentFullPath();

            if (filePath != null)
            {
                this.editingSession = EditingSessionFactory.WaitForSession(_view.GetDocumentFullPath());
                editingSession.ConflictDataChanged += editingSession_ConflictDataChanged;
            }
        }
Пример #53
0
        public CurrentColumnAdornment(
            IWpfTextView view, IClassificationFormatMap formatMap,
            IClassificationType formatType, IVsfSettings settings)
        {
            this.view       = view;
            this.formatMap  = formatMap;
            this.formatType = formatType;
            this.settings   = settings;
            this.columnRect = new Rectangle();
            layer           = view.GetAdornmentLayer(Constants.COLUMN_HIGHLIGHT);

            view.Caret.PositionChanged += OnCaretPositionChanged;
            view.ViewportWidthChanged  += OnViewportChanged;
            view.ViewportHeightChanged += OnViewportChanged;
            view.LayoutChanged         += OnViewLayoutChanged;
            view.TextViewModel.EditBuffer.PostChanged += OnBufferPostChanged;
            view.Closed += OnViewClosed;

            this.settings.SettingsChanged += OnSettingsChanged;
            formatMap.ClassificationFormatMappingChanged +=
                OnClassificationFormatMappingChanged;

            CreateDrawingObjects();
        }
Пример #54
0
 public MatchGlyphFactory(IWpfTextView view)
 {
     Layer     = view.GetAdornmentLayer("SelectionHighlight");
     Selection = view.Selection;
 }
Пример #55
0
 internal BlockCaret(IWpfTextView textView, string adornmentLayerName, IClassificationFormatMap classificationFormatMap, IEditorFormatMap formatMap, IControlCharUtil controlCharUtil, IProtectedOperations protectedOperations) :
     this(textView, classificationFormatMap, formatMap, textView.GetAdornmentLayer(adornmentLayerName), controlCharUtil, protectedOperations)
 {
 }
Пример #56
0
        //---------------------------------------------------------------------
        void RemoveHighlight(IWpfTextView textView)
        {
            var adornmentLayer = textView.GetAdornmentLayer(HighlightLinesAdornment);

            adornmentLayer.RemoveAllAdornments();
        }
Пример #57
0
 internal BlockCaret(IWpfTextView view, string adornmentLayerName, IEditorFormatMap formatMap, IProtectedOperations protectedOperations) :
     this(view, formatMap, view.GetAdornmentLayer(adornmentLayerName), protectedOperations)
 {
 }
Пример #58
0
 public void SetView(IWpfTextView wpfTextView)
 {
     this.textView = wpfTextView;
     this.aceLayer = textView.GetAdornmentLayer("AceJump");
 }
Пример #59
0
 public IAdornmentLayer GetAdornmentLayer(string name) =>
 _innerTextView.GetAdornmentLayer(name);
Пример #60
0
 public IAdornmentLayer GetAdornmentLayer(string name)
 {
     return(_innerTextView.GetAdornmentLayer(name));
 }