public BottomMargin(IWpfTextView textView, IClassifierAggregatorService classifier, ITextDocumentFactoryService documentService)
        {
            _textView = textView;
            _classifier = classifier.GetClassifier(textView.TextBuffer);
            _foregroundBrush = new SolidColorBrush((Color)FindResource(VsColors.CaptionTextKey));
            _backgroundBrush = new SolidColorBrush((Color)FindResource(VsColors.ScrollBarBackgroundKey));

            this.Background = _backgroundBrush;
            this.ClipToBounds = true;

            _lblEncoding = new TextControl("Encoding");
            this.Children.Add(_lblEncoding);

            _lblContentType = new TextControl("Content type");
            this.Children.Add(_lblContentType);

            _lblClassification = new TextControl("Classification");
            this.Children.Add(_lblClassification);

            _lblSelection = new TextControl("Selection");
            this.Children.Add(_lblSelection);

            UpdateClassificationLabel();
            UpdateContentTypeLabel();
            UpdateContentSelectionLabel();

            if (documentService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _doc))
            {
                _doc.FileActionOccurred += FileChangedOnDisk;
                UpdateEncodingLabel(_doc);
            }

            textView.Caret.PositionChanged += CaretPositionChanged;
        }
Example #2
0
    private TextViewTracker(IWpfTextView textView, ProjectTracker projectTracker, VSTextProperties vsTextProperties)
      : base() {
      Contract.Requires(textView != null);
      Contract.Requires(projectTracker != null);

      VSServiceProvider.Current.ExtensionFailed += OnFailed;
      this.TextView = textView;
      if (textView.TextBuffer != null)
      {
        textView.TextBuffer.Changed += OnTextBufferChanged;
      }
      TextView.Closed += OnClosed;
      this._projectTracker = projectTracker;
      projectTracker.BuildDone += OnBuildDone;
//      VSServiceProvider.Current.NewSourceFile += OnNewSourceFile;
      VSServiceProvider.Current.NewCompilation += OnNewComilation;
      
      //Timer
      _textBufferChangedTimer = new System.Timers.Timer();
      _textBufferChangedTimer.AutoReset = false;
      _textBufferChangedTimer.Elapsed += OnTextViewSettled;
      _textBufferChangedTimer.Interval = DelayOnTextViewOpened; //Wait two seconds before attempting to fetch any syntactic/semantic information. This gives VS a chance to properly initialize everything.
      _textBufferChangedTimer.Start();

      //Set the text properties
      VSTextProperties = vsTextProperties;
      VSServiceProvider.Current.QueueWorkItem((() => { VSTextProperties.LineHeight = TextView.LineHeight; }));

      //Set the file name
      var fn = TextView.GetFileName();
      if (fn == null) { fn = "dummyFileName"; }
      FileName = new FileName(fn);
    }
 public SurroundWith(IVsTextView adapter, IWpfTextView textView, ICompletionBroker broker)
     : base(adapter, textView, GuidList.guidFormattingCmdSet, PkgCmdIDList.SurroundWith)
 {
     _broker = broker;
     _view = textView;
     _buffer = textView.TextBuffer;
 }
        private bool IsValidTextBuffer(IWpfTextView view)
        {
            var projection = view.TextBuffer as IProjectionBuffer;

            if (projection != null)
            {
                int position = view.Caret.Position.BufferPosition.Position;
                var snapshotPoint = view.Caret.Position.BufferPosition;

                var buffers = projection.SourceBuffers.Where(s => s.ContentType.IsOfType("css"));

                foreach (ITextBuffer buffer in buffers)
                {
                    SnapshotPoint? point = view.BufferGraph.MapDownToBuffer(snapshotPoint, PointTrackingMode.Negative, buffer, PositionAffinity.Predecessor);

                    if (point.HasValue)
                    {
                        return true;
                    }
                }

                return false;
            }

            return true;
        }
Example #5
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(); };
        }
Example #6
0
        internal EditorDiffMargin(IWpfTextView textView, UnifiedDiff unifiedDiff, IMarginCore marginCore)
            : base(textView)
        {
            ViewModel = new EditorDiffMarginViewModel(marginCore, unifiedDiff, UpdateDiffDimensions);

            UserControl = new EditorDiffMarginControl {DataContext = ViewModel, Width = MarginWidth};
        }
        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));
        }
Example #8
0
		public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) {
			foreach (var buffer in subjectBuffers) {
				foreach (var document in buffer.GetRelatedDocuments()) {
					buffer.GetWorkspace().CloseDocument(document.Id);
				}
			}
		}
        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
        {
            if (reason != ConnectionReason.TextViewLifetime)
                return;

            instants.Add (textView, new InstantVisualStudio (textView, this.documentService));
        }
        public CommandFilter(IWpfTextView textView, ICompletionBroker broker)
        {
            _currentSession = null;

            TextView = textView;
            Broker = broker;
        }
 public void CreateBuffer(params string[] lines)
 {
     var tuple = EditorUtil.CreateViewAndOperations(lines);
     _textView = tuple.Item1;
     var service = EditorUtil.FactoryService;
     _buffer = service.vim.CreateBuffer(_textView);
 }
Example #12
0
        /// <summary>
        /// Creates a very long line at the bottom of bounds.
        /// </summary>
        public override GraphicsResult GetGraphics(IWpfTextView view, Geometry bounds)
        {
            Initialize(view);

            var border = new Border()
            {
                BorderBrush = _graphicsTagBrush,
                BorderThickness = new Thickness(0, 0, 0, bottom: 1),
                Height = 1,
                Width = view.ViewportWidth
            };
            EventHandler viewportWidthChangedHandler = (s, e) =>
            {
                border.Width = view.ViewportWidth;
            };

            view.ViewportWidthChanged += viewportWidthChangedHandler;

            // Subtract rect.Height to ensure that the line separator is drawn
            // at the bottom of the line, rather than immediately below.
            // This makes the line separator line up with the outlining bracket.
            Canvas.SetTop(border, bounds.Bounds.Bottom - border.Height);

            return new GraphicsResult(border,
                () => view.ViewportWidthChanged -= viewportWidthChangedHandler);
        }
 public void TextViewCreated(IWpfTextView textView)
 {
     if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _document))
     {
         _document.FileActionOccurred += document_FileActionOccurred;
     }
 }
 public RemoveWhitespaceOnSave(IVsTextView textViewAdapter, IWpfTextView view, DTE2 dte, ITextDocument document)
 {
     textViewAdapter.AddCommandFilter(this, out _nextCommandTarget);
     _view = view;
     _dte = dte;
     _document = document;
 }
        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 EnterFormat(IVsTextView adapter, IWpfTextView textView, IEditorFormatterProvider formatterProvider, ICompletionBroker broker)
     : base(adapter, textView, typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, 3)
 {
     _tree = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
     _formatter = formatterProvider.CreateRangeFormatter();
     _broker = broker;
 }
Example #17
0
        public InformationBarMargin(IWpfTextView textView, ITextDocument document, IEditorOperations editorOperations, ITextUndoHistory undoHistory, DTE dte)
        {
            _textView = textView;
            _document = document;
            _operations = editorOperations;
            _undoHistory = undoHistory;
            _dte = dte;

            _informationBarControl = new InformationBarControl();
            _informationBarControl.Hide.Click += Hide;
            _informationBarControl.DontShowAgain.Click += DontShowAgain;
            var format = new Action(() => this.FormatDocument());
            _informationBarControl.Tabify.Click += (s, e) => this.Dispatcher.Invoke(format);

            this.Height = 0;
            this.Content = _informationBarControl;
            this.Name = MarginName;

            document.FileActionOccurred += FileActionOccurred;
            textView.Closed += TextViewClosed;

            // Delay the initial check until the view gets focus
            textView.GotAggregateFocus += GotAggregateFocus;

            this._tabDirectiveParser = new TabDirectiveParser(textView, document, dte);
            this._fileHeuristics = new FileHeuristics(textView, document, dte);

            var fix = new Action(() => this.FixFile());
            this._tabDirectiveParser.Change += (s, e) => this.Dispatcher.Invoke(fix);
        }
 public void TextViewCreated(IWpfTextView textView)
 {
   // Add the error list support to the just created view
   textView.TextBuffer.Properties.GetOrCreateSingletonProperty<ErrorListPresenter>(() =>
       new ErrorListPresenter(textView.TextBuffer, _errorProviderFactory, _serviceProviderServiceProvider)
   );
 }
        internal CommandFilter(IVsTextView textViewAdapter, IWpfTextView textView)
        {
            recorder = new Recorder();
            listening = false;

            this.textView = textView;
            textViewAdapter.AddCommandFilter(this, out nextFilter);

            // trying to get document path from TextBuffer
            ITextBuffer buffer = this.textView.TextBuffer;
            ITextDocument document;

            var result = buffer.Properties.TryGetProperty<ITextDocument>(
                typeof(ITextDocument), out document);

            if (result)
            {
                string documentFullPath = document.FilePath;
                recordFullPath = documentFullPath + ".rec";
            }
            else
            {
                // TODO: save to some folder
                recordFullPath = "document.rec";
            }

            // subscribe to RecorderControl event
            RecorderControl.RecordStateChanged += new EventHandler<RecordStateChangedArgs>(OnRecordStateChanged);
        }
Example #20
0
        public override GraphicsResult GetGraphics(IWpfTextView view, Geometry geometry)
        {
            Initialize(view);

            // We clip off a bit off the start of the line to prevent a half-square being
            // drawn.
            var clipRectangle = geometry.Bounds;
            clipRectangle.Offset(2, 0);

            var line = new Line
            {
                X1 = geometry.Bounds.Left,
                Y1 = geometry.Bounds.Bottom - _graphicsTagPen.Thickness,
                X2 = geometry.Bounds.Right,
                Y2 = geometry.Bounds.Bottom - _graphicsTagPen.Thickness,
                Clip = new RectangleGeometry { Rect = clipRectangle }
            };
            // RenderOptions.SetEdgeMode(line, EdgeMode.Aliased);

            ApplyPen(line, _graphicsTagPen);

            // Shift the line over to offset the clipping we did.
            line.RenderTransform = new TranslateTransform(-_graphicsTagPen.Thickness, 0);
            return new GraphicsResult(line, null);
        }
 public static void Register(IVsTextView interopTextView, IWpfTextView textView, Services services)
 {
     var dispatcher = new StandardCommandDispatcher();
     dispatcher._textView = textView;
     dispatcher._services = services;
     interopTextView.AddCommandFilter(dispatcher, out dispatcher._commandChain);
 }
    public ILineTransformSource Create(IWpfTextView textView) {
      Contract.Assume(textView != null);

      if (VSServiceProvider.Current == null || VSServiceProvider.Current.ExtensionHasFailed) {
        //If the VSServiceProvider is not initialize, we can't do anything.
        return null;// new DummyLineTransformSource();
      }

      try {
        VSServiceProvider.Current.ExtensionFailed += OnFailed;

        if (hasFailed) return null;

        Contract.Assume(this.OutliningManagerService != null, "Import attribute guarantees this.");

        var outliningManager = OutliningManagerService.GetOutliningManager(textView);
        if (outliningManager == null)
          return null;//new DummyLineTransformSource();

        var inheritanceManager = AdornmentManager.GetOrCreateAdornmentManager(textView, "InheritanceAdornments", outliningManager, VSServiceProvider.Current.Logger);
        var metadataManager = AdornmentManager.GetOrCreateAdornmentManager(textView, "MetadataAdornments", outliningManager, VSServiceProvider.Current.Logger);

        return new LineTransformSource(VSServiceProvider.Current.Logger, inheritanceManager.Adornments.Values, metadataManager.Adornments.Values);
      } catch (Exception exn) {
        VSServiceProvider.Current.Logger.PublicEntryException(exn, "Create");
        return null;// new DummyLineTransformSource();
      }
    }
Example #23
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;
		}
Example #24
0
        internal void Update(
            string text,
            ITextViewLine line,
            IWpfTextView view,
            TextRunProperties formatting,
            double marginWidth,
            double verticalOffset)
        {
            LineTag = line.IdentityTag;

            if (_text == null || !string.Equals(_text, text, StringComparison.Ordinal))
            {
                _text = text;
                _formattedText = new FormattedText(
                    _text,
                    CultureInfo.InvariantCulture,
                    FlowDirection.LeftToRight,
                    formatting.Typeface,
                    formatting.FontRenderingEmSize,
                    formatting.ForegroundBrush);

                _horizontalOffset = Math.Round(marginWidth - _formattedText.Width);
                InvalidateVisual();
            }

            var num = line.TextTop - view.ViewportTop + verticalOffset;
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (num == _verticalOffset) return;
            _verticalOffset = num;
            InvalidateVisual();
        }
        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();
        }
Example #26
0
        private static void InsertText(IWpfTextView view, DTE2 dte, string text)
        {
            try
            {
                dte.UndoContext.Open("Generate text");

                using (var edit = view.TextBuffer.CreateEdit())
                {
                    if (!view.Selection.IsEmpty)
                    {
                        edit.Delete(view.Selection.SelectedSpans[0].Span);
                        view.Selection.Clear();
                    }

                    edit.Insert(view.Caret.Position.BufferPosition, text);
                    edit.Apply();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
            finally
            {
                dte.UndoContext.Close();
            }
        }
Example #27
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 DropHandler(IWpfTextView wpfTextView, IEnumerable<IDropInfoHandler> dropInfoHandlers, IDropAction dropAction)
 {
     _log.Debug("DropHandler.ctor");
     _tgt = wpfTextView;
     _dropInfoHandlers = dropInfoHandlers;
     _dropAction = dropAction;
 }
 public void TextViewCreated(IWpfTextView textView)
 {
     IPresentationModeState state = PkgSource.PresentationMode;
       textView.Properties.GetOrCreateSingletonProperty(
     () => new PresentationMode(textView, state, Settings)
       );
 }
        private CaretFisheyeLineTransformSource(IWpfTextView textView)
        {
            _textView = textView;

            //Sync to changing the caret position. 
            _textView.Caret.PositionChanged += OnCaretChanged;
        }
Example #31
0
 public void TextViewCreated(IWpfTextView textView)
 {
     textView.Caret.PositionChanged += new EventHandler <CaretPositionChangedEventArgs>(Caret_PositionChanged);
 }
Example #32
0
        private static FrameworkElement CreateElement(
            ImmutableArray <TaggedText> taggedTexts,
            IWpfTextView textView,
            TextFormattingRunProperties format,
            IClassificationFormatMap formatMap,
            ClassificationTypeMap typeMap,
            bool classify)
        {
            // Constructs the hint block which gets assigned parameter name and fontstyles according to the options
            // page. Calculates a inline tag that will be 3/4s the size of a normal line. This shrink size tends to work
            // well with VS at any zoom level or font size.

            var block = new TextBlock
            {
                FontFamily = format.Typeface.FontFamily,
                FontSize   = 0.75 * format.FontRenderingEmSize,
                FontStyle  = FontStyles.Normal,
                Foreground = format.ForegroundBrush,

                // Adds a little bit of padding to the left of the text relative to the border to make the text seem
                // more balanced in the border
                Padding = new Thickness(left: 2, top: 0, right: 2, bottom: 0)
            };

            var(trimmedTexts, leftPadding, rightPadding) = Trim(taggedTexts);

            foreach (var taggedText in trimmedTexts)
            {
                var run = new Run(taggedText.ToVisibleDisplayString(includeLeftToRightMarker: true));

                if (classify && taggedText.Tag != TextTags.Text)
                {
                    var properties = formatMap.GetTextProperties(typeMap.GetClassificationType(taggedText.Tag.ToClassificationTypeName()));
                    var brush      = properties.ForegroundBrush.Clone();
                    run.Foreground = brush;
                }

                block.Inlines.Add(run);
            }

            // Encapsulates the textblock within a border. Gets foreground/background colors from the options menu.

            // If the tag is started or followed by a space, we trim that off but represent the space as buffer on hte
            // left or right side.
            var left  = leftPadding * 5;
            var right = rightPadding * 5;

            var border = new Border
            {
                Background        = format.BackgroundBrush,
                Child             = block,
                CornerRadius      = new CornerRadius(2),
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin            = new Thickness(left, top: 0, right, bottom: 0),
            };

            border.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            // gets pixel distance of baseline to top of the font height
            var dockPanelHeight = format.Typeface.FontFamily.Baseline * format.FontRenderingEmSize;

            var dockPanel = new DockPanel
            {
                Height        = dockPanelHeight,
                LastChildFill = false,
                // VerticalAlignment is set to Top because it will rest to the top relative to the stackpanel
                VerticalAlignment = VerticalAlignment.Top
            };

            dockPanel.Children.Add(border);
            DockPanel.SetDock(border, Dock.Bottom);

            var stackPanel = new StackPanel
            {
                // Height set to align the baseline of the text within the TextBlock with the baseline of text in the editor
                Height      = dockPanelHeight + (block.DesiredSize.Height - (block.FontFamily.Baseline * block.FontSize)),
                Orientation = Orientation.Vertical
            };

            stackPanel.Children.Add(dockPanel);
            // Need to set these properties to avoid unnecessary reformatting because some dependancy properties
            // affect layout
            TextOptions.SetTextFormattingMode(stackPanel, TextOptions.GetTextFormattingMode(textView.VisualElement));
            TextOptions.SetTextHintingMode(stackPanel, TextOptions.GetTextHintingMode(textView.VisualElement));
            TextOptions.SetTextRenderingMode(stackPanel, TextOptions.GetTextRenderingMode(textView.VisualElement));

            return(stackPanel);
        }
Example #33
0
 public FontDropHandler(IWpfTextView view)
 {
     this.view = view;
 }
Example #34
0
 public IDropHandler GetAssociatedDropHandler(IWpfTextView view)
 {
     return(view.Properties.GetOrCreateSingletonProperty <FontDropHandler>(() => new FontDropHandler(view)));
 }
Example #35
0
 protected override void CreateAdornmentManager(IWpfTextView textView)
 {
     // the manager keeps itself alive by listening to text view events.
     _ = new LineSeparatorAdornmentManager(ThreadingContext, textView, TagAggregatorFactoryService, AsyncListener, AdornmentLayerName);
 }
Example #36
0
 public void OnSizeChanged(IAdornmentLayer adornmentLayer, IWpfTextView view, int streakCount, bool backgroundColorChanged = false)
 {
     particlesList.ForEach(image => { adornmentLayer.RemoveAdornment(image); });
     particlesList.Clear();
 }
Example #37
0
 public void Cleanup(IAdornmentLayer adornmentLayer, IWpfTextView view)
 {
     particlesList.ForEach(image => { adornmentLayer.RemoveAdornment(image); });
     particlesList.Clear();
 }
Example #38
0
 private bool TryLoadPath(string filePath, out IWpfTextView textView)
 {
     return
         (TryLoadPathAsFile(filePath, out textView) ||
          TryLoadPathAsDirectory(filePath, out textView));
 }
Example #39
0
 public virtual GherkinEditorCommandStatus QueryStatus(IWpfTextView textView, Guid commandGroup, uint commandId)
 {
     return(GherkinEditorCommandStatus.Supported);
 }
Example #40
0
        private ITextBuffer GetTextBufferOnUIThread()
        {
            IVsTextManager textMgr = (IVsTextManager)GetService(typeof(SVsTextManager));
            var            model   = GetService(typeof(SComponentModel)) as IComponentModel;
            var            adapter = model.GetService <IVsEditorAdaptersFactoryService>();
            uint           itemid;

            IVsRunningDocumentTable rdt = ProjectMgr.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;

            if (rdt != null)
            {
                IVsHierarchy      hier;
                IVsPersistDocData persistDocData;
                uint   cookie;
                bool   docInRdt = true;
                IntPtr docData  = IntPtr.Zero;
                int    hr       = NativeMethods.E_FAIL;
                try {
                    //Getting a read lock on the document. Must be released later.
                    hr = rdt.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_ReadLock, GetMkDocument(), out hier, out itemid, out docData, out cookie);
                    if (ErrorHandler.Failed(hr) || docData == IntPtr.Zero)
                    {
                        Guid iid = VSConstants.IID_IUnknown;
                        cookie   = 0;
                        docInRdt = false;
                        ILocalRegistry localReg = this.ProjectMgr.GetService(typeof(SLocalRegistry)) as ILocalRegistry;
                        ErrorHandler.ThrowOnFailure(localReg.CreateInstance(CLSID_VsTextBuffer, null, ref iid, (uint)CLSCTX.CLSCTX_INPROC_SERVER, out docData));
                    }
                    persistDocData = Marshal.GetObjectForIUnknown(docData) as IVsPersistDocData;
                } finally {
                    if (docData != IntPtr.Zero)
                    {
                        Marshal.Release(docData);
                    }
                }

                //Try to get the Text lines
                IVsTextLines srpTextLines = persistDocData as IVsTextLines;
                if (srpTextLines == null)
                {
                    // Try getting a text buffer provider first
                    IVsTextBufferProvider srpTextBufferProvider = persistDocData as IVsTextBufferProvider;
                    if (srpTextBufferProvider != null)
                    {
                        hr = srpTextBufferProvider.GetTextBuffer(out srpTextLines);
                    }
                }

                // Unlock the document in the RDT if necessary
                if (docInRdt && rdt != null)
                {
                    ErrorHandler.ThrowOnFailure(rdt.UnlockDocument((uint)(_VSRDTFLAGS.RDT_ReadLock | _VSRDTFLAGS.RDT_Unlock_NoSave), cookie));
                }

                if (srpTextLines != null)
                {
                    return(adapter.GetDocumentBuffer(srpTextLines));
                }
            }

            IWpfTextView view = GetTextView();

            return(view.TextBuffer);
        }
Example #41
0
 public FormatDocumentHandler(IVsTextView vsTextView, IWpfTextView textView)
     : base(vsTextView, textView)
 {
     IndentationCharacter = SassyStudioPackage.Instance.LanguageSettings.IsUsingSpaces ? ' ' : '\t';
     IndentationSize      = SassyStudioPackage.Instance.LanguageSettings.FormatterIndentSize;
 }
        public List <GazeTarget> GetTargetCandidateTokens(IWpfTextView editorInstance, Workspace workspace, double x, double y)
        {
            var potentialGazePoints = GetPointsFromGazeCenter(editorInstance, x, y, strideWidthX: editorInstance.LineHeight / 2, strideWidthY: editorInstance.LineHeight);

            return(ScoreLikelyGazeTargetsFromScatteredPoints(editorInstance, workspace, potentialGazePoints));
        }
 public CommentCompletionCommandTarget(IVsTextView adapter, IWpfTextView textView, IClassifierAggregatorService classifier)
     : base(adapter, textView, VSConstants.VSStd2KCmdID.TYPECHAR)
 {
     _classifier = classifier.GetClassifier(textView.TextBuffer);
 }
 public CommentIndentationCommandTarget(IVsTextView adapter, IWpfTextView textView, IClassifierAggregatorService classifier, ICompletionBroker broker)
     : base(adapter, textView, VSConstants.VSStd2KCmdID.RETURN)
 {
     _classifier = classifier.GetClassifier(textView.TextBuffer);
     _broker     = broker;
 }
Example #45
0
 public IMouseProcessor GetAssociatedProcessor(IWpfTextView textView)
 {
     return(StructureAdornmentManager.Create(textView, this));
 }
 public IgnoreDropHandler(IWpfTextView view, string fileName)
 {
     _view             = view;
     _documentFileName = fileName;
 }
Example #47
0
 public ReplEditorOperations(IReplEditor2 replEditor, IWpfTextView wpfTextView, IEditorOperationsFactoryService editorOperationsFactoryService)
 {
     this.replEditor  = replEditor;
     this.wpfTextView = wpfTextView;
     EditorOperations = editorOperationsFactoryService.GetEditorOperations(wpfTextView);
 }
 public CommandFilter(IWpfTextView textView, ICompletionBroker broker)
 {
     _textView       = textView;
     _broker         = broker;
     _currentSession = null;
 }
Example #49
0
 public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers)
 {
 }
Example #50
0
 public void TextViewCreated(IWpfTextView textView)
 {
     StructureAdornmentManager.Create(textView, this);
 }
#pragma warning restore 649, 169

        #region IWpfTextViewCreationListener

        /// <summary>
        /// Called when a text view having matching roles is created over a text data model having a matching content type.
        /// Instantiates a TextAdornment2 manager when the textView is created.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> upon which the adornment should be placed</param>
        public void TextViewCreated(IWpfTextView textView)
        {
            // The adornment will listen to any event that changes the layout (text changes, scrolling, etc)
            new TextAdornment2(textView);
        }
Example #52
0
 private static bool HasFocus(IWpfTextView textView)
 {
     return(textView.HasAggregateFocus);
 }
Example #53
0
        public ActiveTextEditor GetActiveTextEditor(ITextDocumentFactoryService textDocumentFactoryService, IWpfTextView wpfTextView)
        {
            try {
                if (textDocumentFactoryService == null || wpfTextView == null)
                {
                    return(null);
                }
                if (!TextDocumentExtensions.TryGetTextDocument(textDocumentFactoryService, wpfTextView.TextBuffer, out var textDocument))
                {
                    return(null);
                }

                return(new ActiveTextEditor(wpfTextView,
                                            textDocument.FileName,
                                            textDocument.Uri,
                                            wpfTextView.TextSnapshot.LineCount));
            }
            catch (Exception ex) {
                Log.Error(ex, nameof(GetActiveTextEditor));
            }
            return(null);
        }
 internal void ConnectToView(IWpfTextView textView)
 {
     textView.Closed += OnTextViewClosed;
     _textViews.Add(textView);
 }
Example #55
0
 public MouseProcessor(MouseProcessorProvider provider, IWpfTextView view)
 {
     this.provider = provider;
     this.view     = view;
 }
        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, System.Collections.ObjectModel.Collection <Microsoft.VisualStudio.Text.ITextBuffer> subjectBuffers)
        {
            Telemetry.Client.Get().TrackEvent("App.EditorOpen");
            TextViews.Add(textView);
            if (TextViews.Count == 1)
            {
                IdleCookie = RegisterIdleLoop(ServiceProvider, this);
            }

            var javaEditor = JavaEditorFactory.Configure(textView, subjectBuffers);

            if (javaEditor == null)
            {
                JavaEditorFactory.Unconfigure(textView, subjectBuffers);
            }

            //EclipseWorkspace eclipseWorkspace = null;
            //Protocol.TypeRootIdentifier presetTypeRootIdentifier = null;

            //string fileName = VSHelpers.GetFileName(textView);
            //if (DefinitionCache.ContainsKey(fileName))
            //{
            //    eclipseWorkspace = DefinitionCache[fileName].Item1;
            //    presetTypeRootIdentifier = DefinitionCache[fileName].Item2;
            //    DefinitionCache.Remove(fileName);
            //}
            //else
            //    eclipseWorkspace = EclipseWorkspace.FromFilePath(fileName);

            //var javaPkgServer = JavaPkgServerMgr.GetProxy(eclipseWorkspace);
            //textView.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);

            //JavaEditor javaEditor = null;
            //JavaUnconfiguredEditor javaUnconfiguredEditor = null;
            //if (javaPkgServer != null)
            //{
            //    javaEditor = textView.Properties.GetOrCreateSingletonProperty<JavaEditor>(() => new JavaEditor(subjectBuffers, textView, javaPkgServer, eclipseWorkspace));
            //    Telemetry.Client.Get().TrackEvent("App.EditorOpenConfigured");

            //    if (presetTypeRootIdentifier == null)
            //    {
            //        javaPkgServer.Send(javaEditor, ProtocolHandlers.CreateOpenTypeRootRequest(fileName)).ContinueWith((System.Threading.Tasks.Task<Protocol.Response> responseTask) =>
            //        {
            //            var openTypeResponse = responseTask.Result;

            //            if (openTypeResponse.responseType == Protocol.Response.ResponseType.OpenTypeRoot &&
            //                openTypeResponse.openTypeRootResponse != null)
            //            {
            //                javaEditor.TypeRootIdentifier = openTypeResponse.openTypeRootResponse.typeRootIdentifier;
            //            }

            //        });
            //    }
            //    else
            //    {
            //        // Usually preset when opening a source file from a .jar
            //        javaEditor.TypeRootIdentifier = presetTypeRootIdentifier;
            //        javaEditor.DisableParsing(); // No need to parse .class files for squiggles
            //    }
            //}
            //else
            //{
            //    javaUnconfiguredEditor = textView.Properties.GetOrCreateSingletonProperty<JavaUnconfiguredEditor>(() => new JavaUnconfiguredEditor(subjectBuffers, textView, JavaPkgServerMgr, eclipseWorkspace));
            //    Telemetry.Client.Get().TrackEvent("App.EditorOpenUnconfigured");
            //}

            textView.GotAggregateFocus += textView_GotAggregateFocus;

            //foreach(var buffer in subjectBuffers)
            //{
            //    buffer.Properties.AddProperty(typeof(ServerProxy), javaPkgServer);
            //    if (javaUnconfiguredEditor != null) buffer.Properties.AddProperty(typeof(JavaUnconfiguredEditor), javaUnconfiguredEditor);
            //    if (javaEditor != null)
            //    {
            //        buffer.Properties.AddProperty(typeof(JavaEditor), javaEditor);
            //        JavaOutline outline = null;
            //        if (buffer.Properties.TryGetProperty<JavaOutline>(typeof(JavaOutline), out outline))
            //        {
            //            outline.JavaEditor = javaEditor;
            //        }

            //        JavaSquiggles squiggles = null;
            //        if (buffer.Properties.TryGetProperty<JavaSquiggles>(typeof(JavaSquiggles), out squiggles))
            //        {
            //            squiggles.JavaEditor = javaEditor;
            //        }
            //    }
            //}
        }
 public void TextViewCreated(IWpfTextView textView)
 {
     textView.Properties.GetOrCreateSingletonProperty(
         () => new XmlCommentShrinker(textView, _formatMapService.GetClassificationFormatMap(textView)));
 }
 public SmartIndentCommandTarget(IVsTextView adapter, IWpfTextView textView)
     : base(adapter, textView, VSConstants.VSStd2KCmdID.RETURN)
 {
 }
 public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers)
 {
     // Create it for the view if we don't already have one
     textView.GetOrCreateAutoClosingProperty(v => new DashboardAdornmentManager(_renameService, v));
 }
Example #60
0
 public IMouseProcessor GetAssociatedProcessor(IWpfTextView view)
 {
     return(new MouseProcessor(this, view));
 }