public void Process() { while (true) { try { weatherRequest = "https://api.openweathermap.org/data/2.5/weather?q=" + Settings.City + "&appid=da5bd0105833e7d94fbfcb03212a19b6&units=metric"; WebClient webClient = new WebClient(); weatherResponse = webClient.DownloadString(weatherRequest).Replace("base", "based");//замена из-за резервации base языком WeatherResponse responseObject = JsonSerializer.Deserialize <WeatherResponse>(weatherResponse); //image.ImageLocation = "http://openweathermap.org/img/wn/" + responseObject.weather[0].icon + "@2x.png"; if (panel.BackgroundImage != Image.FromFile("weather-pictures/" + responseObject.weather[0].icon + ".png")) { panel.BackgroundImage = Image.FromFile("weather-pictures/" + responseObject.weather[0].icon + ".png"); } SafeWriter.WriteTextSafe(Math.Round(responseObject.main.temp).ToString() + "°", temperature); SafeWriter.WriteTextSafe(DateTime.Now.DayOfWeek.ToString() + ", " + DateTime.Now.Date.Day.ToString() + " " + DateTime.Now.ToString("MMMM"), date); SafeWriter.WriteTextSafe(responseObject.weather[0].description, condition); SafeWriter.WriteTextSafe(Settings.City, city); //MessageBox.Show(weatherResponse); //MessageBox.Show(responseObject.weather[0].description.ToString()); } catch (WebException ex) { MessageBox.Show(ex.Message + ex.Data); } Thread.Sleep(5000); } }
public void Process() { while (true) { SafeWriter.WriteTextSafe(DateTime.Now.ToShortTimeString(), time); SafeWriter.WriteTextSafe(DateTime.Now.Day.ToString() + " / " + DateTime.Now.Month.ToString(), date); SafeWriter.WriteTextSafe(DateTime.Now.DayOfWeek.ToString(), day); Thread.Sleep(1000); } }
public void Process() { while (true) { try { WebClient webClient = new WebClient(); currentCurrencyResponse = webClient.DownloadString(currencyRequest).Replace("base", "based"); //MessageBox.Show(currentCurrencyResponse); CurrencyResponse currencyResponse = JsonSerializer.Deserialize <CurrencyResponse>(currentCurrencyResponse); yesterdayCurrencyRequest = "https://openexchangerates.org/api/historical/" + DateTime.Now.AddDays(-1).Year + "-" + DateTime.Now.AddDays(-1).ToString("MM") + "-" + DateTime.Now.AddDays(-1).ToString("dd") + ".json?app_id=837b5e828db04d0dbb2a01367acfad5c&symbols=RUB,EUR"; //MessageBox.Show(yesterdayCurrencyRequest); yesterdayCurrencyResponse = webClient.DownloadString(yesterdayCurrencyRequest).Replace("base", "based"); //MessageBox.Show(yesterdayCurrencyResponse); CurrencyResponse currencyResponseYesterday = JsonSerializer.Deserialize <CurrencyResponse>(yesterdayCurrencyResponse); if (currencyResponse.rates["RUB"] > currencyResponseYesterday.rates["RUB"]) { usdTendency.ImageLocation = "currency-pictures/up-tendency.png"; } else { usdTendency.ImageLocation = "currency-pictures/down-tendency.png"; } if (currencyResponse.rates["RUB"] / currencyResponse.rates["EUR"] > currencyResponseYesterday.rates["RUB"] / currencyResponseYesterday.rates["EUR"]) { eurTendency.ImageLocation = "currency-pictures/up-tendency.png"; } else { eurTendency.ImageLocation = "currency-pictures/down-tendency.png"; } SafeWriter.WriteTextSafe("USD: " + Math.Round(currencyResponse.rates["RUB"], 2).ToString(), usdLabel); SafeWriter.WriteTextSafe("EUR: " + Math.Round(currencyResponse.rates["RUB"] / currencyResponse.rates["EUR"], 2).ToString(), eurLabel); } catch (WebException ex) { MessageBox.Show(ex.Message + ex.Data); } Thread.Sleep(60000); } }
private static void TranslateAsync(object wannaCast) { TranslateObj translateObj = (TranslateObj)wannaCast; Control control = translateObj.obj; int toX = translateObj.toX; int toY = translateObj.toY; double time = translateObj.time; BezierCurve curve = translateObj.curve; //Point dest = new Point(control.Location.X + toX, control.Location.Y + toY); double timePassed = 0; while (timePassed < time) { double coeff = BezierCurveCount(curve, timePassed / time, 0.016 / time) * time * 10; SafeWriter.WriteLocationSafe(new Point((int)Math.Round(toX * coeff / (time / 0.016)) + control.Location.X, (int)Math.Round(toY * coeff / (time / 0.016)) + control.Location.Y), control); /*if(coeff < 0) * MessageBox.Show(coeff.ToString());*/ timePassed += 0.016; Thread.Sleep(16); } }