Beispiel #1
0
        private void fillFormulas()
        {
            Hashtable variables = recursive.Variables;

            formulaHash.Clear();
            formulaPanels.Clear();
            panelFormula.Controls.Clear();
            int top = 0;

            foreach (char c in variables.Keys)
            {
                PanelFormula p = new PanelFormula("" + c, this, panelFormula.Width, 200, Forms.FormDiffEquation.Variables, false, null, null);
                p.Left = 0;
                p.Top  = top;
                top   += p.Height;
                object[] o = variables[c] as object[];
                if (o[1] != null)
                {
                    string f = o[1] as string;
                    p.Formula = f;
                }
                panelFormula.Controls.Add(p);
                formulaHash[c] = p;
            }
        }
 private void acceptFormulas()
 {
     try
     {
         ResetCombo();
         int i = 0;
         foreach (Control c in panelFormula.Controls)
         {
             if (!(c is PanelFormula))
             {
                 continue;
             }
             PanelFormula p = c as PanelFormula;
             consumer.SetFormula(p.Formula, i);
             ++i;
         }
         consumer.AcceptFormulas();
         checkedListBoxP.Items.Clear();
         string par = consumer.AllVariables;
         foreach (char c in par)
         {
             checkedListBoxP.Items.Add("" + c);
         }
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
     }
 }
        private void createFormulaControls()
        {
            ArrayList formulas = new ArrayList();

            foreach (Control c in panelFormula.Controls)
            {
                if (!(c is PanelFormula))
                {
                    continue;
                }
                PanelFormula p = c as PanelFormula;
                formulas.Add(p.Formula);
            }
            panelFormula.Controls.Clear();
            int           w = panelFormula.Width;
            int           y = 0;
            IMeasurements m = consumer;
            int           n = m.Count;

            for (int i = 0; i < n; i++)
            {
                PanelFormula p = new PanelFormula(form + (i + 1), this, panelFormula.Width, 200,
                                                  "abcdfghijklmnopqrstuvwxyz", false, null, null);
                p.Left = 0;
                p.Top  = y;
                y     += p.Height;
                if (i < formulas.Count)
                {
                    string formula = formulas[i] as string;
                    p.Formula = formula;
                }
                panelFormula.Controls.Add(p);
            }
        }
        new internal void Load()
        {
            /*         userControlCommentsFont.AcceptComments += delegate(ICollection comm)
             *       {
             *           consumer.Comments = comm;
             *       };
             */
            PanelFormula.SetResize(panelFormula);
            fill();
            IList <string> a = consumer.AliasNames;

            numericUpDownOrder.Value = consumer.DerivationOrder;
            first = false;
            Diagram.UI.PropertyEditors.AliasTable.AddDicitionary(consumer, tempAliases);
            try
            {
                IAlias         alias = consumer;
                IList <string> al    = alias.AliasNames;
                propertyGridAlias.SetAlias(consumer);
                string str = consumer.AllVariables;
                foreach (char c in str)
                {
                    if (al.Contains(c + ""))
                    {
                        checkedListBoxP.Items.Add("" + c, CheckState.Checked);
                    }
                    else
                    {
                        checkedListBoxP.Items.Add("" + c, CheckState.Unchecked);
                    }
                }
                IMeasurements m = consumer;
                numericUpDownQuantity.Value = m.Count;
                fillFormulas();
                setComboboxes();
                userControlFeedBack.Reset();
                userControlFeedBack.Set(consumer.Feedback);
                userControlForward.Measurements = consumer;
                userControlForward.Items        = consumer.ForwardAliases;
                userControlForward.OnChange    += (Dictionary <int, string> d) =>
                {
                    consumer.ForwardAliases = userControlForward.Items;
                };
                IRuntimeUpdate start = consumer;

                checkBoxRuntimeUpdate.Checked            = start.ShouldRuntimeUpdate;
                checkBoxRuntimeUpdate.CheckStateChanged += (object o, EventArgs e) =>
                {
                    start.ShouldRuntimeUpdate = checkBoxRuntimeUpdate.Checked;
                };
            }
            catch (Exception ex)
            {
                ex.ShowError(10);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label">Component label</param>
        public FormRecursive(IObjectLabel label)
            : this()
        {
            PanelFormula.SetResize(panelFormula);
            this.label = label;
            recursive  = label.Object as Recursive;
            propertyGridAl.SetAlias(recursive);
            ArrayList comments = recursive.Comments;

            this.SetComments(comments);
            UpdateFormUI();
            fillVariables();
            fillFormulas();
            fillConstants();
            fillMeasurements();
            createAndFillAliasComboBox();
        }
Beispiel #6
0
 private void buttonAcceptForm_Click(object sender, EventArgs e)
 {
     try
     {
         Hashtable table = new Hashtable();
         foreach (char c in formulaHash.Keys)
         {
             PanelFormula p = formulaHash[c] as PanelFormula;
             table[c] = p.Formula;
         }
         recursive.Formulas = table;
         fillConstants();
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
     }
 }
Beispiel #7
0
        private void showEquations()
        {
            solver.ClearVariables();
            panelFormula.Controls.Clear();
            int           w    = panelFormula.Width;
            int           y    = 0;
            List <string> vars = new List <string>();

            foreach (string s in checkedListBoxV.CheckedItems)
            {
                vars.Add(s);
                Panel p = new PanelFormula(s, this, panelFormula.Width, 200, Variables, true, null, null);
                p.Left = 0;
                p.Top  = y;
                y     += p.Height;
                panelFormula.Controls.Add(p);
            }
            userControlCharIntDictionary.Keys = vars;
        }
Beispiel #8
0
 private void acceptEquations()
 {
     try
     {
         solver.ClearParameters();
         Hashtable t = new Hashtable();
         foreach (DataRow row in dataTableInitial.Rows)
         {
             string s = row[0] as string;
             double x = (double)row[1];
             t[s[0]] = x;
         }
         dataTableInitial.Clear();
         foreach (Control c in panelFormula.Controls)
         {
             if (!(c is PanelFormula))
             {
                 continue;
             }
             PanelFormula p   = c as PanelFormula;
             char         var = p.Variable;
             solver.AddVariable(var);
             solver.SetVariable(var, p.Formula);
             double x = 0;
             if (t.ContainsKey(var))
             {
                 x = (double)t[var];
             }
             dataTableInitial.Rows.Add(new object[] { var + "", x });
         }
         string par = solver.AllParameters;
         checkedListBoxP.Items.Clear();
         foreach (char c in par)
         {
             checkedListBoxP.Items.Add("" + c);
         }
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
     }
 }
        private void fillFormulas()
        {
            panelFormula.Controls.Clear();
            int           w = panelFormula.Width;
            int           y = 0;
            IMeasurements m = consumer;
            int           n = m.Count;

            for (int i = 0; i < n; i++)
            {
                PanelFormula p = new PanelFormula(form + (i + 1), this, panelFormula.Width, 200,
                                                  "abcdfghijklmnopqrstuvwxyz", false, null, null);
                p.Left = 0;
                p.Top  = y;
                y     += p.Height;
                panelFormula.Controls.Add(p);
                string f = consumer.GetFormula(i);
                if (f != null)
                {
                    p.Formula = f;
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label"></param>
        public FormDiffEquation(IObjectLabel label)
            : this()
        {
            PanelFormula.SetResize(panelFormula);
            this.label = label;
            solver     = label.Object as DifferentialEquationSolver;
            consumer   = solver;
            // ArrayList comments = solver.Comments;
            this.SetComments(solver.Comments);
            numericUpDownDerivationOrder.Value = solver.DerivationOrder;
            first = false;
            string        var = "";
            List <string> vv  = new List <string>();

            foreach (char c in solver.Keys)
            {
                var += c;
                vv.Add(c + "");
            }
            for (int i = 0; i < Variables.Length; i++)
            {
                char v = Variables[i];
                if (var.IndexOf(v) > -1)
                {
                    checkedListBoxV.Items.Add("" + v, CheckState.Checked);
                }
                else
                {
                    checkedListBoxV.Items.Add("" + v, CheckState.Unchecked);
                }
            }
            userControlCharIntDictionary.Minimum = 1;
            userControlCharIntDictionary.Keys    = vv;
            Dictionary <string, int> dder = new Dictionary <string, int>();
            Dictionary <string, int> dor  = solver.DerivationOrders;

            foreach (string key in dor.Keys)
            {
                dder[key] = dor[key] + 1;
            }
            userControlCharIntDictionary.Dictionary = dder;
            string         str = solver.AllParameters;
            IList <string> l   = solver.AliasNames;

            foreach (char c in str)
            {
                string s = c + "";
                if (l.Contains(s))
                {
                    checkedListBoxP.Items.Add(s, CheckState.Checked);
                }
                else
                {
                    checkedListBoxP.Items.Add(s, CheckState.Unchecked);
                }
            }
            int top = 0;

            foreach (char c in solver.Keys)
            {
                PanelFormula p = new PanelFormula("" + c, this, panelFormula.Width, 200, Variables, true, null, null);
                p.Left    = 0;
                p.Top     = top;
                top      += p.Height;
                p.Formula = solver[c];
                panelFormula.Controls.Add(p);
            }
            UpdateFormUI();
            setFormulas();
            fillTable();
            createAndFillAliasComboBox();
        }