/// <summary> /// Yes button message handler. Saves all selected documents. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_buttonYes_Click(object sender, System.EventArgs e) { foreach (object item in m_listBoxUnsavedDocuments.SelectedItems) { if (item is DocumentLBItem) { DocumentLBItem docItem = (DocumentLBItem)item; docItem.Value.Save(docItem.Value.FullName); } // this is probably superflous else if (item is ProjectLBItem) { ProjectLBItem projectItem = (ProjectLBItem)item; projectItem.Value.Save(projectItem.Value.FullName); } } this.Close(); }
/// <summary> /// Adds a document to the listbox. Document name is indented and /// preceeded with hierarchically outlined corresponding project name /// and solution name. /// </summary> /// <param name="document"></param> private void AddDocumentItem(Document document) { Project project = document.ProjectItem.ContainingProject; string projectName = project.Name; Solution solution = project.DTE.Solution; SolutionLBItem newSolutionLBItem = new SolutionLBItem(solution); if (m_listBoxUnsavedDocuments.FindStringExact(newSolutionLBItem.ToString()) == -1) { m_listBoxUnsavedDocuments.Items.Add(newSolutionLBItem); } ProjectLBItem newProjectLBItem = new ProjectLBItem(project); int index = m_listBoxUnsavedDocuments.FindStringExact(newProjectLBItem.ToString()); if (index == -1) { index = m_listBoxUnsavedDocuments.Items.Add(newProjectLBItem); } m_listBoxUnsavedDocuments.Items.Insert(index + 1, new DocumentLBItem(document)); }