public bool TrySelectFile(Project project, string title, string filter, string storageKey, out string file) { IVsHierarchy vsHierarchy; if (!NativeMethods.Succeeded(((IVsSolution)this.Dialog.ServiceProvider.GetService(typeof(SVsSolution))).GetProjectOfUniqueName(project.FullName, out vsHierarchy))) { file = null; return(false); } string item = null; ProjectSettings projectSetting = null; IVsBuildPropertyStorage vsBuildPropertyStorage = null; if (storageKey != null) { vsBuildPropertyStorage = vsHierarchy as IVsBuildPropertyStorage; } if (vsBuildPropertyStorage != null) { try { projectSetting = new ProjectSettings(vsBuildPropertyStorage); item = projectSetting[storageKey]; } catch { projectSetting = null; } } if (!ProjectItemSelector.TrySelectItem(vsHierarchy, title, filter, item, out file)) { return(false); } if (projectSetting != null) { try { projectSetting[storageKey] = file; } catch { projectSetting = null; } } return(true); }
public static bool TrySelectItem(IVsHierarchy hierarchy, string title, string filter, string preselectedItem, out string relativePath) { bool flag; if (hierarchy == null) { throw new ArgumentNullException("hierarchy"); } if (title == null) { throw new ArgumentNullException("title"); } if (filter == null) { throw new ArgumentNullException("filter"); } if (!NativeMethods.Succeeded(ProjectItemSelector.SelectItem(hierarchy, filter, title, preselectedItem, out relativePath, out flag))) { return(false); } return(!flag); }