private async void okButton_Click(object sender, EventArgs e) { okButton.Enabled = false; JsonConfig.settings.useWindowsLocation = radioButton2.Checked; JsonConfig.settings.dontUseLocation = radioButton3.Checked; if (radioButton1.Checked) { LocationIQService.GetLocationData(locationBox.Text, this); } else if (radioButton2.Checked) { bool locationUpdated = await UwpLocation.UpdateGeoposition(); if (locationUpdated) { HandleScheduleChange(); } else { hasLocationPermission = UwpLocation.HasAccess(); UpdateLocationState(); MessageDialog.ShowWarning(_("Failed to get location from Windows location service."), _("Error")); } } else if (radioButton3.Checked) { JsonConfig.settings.sunriseTime = sunriseTimePicker.Value.ToLongTimeString(); JsonConfig.settings.sunsetTime = sunsetTimePicker.Value.ToLongTimeString(); JsonConfig.settings.sunriseSunsetDuration = (int)sunriseSunsetDurationBox.Value; this.Close(); } okButton.Enabled = true; }
private async void okButton_Click(object sender, EventArgs e) { okButton.Enabled = false; if (!locationCheckBox.Checked) { LocationIQService.GetLocationData(inputBox.Text, this); } else { bool locationUpdated = await UwpLocation.UpdateGeoposition(); if (locationUpdated) { HandleLocationChange(); } else { MessageBox.Show(_("Failed to get location from Windows location service."), _("Error"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } okButton.Enabled = true; }
private async void okButton_Click(object sender, EventArgs e) { okButton.Enabled = false; if (!locationCheckBox.Checked) { LocationIQData data = LocationIQService.GetLocationData(inputBox.Text); if (data != null) { JsonConfig.settings.location = inputBox.Text; JsonConfig.settings.latitude = data.lat; JsonConfig.settings.longitude = data.lon; this.Hide(); if (ThemeManager.isReady) { AppContext.wcsService.RunScheduler(); } MessageBox.Show("Location set successfully to: " + data.display_name + "\n(Latitude = " + data.lat + ", Longitude = " + data.lon + ")", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("The location you entered was invalid, or you are not " + "connected to the Internet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { this.Hide(); bool locationUpdated = await UwpLocation.UpdateGeoposition(); if (locationUpdated) { if (ThemeManager.isReady) { AppContext.wcsService.RunScheduler(); } this.Close(); } else { MessageBox.Show("Failed to get location from Windows location service.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Show(); } } okButton.Enabled = true; }
private void HandleTimerEvent(bool updateLocation) { if (updateLocation && JsonConfig.settings.useWindowsLocation) { Task.Run(() => UwpLocation.UpdateGeoposition()); } RunScheduler(); UpdateChecker.TryCheckAuto(); }
private async void okButton_Click(object sender, EventArgs e) { okButton.Enabled = false; if (!locationCheckBox.Checked) { LocationIQData data = LocationIQService.GetLocationData(inputBox.Text); if (data != null) { JsonConfig.settings.location = inputBox.Text; JsonConfig.settings.latitude = data.lat; JsonConfig.settings.longitude = data.lon; SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today); DialogResult result = MessageBox.Show(string.Format(_("Is this location " + "correct?\n\n{0}\nSunrise: {1}, Sunset: {2}"), data.display_name, solarData.sunriseTime.ToShortTimeString(), solarData.sunsetTime.ToShortTimeString()), _("Question"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { AppContext.wpEngine.RunScheduler(); this.Close(); } } else { MessageBox.Show(_("The location you entered was invalid, or you are not " + "connected to the Internet. Check your Internet connection and try a " + "different location. You can use a complete address or just the name of " + "your city/region."), _("Error"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { bool locationUpdated = await UwpLocation.UpdateGeoposition(); if (locationUpdated) { AppContext.wpEngine.RunScheduler(); this.Close(); } else { MessageBox.Show(_("Failed to get location from Windows location service."), _("Error"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } okButton.Enabled = true; }
public void RunScheduler() { if (ThemeManager.currentTheme == null) { return; } wallpaperTimer.Stop(); if (JsonConfig.settings.useWindowsLocation) { Task.Run(() => UwpLocation.UpdateGeoposition()); } string currentDate = GetDateString(); todaysData = GetWeatherData(currentDate); if (DateTime.Now < todaysData.SunriseTime + timerError) { // Before sunrise yesterdaysData = GetWeatherData(GetDateString(-1)); tomorrowsData = null; } else if (DateTime.Now >= todaysData.SunsetTime - timerError) { // After sunset yesterdaysData = null; tomorrowsData = GetWeatherData(GetDateString(1)); } else { // Between sunrise and sunset yesterdaysData = null; tomorrowsData = null; } isDayNow = (yesterdaysData == null && tomorrowsData == null); lastImageId = -1; if (isDayNow) { UpdateDayImage(); } else { UpdateNightImage(); } SystemThemeChanger.TryUpdateSystemTheme(); }
private void OnWallpaperTimerTick(object sender, EventArgs e) { if (ThemeManager.currentTheme != null) { if (JsonConfig.settings.useWindowsLocation) { Task.Run(() => UwpLocation.UpdateGeoposition()); } RunScheduler(); } UpdateChecker.TryCheckAuto(); }
public void HandleTimerEvent(bool updateLocation) { if (JsonConfig.settings.fullScreenPause && fullScreenChecker.runningFullScreen) { fullScreenChecker.timerEventPending = true; return; } if (updateLocation && JsonConfig.settings.useWindowsLocation) { Task.Run(() => UwpLocation.UpdateGeoposition()); } RunScheduler(); UpdateChecker.TryCheckAuto(); }