Exemplo n.º 1
0
        private async void CbAutomaticLocationClick(object sender, RoutedEventArgs e)
        {
            settings["AutomaticDetection"] = cbAutomaticLocation.IsChecked.Value;

            if (settings.GetValue <bool>("AutomaticDetection"))
            {
                location = new PCLocation();
                cbAutomaticLocation.IsChecked = settings.GetValue <bool>("AutomaticDetection");
                cbCuntry.IsEnabled            = false;
                cbCity.IsEnabled = false;
            }
            else
            {
                location.Stop();
                location = null;

                cbCuntry.IsEnabled = true;
                cbCity.IsEnabled   = true;

                cbCuntry.ItemsSource = weather.geonames.geonames;
                var selectedContry = from contry in weather.geonames.geonames where contry.geonameId == settings.GetValue("GeonameID", 6252001) select contry;
                cbCuntry.SelectedItem      = selectedContry.FirstOrDefault();
                cbCuntry.SelectionChanged += CbCuntrySelectionChanged;

                var cityList = await LoadCity((cbCuntry.SelectedItem as Geoname).countryCode);

                cbCity.ItemsSource = cityList;
                var selectedCity = from city in cityList where city.geonameId == settings.GetValue("CityGeonameID", 5128581) select city;
                cbCity.SelectedItem      = selectedCity.FirstOrDefault();
                cbCity.SelectionChanged += CbCitySelectionChanged;
            }
        }
Exemplo n.º 2
0
        //comon events
        private async void windowLoaded(object sender, RoutedEventArgs e)
        {
            if (CanWork)
            {
                CreateIcon();

                var list = await LoadLanguages();

                list.Add(new LanguageObject()
                {
                    LanguageIso = "en", LanguageName = "English"
                });
                cbLanguage.ItemsSource = list;
                var selectedLang = from lang in list where lang.LanguageIso == settings.GetValue("LanguageIso", "en") select lang;
                cbLanguage.SelectedItem      = selectedLang.FirstOrDefault();
                cbLanguage.SelectionChanged += CbLanguageSelectionChanged;


                if (settings.GetValue("AutomaticDetection", false))
                {
                    location = new PCLocation();
                    cbAutomaticLocation.IsChecked = settings.GetValue <bool>("AutomaticDetection");
                    cbCuntry.IsEnabled            = false;
                    cbCity.IsEnabled = false;
                }
                else
                {
                    cbCuntry.IsEnabled   = true;
                    cbCuntry.ItemsSource = weather.geonames.geonames;
                    var selectedContry = from contry in weather.geonames.geonames where contry.geonameId == settings.GetValue("GeonameID", 6252001) select contry;
                    cbCuntry.SelectedItem      = selectedContry.FirstOrDefault();
                    cbCuntry.SelectionChanged += CbCuntrySelectionChanged;

                    cbCity.IsEnabled = true;
                    var cityList = await LoadCity((cbCuntry.SelectedItem as Geoname).countryCode);

                    cbCity.ItemsSource = cityList;
                    var selectedCity = from city in cityList where city.geonameId == settings.GetValue("CityGeonameID", 5128581) select city;
                    cbCity.SelectedItem      = selectedCity.FirstOrDefault();
                    cbCity.SelectionChanged += CbCitySelectionChanged;
                }
                cbAutomaticLocation.Click += CbAutomaticLocationClick;


                cbThemperature.SelectedIndex     = settings.GetValue("Celsium", 0);
                cbThemperature.SelectionChanged += CbThemperatureSelectionChanged;

                cbIcon.IsChecked = settings.GetValue("LoadIcon", true);
                cbIcon.Click    += CbIconClick;

                cbCondition.IsChecked = settings.GetValue("ShowCondition", true);
                cbCondition.Click    += CbConditionClick;

                cbThemperatureShow.IsChecked = settings.GetValue("ShowThemperatue", true);
                cbThemperatureShow.Click    += CbThemperatureShowClick;

                cbLocationShow.IsChecked = settings.GetValue("ShowLocation", true);
                cbLocationShow.Click    += CbLocationShowClick;

                cbShowInetMessage.IsChecked = settings.GetValue("ShowInetDis", false);
                cbShowInetMessage.Click    += CbShowInetMessageClick;

                RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                if ((string)key.GetValue("Weather Widget") == null)
                {
                    cbStartUP.IsChecked = false;
                }
                else
                {
                    cbStartUP.IsChecked = true;
                }
                cbStartUP.Click += CbStartUPClick;

                colorPicker.SelectedColor         = settings.GetValue("TextColor", new WeatherColor(255, 255, 255, 255)).GetColor();
                colorPicker.SelectedColorChanged += colorPickerSelectionColorChanged;

                colorPickerBackground.SelectedColor         = settings.GetValue("BackgroundColor", new WeatherColor(0, 255, 255, 255)).GetColor();
                colorPickerBackground.SelectedColorChanged += ColorPickerBackgroundSelectedColorChanged;

                colorPickerBorder.SelectedColor         = settings.GetValue("BorderColor", new WeatherColor(0, 255, 255, 255)).GetColor();
                colorPickerBorder.SelectedColorChanged += ColorPickerBorderSelectedColorChanged;

                var th = settings.GetValue("WidgetBorder", new WidgetBorder(1, 1, 1, 1)).GetBorder();
                tbBorderLeft.Text   = th.Left.ToString();
                tbBorderRight.Text  = th.Right.ToString();
                tbBorderTop.Text    = th.Top.ToString();
                tbBorderBottom.Text = th.Bottom.ToString();

                tbBorderLeft.TextChanged   += TbBorderTextChanged;
                tbBorderRight.TextChanged  += TbBorderTextChanged;
                tbBorderTop.TextChanged    += TbBorderTextChanged;
                tbBorderBottom.TextChanged += TbBorderTextChanged;

                widget.SetWidgetBorder();
                widget.SetWidgetTextColor();
                widget.SetWidgetBackgroundColor();
                widget.SetWidgetBorderColor();
                UpdateWidget();
                widget.ShowWidget(true);

                Update             = new UpdateClient("https://ogycode.github.io/WeatherWidget/update.json");
                Update.NewVersion += UpdateNewVersion;
                var assembly = Assembly.GetExecutingAssembly();
                var version  = assembly.GetName().Version;
                Update.Check(new Verloka.HelperLib.Update.Version(version.Major, version.Minor, version.MajorRevision, version.MinorRevision));
            }
        }