public static void BuildTreeView(TreeNode node, string dir, Project project, ContextMenuStrip synthDirAndFileMenu) { DirectoryInfo dInfo = new DirectoryInfo(dir); //Loop through the subdirs foreach (DirectoryInfo directory in dInfo.GetDirectories()) { TreeNode t = new TreeNode(directory.Name); Regex synDirRegEx = new Regex(@"\d+_{1}"); bool synDirMatch = synDirRegEx.IsMatch(directory.Name); if (synDirMatch) { Console.WriteLine("Building TreeView, found a syn dir match " + directory.Name); t.Tag = new SynthesisDirectory(directory.FullName, project); t.ContextMenuStrip = synthDirAndFileMenu; } t.Name = directory.FullName; BuildTreeView(t, directory.FullName, project, synthDirAndFileMenu); node.Nodes.Add(t); } foreach (FileInfo file in dInfo.GetFiles()) { TreeNode t = new TreeNode(file.Name); t.Name = file.FullName; t.ContextMenuStrip = synthDirAndFileMenu; t.Tag = project.FindSynthesis(Path.GetFileNameWithoutExtension(file.FullName)); node.Nodes.Add(t); } }
public ReactionListViewTabPage(Project project) { InitializeComponent(); currentProject = project; BuildList(); //this.Paint +=new PaintEventHandler(this.paint); }
public SynthesisDirectory(string path, Project project) { DInfo = new DirectoryInfo(path); OwningProject = project; FileInfo[] synthFInfo = DInfo.GetFiles("*.syn", SearchOption.TopDirectoryOnly); string synthName = Path.GetFileNameWithoutExtension(synthFInfo[0].Name); Synth = OwningProject.FindSynthesis(synthName); }
public static void DeleteSynthesisFolder(Synthesis syn, Project project) { //Folder names for a synthesis are generated by an index 0-whatever an underscore and the synthesis name, so 0_synthesisname int projectID = syn.ProjectID; if (projectID == -1) { //the synthesis was not found in the project list, report error Console.WriteLine("Attempting to delete a syn folder but the synthesis is not present in the current project"); } string foldername = projectID + "_" + syn.Name; string folderpath = project.ProjectPath + "\\" + foldername; Directory.Delete(folderpath, true); //delete the folder and all contents }
public static void SaveSynFile(Synthesis syn, Project project) { Header header = new Header(project.ProjectUser.UserID, DateTime.Now, 0); //Determine the new folder for this synthesis //Folder names for a synthesis are generated by an index 0-whatever an underscore and the synthesis name, so 0_synthesisname int index = project.AllSyntheses.IndexOf(syn); if (index == -1) { //the synthesis was not found in the project list, report error Console.WriteLine("Attempting to save a syn file but the synthesis is not present in the current project"); } string foldername = index + "_" + syn.Name; string folderpath = project.ProjectPath + "\\" + foldername; Directory.CreateDirectory(folderpath); //Create a folder for spectra Directory.CreateDirectory(folderpath + "\\spectra"); //and one for the molecules Directory.CreateDirectory(folderpath + "\\molecules"); //And finally write the syn file List<Edit> edits = new List<Edit>(); edits.Add(new Edit(syn, DateTime.Now)); SynTypeFileWriter.WriteFile(header, edits, folderpath + "\\" + syn.Name+".syn"); }
private void AddReactionListViewTabPage(Project project) { tabControl.TabPages.Add("All Reactions"); ReactionListViewTabPage control = new ReactionListViewTabPage(project); control.Anchor = (AnchorStyles.Bottom | AnchorStyles.Top); control.Dock = DockStyle.Fill; tabControl.TabPages[tabControl.TabPages.Count - 1].Controls.Add(control); //switch to the new tab tabControl.SelectTab(tabControl.TabPages[tabControl.TabPages.Count - 1]); }
private void OpenProject(User user, ProjectInfo projectInfo) { this.user = user; this.Text = "SynType " + this.user.UserInitials + " loaded project: " + projectInfo.ProjectName; currentProject = new Project(projectInfo.ProjectName, projectInfo.ProjectPath, user); if (currentProject.AllSyntheses.Count == 0) { //IF there are no syntheses then we prompt the user to create a new one if (MessageBox.Show("The project is empty, would you like to create a new synthesis now?", "Create a new synthesis?", MessageBoxButtons.YesNo) == DialogResult.Yes) { InputDialog inputDialog = new InputDialog("Enter a name for the new synthesis"); if (inputDialog.ShowDialog() == DialogResult.OK) { while(string.IsNullOrEmpty(inputDialog.Input)) { if (inputDialog.ShowDialog() == DialogResult.Cancel) return; } Synthesis newSynth = new Synthesis(inputDialog.Input, currentProject.GetNewProjectID()); currentSynthesis = newSynth; currentProject.AllSyntheses.Add(currentSynthesis); //Save the synthesis FFManager.SaveSynFile(currentSynthesis, currentProject); } } } UpdateTreeView(); }