Пример #1
0
        /// <summary>
        /// Adds a JumpTask and if needed creates the JumpList
        /// </summary>
        /// <param name="game"></param>
        public void AddTask(Game game)
        {
            try
            {
                Game g = game.Copy();
                g.Name = g.Name.Replace("fav_", "");
                // Configure a new JumpTask.
                JumpTask jumpTask1 = CreateJumpTask(g);

                // Get the JumpList from the application and update it.
                if (jumpList == null)
                {
                    LoadJumpList();
                }


                if (!jumpList.JumpItems.Exists(j => ((JumpTask)j).Title == g.Description))
                {
                    jumpList.JumpItems.Insert(0, jumpTask1);
                    SettingsManager.AddGameToJumpList(g.Name);
                }


                jumpList.Apply();
            }
            catch (Exception)
            {
                //No jump list, we're on XP/Vista
            }
        }
Пример #2
0
        /// <summary>
        /// Adds a JumpTask and if needed creates the JumpList
        /// </summary>
        /// <param name="game"></param>
        public void AddTask(Game game)
        {
            try
            {
                Game g = game.Copy();
                g.Name = g.Name.Replace("fav_", "");
                // Configure a new JumpTask.
                JumpTask jumpTask1 = CreateJumpTask(g);

                // Get the JumpList from the application and update it.
                if (jumpList == null)
                    LoadJumpList();

                if (!jumpList.JumpItems.Exists(j => ((JumpTask) j).Title == g.Description))
                {
                    jumpList.JumpItems.Insert(0, jumpTask1);
                    SettingsManager.AddGameToJumpList(g.Name);
                }

                jumpList.Apply();
            }
            catch (Exception)
            {
                //No jump list, we're on XP/Vista
            }
        }
Пример #3
0
        /// <summary>
        /// Loads our favorites from favorites.ini
        /// </summary>
        /// <returns>How many favorites have been added already to our internal list.</returns>
        private int LoadFavorites()
        {
            _gamesFavorites = new Games();
            _countFavorites = 0;
            if (File.Exists(Settings.Default.favorites_ini))
            {
                string[] favs = File.ReadAllLines(Settings.Default.favorites_ini);
                foreach (string s in favs) //Some of the lines are not favorites, just ignores them.
                {
                    try
                    {
                        Game game = XmlParser.Games.FindGame(s);
                        if (game != null)
                        {
                            Game g = game.Copy();
                            g.Name       = "fav_" + g.Name;
                            g.IsFavorite = true;
                            _gamesFavorites.Add(g.Name, g);
                        }
                    }
                    catch (Exception)
                    {
                        //Not a game, do nothing.
                    }
                }

                //Sorts out the list by description alphabetically and filters it according to what the user set.
                var sortedDict = (from entry in _gamesFavorites
                                  where
                                  entry.Value.Name.Contains(_filter, StringComparison.InvariantCultureIgnoreCase) ||
                                  entry.Value.Manufacturer.Contains(_filter,
                                                                    StringComparison.InvariantCultureIgnoreCase) ||
                                  entry.Value.Year.Contains(_filter,
                                                            StringComparison.InvariantCultureIgnoreCase) ||
                                  entry.Value.SourceFile.Contains(_filter,
                                                                  StringComparison.InvariantCultureIgnoreCase) ||
                                  entry.Value.Description.Contains(_filter,
                                                                   StringComparison.InvariantCultureIgnoreCase)
                                  orderby entry.Value.Description.ToLower() ascending
                                  select entry);


                //Add the filtered favorites to our game list.
                Game prevGame = null;
                int  i        = 0;
                foreach (var fGame in sortedDict)
                {
                    fGame.Value.Index = i++;
                    Games.Add(fGame.Key, fGame.Value);
                    _countFavorites++;
                    if (prevGame != null)
                    {
                        prevGame.NextGame = fGame.Value;
                    }
                    fGame.Value.PreviousGame = prevGame;
                    prevGame = fGame.Value;
                }
                return(i);
            }
            return(0);
        }