public stockView() { //when implementing this, just call whatever the onCLick calls, hopefully we wont crash and fail :)))) InitializeComponent(); FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; t = new Timer(); t.Interval = 10; t.Tick += t_Tick; InputPinConfiguration p = new InputPinConfiguration(ConnectorPin.P1Pin07.ToProcessor()); GpioConnection g = new GpioConnection(p); g.PinStatusChanged += g_Detected; this.Opacity = 0; MMirrorManager mmc = MMirrorManager.instance; label42.Hide(); List <Label> stockData = new List <Label>(40); var c = GetAll(this, typeof(Label)); for (int i = 0; i < c.Count(); i++) { c.ElementAt(i).Text = ""; } label42.Text = "No Internet Connection. Try again Later"; label1.Text = mmc.getStock(0).stockName; label2.Text = mmc.getStock(1).stockName; label3.Text = mmc.getStock(2).stockName; label4.Text = mmc.getStock(3).stockName; //the ugly forward slashes below are because we were converting the settings from an html file and apparently couldnt remove all the tags if (mmc.getStock(4).stockName == "\"^FTSE\"") { label5.Text = "FTSE 100"; } else if (mmc.getStock(4).stockName == "\"^FTMC\"") { label5.Text = "FTSE 250"; } else if (mmc.getStock(4).stockName == "\"^N225\"") { label5.Text = "NIKKEI"; } if (mmc.getStock(5).stockName == "\"BZZ15.NYM\"") { label6.Text = "Brent Crude Oil"; } else if (mmc.getStock(5).stockName == "\"^GSPC\"") { label6.Text = "S" + '&' + "P 500"; } else if (mmc.getStock(5).stockName == "\"WTI\"") { label6.Text = "WTI"; } label9.Text = mmc.getStock(0).closePrice + ""; label10.Text = mmc.getStock(1).closePrice + ""; label11.Text = mmc.getStock(2).closePrice + ""; label12.Text = mmc.getStock(3).closePrice + ""; label13.Text = mmc.getStock(4).closePrice + ""; label14.Text = mmc.getStock(4).closePrice + ""; label33.Text = mmc.getStock(0).volatility; label34.Text = mmc.getStock(1).volatility; label35.Text = mmc.getStock(2).volatility; label36.Text = mmc.getStock(3).volatility; label21.Text = mmc.getStock(4).volatility; label22.Text = mmc.getStock(5).volatility; startFadeinTimer(); try { sc.getStockFile(); } catch (Exception) { } }
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); }