private void okButton_Click(object sender, EventArgs e)
        {
            okButton.Enabled = false;

            LocationIQData data = LocationIQService.GetLocationData(inputBox.Text);

            if (data != null)
            {
                JsonConfig.settings.location  = inputBox.Text;
                JsonConfig.settings.latitude  = data.lat;
                JsonConfig.settings.longitude = data.lon;
                JsonConfig.SaveConfig();

                wcsService.StartScheduler(true);

                MessageBox.Show("Location set successfully to: " + data.display_name +
                                Environment.NewLine + "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);
            }

            okButton.Enabled = true;
        }
        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;
        }
示例#4
0
        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 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;
        }
示例#6
0
        private void setLocationButton_Click(object sender, EventArgs e)
        {
            LocationIQService service = new LocationIQService();
            LocationIQData    data    = service.GetLocationData(locationInput.Text);

            if (data != null)
            {
                AppendToLog("Location set successfully to: " + data.display_name);
                AppendToLog("Latitude = " + data.lat + ", Longitude= " + data.lon);

                JsonConfig.settings.Location  = locationInput.Text;
                JsonConfig.settings.Latitude  = data.lat;
                JsonConfig.settings.Longitude = data.lon;
                JsonConfig.SaveConfig();

                wcsService.StartScheduler();
            }
            else
            {
                MessageBox.Show("The location you entered was invalid, or you are not connected to " +
                                "the Internet", "Error");
            }
        }