예제 #1
0
 public override void PostprocessMouseMove(System.Windows.Input.MouseEventArgs e)
 {
     try
     {
         if (this._isMouseDown && (e.RightButton == System.Windows.Input.MouseButtonState.Pressed))
         {
             string lineColor = Umc.Core.Tools.VSGesture.Services.VSGestureService.Current.VSGestureInfo.UserSettings.LineColor;
             string lineThickness = Umc.Core.Tools.VSGesture.Services.VSGestureService.Current.VSGestureInfo.UserSettings.LineThickness;
             string[] strArray = lineColor.Split(new char[] { ',' });
             Point position = e.GetPosition(this._view.VisualElement);
             Brush brush = new SolidColorBrush(Color.FromRgb(byte.Parse(strArray[0]), byte.Parse(strArray[1]), byte.Parse(strArray[2])));
             this._analyzer.Add(new System.Windows.Input.StylusPoint(position.X, position.Y));
             this._layer = this._view.GetAdornmentLayer("VSGestureWindow");
             var adornment = new System.Windows.Shapes.Line
             {
                 X1 = this._preX,
                 Y1 = this._preY,
                 X2 = position.X + this._view.ViewportLeft,
                 Y2 = position.Y + this._view.ViewportTop,
                 StrokeThickness = (float)((Umc.Core.Tools.VSGesture.Controls.LineThicknessStyle)Enum.Parse(typeof(Umc.Core.Tools.VSGesture.Controls.LineThicknessStyle), lineThickness)),
                 Stroke = brush
             };
             this._layer.AddAdornment(AdornmentPositioningBehavior.ViewportRelative, null, null, adornment, null);
             this._preX = position.X + this._view.ViewportLeft;
             this._preY = position.Y + this._view.ViewportTop;
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
     base.PostprocessMouseMove(e);
 }
예제 #2
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)
     {
     }
 }
예제 #3
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(); };
        }
        /// <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));
        }
        public ProvisionalText(ITextView textView, Span textSpan)
        {
            IgnoreChange = false;

            _textView = textView;

            var wpfTextView = (IWpfTextView)_textView;
            _layer = wpfTextView.GetAdornmentLayer("HtmlProvisionalTextHighlight");

            var textBuffer = _textView.TextBuffer;
            var snapshot = textBuffer.CurrentSnapshot;
            var provisionalCharSpan = new Span(textSpan.End - 1, 1);

            TrackingSpan = snapshot.CreateTrackingSpan(textSpan, SpanTrackingMode.EdgeExclusive);
            _textView.Caret.PositionChanged += OnCaretPositionChanged;

            textBuffer.Changed += OnTextBufferChanged;
            textBuffer.PostChanged += OnPostChanged;

            var projectionBuffer = _textView.TextBuffer as IProjectionBuffer;
            if (projectionBuffer != null)
            {
                projectionBuffer.SourceSpansChanged += OnSourceSpansChanged;
            }

            Color highlightColor = SystemColors.HighlightColor;
            Color baseColor = Color.FromArgb(96, highlightColor.R, highlightColor.G, highlightColor.B);
            _highlightBrush = new SolidColorBrush(baseColor);

            ProvisionalChar = snapshot.GetText(provisionalCharSpan)[0];
            HighlightSpan(provisionalCharSpan.Start);
        }
        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();
            };
        }
예제 #8
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(); };
        }
예제 #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();
        }
        /// <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(); };
        }
예제 #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);
 }
        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();
        }
예제 #13
0
		public TextCaret(IWpfTextView textView, IAdornmentLayer caretLayer, ISmartIndentationService smartIndentationService, IClassificationFormatMap classificationFormatMap) {
			if (textView == null)
				throw new ArgumentNullException(nameof(textView));
			if (caretLayer == null)
				throw new ArgumentNullException(nameof(caretLayer));
			if (smartIndentationService == null)
				throw new ArgumentNullException(nameof(smartIndentationService));
			if (classificationFormatMap == null)
				throw new ArgumentNullException(nameof(classificationFormatMap));
			this.textView = textView;
			imeState = new ImeState();
			this.smartIndentationService = smartIndentationService;
			preferredXCoordinate = 0;
			__preferredYCoordinate = 0;
			Affinity = PositionAffinity.Successor;
			currentPosition = new VirtualSnapshotPoint(textView.TextSnapshot, 0);
			textView.TextBuffer.ChangedHighPriority += TextBuffer_ChangedHighPriority;
			textView.TextBuffer.ContentTypeChanged += TextBuffer_ContentTypeChanged;
			textView.Options.OptionChanged += Options_OptionChanged;
			textView.VisualElement.AddHandler(UIElement.GotKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_GotKeyboardFocus), true);
			textView.VisualElement.AddHandler(UIElement.LostKeyboardFocusEvent, new KeyboardFocusChangedEventHandler(VisualElement_LostKeyboardFocus), true);
			textView.LayoutChanged += TextView_LayoutChanged;
			textCaretLayer = new TextCaretLayer(this, caretLayer, classificationFormatMap);
			InputMethod.SetIsInputMethodSuspended(textView.VisualElement, true);
		}
        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
            }
        }
예제 #15
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;
        }
예제 #16
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();
        }
예제 #17
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(); };
        }
예제 #18
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
			{
			}
		}
        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();
        }
예제 #20
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;
		}
예제 #21
0
        public CodeTagsEditorAdornment(IWpfTextView view)
        {
            _view = view;
            _layer = view.GetAdornmentLayer("Usus.net.EditorAdornment");
            _view.LayoutChanged += OnLayoutChanged;

            Initialize();
        }
예제 #22
0
        public ColourForColour(IWpfTextView view)
        {
            _view = view;
            _layer = view.GetAdornmentLayer("ColourForColour");

            _view.MouseHover += OnMouseHover;
            _view.LayoutChanged += OnLayoutChanged;
        }
        GoToDefinitionAdorner(IWpfTextView textTextView, IComponentModel componentModel) {
            _textView = textTextView;

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

            _textView.Closed += OnTextViewClosed;
        }
예제 #24
0
        internal NewLineDisplay(IWpfTextView textView, IAdornmentLayer adornmentLayer, IVimAppOptions vimAppOptions)
        {
            _wpfTextView = textView;
            _adornmentLayer = adornmentLayer;
            _vimAppOptions = vimAppOptions;

            _wpfTextView.LayoutChanged += OnLayoutChanged;
            _vimAppOptions.Changed += OnOptionsChanged;
        }
예제 #25
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;
 }
        private TranslationAdornmentManager(IWpfTextView view)
        {
            _view = view;
            _view.LayoutChanged += OnLayoutChanged;
            _view.Closed += OnClosed;
            _buffer = _view.TextBuffer;
            _buffer.Changed += OnBufferChanged;

            _layer = view.GetAdornmentLayer("TranslationAdornmentLayer");
        }
예제 #27
0
 public RainbowHighlight(
     IWpfTextView textView,
     IClassificationFormatMap map,
     IClassificationType[] rainbowTags)
 {
     this.view = textView;
       this.formatMap = map;
       this.rainbowTags = rainbowTags;
       layer = view.GetAdornmentLayer(LAYER);
 }
        internal ViewportAdornment1(IWpfTextView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException(nameof(view));
            }

            textView = view;
            adornmentLayer = view.GetAdornmentLayer("ViewportAdornment1");
            ((UIElement)view).KeyDown += KeyDown;
        }
예제 #29
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();
        }
예제 #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
        public UnitTestSelector(double ypos, UnitTestAdornment coveredLineInfo, IAdornmentLayer layer)
        {
            _layer = layer;
            string HeavyCheckMark          = ((char)(0x2714)).ToString();
            string HeavyMultiplicationSign = ((char)(0x2716)).ToString();

            var myResourceDictionary = new ResourceDictionary();

            myResourceDictionary.Source =
                new Uri("/Testify;component/UnitTestAdornment/ResourceDictionary.xaml",
                        UriKind.RelativeOrAbsolute);

            var backgroundBrush = (Brush)myResourceDictionary["BackgroundBrush"];
            var borderBrush     = (Brush)myResourceDictionary["BorderBrush"];
            var textBrush       = (Brush)myResourceDictionary["TextBrush"];

            if (brush == null)
            {
                brush = (Brush)myResourceDictionary["BackgroundBrush"];
                //brush.Freeze();
                var penBrush = (Brush)myResourceDictionary["BorderBrush"];
                //penBrush.Freeze(); Can't be frozen because it is a Dynamic Resource
                solidPen = new Pen(penBrush, 0.5);
                //solidPen.Freeze(); Can't be frozen because it is a Dynamic Resource
                dashPen = new Pen(penBrush, 0.5);
                //dashPen.DashStyle = DashStyles.Dash;
                //dashPen.Freeze(); Can't be frozen because it is a Dynamic Resource
            }


            var tb = new TextBlock();

            tb.Text = " ";
            const int marginWidth = 20;
            var       Margin      = new Thickness(marginWidth, 0, marginWidth, 0);

            Grid postGrid = new Grid();

            postGrid.RowDefinitions.Add(new RowDefinition());
            postGrid.RowDefinitions.Add(new RowDefinition());
            var cEdge = new ColumnDefinition();

            cEdge.Width = new GridLength(1, GridUnitType.Auto);
            var cEdge2 = new ColumnDefinition {
                Width = new GridLength(19, GridUnitType.Star)
            };

            postGrid.ColumnDefinitions.Add(cEdge);
            postGrid.ColumnDefinitions.Add(new ColumnDefinition());
            postGrid.ColumnDefinitions.Add(cEdge2);
            var rect = new Rectangle();

            rect.Fill   = brush;
            rect.Stroke = (Brush)myResourceDictionary["BorderBrush"];

            var inf = new Size(double.PositiveInfinity, double.PositiveInfinity);

            tb.Measure(inf);

            Grid.SetColumn(rect, 0);
            Grid.SetRow(rect, 0);
            Grid.SetRowSpan(rect, 3);
            Grid.SetColumnSpan(rect, 3);
            postGrid.Children.Add(rect);
            double desiredSize = 0;

            var header = new Label {
                Foreground = textBrush, Background = backgroundBrush, BorderBrush = borderBrush
            };

            Grid.SetRow(header, 0);
            Grid.SetColumn(header, 1);
            Grid.SetColumnSpan(header, 3);
            header.Content = string.Format("Unit tests covering Line # {0}", coveredLineInfo.CoveredLine.LineNumber);
            postGrid.Children.Add(header);
            var unitTests       = coveredLineInfo.CoveredLine.UnitTests;
            var sortedUnitTests = unitTests.OrderByDescending(x => x.IsSuccessful ? 0 : 1).ToList();

            for (int i = 0; i < sortedUnitTests.Count; i++)
            {
                UnitTest test = sortedUnitTests.ElementAt(i);
                postGrid.RowDefinitions.Add(new RowDefinition());
                var icon = new Label {
                    Background = backgroundBrush, BorderBrush = borderBrush, FocusVisualStyle = null
                };
                if (test.IsSuccessful)
                {
                    icon.Content    = HeavyCheckMark;
                    icon.Foreground = new SolidColorBrush(Colors.Green);
                }
                else
                {
                    icon.Content    = HeavyMultiplicationSign;
                    icon.Foreground = new SolidColorBrush(Colors.Red);
                }
                //icon.DataContext = test;
                //Binding iconBinding = new Binding("IsSuccessful");
                //icon.SetBinding(TextBox.TextProperty, iconBinding);
                Grid.SetRow(icon, i + 1);
                Grid.SetColumn(icon, 0);
                postGrid.Children.Add(icon);

                var testName = new TextBox
                {
                    Foreground       = textBrush,
                    Background       = backgroundBrush,
                    BorderBrush      = borderBrush,
                    FocusVisualStyle = null,
                    DataContext      = test,
                    Text             = test.TestMethodName,
                    Margin           = Margin
                };

                var testBinding = new Binding("TestMethodName");

                testName.MouseDoubleClick += TestName_MouseDoubleClick;
                testName.SetBinding(TextBox.TextProperty, testBinding);
                Grid.SetRow(testName, i + 1);
                Grid.SetColumn(testName, 1);
                postGrid.Children.Add(testName);
                testName.Measure(inf);

                if (testName.DesiredSize.Width > desiredSize)
                {
                    desiredSize = testName.DesiredSize.Width;
                }
            }

            SetLeft(postGrid, 0);
            SetTop(postGrid, ypos);

            Focus();
            postGrid.Background           = backgroundBrush;
            postGrid.LostFocus           += postGrid_LostFocus;
            postGrid.MouseLeftButtonDown += postGrid_MouseLeftButtonDown;
            Children.Add(postGrid);
        }
예제 #32
0
 public LeapCaret(IWpfTextView textView)
 {
     this.textView           = textView;
     adornmentLayer          = textView.GetAdornmentLayer("LeapExtension");
     textView.LayoutChanged += (s, e) => Update();
 }
 public SelectNextCommandFilter(IWpfTextView tv)
 {
     m_textView       = tv;
     m_adornmentLayer = tv.GetAdornmentLayer("SelectNextTextAdornment");
     m_dte            = Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
 }
예제 #34
0
 internal void SetAdornmentLayer(IAdornmentLayer adornmentLayer)
 {
     Debug.Assert(_adornmentLayer == null);
     _adornmentLayer = adornmentLayer;
     Subscribe();
 }
예제 #35
0
        internal BlockCaret(ITextView textView, IClassificationFormatMap classificationFormatMap, IEditorFormatMap formatMap, IAdornmentLayer layer, IControlCharUtil controlCharUtil, IProtectedOperations protectedOperations)
        {
            _textView                = textView;
            _editorFormatMap         = formatMap;
            _adornmentLayer          = layer;
            _protectedOperations     = protectedOperations;
            _classificationFormatMap = classificationFormatMap;
            _controlCharUtil         = controlCharUtil;

            _textView.LayoutChanged         += OnCaretEvent;
            _textView.GotAggregateFocus     += OnCaretEvent;
            _textView.LostAggregateFocus    += OnCaretEvent;
            _textView.Caret.PositionChanged += OnCaretPositionChanged;
            _textView.Closed += OnTextViewClosed;

            _blinkTimer = CreateBlinkTimer(protectedOperations, OnCaretBlinkTimer);
        }
예제 #36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WhereAmI"/> class.
        /// 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="settings">The <see cref="IWhereAmISettings"/> injected by the provider</param>
        public WhereAmI(IWpfTextView view, IWhereAmISettings settings)
        {
            _view     = view;
            _settings = settings;

            _fileName        = new TextBlock();
            _folderStructure = new TextBlock();
            _projectName     = new TextBlock();

            ITextDocument textDoc;
            object        obj;

            if (view.TextBuffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out textDoc))
            {
                // Retrieved the ITextDocument from the first level
            }
            else if (view.TextBuffer.Properties.TryGetProperty <object>("IdentityMapping", out obj))
            {
                // Try to get the ITextDocument from the second level (e.g. Razor files)
                if ((obj as ITextBuffer) != null)
                {
                    (obj as ITextBuffer).Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out textDoc);
                }
            }

            // If I found an ITextDocument, access to its FilePath prop to retrieve informations about Proj
            if (textDoc != null)
            {
                string fileName = System.IO.Path.GetFileName(textDoc.FilePath);

                Project proj = GetContainingProject(fileName);
                if (proj != null)
                {
                    string projectName = proj.Name;

                    if (_settings.ViewFilename)
                    {
                        _fileName.Text = fileName;

                        Brush fileNameBrush = new SolidColorBrush(Color.FromArgb(_settings.FilenameColor.A, _settings.FilenameColor.R, _settings.FilenameColor.G, _settings.FilenameColor.B));
                        _fileName.FontFamily          = new FontFamily("Consolas");
                        _fileName.FontSize            = _settings.FilenameSize;
                        _fileName.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        _fileName.TextAlignment       = System.Windows.TextAlignment.Right;
                        _fileName.Foreground          = fileNameBrush;
                        _fileName.Opacity             = _settings.Opacity;
                    }

                    if (_settings.ViewFolders)
                    {
                        _folderStructure.Text = GetFolderDiffs(textDoc.FilePath, proj.FullName);

                        Brush foldersBrush = new SolidColorBrush(Color.FromArgb(_settings.FoldersColor.A, _settings.FoldersColor.R, _settings.FoldersColor.G, _settings.FoldersColor.B));
                        _folderStructure.FontFamily          = new FontFamily("Consolas");
                        _folderStructure.FontSize            = _settings.FoldersSize;
                        _folderStructure.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        _folderStructure.TextAlignment       = System.Windows.TextAlignment.Right;
                        _folderStructure.Foreground          = foldersBrush;
                        _folderStructure.Opacity             = _settings.Opacity;
                    }

                    if (_settings.ViewProject)
                    {
                        _projectName.Text = projectName;

                        Brush projectNameBrush = new SolidColorBrush(Color.FromArgb(_settings.ProjectColor.A, _settings.ProjectColor.R, _settings.ProjectColor.G, _settings.ProjectColor.B));
                        _projectName.FontFamily          = new FontFamily("Consolas");
                        _projectName.FontSize            = _settings.ProjectSize;
                        _projectName.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        _projectName.TextAlignment       = System.Windows.TextAlignment.Right;
                        _projectName.Foreground          = projectNameBrush;
                        _projectName.Opacity             = _settings.Opacity;
                    }
                }
            }

            // Force to have an ActualWidth
            System.Windows.Rect finalRect = new System.Windows.Rect();
            _fileName.Arrange(finalRect);
            _folderStructure.Arrange(finalRect);
            _projectName.Arrange(finalRect);

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

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged  += delegate { this.onSizeChange(); };
        }
예제 #37
0
 public void SetView(IWpfTextView wpfTextView)
 {
     textView = wpfTextView;
     aceLayer = textView.GetAdornmentLayer("AceJump");
 }
예제 #38
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="sp"></param>
        public ColorfulIde(IWpfTextView view, IServiceProvider sp)
        {
            try
            {
                _serviceProvider = sp;
                _view            = view;
                _config          = GetConfigFromVisualStudioSettings();

                if (_config.IsDirectory)
                {
                    var imagelist = new List <string>();
                    AddImages("*.png", imagelist);
                    AddImages("*.jpg", imagelist);
                    AddImages("*.gif", imagelist);
                    AddImages("*.bmp", imagelist);
                    _imagePaths = imagelist.ToArray();
                }
                else
                {
                    var path = _config.BackgroundImageFileAbsolutePath;
                    if (File.Exists(path))
                    {
                        _imagePaths = new[] { path }
                    }
                    ;
                }

                if (_imagePaths.Length == 0)
                {
                    return;
                }

                RandomSequence();

                _current = 0;

                _adornmentLayer = view.GetAdornmentLayer("Colorful-IDE");

                ChangeImage();

                _timer          = new Timer(_config.Interval);
                _timer.Elapsed += delegate
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(RefreshImage));
                };
                //_Timer.Start();
                _timer.Enabled = _config.IsDirectory;

                _opacityIndex          = 10;
                _flag                  = 0;
                _opacityTimer          = new Timer(_config.OpacityInterval);
                _opacityTimer.Elapsed += delegate
                {
                    try
                    {
                        if (_opacityIndex < 0 || _opacityIndex > 10)
                        {
                            return;
                        }
                        if (_flag == 0)
                        {
                            _opacityIndex -= 2;
                        }
                        else
                        {
                            _opacityIndex += 2;
                        }

                        Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            _adornmentLayer.Opacity = _opacityIndex / 10.0;
                        }));

                        if (Math.Abs(_opacityIndex) < 1e-6)
                        {
                            _opacityTimer.Stop();
                            _flag = 1;
                            Application.Current.Dispatcher.BeginInvoke(new Action(() => { ChangeImage(); this.OnSizeChange(); }));
                            _opacityIndex = 0;
                            _opacityTimer.Start();
                        }
                        else if (_opacityIndex == 10)
                        {
                            _opacityTimer.Stop();
                            _flag = 0;
                            Application.Current.Dispatcher.BeginInvoke(new Action(this.OnSizeChange));
                            _opacityIndex = 10;
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                };

                _view.ViewportHeightChanged += delegate { this.OnSizeChange(); };
                _view.ViewportWidthChanged  += delegate { this.OnSizeChange(); };
            }
            catch (Exception)
            {
                // ignored
            }
        }
예제 #39
0
 public ToDoGlyphFactory(IWpfTextView view)
 {
     this._layer     = view.GetAdornmentLayer("SelectionHighlight");
     this._selection = view.Selection;
 }
예제 #40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WhereAmI"/> class.
        /// 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 WhereAmI(IWpfTextView view, IWhereAmISettings settings)
        {
            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer(Constants.AdornmentLayerName);

            _view     = view;
            _settings = settings;

            _fileName        = new TextBlock();
            _folderStructure = new TextBlock();
            _projectName     = new TextBlock();

            ITextDocument textDoc;
            object        obj;

            if (view.TextBuffer.Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out textDoc))
            {
                // Retrieved the ITextDocument from the first level
            }
            else if (view.TextBuffer.Properties.TryGetProperty <object>("IdentityMapping", out obj))
            {
                // Try to get the ITextDocument from the second level (e.g. Razor files)
                if ((obj as ITextBuffer) != null)
                {
                    (obj as ITextBuffer).Properties.TryGetProperty <ITextDocument>(typeof(ITextDocument), out textDoc);
                }
            }

            // If I found an ITextDocument, access to its FilePath prop to retrieve informations about Proj
            if (textDoc != null)
            {
                string fileName = System.IO.Path.GetFileName(textDoc.FilePath);

                var proj = GetContainingProject(textDoc.FilePath);
                if (proj != null)
                {
                    string projectName = proj.Name;

                    if (_settings.ViewFilename)
                    {
                        _fileName.Text = fileName;

                        Brush fileNameBrush = new SolidColorBrush(Color.FromArgb(_settings.FilenameColor.A, _settings.FilenameColor.R, _settings.FilenameColor.G, _settings.FilenameColor.B));
                        _fileName.FontFamily          = new FontFamily("Consolas");
                        _fileName.FontSize            = _settings.FilenameSize;
                        _fileName.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        _fileName.TextAlignment       = System.Windows.TextAlignment.Right;
                        _fileName.Foreground          = fileNameBrush;
                        _fileName.Opacity             = _settings.Opacity;

                        // Updates the _fileName layer in case file gets renamed
                        textDoc.FileActionOccurred += delegate {
                            string newFileName = System.IO.Path.GetFileName(textDoc.FilePath);
                            _fileName.Text = newFileName;
                            _fileName.UpdateLayout();
                            this.onSizeChange();
                        };
                    }

                    if (_settings.ViewFolders)
                    {
                        _folderStructure.Text = GetFolderDiffs(textDoc.FilePath, proj.FullName);

                        Brush foldersBrush = new SolidColorBrush(Color.FromArgb(_settings.FoldersColor.A, _settings.FoldersColor.R, _settings.FoldersColor.G, _settings.FoldersColor.B));
                        _folderStructure.FontFamily          = new FontFamily("Consolas");
                        _folderStructure.FontSize            = _settings.FoldersSize;
                        _folderStructure.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        _folderStructure.TextAlignment       = System.Windows.TextAlignment.Right;
                        _folderStructure.Foreground          = foldersBrush;
                        _folderStructure.Opacity             = _settings.Opacity;
                    }

                    if (_settings.ViewProject)
                    {
                        _projectName.Text = projectName;

                        Brush projectNameBrush = new SolidColorBrush(Color.FromArgb(_settings.ProjectColor.A, _settings.ProjectColor.R, _settings.ProjectColor.G, _settings.ProjectColor.B));
                        _projectName.FontFamily          = new FontFamily("Consolas");
                        _projectName.FontSize            = _settings.ProjectSize;
                        _projectName.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                        _projectName.TextAlignment       = System.Windows.TextAlignment.Right;
                        _projectName.Foreground          = projectNameBrush;
                        _projectName.Opacity             = _settings.Opacity;

                        Community.VisualStudio.Toolkit.VS.Events.SolutionEvents.OnAfterRenameProject += delegate(Community.VisualStudio.Toolkit.Project p)
                        {
                            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
                            var _proj = GetContainingProject(textDoc.FilePath);
                            _projectName.Text = _proj.Name;
                            _projectName.UpdateLayout();
                            this.onSizeChange();
                        };
                    }
                }
            }

            // Force to have an ActualWidth
            System.Windows.Rect finalRect = new System.Windows.Rect();
            _fileName.Arrange(finalRect);
            _folderStructure.Arrange(finalRect);
            _projectName.Arrange(finalRect);

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

            settings.SettingsChanged += Settings_SettingsChanged;
        }
예제 #41
0
 public void Cleanup(IAdornmentLayer adornmentLayer, IWpfTextView view)
 {
     lastShakeTime = DateTime.Now;
 }
예제 #42
0
 public void OnSizeChanged(IAdornmentLayer adornmentLayer, IWpfTextView view, int streakCount, bool backgroundColorChanged = false)
 {
     particlesList.ForEach(image => { adornmentLayer.RemoveAdornment(image); });
     particlesList.Clear();
 }
예제 #43
0
 public void OnSizeChanged(IAdornmentLayer adornmentLayer, IWpfTextView view, int streakCount, bool backgroundColorChanged = false)
 {
     lastShakeTime = DateTime.Now;
 }
예제 #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextAdornment1"/> class.
 /// </summary>
 /// <param name="view">Text view to create the adornment for</param>
 public TextAdornment1(IWpfTextView view)
 {
     this.view  = view;
     this.layer = this.view.GetAdornmentLayer("TextAdornment1");
     this.view.LayoutChanged += (s, e) => setImage();
 }
예제 #45
0
 public void Cleanup(IAdornmentLayer adornmentLayer, IWpfTextView view)
 {
     particlesList.ForEach(image => { adornmentLayer.RemoveAdornment(image); });
     particlesList.Clear();
 }