Пример #1
0
        public void marketByOrderToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            MarketByOrder newMDIChild = new MarketByOrder(Subject, sender.ToString());

            // Set the parent form of the child window.
            newMDIChild.Text      = "Market Depth By Order (" + sender.ToString() + ")";
            newMDIChild.MdiParent = this;
            // Display the new form.
            newMDIChild.Show();
        }
        public void marketByOrderToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            //open the market by order and get the valid info
            var     returnVal  = this.GetBuyOrders();
            var     stringjson = parse_server_response(returnVal);
            JObject jsonData   = JObject.Parse(stringjson);

            JArray  ja = (JArray)jsonData[sender.ToString()];
            Company cmp;

            //this is for all buy orders
            foreach (var company in this.Subject.getCompanies())
            {
                if (company.Name == sender.ToString())
                {
                    cmp = company;
                    cmp.clearBuyOrders();
                    foreach (JObject jo in ja)
                    {
                        cmp.addBuyOrder(Double.Parse(jo["price"].ToString()), Int32.Parse(jo["volume"].ToString()));
                    }
                }
            }

            var     returnedSellVal = this.GetSellOrders();
            var     sellStringjson  = parse_server_response(returnedSellVal);
            JObject jsonSellData    = JObject.Parse(sellStringjson);

            JArray jsa = (JArray)jsonSellData[sender.ToString()];

            //this is for all sell orders
            foreach (var c in this.Subject.getCompanies())
            {
                if (c.Name == sender.ToString())
                {
                    c.clearSellOrders();
                    foreach (JObject jo in jsa)
                    {
                        c.addSellOrder(Double.Parse(jo["price"].ToString()), Int32.Parse(jo["volume"].ToString()));
                    }
                }
            }

            MarketByOrder newMDIChild = new MarketByOrder(Subject, sender.ToString());

            // Set the parent form of the child window.
            newMDIChild.Text      = "Market Depth By Order (" + sender.ToString() + ")";
            newMDIChild.MdiParent = this;
            // Display the new form.
            newMDIChild.Show();
        }