private static int SelectItem(IVsHierarchy hierarchy, string filter, string title, string preselectedItem, out string appRelUrlOfSelectedItem, out bool canceled) { appRelUrlOfSelectedItem = null; canceled = false; int hr = NativeMethods.E_FAIL; if (hierarchy != null) { IOleServiceProvider site = null; hr = hierarchy.GetSite(out site); if (NativeMethods.Succeeded(hr) && site != null) { IProjectItemSelector selector = site.CreateSitedInstance <IProjectItemSelector>(typeof(IProjectItemSelector_Class).GUID); if (selector != null) { hr = selector.SelectItem( hierarchy, VSConstants.VSITEMID_NIL, filter, title, ProjectItemSelectorFlags.PISF_ReturnAppRelativeUrls, null, preselectedItem, null, out appRelUrlOfSelectedItem, out canceled); } } } return(hr); }
private static int SelectItem(IVsHierarchy hierarchy, string filter, string title, string preselectedItem, out string appRelUrlOfSelectedItem, out bool canceled) { appRelUrlOfSelectedItem = null; canceled = false; int site = -2147467259; if (hierarchy != null) { Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider = null; site = hierarchy.GetSite(out serviceProvider); if (NativeMethods.Succeeded(site) && serviceProvider != null) { IProjectItemSelector projectItemSelector = serviceProvider.CreateSitedInstance <IProjectItemSelector>(typeof(IProjectItemSelector).GUID); if (projectItemSelector != null) { site = projectItemSelector.SelectItem(hierarchy, Convert.ToUInt32(-1), filter, title, ProjectItemSelectorFlags.PISF_ReturnAppRelativeUrls, null, preselectedItem, null, out appRelUrlOfSelectedItem, out canceled); } } } return(site); }