예제 #1
0
        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);
        }
        public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, ToolTip tip)
        {
            if (!this.textView.IsClosed)
            {
                Point pt = e.GetPosition(this);
                if ((pt.X >= 0.0) && (pt.X <= MarginWidth))
                {
                    SnapshotPoint position = this.scrollBar.GetBufferPositionOfYCoordinate(pt.Y);

                    IBlockTag deepestTag = null;
                    var       tags       = this.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)
                    {
                        tip.IsOpen = true;

                        FrameworkElement context = deepestTag.Context(this.blockColoring,
                                                                      this.textView.FormattedLineSource.DefaultTextProperties.Typeface,
                                                                      this.textView.FormattedLineSource.DefaultTextProperties.FontRenderingEmSize);

                        //The width of the view is in zoomed coordinates so factor the zoom factor into the tip window width computation.
                        double zoom = this.textView.ZoomLevel / 100.0;
                        tip.MinWidth  = tip.MaxWidth = Math.Floor(Math.Max(50.0, this.textView.ViewportWidth * zoom * 0.5));
                        tip.MinHeight = tip.MaxHeight = context.Height + 12.0;

                        tip.Content = context;

                        return(true);
                    }
                }
            }

            return(false);
        }