Beispiel #1
0
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            Game           = e.NavigationParameter as cGame;
            pageTitle.Text = Game.Name;

            imgCover.Source = new BitmapImage(new Uri(Game.Image));
            if (Game.ReleaseDate != "")
            {
                txtDate.Text = "Release Date: " + Game.ReleaseDate;
            }
            if (Game.Description != "")
            {
                txtDesc.Text = "Description: " + Game.Description;
            }

            if (Game.Path == "")
            {
                txtLastPlay.Visibility  = Windows.UI.Xaml.Visibility.Collapsed;
                txtTotalPlay.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                txtPath.Visibility      = Windows.UI.Xaml.Visibility.Collapsed;
                btnPlay.Visibility      = Windows.UI.Xaml.Visibility.Collapsed;
            }
            else
            {
                txtLastPlay.Text  = "Last Play Time:   " + Game.lastTimeS;
                txtTotalPlay.Text = "Total Play Time:  " + Game.totalTimeS;
                txtPath.Text      = "Game Path Location: " + Game.Path;
                txtMsg.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
        }
Beispiel #2
0
        private void btnAddToLib_Click(object sender, RoutedEventArgs e)
        {
            string name = Path.GetFileName(App.modelArchive.GamesCollection[lstAllGames.SelectedIndex].Image);

            cGame game = lstAllGames.SelectedItem as cGame;

            ///App.modelArchive.GamesCollection.Add(game);
            App.gvm.GamesCollection.Add(game);

            cUserData.AddNewGame();
            //cUserData.AddToArchive();

            cGuFuncs.CreateToast("GameR Desk", game.Name + " is now in Games Library");



            //Now removing Game from Main Grid

            //App.gvm.GamesCollection[grdAllGames.SelectedIndex].Image = "";
            //await cUserData.delCover(name);

            //App.modelArchive.GamesCollection[lstAllGames.SelectedIndex].Image = "";
            //await cUserData.delCover(name);


            if (lstAllGames.SelectedIndex != -1)
            {
                App.modelArchive.GamesCollection.RemoveAt(lstAllGames.SelectedIndex);
                cUserData.AddToArchive();

                //cGuFuncs.CreateToast("GameR Desk", game.Name + " removed from Games Library");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            Game           = e.NavigationParameter as cGame;
            pageTitle.Text = Game.Name;
            txtName.Text   = Game.Name;
            txtPath.Text   = Game.Path;
            txtDate.Text   = Game.ReleaseDate;
            txtDesc.Text   = Game.Description;

            if (Game.Image != null || Game.Image != "")
            {
                imgGameCover.Source = new BitmapImage(new Uri(Game.Image));
            }
        }
Beispiel #4
0
        private async void btnRemoveGame_Click(object sender, RoutedEventArgs e)
        {
            if (grdAllGames.SelectedIndex != -1)
            {
                string name = Path.GetFileName(App.gvm.GamesCollection[grdAllGames.SelectedIndex].Image);

                //message dialog
                var confirm = new MessageDialog("Are you sure you want to delete this game from Library? All Game track time will be lost. GU recommends to Backup your Gamer Desk Data folder before removing any game.");
                confirm.Commands.Add(new UICommand("Yes", async delegate(IUICommand command)
                {
                    App.gvm.GamesCollection[grdAllGames.SelectedIndex].Image = "";
                    await cUserData.delCover(name);

                    cGame game = grdAllGames.SelectedItem as cGame;

                    if (grdAllGames.SelectedIndex != -1)
                    {
                        App.gvm.GamesCollection.RemoveAt(grdAllGames.SelectedIndex);
                        cUserData.AddNewGame();

                        cGuFuncs.CreateToast("GameR Desk", game.Name + " removed from Games Library");
                    }
                }));

                confirm.Commands.Add(new UICommand("No"));

                await confirm.ShowAsync();



                /*await new MessageDialog("to del: " + name ).ShowAsync();
                 * if (await classUserData.delCover(name))
                 * {
                 *  await new MessageDialog("img delted").ShowAsync();
                 * }
                 * else
                 * {
                 *  await new MessageDialog("img not delted").ShowAsync();
                 * }
                 */

                //did this as image is locked previously to access
            }
            else
            {
                await new MessageDialog("unable to remove").ShowAsync();
            }
        }
Beispiel #5
0
        private async void btnHideGame_Click(object sender, RoutedEventArgs e)
        {
            if (grdAllGames.SelectedIndex != -1)
            {
                string name = Path.GetFileName(App.gvm.GamesCollection[grdAllGames.SelectedIndex].Image);

                //message dialog

                /*var confirm = new MessageDialog("Are you sure you want to delete this game from Library? All Game track time will be lost. GU recommends to Backup your Gamer Desk Data folder before removing any game.");
                 * confirm.Commands.Add(new UICommand("Yes", async delegate(IUICommand command)
                 * {
                 *  App.gvm.GamesCollection[grdAllGames.SelectedIndex].Image = "";
                 *  await cUserData.delCover(name);
                 */
                cGame game = grdAllGames.SelectedItem as cGame;

                App.modelArchive.GamesCollection.Add(game);

                cUserData.AddToArchive();

                cGuFuncs.CreateToast("GameR Desk", game.Name + " is now in Archived Games Library");

                // }));

                // confirm.Commands.Add(new UICommand("No"));

                // await confirm.ShowAsync();


                //Now removing Game from Main Grid

                //App.gvm.GamesCollection[grdAllGames.SelectedIndex].Image = "";
                //await cUserData.delCover(name);

                if (grdAllGames.SelectedIndex != -1)
                {
                    App.gvm.GamesCollection.RemoveAt(grdAllGames.SelectedIndex);
                    cUserData.AddNewGame();

                    //cGuFuncs.CreateToast("GameR Desk", game.Name + " removed from Games Library");
                }
            }
            else
            {
                await new MessageDialog("Unable to add to Archive").ShowAsync();
            }
        }
Beispiel #6
0
        private async void btnAddGame_Click(object sender, RoutedEventArgs e)
        {
            ringImgDownload.IsActive = true;
            btnAddGame.IsEnabled     = false;

            string date;
            string imgLink = game.image.super_url;

            string imgName = Path.GetFileName(imgLink);//game.name + Path.GetExtension(imgLink);

            //download picture and save
            await cGuFuncs.DownloadPic(imgLink, imgName);


            if (game.original_release_date != null)
            {
                date = game.original_release_date;
            }
            else if (game.expected_release_year != null)
            {
                date = game.expected_release_year.ToString();
            }
            else
            {
                date = "";
            }



            cGame Game = new cGame(game.name, "", "ms-appdata:///local/" + imgName,
                                   date, game.deck + " \n " + HtmlUtilities.ConvertToText(game.description));


            App.gvm.AddGame(Game);

            cUserData.AddNewGame();
            await cUserData.GetGames();


            ringImgDownload.IsActive = false;
            btnAddGame.IsEnabled     = true;

            //send toast
            cGuFuncs.CreateToast("GameR Desk ", game.name + " Added to Library.");
        }
Beispiel #7
0
        private async void btnAddGame_Click(object sender, RoutedEventArgs e)
        {
            //if (StorageApplicationPermissions.FutureAccessList.ContainsItem("AccessToken"))
            //{
            //    StorageFolder userFolder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync("AccessToken", AccessCacheOptions.FastLocationsOnly);
            //    StorageFolder f = await userFolder.CreateFolderAsync("Gamer Desk Data", CreationCollisionOption.OpenIfExists);

            ringAddGame.IsActive = true;
            btnAddGame.IsEnabled = false;

            if (txtName.Text == "")
            {
                await new MessageDialog("You must provide Game Name.").ShowAsync();

                ringAddGame.IsActive = false;
                btnAddGame.IsEnabled = true;

                return;
            }
            if (txtDate.Text == "" && txtDesc.Text == "")
            {
                txtDate.Text = "No Release Date Available";
                txtDesc.Text = "No Description Available";
            }


            string imgName;

            //for downloaded image
            if (bImgDown != null && GameCover == null)
            {
                imgName = Path.GetFileName(imgLink);//txtName.Text + Path.GetExtension(imgLink);

                #region Dowload Image
                //download image code start
                var httpClient = new HttpClient();
                var data       = await httpClient.GetByteArrayAsync(new Uri(imgLink));

                GameCover = await localFolder.CreateFileAsync(imgName, CreationCollisionOption.ReplaceExisting);

                var targetStream = await GameCover.OpenAsync(FileAccessMode.ReadWrite);

                await targetStream.AsStreamForWrite().WriteAsync(data, 0, data.Length);

                await targetStream.FlushAsync();

                targetStream.Dispose();
                //download image code end
                #endregion
            }
            else
            {
                if (GameCover == null)
                {
                    await new MessageDialog("Please Select Game Cover Image.").ShowAsync();

                    ringAddGame.IsActive = false;
                    btnAddGame.IsEnabled = true;

                    return;
                }
                //imgName = txtName.Text + Path.GetExtension(GameCover.Name);
                imgName = Path.GetFileName(GameCover.Name);

                try
                {
                    StorageFile file = await localFolder.CreateFileAsync(imgName, CreationCollisionOption.ReplaceExisting);

                    await GameCover.CopyAndReplaceAsync(file);
                }
                catch (Exception) { }
            }



            if (GameCover != null)
            {
                //increment games static id counter
                cGame.GamesCount++;
                await cGuFuncs.UpdateCounterFile();

                cGame Game = new cGame(txtName.Text, txtPath.Text, "ms-appdata:///local/" + imgName,
                                       txtDate.Text, txtDesc.Text);

                App.gvm.AddGame(Game);

                cUserData.AddNewGame();
                await cUserData.GetGames();

                if (this.Frame.CanGoBack)
                {
                    this.Frame.GoBack();
                }

                cGuFuncs.CreateToast("GameR Desk ", txtName.Text + " Added to Library.");
            }
            else
            {
                await new MessageDialog("Please select Game Cover Image").ShowAsync();
            }

            ringAddGame.IsActive = false;
            btnAddGame.IsEnabled = true;
        }
Beispiel #8
0
        public async static Task <bool> GameRequest(cGame game)
        {
            if (StorageApplicationPermissions.FutureAccessList.ContainsItem("AccessToken"))
            {
                userFolder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync("AccessToken", AccessCacheOptions.FastLocationsOnly);

                f = await userFolder.CreateFolderAsync("Gamer Desk Data", CreationCollisionOption.OpenIfExists);

                //await new MessageDialog("Folder found" + userFolder.Path.ToString()).ShowAsync();


                StorageFile file = await f.CreateFileAsync
                                       ("GameLaunch.txt", CreationCollisionOption.OpenIfExists);

                /*
                 *
                 * //creating file
                 *
                 * FileOpenPicker picker = new FileOpenPicker();
                 * picker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
                 * picker.ViewMode = PickerViewMode.List;
                 * picker.FileTypeFilter.Add(".txt");
                 * picker.FileTypeFilter.Add(".jpg");
                 * picker.FileTypeFilter.Add(".exe");
                 *
                 *
                 * // await new MessageDialog("Pick a File to save location.","Pick a File to Launch").ShowAsync();
                 * MessageDialog msgDialog = new MessageDialog("Pick a File to save location.", "Pick a File to Launch");
                 * UICommand okBtn = new UICommand("OK");
                 * //okBtn.Invoked = OkBtnClick;
                 * msgDialog.Commands.Add(okBtn);
                 * UICommand cancelBtn = new UICommand("Cancel");
                 * //cancelBtn.Invoked = CancelBtnClick;
                 * msgDialog.Commands.Add(cancelBtn);
                 * await msgDialog.ShowAsync();
                 *
                 *
                 * StorageFile filepath = await picker.PickSingleFileAsync();
                 */

                if (file != null)// && filepath != null)
                {
                    //string json = JsonConvert.SerializeObject(game.Path);

                    await FileIO.WriteTextAsync(file, game.Path);

                    //await new MessageDialog("Game Launch request made").ShowAsync();
                    return(true);
                }
                else
                {
                    //await new MessageDialog("Unable to Launch Game").ShowAsync();
                    return(false);
                }
            }
            else
            {
                //folder access token not found
                return(false);
            }
        }
Beispiel #9
0
 public void AddGame(cGame game)
 {
     gamesCollection.Add(game);
     NotifyPropertyChanged();
 }
Beispiel #10
0
        private void grdAllGames_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (grdAllGames.SelectedIndex != -1)
            {
                if (!this.BottomAppBar.IsOpen)
                {
                    this.BottomAppBar.IsOpen   = true;
                    this.BottomAppBar.IsSticky = true;
                    btnRemoveGame.Visibility   = Windows.UI.Xaml.Visibility.Visible;
                    btnEditGame.Visibility     = Windows.UI.Xaml.Visibility.Visible;
                    btnPlayGame.Visibility     = Windows.UI.Xaml.Visibility.Visible;
                    btnHideGame.Visibility     = Windows.UI.Xaml.Visibility.Visible;

                    sep0.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    sep1.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    sep2.Visibility = Windows.UI.Xaml.Visibility.Visible;

                    btnFolderChange.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    btnSettings.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;

                    btnDownload.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }
                else
                {
                    this.BottomAppBar.IsOpen   = false;
                    this.BottomAppBar.IsSticky = false;
                    btnRemoveGame.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;
                    btnEditGame.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
                    btnPlayGame.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
                    btnHideGame.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;

                    sep0.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    sep1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    sep2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

                    btnFolderChange.Visibility = Windows.UI.Xaml.Visibility.Visible;
                    btnSettings.Visibility     = Windows.UI.Xaml.Visibility.Visible;

                    btnDownload.Visibility    = Windows.UI.Xaml.Visibility.Visible;
                    grdAllGames.SelectedIndex = -1;
                }
            }
            else
            {
                this.BottomAppBar.IsOpen   = false;
                this.BottomAppBar.IsSticky = false;
                btnRemoveGame.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;
                btnEditGame.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
                btnPlayGame.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;
                btnHideGame.Visibility     = Windows.UI.Xaml.Visibility.Collapsed;

                sep0.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                sep1.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                sep2.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

                btnFolderChange.Visibility = Windows.UI.Xaml.Visibility.Visible;
                btnSettings.Visibility     = Windows.UI.Xaml.Visibility.Visible;

                btnDownload.Visibility    = Windows.UI.Xaml.Visibility.Visible;
                grdAllGames.SelectedIndex = -1;
            }
            if (grdAllGames.SelectedIndex != -1)
            {
                cGame game = grdAllGames.SelectedItem as cGame;
                if (game.Path == "")
                {
                    btnPlayGame.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }
            }
        }