/// <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 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; } }; }
/// <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); }