コード例 #1
0
        private void FindFormula(FormulaSpace fs, string Formula)
        {
            foreach (FormulaProgram fp in fs.Programs)
            {
                if (Formula == null)
                {
                    if (CurrentProgram == null)
                    {
                        CurrentProgram = fp;
                    }
                }
                else if (Formula == fp.Name)
                {
                    CurrentProgram = fp;
                }

                if (!IsPostBack)
                {
                    ddlFormula.Items.Add(new ListItem(fp.FullName, fp.Name));
                }
            }

            foreach (FormulaSpace fsc in fs.Namespaces)
            {
                FindFormula(fsc, Formula);
            }
        }
コード例 #2
0
        private void LoadToTree(TreeNode tn, FormulaProgram p, string FullName)
        {
            tn.Text = p.Name;
            bool b = false;

            if (CurrentName != null && CurrentName != "" && string.Compare(CurrentName, p.Name) == 0)
            {
                b = true;
            }
            if (!b && CurrentId == Index - 1)
            {
                b = true;
            }
            if (b)
            {
                CurrentNode     = tn;
                CurrentProgram  = p;
                CurrentFullName = FullName;
            }

            foreach (FormulaParam fp in p.Params)
            {
                TreeNode t = new TreeNode();
                t.ImageUrl = Root() + "/Images/Parameter.bmp";
                tn.Nodes.Add(t);
                LoadToTree(t, fp);
            }
        }
コード例 #3
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            //Create a Formula namespace
            FormulaSpace fms = new FormulaSpace("FML");

            //Create a Formula program , set Formula name and script code on the fly
            FormulaProgram fp = new FormulaProgram();

            fp.Name = tbFormulaName.Text;
            fp.Code = tbProgramScript.Text;

            //Add the script program to the Formula namespace
            fms.Programs.Add(fp);

            //Add parameters to Formula program
            for (int i = 1; i < 5; i++)
            {
                if (Request.Form["tbParamName" + i] != "")
                {
                    fp.Params.Add(new FormulaParam(
                                      Request.Form["tbParamName" + i],
                                      Request.Form["tbDefValue" + i],
                                      Request.Form["tbMinValue" + i],
                                      Request.Form["tbMaxValue" + i], FormulaParamType.Double));
                }
            }

            try
            {
                //Compile the Formula script on the fly
                Assembly    a  = fms.CompileInMemory();
                FormulaBase fb = FormulaBase.GetFormulaByName(a, fms.Name + "." + fp.Name);

                //Create YahooDataManager , Get stock data from yahoo.
                YahooDataManager ydm = new YahooDataManager();
                ydm.CacheRoot = HttpRuntime.AppDomainAppPath + "Cache\\";
                CommonDataProvider DataProvider = (CommonDataProvider)ydm[tbCode.Text];

                //Create financial chart instance
                FormulaChart fc = new FormulaChart();
                fc.PriceLabelFormat = "{CODE}";
                fc.LatestValueType  = LatestValueType.Custom;
                fc.AddArea("MAIN", 3);
                fc.AddArea(fb);
                fc.DataProvider = DataProvider;
                fc.SetSkin(Config.DefaultSkin);

                //Show the temp image just created
                lChart.Text = "<img src=ImageFromCache.aspx?CacheId=" + fc.SaveToImageStream(440, 440, ImageFormat.Png, 0, 0) + ">";
            }
            catch (FormulaErrorException fee)
            {
                //Show the compile result if the script has some errors
                lChart.Text = fee.ToHtml();
            }
        }
コード例 #4
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;
                }
            }
        }
コード例 #5
0
ファイル: Explore.aspx.cs プロジェクト: Bulletz4mysa/NBTrade
 private void LoadToTree(Msft.TreeNode tn, FormulaProgram p, string FullName)
 {
     tn.Text = p.Name;
     if (CurrentId == Index - 1)
     {
         CurrentNode     = tn;
         CurrentProgram  = p;
         CurrentFullName = FullName;
     }
     foreach (FormulaParam fp in p.Params)
     {
         Msft.TreeNode t = new Msft.TreeNode();
         t.ImageUrl = Root() + "/Images/Parameter.bmp";
         tn.Nodes.Add(t);
         LoadToTree(t, fp);
     }
 }
コード例 #6
0
        protected void btnOK_Click(object sender, System.EventArgs e)
        {
            //Create a Formula namespace
            FormulaSpace fms = new FormulaSpace("FML");

            //Create a Formula program , set Formula name and script code on the fly
            FormulaProgram fp = new FormulaProgram();

            fp.Name = tbFormulaName.Text;
            fp.Code = tbProgramScript.Text;

            //Add the script program to the Formula namespace
            fms.Programs.Add(fp);

            //Add parameters to Formula program
            for (int i = 1; i < 5; i++)
            {
                if (Request.Form["tbParamName" + i] != "")
                {
                    fp.Params.Add(new FormulaParam(
                                      Request.Form["tbParamName" + i],
                                      float.Parse(Request.Form["tbDefValue" + i]),
                                      float.Parse(Request.Form["tbMinValue" + i]),
                                      float.Parse(Request.Form["tbMaxValue" + i])));
                }
            }

            try
            {
                //Compile the Formula script on the fly
                Assembly    a  = fms.CompileInMemory(HttpRuntime.BinDirectory);
                FormulaBase fb = FormulaBase.GetFormulaByName(a, fms.Name + "." + fp.Name);

                //Create YahooDataManager , Get stock data from yahoo.
                YahooDataManager ydm = new YahooDataManager();
                ydm.CacheRoot = HttpRuntime.AppDomainAppPath + "Cache\\";
                CommonDataProvider DataProvider = (CommonDataProvider)ydm[tbCode.Text];

                //Create financial chart instance
                FormulaChart fc = new FormulaChart();
                fc.AddArea("MAIN", 3);
                fc.AddArea(fb);
                fc.DataProvider = DataProvider;
                fc.SetSkin(Config.DefaultSkin);


                //Show the temp image just created
                lChart.Text = "<img src=ImageFromCache.aspx?CacheId=" + fc.SaveToImageStream(440, 440, ImageFormat.Png, 0, 0) + ">";
            }
            catch (FormulaErrorException fee)
            {
                //Show the compile result if the script has some errors
                lChart.Text = "<font color=red>";
                foreach (System.CodeDom.Compiler.CompilerError ce in fee.ces)
                {
                    FormulaProgram fpa = fms.GetProgramByLineNum(ce.Line);
                    if (fpa != null)
                    {
                        fpa.AdjustErrors(ce);
                        lChart.Text += string.Format("Name:{0} line:{1} column:{2} error:{3} {4}<br>", fpa.Name, ce.Line, ce.Column, ce.ErrorNumber, ce.ErrorText);
                    }
                }
                lChart.Text += "</font>";
            }
        }