/// <summary> /// Constructor for the CaretMarginElement. /// </summary> /// <param name="textView">ITextView to which this CaretMargenElement will be attached.</param> /// <param name="factory">Instance of the CaretMarginFactory that is creating the margin.</param> /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param> public CaretMarginElement(IWpfTextView textView, CaretMarginFactory factory, IVerticalScrollBar verticalScrollbar) { this.textView = textView; this.layer = textView.GetAdornmentLayer("CaretAdornmentLayer"); factory.LoadOption(textView.Options, CaretMarginElement.EnabledOptionId.Name); factory.LoadOption(textView.Options, CaretMarginElement.CaretColorId.Name); factory.LoadOption(textView.Options, CaretMarginElement.MatchColorId.Name); factory.LoadOption(textView.Options, CaretMarginElement.AdornmentMatchColorId.Name); factory.LoadOption(textView.Options, CaretMarginElement.MarginWidthId.Name); this.scrollBar = verticalScrollbar; //Make our width big enough to see, but not so big that it consumes a lot of //real-estate. this.Width = textView.Options.GetOptionValue(CaretMarginElement.MarginWidthId); this.caretBrush = GetBrush(CaretMarginElement.CaretColorId); this.matchBrush = GetBrush(CaretMarginElement.MatchColorId); this.adornmentMatchBrush = GetBrush(CaretMarginElement.AdornmentMatchColorId); this.textView.Closed += OnClosed; this.OnOptionsChanged(null, null); this.textView.Options.OptionChanged += this.OnOptionsChanged; this.UpdateEventHandlers(null); this.IsVisibleChanged += delegate(object sender, DependencyPropertyChangedEventArgs e) { this.UpdateEventHandlers(null); }; }
/// <summary> /// Constructor for the OverviewChangeTrackingMargin. /// </summary> private OverviewMarkMargin( IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, OverviewMarkMarginProvider provider) { _markMarginElement = new MarkMarginElement(textViewHost.TextView, scrollBar, provider); }
public DocumentMarkScrollbar( IWpfTextViewHost wpfTextViewHost, IVerticalScrollBar verticalScrollBar, ISessionService sessionService) { if (wpfTextViewHost == null) { throw new ArgumentNullException(nameof(wpfTextViewHost)); } _sessionService = sessionService; _textView = wpfTextViewHost.TextView; _verticalScrollBar = verticalScrollBar; IsHitTestVisible = false; Width = DefaultMarginWidth; _textView.Options.OptionChanged += OnOptionChanged; IsVisibleChanged += OnViewOrMarginVisibilityChanged; _textView.VisualElement.IsVisibleChanged += OnViewOrMarginVisibilityChanged; OnOptionChanged(null, null); TryInitialize(); }
public PeerReviewMargin(IWpfTextView textView, IVerticalScrollBar scrollBar) { this.textView = textView; this.textView.LayoutChanged += OnLayoutChanged; this.scrollBar = scrollBar; this.Width = 6.0; }
/// <summary> /// Initializes a new instance of the <see cref="CodeCoverageMargin"/> class for a given <paramref name="textView"/>. /// </summary> /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param> /// <param name="scrollBar"></param> public CodeCoverageMargin(IWpfTextView textView, IVerticalScrollBar scrollBar) { _textView = textView; _scrollBar = scrollBar; _scrollBar.TrackSpanChanged += ScrollBarOnTrackSpanChanged; Width = 10; // Add a green colored label that says "Hello CodeCoverageMargin" _margin = new CodeCoverageMarginView(); UpdateScrollbarMargin(); Children.Add(_margin); _codeCoverage = PowershellService.Current.CodeCoverage; SetCodeCoverageChanged(); _codeCoverage.ModelChanged += SetCodeCoverageChanged; _codeCoverage.ShowHitsModelChanged += SetCodeCoverageChanged; if (!_codeCoverage.ShowLinesHit) { Visibility = Visibility.Collapsed; } else { Visibility = Visibility.Visible; } }
public SimpleScrollBar(IWpfTextViewHost host, IWpfTextViewMargin containerMargin, FrameworkElement container, IScrollMapFactoryService scrollMapFactoryService) { _textView = host.TextView; _realScrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin; if (_realScrollBarMargin != null) { _realScrollBar = _realScrollBarMargin as IVerticalScrollBar; if (_realScrollBar != null) { _realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged; _realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged; } } ResetTrackSpan(); _scrollMapFactory = scrollMapFactoryService; _useElidedCoordinates = false; ResetScrollMap(); _scrollMap.MappingChanged += delegate { RaiseTrackChangedEvent(); }; container.SizeChanged += OnContainerSizeChanged; }
/// <summary> /// Constructor for the StructureMargin. /// </summary> /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param> public StructureMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, StructureMarginFactory factory) { // Validate if (textViewHost == null) throw new ArgumentNullException("textViewHost"); this.structureMarginElement = new StructureMarginElement(textViewHost.TextView, scrollBar, factory); }
/// <summary> /// Factory for the ChangeTrackingMargin. /// </summary> public static OverviewChangeTrackingMargin Create(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, OverviewChangeTrackingMarginProvider provider) { // Validate if (textViewHost == null) throw new ArgumentNullException("textViewHost"); return new OverviewChangeTrackingMargin(textViewHost, scrollBar, provider); }
/// <summary> /// Constructor for the CaretMargin. /// </summary> /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param> /// <param name="navigator">Instance of an ITextStructureNavigator used to define words in the host's TextView. Created from the /// ITextStructureNavigatorFactory service.</param> public CaretMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, CaretMarginFactory factory) { // Validate if (textViewHost == null) throw new ArgumentNullException("textViewHost"); this.caretMarginElement = new CaretMarginElement(textViewHost.TextView, factory, scrollBar); }
public bool UpdateTip(IVerticalScrollBar margin, MouseEventArgs e, ToolTip tip) { if ((!_textView.IsClosed) && (_tagger != null) && _previewEnabled) { Point pt = e.GetPosition(this); if ((pt.X >= 0.0) && (pt.X <= this.Width)) { SnapshotPoint position = _scrollBar.GetBufferPositionOfYCoordinate(pt.Y); IBlockTag deepestTag = null; var tags = _tagger.GetTags(new SnapshotSpan(position, 0)); foreach (var tagSpan in tags) { if (tagSpan.Tag.Type != BlockType.Unknown) { if ((deepestTag == null) || (tagSpan.Tag.Level > deepestTag.Level)) { deepestTag = tagSpan.Tag; } } } if (deepestTag != null) { if (tip.IsOpen) { var existingContext = tip.Content as FrameworkElement; if ((existingContext != null) && (existingContext.Tag == deepestTag)) { // No changes from the last time we opened the tip. return(true); } } FrameworkElement context = deepestTag.Context(_coloring, _textView.FormattedLineSource.DefaultTextProperties); context.Tag = deepestTag; //The width of the view is in zoomed coordinates so factor the zoom factor into the tip window width computation. double zoom = _textView.ZoomLevel / 100.0; tip.MinWidth = tip.MaxWidth = Math.Floor(Math.Max(50.0, _textView.ViewportWidth * zoom * 0.5)); tip.MinHeight = tip.MaxHeight = context.Height + 12.0; tip.Content = context; tip.IsOpen = true; StructureMarginElement.LogTipOpened("VS/PPT-Structure/MarginTipOpened", context); return(true); } } } return(false); }
/// <summary> /// Constructor for the StructureMargin. /// </summary> /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param> public StructureMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, StructureMarginFactory factory) { // Validate if (textViewHost == null) { throw new ArgumentNullException("textViewHost"); } this.structureMarginElement = new StructureMarginElement(textViewHost.TextView, scrollBar, factory); }
/// <summary> /// Constructor for the CaretMargin. /// </summary> /// <param name="textViewHost">The IWpfTextViewHost in which this margin will be displayed.</param> /// <param name="navigator">Instance of an ITextStructureNavigator used to define words in the host's TextView. Created from the /// ITextStructureNavigatorFactory service.</param> public CaretMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, CaretMarginFactory factory) { // Validate if (textViewHost == null) { throw new ArgumentNullException("textViewHost"); } this.caretMarginElement = new CaretMarginElement(textViewHost.TextView, factory, scrollBar); }
internal ScrollDiffMargin(IWpfTextView textView, UnifiedDiff unifiedDiff, IMarginCore marginCore, IWpfTextViewMargin containerMargin) : base(textView) { var scrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar); // ReSharper disable once SuspiciousTypeConversion.Global _scrollBar = (IVerticalScrollBar)scrollBarMargin; ViewModel = new ScrollDiffMarginViewModel(marginCore, unifiedDiff, UpdateDiffDimensions); UserControl = new ScrollDiffMarginControl { DataContext = ViewModel, Width = MarginWidth, MaxWidth = MarginWidth, MinWidth = MarginWidth}; }
public MarkMarginElement(IWpfTextView textView, IVerticalScrollBar scrollbar, OverviewMarkMarginProvider provider) { provider.LoadOption(textView.Options, DefaultOverviewMarginOptions.MarkMarginId.Name); provider.LoadOption(textView.Options, MarkMarginWidthId.Name); _markPen = new Pen(Brushes.DimGray, 1.0); _markPen.Freeze(); _textView = textView; _scrollBar = scrollbar; _editorFormatMap = provider.EditorFormatMapService.GetEditorFormatMap(_textView); _factories = new List <IOverviewMarkFactory>(); foreach (var markProvider in provider.MarkProviders) { IEnumerable <string> providerRoles = markProvider.Metadata.TextViewRoles; if (_textView.Roles.ContainsAny(providerRoles)) { IOverviewMarkFactory factory = markProvider.Value.GetOverviewMarkFactory(textView); if (factory != null) { _factories.Add(factory); factory.MarksChanged += delegate { this.AsynchInvalidateVisual(); }; } } } //Make our width big enough to see, but not so big that it consumes a lot of //real-estate. this.Width = textView.Options.GetOptionValue(MarkMarginWidthId); this.OnOptionsChanged(null, null); textView.Options.OptionChanged += this.OnOptionsChanged; this.IsVisibleChanged += delegate(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue) { //Hook up to the various events we need to keep the caret margin current. _scrollBar.TrackSpanChanged += OnTrackSpanChanged; //Force the margin to be rerendered since things might have changed while the margin was hidden. this.AsynchInvalidateVisual(); } else { _scrollBar.TrackSpanChanged -= OnTrackSpanChanged; } }; }
/// <summary> /// Factory for the OverviewMarkMargin. /// </summary> public static OverviewMarkMargin Create( IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, OverviewMarkMarginProvider provider) { // Validate if (textViewHost == null) { throw new ArgumentNullException("textViewHost"); } return(new OverviewMarkMargin(textViewHost, scrollBar, provider)); }
internal ScrollDiffMargin(IWpfTextView textView, IMarginCore marginCore, IWpfTextViewMargin containerMargin) : base(textView) { var scrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar); // ReSharper disable once SuspiciousTypeConversion.Global _scrollBar = (IVerticalScrollBar)scrollBarMargin; ViewModel = new ScrollDiffMarginViewModel(marginCore, UpdateDiffDimensions); UserControl = new ScrollDiffMarginControl { DataContext = ViewModel, Width = MarginWidth, MaxWidth = MarginWidth, MinWidth = MarginWidth }; }
/// <summary> /// Constructor for the <see cref="CSharpMembersMargin"/>. /// </summary> /// <param name="textView">ITextView to which this <see cref="CSharpMembersMargin"/> will be attacheded.</param> /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param> public CSharpMembersMargin(IWpfTextView textView, IVerticalScrollBar verticalScrollbar) { IsHitTestVisible = false; SnapsToDevicePixels = true; Width = Padding + MarkerSize; _MemberMarker = new MemberMarker(textView, verticalScrollbar, this); _SymbolReferenceMarker = new SymbolReferenceMarker(textView, verticalScrollbar, this); _FormatMap = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView); IsVisibleChanged += _MemberMarker.OnIsVisibleChanged; textView.Closed += TextView_Closed; Config.Updated += Config_Updated; Config_Updated(null, new ConfigUpdatedEventArgs(Features.ScrollbarMarkers)); }
public LineNumberMargin(IWpfTextView textView, IVerticalScrollBar scrollBar) { _TextView = textView; IsHitTestVisible = false; _ScrollBar = scrollBar; _EditorFormatMap = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView); Width = 0; Visibility = Config.Instance.MarkerOptions.MatchFlags(MarkerOptions.LineNumber) ? Visibility.Visible : Visibility.Collapsed; Config.Updated += Config_Updated; Setup(); _TextView.Closed += (s, args) => Dispose(); }
public LineNumberMargin(IWpfTextView textView, IVerticalScrollBar scrollBar) { _TextView = textView; IsHitTestVisible = false; _ScrollBar = scrollBar; _Tags = textView.Properties.GetOrCreateSingletonProperty(() => new TaggerResult()); _EditorFormatMap = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView); Width = 0; Visibility = Config.Instance.MarkerOptions.MatchFlags(MarkerOptions.LineNumber) ? Visibility.Visible : Visibility.Collapsed; Config.Updated += Config_Updated; _TextView.TextBuffer.Changed += TextView_TextBufferChanged; _ScrollBar.TrackSpanChanged += OnMappingChanged; _TextView.Closed += (s, args) => Dispose(); }
/// <summary> /// Constructor for the StructureMarginElement. /// </summary> /// <param name="textView">ITextView to which this StructureMargenElement will be attacheded.</param> /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param> /// <param name="factory">MEF tag factory.</param> public StructureMarginElement(IWpfTextView textView, IVerticalScrollBar verticalScrollbar, StructureMarginFactory factory) { _textView = textView; _scrollBar = verticalScrollbar; _factory = factory; _formatMap = factory.EditorFormatMapService.GetEditorFormatMap(textView); this.IsHitTestVisible = false; this.SnapsToDevicePixels = true; this.Width = marginWidth; textView.Options.OptionChanged += this.OnOptionChanged; this.IsVisibleChanged += this.OnIsVisibleChanged; this.OnOptionChanged(null, null); }
/// <summary> /// Constructor for the MatchMarginElement. /// </summary> /// <param name="textView">ITextView to which this MatchMargenElement will be attached.</param> /// <param name="factory">Instance of the MatchMarginFactory that is creating the margin.</param> /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param> public MatchMarginElement(IWpfTextView textView, MatchMarginFactory factory, IVerticalScrollBar verticalScrollbar) { _textView = textView; this.IsHitTestVisible = false; _layer = textView.GetAdornmentLayer("MatchMarginAdornmentLayer"); _scrollBar = verticalScrollbar; _editorFormatMap = factory.EditorFormatMapService.GetEditorFormatMap(textView); this.Width = 6.0; _textView.Options.OptionChanged += this.OnOptionChanged; this.IsVisibleChanged += this.OnViewOrMarginVisiblityChanged; _textView.VisualElement.IsVisibleChanged += this.OnViewOrMarginVisiblityChanged; this.OnOptionChanged(null, null); }
public CommentMargin(IWpfTextView textView, IVerticalScrollBar verticalScrollbar) { _TextView = textView; IsHitTestVisible = false; _ScrollBar = verticalScrollbar; _Tags = textView.Properties.GetOrCreateSingletonProperty(() => new TaggerResult()); _EditorFormatMap = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(textView); Width = MarkSize + MarkPadding + MarkPadding + /*extra padding*/ 2 * MarkPadding; Visibility = Config.Instance.MarkerOptions.HasAnyFlag(MarkerOptions.CodeMarginMask) ? Visibility.Visible : Visibility.Collapsed; Config.Updated += Config_Updated; //subscribe to change events and use them to update the markers _TextView.TextBuffer.Changed += TextView_TextBufferChanged; IsVisibleChanged += OnViewOrMarginVisiblityChanged; //_TextView.VisualElement.IsVisibleChanged += OnViewOrMarginVisiblityChanged; _ScrollBar.TrackSpanChanged += OnMappingChanged; }
/// <summary> /// Creates a <see cref="ScrollbarMargin"/> for a given <see cref="IWpfTextView"/>. /// </summary> /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param> /// <param name="marginContainer">Margin container. Is defined in the <see cref="ScrollbarMarginFactory"/> by the <see cref="MarginContainerAttribute"/>.</param> /// <param name="marginCore">The class which receives, processes and provides necessary data for <see cref="ScrollbarMargin"/>.</param> public ScrollbarMargin(IWpfTextView textView, IWpfTextViewMargin marginContainer, MarginCore marginCore) { Debug.WriteLine("Entering constructor.", MarginName); _textView = textView; _marginCore = marginCore; InitializeLayout(); ITextViewMargin scrollBarMargin = marginContainer.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar); // ReSharper disable once SuspiciousTypeConversion.Global - scrollBarMargin is IVerticalScrollBar. _scrollBar = (IVerticalScrollBar)scrollBarMargin; marginCore.MarginRedraw += OnMarginCoreMarginRedraw; if (marginCore.IsActivated) { DrawMargins(marginCore.GetChangedLines()); } }
/// <summary> /// Constructor for the ChangeTrackingMarginElement. /// </summary> /// <param name="textView">ITextView to which this ChangeTrackingMargenElement will be attached.</param> /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param> public ChangeTrackingMarginElement(IWpfTextView textView, IVerticalScrollBar verticalScrollbar, OverviewChangeTrackingMarginProvider provider) { provider.LoadOption(textView.Options, DefaultOverviewMarginOptions.ChangeTrackingMarginId.Name); provider.LoadOption(textView.Options, ChangeTrackingMarginWidthId.Name); _textView = textView; _scrollBar = verticalScrollbar; _tagAggregatorFactoryService = provider.TagAggregatorFactoryService; _editorFormatMap = provider.EditorFormatMapService.GetEditorFormatMap(textView); _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged; _textView.Closed += (sender, args) => _editorFormatMap.FormatMappingChanged -= OnFormatMappingChanged; UpdateBrushes(); //Make our width big enough to see, but not so big that it consumes a lot of //real-estate. this.Width = _textView.Options.GetOptionValue(ChangeTrackingMarginWidthId); this.OnOptionsChanged(null, null); textView.Options.OptionChanged += this.OnOptionsChanged; this.IsVisibleChanged += delegate(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue) { //Hook up to the various events we need to keep the changeTracking margin current. _textView.LayoutChanged += OnLayoutChanged; _scrollBar.TrackSpanChanged += OnTrackSpanChanged; this.InvalidateVisual(); } else { _textView.LayoutChanged -= OnLayoutChanged; _scrollBar.TrackSpanChanged -= OnTrackSpanChanged; } }; }
public DiagnosticStripeMargin(IWpfTextView textView, IVerticalScrollBar scrollBar, IEditorFormatMapService editorFormatMapService) { _textView = textView; _isDisposed = false; _scrollBar = scrollBar; _editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView); _diagnosticService = DiagnosticService.GetOrCreate(textView); ClipToBounds = true; Background = null; VerticalAlignment = VerticalAlignment.Stretch; Focusable = false; Width = 10; RenderOptions.SetEdgeMode(this, EdgeMode.Aliased); _diagnosticService.DiagnosticsChanging += OnDiagnosticsChanging; _diagnosticService.DiagnosticsChanged += OnDiagnosticsChanged; _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged; _scrollBar.TrackSpanChanged += OnTrackSpanChanged; _textView.LayoutChanged += OnTextViewLayoutChanged; _textView.Closed += OnTextViewClosed; }
public DiagnosticStripeMargin(IWpfTextView textView, IVerticalScrollBar scrollBar, IEditorFormatMapService editorFormatMapService) { _textView = textView; _isDisposed = false; _scrollBar = scrollBar; _editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView); _diagnosticService = DiagnosticService.GetOrCreate(textView); ClipToBounds = true; Background = null; VerticalAlignment = VerticalAlignment.Stretch; Focusable = false; Width = 10; RenderOptions.SetEdgeMode(this, System.Windows.Media.EdgeMode.Aliased); _diagnosticService.DiagnosticsChanging += OnDiagnosticsChanging; _diagnosticService.DiagnosticsChanged += OnDiagnosticsChanged; _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged; _scrollBar.TrackSpanChanged += OnTrackSpanChanged; _textView.LayoutChanged += OnTextViewLayoutChanged; _textView.Closed += OnTextViewClosed; }
public SimpleScrollBar(IWpfTextView textView, IWpfTextViewMargin containerMargin, IScrollMapFactoryService scrollMapFactory) { _textView = textView; _textView.LayoutChanged += OnLayoutChanged; Width = Options.ScrollBarWidth; _realScrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin; if (_realScrollBarMargin != null) { _realScrollBar = _realScrollBarMargin as IVerticalScrollBar; if (_realScrollBar != null) { _realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged; _realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged; } } ResetTrackSpan(); _scrollMapFactory = scrollMapFactory; ResetScrollMap(); _scrollMap.MappingChanged += delegate { RaiseTrackChangedEvent(); }; }
public SimpleScrollBar(IWpfTextViewHost host, IWpfTextViewMargin containerMargin, IScrollMapFactoryService scrollMapFactory, FrameworkElement container, bool useElidedCoordinates) { _textView = host.TextView; _realScrollBarMargin = containerMargin.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar) as IWpfTextViewMargin; if (_realScrollBarMargin != null) { _realScrollBar = _realScrollBarMargin as IVerticalScrollBar; if (_realScrollBar != null) { _realScrollBarMargin.VisualElement.IsVisibleChanged += OnScrollBarIsVisibleChanged; _realScrollBar.TrackSpanChanged += OnScrollBarTrackSpanChanged; } } this.ResetTrackSpan(); _scrollMapFactory = scrollMapFactory; _useElidedCoordinates = useElidedCoordinates; this.ResetScrollMap(); _scrollMap.MappingChanged += delegate { this.RaiseTrackChangedEvent(); }; container.SizeChanged += OnContainerSizeChanged; }
public MemberMarker(IWpfTextView textView, IVerticalScrollBar verticalScrollbar, CSharpMembersMargin element) { _TextView = textView; _ScrollBar = verticalScrollbar; _Element = element; }
public bool UpdateTip(IVerticalScrollBar margin, MouseEventArgs e, ToolTip tip) { return(this.Enabled ? _structureMarginElement.UpdateTip(margin, e, tip) : false); }
/// <summary> /// Creates a <see cref="ScrollbarMargin"/> for a given <see cref="IWpfTextView"/>. /// </summary> /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param> /// <param name="marginContainer">Margin container. Is defined in the <see cref="ScrollbarMarginFactory"/> by the <see cref="MarginContainerAttribute"/>.</param> /// <param name="marginCore">The class which receives, processes and provides necessary data for <see cref="ScrollbarMargin"/>.</param> public ScrollbarMargin(IWpfTextView textView, IWpfTextViewMargin marginContainer, MarginCore marginCore) { Debug.WriteLine("Entering constructor.", MarginName); _textView = textView; _marginCore = marginCore; InitializeLayout(); ITextViewMargin scrollBarMargin = marginContainer.GetTextViewMargin(PredefinedMarginNames.VerticalScrollBar); // ReSharper disable once SuspiciousTypeConversion.Global - scrollBarMargin is IVerticalScrollBar. _scrollBar = (IVerticalScrollBar)scrollBarMargin; marginCore.MarginRedraw += OnMarginCoreMarginRedraw; if (marginCore.IsActivated) DrawMargins(marginCore.GetChangedLines()); }
/// <summary> /// Constructor for the OverviewChangeTrackingMargin. /// </summary> private OverviewChangeTrackingMargin(IWpfTextViewHost textViewHost, IVerticalScrollBar scrollBar, OverviewChangeTrackingMarginProvider provider) { _changeTrackingMarginElement = new ChangeTrackingMarginElement(textViewHost.TextView, scrollBar, provider); }
/// <summary> /// Constructor for the StructureMarginElement. /// </summary> /// <param name="textView">ITextView to which this StructureMargenElement will be attacheded.</param> /// <param name="verticalScrollbar">Vertical scrollbar of the ITextViewHost that contains <paramref name="textView"/>.</param> /// <param name="tagFactory">MEF tag factory.</param> public StructureMarginElement(IWpfTextView textView, IVerticalScrollBar verticalScrollbar, StructureMarginFactory factory) { factory.LoadOption(textView.Options, StructureMarginElement.EnabledOptionId.Name); factory.LoadOption(textView.Options, StructureMarginElement.MarginWidthId.Name); factory.LoadOption(textView.Options, StructureMarginElement.MethodEllipseColorId.Name); factory.LoadOption(textView.Options, StructureMarginElement.ClassColorId.Name); factory.LoadOption(textView.Options, StructureMarginElement.ConditionalColorId.Name); factory.LoadOption(textView.Options, StructureMarginElement.LoopColorId.Name); factory.LoadOption(textView.Options, StructureMarginElement.MethodColorId.Name); factory.LoadOption(textView.Options, StructureMarginElement.UnknownColorId.Name); factory.LoadOption(textView.Options, StructureMarginElement.LineWidthId.Name); factory.LoadOption(textView.Options, StructureMarginElement.GapWidthId.Name); this.textView = textView; this.scrollBar = verticalScrollbar; this.SnapsToDevicePixels = true; this.gapWidth = textView.Options.GetOptionValue(StructureMarginElement.GapWidthId); this.lineWidth = textView.Options.GetOptionValue(StructureMarginElement.LineWidthId); this.blockColoring = new BlockColoring(this.lineWidth, textView.Options.GetOptionValue(StructureMarginElement.ClassColorId), textView.Options.GetOptionValue(StructureMarginElement.ConditionalColorId), textView.Options.GetOptionValue(StructureMarginElement.LoopColorId), textView.Options.GetOptionValue(StructureMarginElement.MethodColorId), textView.Options.GetOptionValue(StructureMarginElement.UnknownColorId)); this.tagger = factory.TagAggregatorFactoryService.CreateTagAggregator <IBlockTag>(textView); Color methodColor = textView.Options.GetOptionValue(StructureMarginElement.MethodEllipseColorId); if (methodColor.A != 0) { this.methodBrush = new SolidColorBrush(methodColor); this.methodBrush.Freeze(); } //Make our width big enough to see, but not so big that it consumes a lot of //real-estate. this.Width = textView.Options.GetOptionValue(StructureMarginElement.MarginWidthId); this.OnOptionsChanged(null, null); this.textView.Options.OptionChanged += this.OnOptionsChanged; this.IsVisibleChanged += delegate(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue) { //Hook up to the various events we need to keep the caret margin current. this.tagger.BatchedTagsChanged += OnTagsChanged; this.scrollBar.TrackSpanChanged += OnTrackSpanChanged; //Force the margin to be rerendered since things might have changed while the margin was hidden. this.InvalidateVisual(); } else { this.tagger.BatchedTagsChanged -= OnTagsChanged; this.scrollBar.TrackSpanChanged -= OnTrackSpanChanged; } }; }