private void GetStructureFromImage() { try { IDataObject clipData = Clipboard.GetDataObject(); if (clipData.GetDataPresent(DataFormats.Bitmap)) { Cursor = Cursors.WaitCursor; Image imgChemistry = Clipboard.GetImage(); string strMol_out = ""; bool blIsChiral_out = false; string strErrMsg_out = ""; if (ImageToStructure.GetStructureFromImage(imgChemistry, out strMol_out, out blIsChiral_out, out strErrMsg_out)) { chemRenditor.MolfileString = strMol_out; Cursor = Cursors.Default; } else { Cursor = Cursors.Default; MessageBox.Show(strErrMsg_out); } } Clipboard.Clear(); } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } Cursor = Cursors.Default; }
private void GetStructureFromImage() { try { IDataObject clipData = Clipboard.GetDataObject(); if (clipData.GetDataPresent(DataFormats.Bitmap)) { Cursor = Cursors.WaitCursor; Image imgChemistry = Clipboard.GetImage(); string strMol_out = ""; bool blIsChiral_out = false; string strErrMsg_out = ""; if (ImageToStructure.GetStructureFromImage(imgChemistry, out strMol_out, out blIsChiral_out, out strErrMsg_out)) { ChemRenditor.MolfileString = strMol_out; try { chemaxon.util.MolHandler molHandler_Trgt = new MolHandler(ChemRenditor.MolfileString); Molecule molObj = molHandler_Trgt.getMolecule(); txtMolWeight.Text = molObj.getMass().ToString(); txtMolFormula.Text = molObj.getFormula(); string strMolfile = molObj.toFormat("mol"); string strIUPACName = ""; string strErrMsg = ""; if (ChemistryOperations.GetIUPACNameFromStructure(strMolfile, out strIUPACName, out strErrMsg)) { strIUPACName = ChemistryOperations.RemoveSMILESFromIUPACName(strIUPACName); strIUPACName = ChemistryOperations.GetConvertedIUPACName(strIUPACName); } else { strIUPACName = "IUPAC name not provided"; } } catch { } //if (molObj.isAbsStereo()) //{ // lblChiral.Visible = true; //} //else //{ // lblChiral.Visible = false; //} //txtIUPACName.Text = strIUPACName; Cursor = Cursors.Default; } else { Cursor = Cursors.Default; MessageBox.Show(strErrMsg_out); } Clipboard.Clear(); } } catch (Exception ex) { ErrorHandling.WriteErrorLog(ex.ToString()); } Cursor = Cursors.Default; }