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; }
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 weatherController(MMirrorManager manager) { this.mmc = manager; }
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); }
public WeatherView() { InitializeComponent(); FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; tn = new Timer(); tn.Interval = 1; tn.Tick += t_Tick; InputPinConfiguration p = new InputPinConfiguration(ConnectorPin.P1Pin07.ToProcessor()); GpioConnection g = new GpioConnection(p); g.PinStatusChanged += g_Detected; this.Opacity = 0.5; MMirrorManager mmc = MMirrorManager.Instance; label2.Hide(); //lotta code, but im just populating the labels with the relevant data //current temp currentWeather.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[0].hi - 273.15) + "°C"); //next tweleve hours currentForecast1.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[0].twelveHourForcast[0] - 273.15) + "°C"); currentForecast2.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[0].twelveHourForcast[1] - 273.15) + "°C"); currentForecast3.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[0].twelveHourForcast[2] - 273.15) + "°C"); currentForecast4.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[0].twelveHourForcast[3] - 273.15) + "°C"); //time of the forecast calculations string[] times = new string[4]; int[] timesInt = new int[4]; for (int i = 0; i < times.Length; i++) { if (mmc.getWeather()[0].twelveHourTimes[i] > 12) { timesInt[i] = mmc.getWeather()[0].twelveHourTimes[i] - 12; times[i] = Convert.ToString(timesInt[i]) + "p"; } else if (mmc.getWeather()[0].twelveHourTimes[i] == 12) { timesInt[i] = mmc.getWeather()[0].twelveHourTimes[i]; times[i] = Convert.ToString(timesInt[i]) + "p"; } else if (mmc.getWeather()[0].twelveHourTimes[i] == 0) { timesInt[i] = mmc.getWeather()[0].twelveHourTimes[i] + 12; times[i] = Convert.ToString(timesInt[i]) + "a"; } else { timesInt[i] = mmc.getWeather()[0].twelveHourTimes[i]; times[i] = Convert.ToString(timesInt[i]) + "a"; } } currentTime1.Text = Convert.ToString(times[0]); currentTime2.Text = Convert.ToString(times[1]); currentTime3.Text = Convert.ToString(times[2]); currentTime4.Text = Convert.ToString(times[3]); //the image of the humidity Image humidity = Image.FromFile(@"../../Data/50d.png"); currentHumidityIMG.Size = new System.Drawing.Size(humidity.Width, humidity.Height); currentHumidityIMG.Image = humidity; //humidity currentHumidity.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[0].humidity) + "%"); currentLocation.Text = "Current weather"; location.Text = mmc.getWeather()[0].location; forecastWeather.Text = "Weather Forecast"; //image of current weather Image img = Image.FromFile(@"../../Data/" + mmc.getWeather()[0].weatherConditions + ".png"); currentImage.Size = new System.Drawing.Size(img.Width, img.Height); currentImage.Image = img; //only display this data if we recieve it if (mmc.getWeather()[0].rain == -50) { currentRain.Text = ""; } else { Image rain = Image.FromFile(@"../../Data/rain.png"); rainIMG.Size = new System.Drawing.Size(50, 50); rainIMG.Image = rain; currentRain.Text = Convert.ToString(Convert.ToDouble(mmc.getWeather()[0].rain) + "mm"); } if (mmc.getWeather()[0].snow == -50) { currentSnow.Text = ""; } else { Image snow = Image.FromFile(@"../../Data/snow.png"); snowIMG.Size = new System.Drawing.Size(50, 50); snowIMG.Image = snow; currentSnow.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[0].snow) + "cm"); } //the highs of the next few days forecastTemp1.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[1].hi - 273.15) + "°"); forecastTemp2.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[2].hi - 273.15) + "°"); forecastTemp3.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[3].hi - 273.15) + "°"); forecastTemp4.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[4].hi - 273.15) + "°"); //the los of the next 4 days forecastLo1.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[1].lo - 273.15) + "°"); forecastLo2.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[2].lo - 273.15) + "°"); forecastLo3.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[3].lo - 273.15) + "°"); forecastLo4.Text = Convert.ToString(Convert.ToInt32(mmc.getWeather()[4].lo - 273.15) + "°"); //the image of the next few days forecastIMG1.Size = new System.Drawing.Size(50, 50); forecastIMG2.Size = new System.Drawing.Size(50, 50); forecastIMG3.Size = new System.Drawing.Size(50, 50); forecastIMG4.Size = new System.Drawing.Size(50, 50); forecastIMG1.Image = Image.FromFile(@"../../Data/" + mmc.getWeather()[1].weatherConditions + ".png"); forecastIMG2.Image = Image.FromFile(@"../../Data/" + mmc.getWeather()[2].weatherConditions + ".png"); forecastIMG3.Image = Image.FromFile(@"../../Data/" + mmc.getWeather()[3].weatherConditions + ".png"); forecastIMG4.Image = Image.FromFile(@"../../Data/" + mmc.getWeather()[4].weatherConditions + ".png"); //the days of the weather forecast DateTime dt = DateTime.Now; Tomorrow.Text = Convert.ToString(dt.AddDays(1).DayOfWeek); tomorrow2.Text = Convert.ToString(dt.AddDays(2).DayOfWeek); tomorrow3.Text = Convert.ToString(dt.AddDays(3).DayOfWeek); tomorrow4.Text = Convert.ToString(dt.AddDays(4).DayOfWeek); startFadeinTimer(); try { wc.getWeatherJSON(); } catch (Exception) { } }