/* List<Edit> edits; //everything is stored by edits public List<Edit> Edits { get { return edits; } set { edits = value; } } */ //Records when an edit has occured and what the edit was //The above structures contain the most updated version of the synthesis /* <localid>rc1</localid> <name>benzaldehyde</name> <refid>aldehyde</refid> <molweight>106.12</molweight> <state>solid</state> <density temp="20">null</density> <islimiting>true</islimiting> <mols unit="mmol">57</mols> <mass unit="g">6</mass> <volume>null</volume> * */ public static Synthesis ReadFile(string filename) { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlNode header = doc.GetElementById("header"); XmlNodeList editHeader = doc.GetElementsByTagName("editheader"); XmlNodeList reactantNodeList = doc.GetElementsByTagName("reactant"); XmlNodeList reagentNodeList = doc.GetElementsByTagName("reagent"); XmlNodeList productNodeList = doc.GetElementsByTagName("product"); ObservableCollection<Compound> reactants = ReadBlock(reactantNodeList, COMPOUND_TYPES.Reactant); ObservableCollection<Compound> reagents = ReadBlock(reagentNodeList, COMPOUND_TYPES.Reagent); ObservableCollection<Compound> products = ReadBlock(productNodeList, COMPOUND_TYPES.Product); string synthName = GetSynthesisName(editHeader); int projectID = GetSynthesisProjectID(editHeader); SynthesisInfo previousStep = GetPreviousStep(editHeader); SynthesisInfo nextStep = GetNextStep(editHeader); string procedureText = GetProcedureText(editHeader); Synthesis synth = new Synthesis(reactants, reagents, products, synthName, projectID, previousStep, nextStep, procedureText); ReadMolData(doc, synth.AllCompounds); return synth; }
public AddCompoundForm(Form1 form1, Synthesis synthesis) { currentSynthesis = synthesis; InitializeComponent(); parent = form1; }
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 Form1() { InitializeComponent(); FFManager.FirstRunSetup("rap"); currentOpenSyntheses = new List<Synthesis>(); currentSynthesis = new Synthesis(); tabControl.Selecting += new TabControlCancelEventHandler(tabControl_Selecting); user = new User("rap","Richard Albert Peck","rap"); OpenLastOpenedProject(); }
private void AddNewTabPage(Synthesis synthesis) { currentOpenSyntheses.Add(synthesis); tabControl.TabPages.Add(new TabPage(synthesis.Name)); TabPageControl control = new TabPageControl(this, synthesis); 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]); currentSynthesis = currentOpenSyntheses.Last(); }
public TabPageControl(Form1 form1, Synthesis synthesis) { InitializeComponent(); baseForm = form1; //init the synthesis we are showing currentSynthesis = synthesis; currentSynthesis.SynthesisChanged += new SynthesisChangedEventHandler(currentSynthesis_SynthesisChanged); //next the data grid SetupDataGridView(); //and then the reaction viewer reactionViewer1.Synth = currentSynthesis; reactionViewer1.Paint +=new PaintEventHandler(reactionViewer1.paint); //and finally the textboxes procedureInputBox.TextChanged += new EventHandler(procedureInputBox_TextChanged); UpdateControl(); }
public Edit(Synthesis synth, DateTime dt) { this.synth = synth; editTime = dt; }
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"); }
public Procedure(Synthesis mySynthesis, string text) { this.rawText = text; MySynthesis = mySynthesis; }
void tabControl_Selecting(object sender, TabControlCancelEventArgs e) { ReactionListViewTabPage reactionListViewTab = e.TabPage.GetChildAtPoint(new Point(0, 0)) as ReactionListViewTabPage; //if we are looking at a synthesis tab we want to change our current synthesis to that TabPageControl synthesisTab = e.TabPage.GetChildAtPoint(new Point(0, 0)) as TabPageControl; if(synthesisTab != null) currentSynthesis = synthesisTab.currentSynthesis; }
void synthAddNextDeleteMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { TreeNode selectedNode = projectView.SelectedNode; if (selectedNode == null) { Console.WriteLine("Tag is somehow null on an item"); return; } Synthesis synthesisToAlter; //first check if its a folder SynthesisDirectory synthDir = selectedNode.Tag as SynthesisDirectory; if (synthDir != null) synthesisToAlter = synthDir.Synth; else synthesisToAlter = selectedNode.Tag as Synthesis; if (synthesisToAlter == null) return; if (e.ClickedItem.Text == "Add Next Step") { 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; } } //unregister our last event handler //currentSynthesis.SynthesisChanged -= new SynthesisChangedEventHandler(currentSynthesis_SynthesisChanged); Synthesis newSynth = new Synthesis(inputDialog.Input, currentProject.GetNewProjectID()); //set the next step to be our new synthesis, and the new synthesis' previous step to be the old synthesis currentSynthesis.NextStep = new SynthesisInfo(newSynth.Name, newSynth.ProjectID); newSynth.PreviousStep = new SynthesisInfo(currentSynthesis.Name, currentSynthesis.ProjectID); //and before we change our synthesis we save the current synth to update its nextstep property FFManager.SaveSynFile(currentSynthesis, currentProject); //Add a new tab with this synthesis AddNewTabPage(newSynth); //Save the synthesis FFManager.SaveSynFile(currentSynthesis, currentProject); } //build the tree view UpdateTreeView(); } else { PromptUserToDeleteSynthesis(synthesisToAlter); } }
private void PromptUserToDeleteSynthesis(Synthesis syn) { if (MessageBox.Show("Are you sure you wish to delete the selected synthesis? This action can not be undone", "Delete synthesis?", MessageBoxButtons.YesNo) == DialogResult.Yes) { //user selected yes so we delete the synthesis FFManager.DeleteSynthesisFolder(syn, currentProject); currentProject.AllSyntheses.Remove(syn); UpdateTreeView(); } }
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(); }
//Creates a new synthesis, opening it in a new tab private void newSynthesisToolStripMenuItem_Click(object sender, EventArgs e) { 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()); AddNewTabPage(newSynth); //currentSynthesis.UpdateSynthesis(); currentProject.AllSyntheses.Add(currentSynthesis); //Save the synthesis FFManager.SaveSynFile(currentSynthesis, currentProject); } //build the tree view UpdateTreeView(); }
public void LoadSynthesis(Synthesis synthesis) { currentSynthesis = synthesis; currentSynthesis_SynthesisChanged(this, EventArgs.Empty); }