Ejemplo n.º 1
0
 public FormulaProgram FindFormulaProgram(string Path, FormulaBase fb)
 {
     if (Path == "")
     {
         Path = this.Name;
     }
     else if (!this.GroupOnly)
     {
         Path = Path + "." + this.Name;
     }
     foreach (FormulaProgram program in this.Programs)
     {
         if (string.Compare(Path + "." + program.Name, fb.GetType().ToString(), true) == 0)
         {
             return(program);
         }
     }
     foreach (FormulaSpace space in this.Namespaces)
     {
         FormulaProgram program2 = space.FindFormulaProgram(Path, fb);
         if (program2 != null)
         {
             return(program2);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
        public FormulaProgram FindFormulaProgram(string Path, FormulaBase fb)
        {
            if (Path == "")
            {
                Path = Name;
            }
            else
            {
                if (!GroupOnly)
                {
                    Path += "." + Name;
                }
            }

            foreach (FormulaProgram fp in Programs)
            {
                if (string.Compare(Path + "." + fp.Name, fb.GetType().ToString(), true) == 0)
                {
                    return(fp);
                }
            }

            foreach (FormulaSpace fs in Namespaces)
            {
                FormulaProgram fp = fs.FindFormulaProgram(Path, fb);
                if (fp != null)
                {
                    return(fp);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        private void tvFormula_AfterSelect(object sender, TreeViewEventArgs e)
        {
            string str = (String)e.Node.Tag;

            if (str != null)
            {
                gbParam.Controls.Clear();
                int            i1             = 10;
                int            j1             = 20;
                int            k1             = 30;
                int            i2             = 0;
                FormulaBase    formulaBase    = FormulaBase.GetFormulaByName(str);
                FormulaProgram formulaProgram = PluginManager.GetFormulaProgram(formulaBase);
                if (formulaProgram != null)
                {
                    lFullName.Text = formulaProgram.FullName;
                    tbDesc.Text    = formulaProgram.Description;
                }
                else
                {
                    lFullName.Text = formulaBase.GetType().ToString();
                    tbDesc.Text    = "";
                }
                for (int j2 = 0; j2 < formulaBase.Params.Count; j2++)
                {
                    Label label1 = new Label();
                    label1.AutoSize = true;
                    label1.Text     = String.Concat(formulaBase.Params[j2].Name, "=");
                    label1.Left     = i1;
                    label1.Top      = j1 + 3;
                    label1.Parent   = gbParam;
                    i2  = Math.Max(i2, label1.Width);
                    j1 += k1;
                }
                j1  = 20;
                i1 += i2 + 6;
                for (int k2 = 0; k2 < formulaBase.Params.Count; k2++)
                {
                    TextBox textBox = new TextBox();
                    textBox.Left   = i1;
                    textBox.Top    = j1;
                    textBox.Text   = formulaBase.Params[k2].DefaultValue;
                    textBox.Parent = gbParam;
                    Label label2 = new Label();
                    label2.AutoSize = true;
                    label2.Text     = String.Concat(new string[] { "(", formulaBase.Params[k2].MinValue, "--", formulaBase.Params[k2].MaxValue, ")" });
                    label2.Left     = i1 + textBox.Width + 6;
                    label2.Top      = j1 + 3;
                    label2.Parent   = gbParam;
                    j1 += k1;
                }
            }
        }
Ejemplo n.º 4
0
        public static string GetFormulaFile(FormulaBase fb)
        {
            string assemblyKey = FormulaBase.GetAssemblyKey(fb.GetType().Assembly);

            if (assemblyKey != null)
            {
                foreach (string str2 in htAssembly.Keys)
                {
                    if (htAssembly[str2].ToString() == assemblyKey)
                    {
                        return(str2);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get formula source xml file of a certain formula.
        /// </summary>
        /// <param name="fb"></param>
        /// <returns></returns>
        public static string GetFormulaFile(FormulaBase fb)
        {
            Assembly a   = fb.GetType().Assembly;
            string   Key = FormulaBase.GetAssemblyKey(a);

            if (Key != null)
            {
                foreach (string s in htAssembly.Keys)
                {
                    if (htAssembly[s].ToString() == Key)
                    {
                        return(s);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
 private void AddFavorite(string[] Formulas)
 {
     ddlFavoriteFormula.Items.Clear();
     ddlFavoriteFormula.Items.Add("Select to add new formula");
     foreach (string s in Formulas)
     {
         FormulaBase fb = FormulaBase.GetFormulaByName(s);
         foreach (object o in ddlFavoriteFormula.Items)
         {
             if (o.GetType() == fb.GetType())
             {
                 goto Next;
             }
         }
         ddlFavoriteFormula.Items.Add(fb);
         Next :;
     }
     ddlFavoriteFormula.SelectedIndex = 0;
 }
Ejemplo n.º 7
0
        private void CreateNode(FormulaBase fb)
        {
            string r = fb.GetType().ToString();

            if (r.StartsWith("FML."))
            {
                r = r.Substring(4);
            }
            int i = r.IndexOf('.');

            if (i < 0)
            {
                r = "Basic." + r;
            }

            TreeNode tn = tvFormula.Nodes[0];

            while ((i = r.IndexOf('.')) > 0)
            {
                string s = r.Substring(0, i);
                r = r.Substring(i + 1);
                TreeNode tnNew = null;
                for (int j = 0; j < tn.Nodes.Count; j++)
                {
                    if (tn.Nodes[j].Text == s)
                    {
                        tnNew = tn.Nodes[j];
                        break;
                    }
                }
                if (tnNew == null)
                {
                    tn.Nodes.Add(tnNew = new TreeNode(s, 0, 0));
                }

                tn = tnNew;
            }
            TreeNode tnText = new TreeNode(fb.CombineName, 1, 1);

            tnText.Tag = fb;
            tn.Nodes.Add(tnText);
        }