/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> public Generator(Project project, SolutionType type) { if (project == null) throw new ArgumentNullException("project"); solutionGenerator = CreateSolutionGenerator(project, type); }
/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> protected SolutionGenerator(Project project) { if (project == null) throw new ArgumentNullException("project"); this.project = project; }
/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> public EmptyProjectNode(Project project) { if (project == null) throw new ArgumentNullException("project"); this.project = project; project.ItemAdded += new ProjectItemEventHandler(project_ItemAdded); this.Text = Strings.DoubleClickToAddDiagram; this.ImageKey = "diagram"; this.SelectedImageKey = "diagram"; }
/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> public ProjectNode(Project project) { if (project == null) throw new ArgumentNullException("project"); this.project = project; this.Text = project.Name; this.ImageKey = "project"; this.SelectedImageKey = "project"; AddProjectItemNodes(project); project.Renamed += new EventHandler(project_Renamed); project.ItemAdded += new ProjectItemEventHandler(project_ItemAdded); project.ItemRemoved += new ProjectItemEventHandler(project_ItemRemoved); }
private void AddProject(Project project) { ModelNode projectNode = new ProjectNode(project); Nodes.Add(projectNode); projectNode.AfterInitialized(); SelectedNode = projectNode; projectNode.Expand(); lblAddProject.Visible = false; if (project.ItemCount == 1) { foreach (IProjectItem item in project.Items) { IDocument document = item as IDocument; if (document != null) OnDocumentOpening(new DocumentEventArgs(document)); } } if (project.IsUntitled) { projectNode.EditLabel(); } }
/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> public bool SaveProject(Project project) { if (project == null) throw new ArgumentNullException("project"); if (project.FilePath == null || project.IsReadOnly) { return SaveProjectAs(project); } else { try { project.Save(); return true; } catch (Exception ex) { MessageBox.Show(Strings.Error + ": " + ex.Message, Strings.SaveAs, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } } }
private void AddProjectItemNodes(Project project) { if (project.IsEmpty) { ModelNode node = new EmptyProjectNode(project); Nodes.Add(node); if (TreeView != null) node.AfterInitialized(); } else { foreach (IProjectItem projectItem in project.Items) { AddProjectItemNode(projectItem); } } }
private void RemoveProject(Project project) { foreach (ProjectNode projectNode in Nodes) { if (projectNode.Project == project) { projectNode.Delete(); break; } } if (!workspace.HasProject) lblAddProject.Visible = true; }
/// <exception cref="IOException"> /// Could not load the project. /// </exception> /// <exception cref="InvalidDataException"> /// The save file is corrupt and could not be loaded. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="fileName"/> is empty string. /// </exception> public static Project Load(string fileName) { if (string.IsNullOrEmpty(fileName)) throw new ArgumentException(Strings.ErrorBlankFilename, "fileName"); if (!File.Exists(fileName)) throw new FileNotFoundException(Strings.ErrorFileNotFound); XmlDocument document = new XmlDocument(); try { document.Load(fileName); } catch (Exception ex) { throw new IOException(Strings.ErrorCouldNotLoadFile, ex); } XmlElement root = document["Project"]; if (root == null) { root = document["ClassProject"]; // Old file format if (root == null) { throw new InvalidDataException(Strings.ErrorCorruptSaveFile); } else { Project oldProject = LoadWithPreviousFormat(root); oldProject.FilePath = fileName; oldProject.name = Path.GetFileNameWithoutExtension(fileName); oldProject.isUntitled = false; return oldProject; } } Project project = new Project(); project.loading = true; try { project.Deserialize(root); } catch (Exception ex) { throw new InvalidDataException(Strings.ErrorCorruptSaveFile, ex); } project.loading = false; project.FilePath = fileName; project.isReadOnly = project.projectFile.IsReadOnly; return project; }
private static Project LoadWithPreviousFormat(XmlElement root) { Project project = new Project(); project.loading = true; Assembly assembly = Assembly.Load("NClass.DiagramEditor"); IProjectItem projectItem = (IProjectItem) assembly.CreateInstance( "NClass.DiagramEditor.ClassDiagram.Diagram", false, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, null, null, null); try { projectItem.Deserialize(root); } catch (Exception ex) { throw new InvalidDataException(Strings.ErrorCorruptSaveFile, ex); } project.Add(projectItem); project.loading = false; project.isReadOnly = true; return project; }
public Project AddEmptyProject() { Project project = new Project(); projects.Add(project); project.Modified += new EventHandler(project_StateChanged); project.FileStateChanged += new EventHandler(project_StateChanged); OnProjectAdded(new ProjectEventArgs(project)); return project; }
/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> public VSSolutionGenerator(Project project, SolutionType version) : base(project) { Version = version; }
public void ShowDialog(Project project) { this.project = project; UpdateTexts(); UpdateValues(); ShowDialog(); if (DialogResult == DialogResult.OK) Settings.Default.Save(); else Settings.Default.Reload(); }
public ProjectEventArgs(Project project) { this.project = project; }
private bool RemoveProject(Project project, bool saveConfirmation) { if (saveConfirmation && project.IsDirty) { DialogResult result = MessageBox.Show( Strings.AskSaveChanges, Strings.Confirmation, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (!SaveProject(project)) return false; } else if (result == DialogResult.Cancel) { return false; } } if (projects.Remove(project)) { project.CloseItems(); project.Modified -= new EventHandler(project_StateChanged); project.FileStateChanged -= new EventHandler(project_StateChanged); OnProjectRemoved(new ProjectEventArgs(project)); if (ActiveProject == project) ActiveProject = null; return true; } return false; }
public bool RemoveProject(Project project) { return RemoveProject(project, true); }
/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> public void AddProject(Project project) { if (project == null) throw new ArgumentNullException("project"); if (!projects.Contains(project)) { projects.Add(project); project.Modified += new EventHandler(project_StateChanged); project.FileStateChanged += new EventHandler(project_StateChanged); if (project.FilePath != null) Settings.Default.AddRecentFile(project.FilePath); OnProjectAdded(new ProjectEventArgs(project)); } }
protected virtual SolutionGenerator CreateSolutionGenerator(Project project, SolutionType type) { return new VSSolutionGenerator(project, type); }
/// <exception cref="ArgumentNullException"> /// <paramref name="project"/> is null. /// </exception> public bool SaveProjectAs(Project project) { if (project == null) throw new ArgumentNullException("project"); using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.FileName = project.Name; dialog.InitialDirectory = project.GetProjectDirectory(); dialog.Filter = Strings.NClassProjectFiles + " (*.ncp)|*.ncp"; if (dialog.ShowDialog() == DialogResult.OK) { try { project.Save(dialog.FileName); Settings.Default.AddRecentFile(project.FilePath); return true; } catch (Exception ex) { MessageBox.Show(Strings.Error + ": " + ex.Message, Strings.SaveAs, MessageBoxButtons.OK, MessageBoxIcon.Error); } } return false; } }