Exemplo n.º 1
0
        private async void SaveData_Click(object sender, RoutedEventArgs e)
        {
            SavedText.Visibility = Visibility.Collapsed;
            if (ChoosenPlace != null && _Themes != null && _SaveData != null && _UnitsFormat != null && _TimeFormat != null && Languages.SelectedIndex != -1)
            {
                UserSettings _Settings     = new UserSettings();
                var          checkLocation = AlwaysDetect.IsChecked == true ? 1 : 0;
                _Settings = new UserSettings()
                {
                    Theme         = _Themes,
                    Language      = (Languages.SelectedItem as Data.ComboBoxItem).Key,
                    CheckLocation = checkLocation,
                    DataFormat    = new DataFormat()
                    {
                        UnitsFormat = _UnitsFormat,
                        TimeFormat  = _TimeFormat
                    },
                    SaveData        = _SaveData,
                    DefaultLocation = ChoosenPlace
                };

                var WriteToFile = (await UserDataHelper.WriteFile("Settings.json", _Settings));
                WeatherPage.IsSettingsChanged = true;
                SavedText.Visibility          = Visibility.Visible;
                DataError.Visibility          = Visibility.Collapsed;
            }
            else
            {
                SavedText.Visibility = Visibility.Collapsed;
                DataError.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 2
0
        private async void StartApp_Click(object sender, RoutedEventArgs e)
        {
            ErrorText.Visibility = Visibility.Collapsed;

            if (ChoosenPlace != null && SaveData.SelectedIndex != -1 && Theme.SelectedIndex != -1 && Units.SelectedIndex != -1 && TimeFormat.SelectedIndex != -1 && Languages.SelectedIndex != -1)
            {
                var checkLocation = AlwaysDetect.IsChecked == true ? 1 : 0;
                var theme         = (Theme.SelectedItem as Data.ComboBoxItem).Key;
                var units         = (Units.SelectedItem as Data.ComboBoxItem).Key;
                var time          = (TimeFormat.SelectedItem as Data.ComboBoxItem).Key;
                var savedata      = (SaveData.SelectedItem as Data.ComboBoxItem).Key;

                UserSettings _Settings = new UserSettings();
                _Settings = new UserSettings()
                {
                    Theme         = theme,
                    Language      = (Languages.SelectedItem as Data.ComboBoxItem).Key,
                    CheckLocation = checkLocation,
                    DataFormat    = new DataFormat()
                    {
                        UnitsFormat = units,
                        TimeFormat  = time
                    },
                    SaveData        = savedata,
                    DefaultLocation = ChoosenPlace
                };

                var WriteToFile = (await UserDataHelper.WriteFile("Settings.json", _Settings));
                if (WriteToFile == true)
                {
                    Frame.Navigate(typeof(ShellPage));
                }
            }
            else
            {
                ErrorText.Visibility = Visibility.Visible;
            }
        }
Exemplo n.º 3
0
        private async void AvailableActions_ItemClick(object sender, ItemClickEventArgs e)
        {
            switch ((e.ClickedItem as StackPanel).Tag.ToString())
            {
            case "SetHome":
                var settings = await UserDataHelper.GetSettings("Settings.json");

                settings.DefaultLocation = _CityData.PlaceInfo;
                await UserDataHelper.WriteFile("Settings.json", settings);

                SetAsHome.IsEnabled = false;
                ShowToolTip("SavedAsHome", 2000);
                break;

            case "Favorite":
                var IsFavorited = (await UserDataHelper.SaveToFavorites("Favorites.json", _CityData.PlaceInfo));
                if (IsFavorited == true)
                {
                    await UserDataHelper.SaveFavoriteWeather(_CityData);

                    SaveToFavorites.Visibility     = Visibility.Collapsed;
                    RemoveFromFavorites.Visibility = Visibility.Visible;
                    ShowToolTip("Favorited", 2000);
                }
                break;

            case "UnFavorite":
                var IsUnfavorited = (await UserDataHelper.RemoveFromFavorites("Favorites.json", _CityData.PlaceInfo));
                if (IsUnfavorited == true)
                {
                    await UserDataHelper.RemoveFavoriteWeather(_CityData.PlaceInfo.PlaceId);

                    SaveToFavorites.Visibility     = Visibility.Visible;
                    RemoveFromFavorites.Visibility = Visibility.Collapsed;
                    ShowToolTip("Unfavorited", 2000);
                }
                break;

            case "Pin":
                ShowToolTip("Pinning", 2000);
                var IsPined = await LiveTile.UpdateCustomTile(PlaceInfo, CurrentWeatherResult, DailyForecastResult, CoverLink);

                if (IsPined == true)
                {
                    PinToStart.Visibility     = Visibility.Collapsed;
                    UnPinFromStart.Visibility = Visibility.Visible;
                    ShowToolTip("Pined", 2000);
                }
                break;

            case "UnPin":
                ShowToolTip("Unpinning", 2000);
                var IsUnPined = await LiveTile.UnpinCustomTile(_CityData.PlaceInfo.PlaceId);

                if (IsUnPined == true)
                {
                    PinToStart.Visibility     = Visibility.Visible;
                    UnPinFromStart.Visibility = Visibility.Collapsed;
                    ShowToolTip("Unpined", 2000);
                }
                break;

            case "Download":
                ShowToolTip("DownloadingImage", 2000);
                BitmapImage bitMap = Cover.Source as BitmapImage;
                string      uri    = bitMap?.UriSource.ToString();
                await UserDataHelper.DownloadAsset(uri);

                ShowToolTip("Downloaded", 2000);
                break;

            case "Rate":
                await Launcher.LaunchUriAsync(new Uri(string.Format("ms-windows-store:REVIEW?PFN={0}", Windows.ApplicationModel.Package.Current.Id.FamilyName)));

                break;

            case "Feedback":
                await Microsoft.Services.Store.Engagement.StoreServicesFeedbackLauncher.GetDefault().LaunchAsync();

                break;

            default:
                break;
            }
        }