Exemple #1
0
 private void CopyStructure_Click(object sender, EventArgs e)
 {
     if (CidCtl.Text != "")
     {
         MolCtl.CopyMoleculeToClipboard();
     }
 }
Exemple #2
0
/// <summary>
/// Display the structure and other basic data for the supplied cid
/// </summary>
/// <param name="cidArg"></param>

        void DisplayCidData(string cidArg)
        {
            MoleculeMx str = null;
            string     mwTxt = "", mfTxt = "", haTxt = "", tok;

            string intCid = CompoundId.Normalize(cidArg, RootTable);
            string extCid = CompoundId.Format(intCid, RootTable);

            CidCtl.Text = extCid;

            if (RootTable == null || RootTable.KeyMetaColumn.DataType == MetaColumnType.CompoundId)
            {
                str = MoleculeUtil.SelectMoleculeForCid(intCid, RootTable);
            }

            if (Lex.IsDefined(str?.PrimaryValue))             // have a structure with at least one atom
            {
                if (str.PrimaryDisplayFormat == MoleculeRendererType.Chemistry)
                {
                    int ha = str.HeavyAtomCount;
                    if (ha > 0)
                    {
                        haTxt = ha.ToString();
                    }

                    double mw = str.MolWeight;
                    if (mw >= 0)
                    {
                        mwTxt = String.Format("{0:f3}", mw);
                    }
                    HeavyAtoms.Text = "";
                    Weight.Text     = mwTxt;

                    string mf = str.MolFormula;
                    HeavyAtoms.Text = "";
                    Formula.Text    = mf;
                }

                else
                {
                }                        // biopolymer, don't calc structure props (too slow for now)

                HeavyAtoms.Text = haTxt;
                Weight.Text     = mwTxt;
                Formula.Text    = mfTxt;

                MolCtl.Molecule = str;

                return;
            }

            else             // no structure
            {
                HeavyAtoms.Text = "";
                Weight.Text     = "";
                Formula.Text    = "";
                MolCtl.ClearMolecule();
                return;
            }
        }
Exemple #3
0
        private void ClearListMenuItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DialogResult dr = MessageBoxMx.Show(
                "Are you sure you want to clear the list?", "Clear List",
                MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                CidListCtl.Text = "";
                CidCtl.Text     = HeavyAtoms.Text = Weight.Text = Formula.Text = "";
                MolCtl.ClearMolecule();
                DisplayFrame.Text = "Item 1 of 1";
            }
            CidListCtl.Focus();
        }
Exemple #4
0
/// <summary>
/// Setup for edit
/// </summary>
/// <param name="inList"></param>
/// <param name="rootTable"></param>
/// <returns></returns>

        bool Setup(
            CidList inList,
            MetaTable rootTable)
        {
            string formattedCid, label, txt;

            RootTable = rootTable;

            InListName = inList.UserObject.Name;
            ListName   = InListName;

            CidList  = inList.Clone();        // make copy of list to edit
            CidCount = InitialCount = CidList.Count;
            if (CidCount > 32000)             // too big to edit?
            {
                txt =
                    "The list contains " + CidList.Count.ToString() + " compound numbers which\n" +
                    "exceeds the maximum of 32,000 that can be directly edited.\n" +
                    " Do you want to clear the list and start a new list?";

                DialogResult dr = MessageBoxMx.Show(txt, "List Too Large to Edit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);

                if (dr != DialogResult.Yes)
                {
                    return(false);
                }

                CidList            = new CidList();
                CidList.UserObject =                         // set name properly
                                     UserObjectUtil.ParseInternalUserObjectName(InListName, UserObjectType.CnList);
            }

            Text = "Edit List - [" + CidList.UserObject.Name + "]";

            Before = FormatList();             // convert & save initial list

            if (rootTable != null)
            {
                label = rootTable.KeyMetaColumn.Label;
            }
            else
            {
                label = "Compound Id";
            }

            ListLabel.Text = " " + label + " - (Enter one number per line) ";
            RNLabel.Text   = label + ":";

            MolCtl.ClearMolecule();             // clear any structure
            CidCtl.Text = HeavyAtoms.Text = Weight.Text = Formula.Text = "";

            CidListCtl.Text = Before;             // put text in editor

            DisplayStatusMsg("");

            if (SS.I.AllowGroupingBySalts)
            {
                SaltsMenu.Enabled = true;
            }
            else
            {
                SaltsMenu.Enabled = false;
            }

            return(true);
        }