c# - How to get IWpfTextView from command Visual Studio Extension 2017 -
i need show popup use textviewadornment, it's require iwpftextview. there old code that:
private iwpftextview getwpftextview(ivstextview vtextview) { iwpftextview view = null; ivsuserdata userdata = vtextview ivsuserdata; if (null != userdata) { iwpftextviewhost viewhost; object holder; guid guidviewhost = defguidlist.guidiwpftextviewhost; userdata.getdata(ref guidviewhost, out holder); viewhost = (iwpftextviewhost)holder; view = viewhost.textview; } return view; }
but when go visual studio 2017 extension defguidlist.guidiwpftextviewhost missing. cannot iwpftextview anymore.
please me. thank everyone.
after sergey vlasov answer found solution:
private iwpftextview getwpfview() { var textmanager = (ivstextmanager)serviceprovider.getservice(typeof(svstextmanager)); var componentmodel = (icomponentmodel)this.serviceprovider.getservice(typeof(scomponentmodel)); var editor = componentmodel.getservice<ivseditoradaptersfactoryservice>(); textmanager.getactiveview(1, null, out ivstextview textviewcurrent); return editor.getwpftextview(textviewcurrent); }
you must add reference manual add reference -> assemblies -> extensions. choose:
microsoft.visualstudio.componentmodelhost microsoft.visualstudio.editor
Comments
Post a Comment