コード例 #1
0
        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;
        }
コード例 #2
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;
        }
コード例 #3
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;
                    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;
        }
コード例 #4
0
        private static void HandleLocationSuccess(LocationIQData data, ScheduleDialog dialog)
        {
            JsonConfig.settings.latitude  = data.lat;
            JsonConfig.settings.longitude = data.lon;
            SolarData solarData = SunriseSunsetService.GetSolarData(DateTime.Today);

            DialogResult result = MessageDialog.ShowQuestion(string.Format(_("Is this location correct?\n\n{0}\n{1}"),
                                                                           data.display_name, SunriseSunsetService.GetSunriseSunsetString(solarData)), _("Question"), true);

            if (result == DialogResult.Yes)
            {
                dialog.Invoke(new Action(() => dialog.HandleScheduleChange()));
            }
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: ihongda/WinDynamicDesktop
        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");
            }
        }