/// <summary>
        /// The event sequence when the formulator window is shown.
        /// </summary>
        /// <param name="sender">Button.</param>
        /// <param name="e">EventArgs.</param>
        private void formulatorButtonClicked(object sender, EventArgs e)
        {
            DataManager manager = m_owner.DataManager;
            if (manager.CurrentProject == null)
                return;
            m_fwin = new FormulatorDialog();
            m_fwin.SetExpression(false);

            List<string> list = new List<string>();
            List<string> mlist = manager.GetModelList();
            List<EcellObject> objList = manager.GetData(mlist[0], null);
            if (objList != null)
            {
                foreach (EcellObject obj in objList)
                {
                    if (obj is EcellSystem)
                    {
                        if (obj.Children == null) continue;
                        foreach (EcellObject data in obj.Children)
                        {
                            if (data is EcellProcess)
                            {
                                list.Add("Process:" + data.Key + ":Activity");
                            }
                            else if (data is EcellVariable)
                            {
                                list.Add("Variable:" + data.Key + ":MolarConc");
                            }
                        }
                    }
                }
            }
            m_fwin.AddReserveString(list);
            try
            {
                m_fwin.ImportFormulate(estimationFormulatorTextBox.Text);
                using (m_fwin)
                {
                    DialogResult res = m_fwin.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        string ext = m_fwin.Result;
                        estimationFormulatorTextBox.Text = ext;
                        m_param.EstimationFormulator = ext;
                    }
                }
            }
            catch (Exception ex)
            {
                Util.ShowErrorDialog(ex.Message);
                return;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Event of clicking the formulator button.
        /// Show the window to edit the formulator.
        /// </summary>
        private string ShowFormulatorDialog(string formula)
        {
            FormulatorDialog fwin = new FormulatorDialog();
            using (fwin)
            {
                List<string> list = new List<string>();
                list.Add("self.getSuperSystem().SizeN_A");
                foreach (EcellData d in m_current.Value)
                {
                    String str = d.Name;
                    if (str != EcellProcess.ACTIVITY &&
                        str != EcellProcess.EXPRESSION && str != EcellProcess.NAME &&
                        str != EcellProcess.PRIORITY && str != EcellProcess.STEPPERID &&
                        str != EcellProcess.VARIABLEREFERENCELIST && str != EcellProcess.ISCONTINUOUS)
                        list.Add(str);
                }
                foreach (EcellReference r in m_refList)
                {
                    list.Add(r.Name + ".MolarConc");
                }
                foreach (EcellReference r in m_refList)
                {
                    list.Add(r.Name + ".Value");
                }
                fwin.AddReserveString(list);

                // Edit Formula
                try
                {
                    fwin.ImportFormulate(formula);
                    if (fwin.ShowDialog() != DialogResult.OK)
                        return null;
                }
                catch (Exception e)
                {
                    Util.ShowErrorDialog(e.Message);
                    return formula;
                }
                return fwin.Result;
            }
        }