public EditorPane( IVsTextLines textLines, string fileName, IVsHierarchy hierarchy, uint itemid, string pszPhysicalView, IntPtr punkDocData, ServiceProvider vsServiceProvider) { InitializeComponent(); // Remember values: _textLines = textLines; _fileName = fileName; _hierarchy = hierarchy; _itemid = itemid; _pszPhysicalView = pszPhysicalView; _punkDocData = punkDocData; _vsServiceProvider = vsServiceProvider; // Handle VS theme colors: ApplyThemeColors(); VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged; // Get the current Project and Solution: EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)_vsServiceProvider.GetService(typeof(EnvDTE.DTE)); EnvDTE.Solution solution = dte.Solution; var projectItem = solution.FindProjectItem(fileName); EnvDTE.Project project = projectItem.ContainingProject; // Create and position the XAML designer control: _xamlDesignerControl = new XamlDesignerControl(project, solution, fileName); ElementHost elementHost = new ElementHost() { Dock = System.Windows.Forms.DockStyle.Fill }; xamlDesignerContainer.Controls.Add(elementHost); elementHost.Child = _xamlDesignerControl; // Listen to changes in the text buffer: _textLineEventListener = new TextLineEventListener(textLines); _textLineEventListener.TextChanged += textLineEventListener_TextChanged; }
private static bool Matches(EnvDTE.DTE dte, string hintPath) { if (String.IsNullOrEmpty(hintPath)) { return(false); } EnvDTE.Solution solution = dte.Solution; if (solution == null) { return(false); } string solutionFolder = Path.GetFullPath(Path.GetDirectoryName(solution.FullName)); if (hintPath.StartsWith(solutionFolder)) { return(true); } EnvDTE.ProjectItem item = solution.FindProjectItem(hintPath); return(item != null); }
public static EnvDTE.Project GetProjectContainingFile(this EnvDTE.Solution solution, string filePath) { return(solution.FindProjectItem(filePath).ContainingProject); }