Exemplo n.º 1
0
        static void Main()
        {
            MMirrorManager mm = MMirrorManager.Instance;

            //incase our downloaded data isnt complete, we just get what we last stored
            try
            {
                dynamic manager = JObject.Parse(File.ReadAllText(@"../../Data/tempArray.json"));

                stocks[] stock;
                stock = manager.stock.ToObject <List <stocks> >().ToArray();

                List <weatherDay> weather;
                weather = manager.weather.ToObject <List <weatherDay> >();

                mm.setStock(stock);
                mm.setWeather(weather);
            }
            catch (Exception)
            {
                stockController si = new stockController();
                si.getStockFile();

                weatherController wc = new weatherController(MMirrorManager.instance);
                wc.getWeatherJSON();
            }



            /* Application.EnableVisualStyles();
             * Application.SetCompatibleTextRenderingDefault(false);
             * stockView = new View.stockView();
             * edges = 0;
             * state = 0;
             * stockView.Visible = true;
             * stockView.startFadeinTimer();
             * Application.Run(stockView);
             *
             */

            InputPinConfiguration p = new InputPinConfiguration(ConnectorPin.P1Pin07.ToProcessor());
            GpioConnection        g = new GpioConnection(p);

            g.PinStatusChanged += g_detected;
        }
Exemplo n.º 2
0
        public void readStockInfo()
        {
            Settings      smo       = Settings.instance;
            List <String> stockList = smo.stocks;
            string        input     = data;
            //string input = File.ReadAllText(@"../../Data/stockInfo.csv");

            int i = 0, j = 0;

            string[,] result = new string[stockList.Count, 5];

            foreach (var row in input.Split('\n'))
            {
                j = 0;
                foreach (var col in row.Trim().Split(','))
                {
                    result[i, j] = col.Trim();
                    j++;
                }
                i++;
                if (i == stockList.Count)
                {
                    break;
                }
            }


            MMirrorManager mmc = MMirrorManager.instance;

            //creating temp stock instance, populate with data from array
            //watch out for N/A



            for (i = 0; i < stockList.Count; i++)
            {
                stocks temp = new stocks();
                temp.stockName = result[i, 0];
                if (result[i, 1] == "N/A")
                {
                    temp.closePrice = mmc.getStock(i).closePrice;
                }
                else
                {
                    temp.closePrice = Convert.ToDouble(result[i, 1]);
                }

                /*   if (result[i, 2] == "N/A")
                 * {
                 *     temp.volume = mmc.getStock(i).volume;
                 * }else
                 *     temp.volume = Convert.ToDouble(result[i, 2]);
                 *
                 * if (result[i, 1] == "N/A")
                 * {
                 *     temp.avgVolume = mmc.getStock(i).avgVolume;
                 * }else
                 *     temp.avgVolume = Convert.ToDouble(result[i, 3]);
                 */
                if (result[i, 1] == "N/A")
                {
                    temp.volatility = mmc.getStock(i).volatility;
                }
                else
                {
                    result[i, 4] = result[i, 4].Replace(" -", " ,");
                    result[i, 4] = result[i, 4].Replace(" , ,", " , -");
                    result[i, 4] = result[i, 4].Replace("\"", "");


                    temp.volatility = result[i, 4];
                }
                mmc.setStock(i, temp);
            }

            // printing debugger :D
            string json        = Newtonsoft.Json.JsonConvert.SerializeObject(mmc);

            File.WriteAllText(Path.Combine(Environment.CurrentDirectory, @"../../Data/", "tempArray.json"), json);
        }