Пример #1
0
 public void GameExit(string name)
 {
     if (RunGameList != null && RunGameList.Count >= 0)
     {
         List <Game> gamelist = (from game in RunGameList
                                 where game.Title.Equals(name)
                                 select game).ToList();
         if (gamelist.Count > 0)
         {
             GameEventArgs gameEvent = new GameEventArgs()
             {
                 game = gamelist
             };
             UnRunGameList.AddRange(gamelist);
             if (ExitGameEvent != null)
             {
                 ExitGameEvent(gameEvent);
             }
             if (RunGameList != null)
             {
                 foreach (Game gg in gamelist)
                 {
                     RunGameList.Remove(gg);
                 }
             }
         }
     }
 }
Пример #2
0
        public void RefreshGameList()
        {
            string path = System.AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "ListenerGameList.json";

            using (Stream stream = new FileStream(path, FileMode.OpenOrCreate))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    List <Game> Temp = JsonConvert.DeserializeObject <List <Game> >(reader.ReadToEnd());
                    for (int i = 0; i < RunGameList.Count; i++)
                    {
                        Game g = (Game)RunGameList[i];
                        if (Temp.Contains(g))
                        {
                            Temp.Remove(g);
                        }
                        else
                        {
                            RunGameList.Remove(g);
                            i--;
                        }
                    }
                    UnRunGameList = Temp;
                }
            }
        }