예제 #1
0
        private void WeatherCheck_CheckedChanged(object sender, System.EventArgs e)
        {
            //If WeatherCheck is checked, now, then open the file dialog to pick up
            //  the location of the weather data file, then store it
            SessionControl openSession = new SessionControl();

            if (WeatherCheckBox.Checked && (!optionsFormInit))
            {
                DialogResult weatherFilePath = WeatherFileDialog.ShowDialog();
                openSession.WeatherDataFilePath = WeatherFileDialog.FileName;
            }
            //Check to see if the Weather file is valid
            WeatherReader wrf = new WeatherReader(openSession.WeatherDataFilePath);

            if (wrf.IsWeatherValid())
            {
                openSession.IsWeatherEnabled   = WeatherCheckBox.Checked;
                settings.WeatherMonitorEnabled = WeatherCheckBox.Checked;
            }
            else
            {
                MessageBox.Show("Invalid Weather Data File");
                openSession.IsWeatherEnabled   = false;
                settings.WeatherMonitorEnabled = false;
                WeatherCheckBox.Checked        = false;
            }
        }
예제 #2
0
 private void SpeakTodaysLowAndHighTemperatures()
 {
     Speak(WeatherReader.GetTodaysLowAndHighTemperatures(Settings.Default.PostalCode,
                                                         Settings.Default.CountryCode,
                                                         (TemperatureUnit)
                                                         Enum.Parse(typeof(TemperatureUnit),
                                                                    Settings.Default.TemperatureUnit)));
 }
예제 #3
0
 private void SpeakCurrentTemperature()
 {
     Speak(WeatherReader.GetCurrentForecast(Settings.Default.PostalCode,
                                            Settings.Default.CountryCode,
                                            (TemperatureUnit)
                                            Enum.Parse(typeof(TemperatureUnit),
                                                       Settings.Default.TemperatureUnit)));
 }
        public IComponent CreateComponent(IMessageHub hub, string fileName)
        {
            var file      = WeatherConfig.GetFileSystem();
            var logger    = WeatherConfig.GetLoggerConfiguration();
            var reader    = new WeatherReader(file, logger);
            var mapper    = new WeatherMapper(logger);
            var notify    = new WeatherNotifier(logger);
            var processor = new WeatherProcessor(reader, mapper, notify, hub, logger);

            _weatherComponent = new Types.WeatherComponent(reader, mapper, notify, processor, fileName);

            return(_weatherComponent);
        }
예제 #5
0
        private async void UpDate()
        {
            string response = null;

            await Task.Run(() =>
                           response = WeatherReader.Read(SelectedCity)
                           );

            var weatherResponse = JsonConvert.DeserializeObject <WeatherYandex>(response);

            App.Current.Dispatcher?.Invoke(() =>
            {
                weather.Clear();
                weather.Add(new DetaliedViewModel(weatherResponse.forecasts[0].parts.morning, "Утро"));
                weather.Add(new DetaliedViewModel(weatherResponse.forecasts[0].parts.day, "День"));
                weather.Add(new DetaliedViewModel(weatherResponse.forecasts[0].parts.evening, "Вечер"));
                weather.Add(new DetaliedViewModel(weatherResponse.forecasts[0].parts.night, "Ночь"));
                Weather.Refresh();
            });
        }
예제 #6
0
 public WeatherReaderTests()
 {
     _fileSystem    = Substitute.For <IFileSystem>();
     _logger        = Substitute.For <ILogger>();
     _weatherReader = new WeatherReader(_fileSystem, _logger);
 }