Esempio n. 1
0
        public static void AddGame(Game addedGame)
        {
            games.Add(addedGame);

            if (addedGame.Owned)
            { ShiftLibraryDown(addedGame.Priority, addedGame.Title); }
            else
            { ShiftWhishListDown(addedGame.Priority, addedGame.Title); }

            SaveGames();
            SortGames();
        }
Esempio n. 2
0
        public static void DecreasePriority(Game editedGame, bool gameFromLibrary)
        {
            if (editedGame.Owned || (!editedGame.Owned && editedGame.Released))
            {
                editedGame.Priority++;
                Game gameToSwapWith = null;

                if (gameFromLibrary)
                {
                    gameToSwapWith = (from g in games
                                      where g.Owned && g.Priority.Equals(editedGame.Priority) && !g.Title.Equals(editedGame.Title)
                                      select g).FirstOrDefault();
                }
                else
                {
                    gameToSwapWith = (from g in games
                                      where !g.Owned && g.Priority.Equals(editedGame.Priority) && !g.Title.Equals(editedGame.Title)
                                      select g).FirstOrDefault();
                }

                if (gameToSwapWith != null)
                { gameToSwapWith.Priority--; }
                else
                { editedGame.Priority--; }

                SaveGames();
                SortGames();
            }
        }
Esempio n. 3
0
        public static void MinimizePriority(Game editedGame, bool gameFromLibrary)
        {
            if (gameFromLibrary || (!gameFromLibrary && editedGame.Released))
            {
                int previousPriority = editedGame.Priority;

                if (gameFromLibrary)
                {
                    editedGame.Priority = LowestLibraryPriority + 1;
                    ShiftLibraryDown(editedGame.Priority, editedGame.Title);
                    ShiftLibraryUp(previousPriority);
                }
                else
                {
                    editedGame.Priority = LowestReleasedWhishListPriority + 1;
                    ShiftWhishListDown(editedGame.Priority, editedGame.Title);
                    ShiftWhishListUp(previousPriority);
                }

                SaveGames();
                SortGames();
            }
        }
Esempio n. 4
0
        public static void MaximizePriority(Game editedGame, bool gameFromLibrary)
        {
            if (gameFromLibrary || (!gameFromLibrary && editedGame.Released))
            {
                editedGame.Priority = 1;

                if (gameFromLibrary)
                { ShiftLibraryDown(editedGame.Priority, editedGame.Title); }
                else
                { ShiftWhishListDown(editedGame.Priority, editedGame.Title); }

                SaveGames();
                SortGames();
            }
        }
Esempio n. 5
0
        public static void EditGame(Game editedGame)
        {
            for (int i = 0; i < games.Count; i++)
            {
                if (games[i].Id == editedGame.Id)
                {
                    bool movedFromWhishListToLibrary = false;
                    bool movedFromLibraryToWhishList = false;
                    bool changedFromReleasedToNotReleased = false;
                    bool changedFromNotReleasedToReleased = false;
                    bool changedReleaseDateOfNotReleasedGame = false;

                    int previousPriority = editedGame.Priority;

                    // Game was moved from Whish List to Library
                    if (!games[i].Owned && editedGame.Owned)
                    {
                        movedFromWhishListToLibrary = true;
                        editedGame.Priority = 1;
                    }
                    // Released game was moved from Library to Whish List
                    else if (editedGame.Released && games[i].Owned && !editedGame.Owned)
                    {
                        movedFromLibraryToWhishList = true;
                        editedGame.Priority = 1;
                    }
                    // Not released game was moved from Library to Whish List
                    else if (!editedGame.Released && games[i].Owned && !editedGame.Owned)
                    {
                        movedFromLibraryToWhishList = true;
                        editedGame.Priority = CalculatePriorityForWhishList(editedGame.ReleaseDate);
                    }
                    // Game on Whish List was changed from released to not released
                    else if (!games[i].Owned && !editedGame.Owned && games[i].Released && !editedGame.Released)
                    {
                        changedFromReleasedToNotReleased = true;
                        editedGame.Priority = CalculatePriorityForWhishList(editedGame.ReleaseDate);
                    }
                    // Game on Whish List was changed from not released to released
                    else if (!games[i].Owned && !editedGame.Owned && !games[i].Released && editedGame.Released)
                    {
                        changedFromNotReleasedToReleased = true;
                        editedGame.Priority = 1;
                    }
                    // Release date of not released game on Whish List was changed
                    else if (games[i].ReleaseDate != editedGame.ReleaseDate && !editedGame.Released && !games[i].Owned && !editedGame.Owned )
                    {
                        changedReleaseDateOfNotReleasedGame = true;
                        editedGame.Priority = CalculatePriorityForWhishList(editedGame.ReleaseDate);
                    }

                    games.RemoveAt(i);
                    games.Insert(i, editedGame);

                    if (movedFromWhishListToLibrary)
                    {
                        ShiftLibraryDown(editedGame.Priority, editedGame.Title);
                        ShiftWhishListUp(previousPriority);
                    }
                    else if (movedFromLibraryToWhishList)
                    {
                        ShiftLibraryUp(previousPriority);
                        ShiftWhishListDown(editedGame.Priority, editedGame.Title);
                    }
                    else if (changedFromReleasedToNotReleased)
                    {
                        ShiftWhishListDown(editedGame.Priority, editedGame.Title);
                        ShiftWhishListUp(previousPriority);
                    }
                    else if (changedFromNotReleasedToReleased)
                    {
                        ShiftWhishListUp(previousPriority);
                        ShiftWhishListDown(editedGame.Priority, editedGame.Title);
                    }
                    else if (changedReleaseDateOfNotReleasedGame)
                    {
                        ShiftWhishListUp(previousPriority);
                        ShiftWhishListDown(editedGame.Priority, editedGame.Title);
                    }

                    SaveGames();
                    SortGames();
                    break;
                }
            }
        }
Esempio n. 6
0
        public static void DeleteGame(Game deletedGame)
        {
            for (int i = 0; i < games.Count; i++)
            {
                if (games[i].Id == deletedGame.Id)
                {
                    bool owned = games[i].Owned;
                    int priority = games[i].Priority;

                    games.RemoveAt(i);

                    if (owned)
                    { ShiftLibraryUp(priority); }
                    else
                    { ShiftWhishListUp(priority); }

                    SaveGames();
                    SortGames();
                    break;
                }
            }
        }
Esempio n. 7
0
 public static Game Clone(Game gameToClone)
 {
     return new Game(gameToClone.Id, gameToClone.Owned, gameToClone.Priority, gameToClone.Title, gameToClone.Platform, gameToClone.Grade, gameToClone.Progress, gameToClone.Released, gameToClone.ReleaseDate, gameToClone.Path);
 }
Esempio n. 8
0
        private void LoadGame(int gameId)
        {
            editedGame = GameList.GetGameById(gameId);
            textBoxTitle.Text = editedGame.Title;
            textBoxTitle.Select(textBoxTitle.Text.Length, 0);
            releasedGame = editedGame.Released;
            textBoxReleaseDate.Text = editedGame.ReleaseDate;
            ownedGame = editedGame.Owned;
            ChangePlatform(Converter.StringToPlatform(editedGame.Platform));
            textBoxGrade.Text = editedGame.Grade.ToString();
            textBoxProgress.Text = editedGame.Progress.ToString();
            textBoxPath.Text = editedGame.Path;

            RefreshReleasedCheckBox();
            RefreshOwnedCheckBox();
            ValidateForm();
        }