简体   繁体   中英

Visual Studio Extension icon in Text Editor

How to insert icon with click events or custom button in editor. I want create control that looks like R# or CodeRush, and then click on icon open smart tag. Sorry for my bad English. Thank you.

Screenshots:

I create smart tags, but have standard mark on text or standard refactoring mark. I want custom button smart tags.

创建智能标记时,可以将ISmartTagSession.IconSource设置为要显示的图标。

I create usercontrol and insert in editor. Old control SmartTag remove. How to add smart tag action in my usercontol? Control have menu, but cant add SmartTagActions. How do I make my control was created instead of the standard? Standart control is always created.

private bool ButtonSmartTag(ITextView view)
    {
        foreach (ISmartTagSession s in _broke.GetSessions(view))
        {
            var wpfTextView = (IWpfTextView)view;               
            var adornmentLayer = wpfTextView.GetAdornmentLayer("SmartTag");

            foreach (var alement in adornmentLayer.Elements)
            {
                adornmentLayer.RemoveAllAdornments();

                var line = view.GetTextViewLineContainingBufferPosition(_view.Caret.Position.BufferPosition);
                alement.VisualSpan, "butRe", but, null);

                var mb = new ReButtonMenu();
                mb.Margin = new Thickness(0, line.Top, 0, 0);
                adornmentLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, alement.VisualSpan, "butRe", mb, null);
            }
        }
        return false;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM