internal void CloseFile(bool closeAll) { if (closeAll) { if (this.files.Count >= 2) { if (MessageBox.Show("Close all files?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } } this.files.Clear(); } else { MSBuildFile f = this.tvMain.SelectedItem as MSBuildFile; if (f != null) { foreach (MSBuildFile mf in this.files) { if (f == mf) { this.files.Remove(mf); break; } } } } this.textBlockTitle.Text = this.tvMain.Items.Count == 0 ? "Explore" : "Explore - " + this.tvMain.Items.Count; }
public void PopulateAll(MSBuildFile f) { this.ClearTargetDetails(); this.PopulateUsings(f); this.PopulateProperties(f); this.PopulateItems(f); this.PopulateImports(f); this.PopulateXml(f); }
internal static MSBuildFile GetFile(FileInfo file) { using (ProjectCollection loadedProjects = new ProjectCollection()) { Project currentProject = loadedProjects.GetLoadedProjects(file.FullName).FirstOrDefault(); if (currentProject != null) { loadedProjects.UnloadProject(currentProject); } loadedProjects.LoadProject(file.FullName); currentProject = loadedProjects.GetLoadedProjects(file.FullName).FirstOrDefault(); MSBuildFile m = new MSBuildFile(currentProject); if (currentProject.Targets != null) { SortedDictionary <string, ProjectTargetInstance> sortedTargets = new SortedDictionary <string, ProjectTargetInstance>(currentProject.Targets); foreach (var t in sortedTargets) { ProjectTargetInstance pti = t.Value; m.Targets.Add(new MSBuildTarget(pti, currentProject, m)); } } foreach (var us in currentProject.Xml.UsingTasks) { m.Usings.Add(new MSBuildUsing(currentProject, us)); } foreach (ResolvedImport import in currentProject.Imports) { m.Imports.Add(new MSBuildImport(import)); } foreach (var property in currentProject.Properties) { m.Properties.Add(new MSBuildProperties(property)); } if (currentProject.AllEvaluatedItems != null) { foreach (var item in currentProject.AllEvaluatedItems) { m.Items.Add(new MSBuildItems(item.ItemType, item.UnevaluatedInclude, item.EvaluatedInclude, item.IsImported)); } } return(m); } }
public void PopulateProperties(MSBuildFile f) { this.properties = new ObservableCollection <MSBuildProperties>(); if (f != null) { this.properties = f.Properties; } this.dataGridProperties.ItemsSource = this.properties; foreach (TabItem t in from TabItem t in this.tabControlDetails.Items where t.Header.ToString().StartsWith("Properties") select t) { t.Header = this.properties.Count == 0 ? "Properties" : "Properties - " + this.properties.Count; } }
public void PopulateImports(MSBuildFile f) { this.imports = new ObservableCollection <MSBuildImport>(); if (f != null) { this.imports = f.Imports; } this.dataGridImports.ItemsSource = this.imports; foreach (TabItem t in from TabItem t in this.tabControlDetails.Items where t.Header.ToString().StartsWith("Imports") select t) { t.Header = this.imports.Count == 0 ? "Imports" : "Imports - " + this.imports.Count; } }
private void tvMain_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { MSBuildFile f = this.tvMain.SelectedItem as MSBuildFile; if (f != null) { foreach (MSBuildFile mf in this.files) { if (f == mf) { this.RootFile = mf; break; } } RaiseEvent(new RoutedEventArgs(TreeExplorer.PopulateEverything, this)); return; } MSBuildTarget t = this.tvMain.SelectedItem as MSBuildTarget; if (t != null) { bool raise = false; this.ActiveMSBuildTarget = t; foreach (MSBuildFile mf in this.files) { if (t.Parent == mf && t.Parent != this.RootFile) { this.RootFile = mf; raise = true; break; } } if (raise) { RaiseEvent(new RoutedEventArgs(TreeExplorer.PopulateEverything, this)); } RaiseEvent(new RoutedEventArgs(TreeExplorer.TargetClick, this)); } if (this.files.Count == 0) { this.RootFile = null; RaiseEvent(new RoutedEventArgs(TreeExplorer.PopulateEverything, this)); } }
public void LoadFile(FileInfo file, bool populate) { if (this.RootFile != null && this.RootFile.ProjectFile.FullPath == file.FullName) { return; } RaiseEvent(new RoutedEventArgs(TreeExplorer.StartExplore, this)); MSBuildFileEqualityComparer eq = new MSBuildFileEqualityComparer(); try { this.RootFile = MSBuildHelper.GetFile(file); } catch (Exception ex) { this.TreeExeption = ex; RaiseEvent(new RoutedEventArgs(TreeExplorer.FailedExplore, this)); return; } if (this.files.Contains(this.RootFile, eq)) { int i = 0; foreach (MSBuildFile f in this.files) { if (f.Name == this.RootFile.Name) { this.files.RemoveAt(i); break; } i++; } } this.files.Add(this.RootFile); this.files.BubbleSort(); this.tvMain.ItemsSource = this.files; if (populate) { RaiseEvent(new RoutedEventArgs(TreeExplorer.PopulateEverything, this)); } this.textBlockTitle.Text = this.tvMain.Items.Count == 0 ? "Explore" : "Explore - " + this.tvMain.Items.Count; RaiseEvent(new RoutedEventArgs(TreeExplorer.FinishedExplore, this)); }
public void PopulateXml(MSBuildFile f) { this.textBoxXml.Text = f != null ? f.ProjectFile.Xml.RawXml : string.Empty; }