public void PopulateDropdown()
        {
            Games.Clear();
            var context = DataEntitiesProvider.Provide();

            Categories.Clear();
            Categories.Add(new GameCategoryVm()
            {
                Id = 0, Name = "(No category)"
            });
            foreach (var c in context.GameCategories.Select(x => new GameCategoryVm {
                Id = x.Id, Name = x.NAME
            }))
            {
                Categories.Add(c);
            }

            Games.Add(new GameVm {
                Text = "New Game", Value = 0
            });
            foreach (var game in context.Games.OrderBy(x => x.Code))
            {
                Games.Add(new GameVm {
                    Text = game.Code + " : " + game.Mind_Sport, Value = game.Id
                });
            }
        }
Esempio n. 2
0
        /// <summary>  Initialize a search towards IGDB based on parameter</summary>
        /// <param name="gameName">Name of the game.</param>
        public async void InitializeGameSearchAsync(string gameName)
        {
            Page.WaitVisual(true);
            Games.Clear();
            var context = new IgdbAccess();

            using (context)
            {
                try
                {
                    var games = await context.GetGamesAsync(gameName).ConfigureAwait(true);

                    if (games.Length != 0)
                    {
                        await InitializeCoversToGameAsync(games, context).ConfigureAwait(true);

                        Page.WaitVisual(false);
                        PreviousGamesObservableCollection = Games;
                        return;
                    }
                }
                catch (HttpRequestException)
                {
                    GrToast.SmallToast(GrToast.Errors.NetworkError);
                    Page.WaitVisual(false);
                    return;
                }
            }

            Page.WaitVisual(false);
            GrToast.SmallToast("No game found");
        }
        private void ResetComponents()
        {
            GoBackButton.IsEnabled                = true;
            GamesList.Visibility                  = Visibility.Visible;
            CreateGameButton.Visibility           = Visibility.Visible;
            CreateGameButton.IsEnabled            = false;
            JoinGameButton.Visibility             = Visibility.Visible;
            JoinGameButton.IsEnabled              = false;
            NumberOfPlayersComboBox.Visibility    = Visibility.Visible;
            NumberOfPlayersComboBox.SelectedIndex = -1;
            TextBoxGameName.Visibility            = Visibility.Visible;
            TextBoxGameName.Clear();
            Games.Clear();
            KickPlayerColumn.Visibility = Visibility.Visible;
            server.GetGames();

            PlayersGrid.Visibility     = Visibility.Hidden;
            StartGameButton.Visibility = Visibility.Hidden;
            StartGameButton.IsEnabled  = false;
            LeaveGameButton.Visibility = Visibility.Hidden;
            Players.Clear();

            gameName        = null;
            isHost          = false;
            numberOfPlayers = 0;
        }
Esempio n. 4
0
        private void InitCommands()
        {
            RemoveGame = new RelayCommand(x =>
            {
                var g      = x as Game;
                FullPrice -= g.Price;
                Games.Remove(g);
                using (var DB = new DAL.Context.SteamContext())
                {
                    DB.Account.Include("Basket").FirstOrDefault(y => y.AccountId == Infrastructure.Account.CurrentAccount.AccountId).Basket.Remove(DB.Game.FirstOrDefault(y => y.GameId == g.GameId));
                    DB.SaveChanges();
                }
            });
            Buy = new RelayCommand(x =>
            {
                using (var DB = new DAL.Context.SteamContext())
                {
                    var curAcc = DB.Account.Include("Basket").Include("Games").FirstOrDefault(y => y.AccountId == Infrastructure.Account.CurrentAccount.AccountId);

                    foreach (var item in curAcc.Basket)
                    {
                        curAcc.Games.Add(item);
                    }
                    curAcc.Basket.Clear();
                    Games.Clear();
                    FullPrice = 0;
                    DB.SaveChanges();
                }
            });
        }
Esempio n. 5
0
 public void InitializeComponent()
 {
     using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_Game"].ConnectionString))
     {
         if (Studios != null)
         {
             Studios.Clear();
         }
         Studios = new ObservableCollection <Studio>(db.Query <Studio>("SELECT * FROM [Studio]").ToList());
         if (Styles != null)
         {
             Styles.Clear();
         }
         Styles = new ObservableCollection <Model.Base.Style>(db.Query <Model.Base.Style>("SELECT * FROM [Style]").ToList());
         if (Mod_s != null)
         {
             Mod_s.Clear();
         }
         Mod_s = new ObservableCollection <Mod_Game>(db.Query <Mod_Game>("SELECT * FROM [Mod_Game]").ToList());
         if (Games != null)
         {
             Games.Clear();
         }
         Games = new ObservableCollection <Game>(db.Query <Game>("SELECT * FROM [Game]").ToList());
         Games.ToList().ForEach(i => i.Studio   = Studios.ToList().Find(j => j.Id == i.Game_Studio_id));
         Games.ToList().ForEach(i => i.Style    = Styles.ToList().Find(j => j.Id == i.Game_Style_id));
         Games.ToList().ForEach(i => i.Mod_Game = Mod_s.ToList().Find(j => j.Id == i.Game_Mod_id));
         OnPropertyChanged("Games");
     }
 }
Esempio n. 6
0
        public void QueryGameList(string gameName, Action callback)
        {
            lock ( lockSearch )
            {
                Games.Clear();

                webClient.ContentType = ContentType.UrlEncodedUTF8;
                webClient.Headers["X-Requested-With"] = "XMLHttpRequest";

                this.With(x => GoodgameGet(String.Format("http://goodgame.ru/ajax/games/all/?q={0}&limit=10", HttpUtility.UrlEncode(gameName))))
                .With(x => String.IsNullOrWhiteSpace(x) ? null : x)
                .With(x => JArray.Parse(x))
                .With(x => x.Select(game => new Game()
                {
                    Id = game[2].ToString(), Name = game[0].ToString()
                }))
                .ToList()
                .ForEach(g => Games.Add(g));

                if (callback != null)
                {
                    UI.Dispatch(() => callback());
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// deserialize specified library file
        /// </summary>
        /// <param name="libraryToLoad"></param>
        static void DeserializeLibrary(string libraryToLoad = null)
        {
            libraryToLoad = libraryToLoad ?? GameLibraryFile;

            Games.Clear();

            if (File.Exists(libraryToLoad))
            {
                string libraryXml;

                // load games from library backup
                if (libraryToLoad.Contains(BackupExtension))
                {
                    libraryXml = Utils.Decompress(File.ReadAllBytes(libraryToLoad));
                }

                else
                {
                    libraryXml = File.ReadAllText(libraryToLoad);
                }

                Games = Utils.Deserialize <ConcurrentDictionary <string, GameInfo> >(libraryXml);

                // fix library
                Games = FixLibrary(Settings.Default.FixLibrary, Games);
            }
        }
Esempio n. 8
0
        public void CreateTutorialGame(int trackId)
        {
            Games.Clear();
            gameData = CreateTutorialGameData();


            ApplyTrack(trackId);
        }
Esempio n. 9
0
 private void RefreshGames()
 {
     Games.Clear();
     foreach (var exe in Scanner.GetExecutables())
     {
         Games.Add(exe);
     }
     //APIController.GetGameCovers();
 }
Esempio n. 10
0
 private void InitCommands()
 {
     Search = new RelayCommand(x =>
     {
         Games.Clear();
         Games.AddRange(gs.GetAll().Where(y => y.GameName.ToLower().Contains(SearchText.ToLower())));
         SearchResult = $"Результатов по вашему запросу {Games.Count}.";
     });
 }
Esempio n. 11
0
        /// <summary>
        /// Loads list of installed games.
        /// </summary>
        private void LoadGames()
        {
            Games.Clear();

            foreach (var lib in Libraries)
            {
                Games.AddRange(lib.GetGames().ToList());
            }
        }
Esempio n. 12
0
 public void LoadGames()
 {
     try { games.Clear(); } catch { }
     try { Games.Clear(); } catch { }
     ReadFile();
     Games = games;
     Application.Current.Dispatcher.Invoke(new Action(() =>
                                                      ((MainWindow)Application.Current.MainWindow).RefreshDataContext()));
 }
Esempio n. 13
0
        private async Task LoadGames()
        {
            var games = await _gameService.GetGamesAsync();

            Games.Clear();
            foreach (Game game in games)
            {
                Games.Add(game);
            }
            Game = Games.FirstOrDefault();
        }
Esempio n. 14
0
 /// <summary>
 /// First thing we do is add the new players to the tournament.
 /// TODO Now we loop over all the games each time the button is pressed and clear the list each time, finally we add for each game a new viewmodel.
 /// TODO Would there be a way or is it necessary to add only the new games?
 /// We have to clear the Observable Games list each time or duplicate viewmodels get added.
 /// </summary>
 private void PairUp()
 {
     AddNewPlayers();
     CurrentTournament.PairUp();
     Games.Clear();
     foreach (Game game in CurrentTournament.Games)
     {
         GameViewModel gameViewModel = new GameViewModel(game);
         Games.Add(gameViewModel);
     }
     RaisePropertyChanged("PlayersRanked");
 }
Esempio n. 15
0
        public void GetGames()
        {
            Games.Clear();
            var games = myGameDbManager.GetGamesForTeam(MainViewModel.Instance.Team.Id);

            if (games == null)
            {
                return;
            }
            Games.AddRange(games);
            OnPropertyChanged(nameof(Games));
        }
Esempio n. 16
0
        public void OnEnterURL(string url)
        {
            var games = SteamProfileLoader.TryGetGamesFromSteamProfile(url);

            if (games != null)
            {
                Games.Clear();
                foreach (Game game in games)
                {
                    Games.Add(game);
                }
            }
        }
Esempio n. 17
0
        private async void LoadData()
        {
            Games.Clear();
            var games = await GameDefinitionSource.LoadDataAsync();

            foreach (var gameDefinition in games)
            {
                var gameData = storage.Get <GameData>("GameData." + gameDefinition.UniqueId) ?? new GameData();
                gameData.Description = gameDefinition.Title;
                gameData.Rank        = BinaryGame.GetRank(gameData.BestPiece);
                Games.Add(gameData);
            }
        }
Esempio n. 18
0
        public void Load()
        {
            // If configuration file exists then...
            if (System.IO.File.Exists(FileName))
            {
                SettingsFile data;
                // Deserialize and load data.
                lock (saveReadFileLock)
                {
                    data = Serializer.DeserializeFromXmlFile <SettingsFile>(FileName);
                }
                if (data == null)
                {
                    return;
                }
                //Programs.Clear();
                //if (data.Programs != null) for (int i = 0; i < data.Programs.Count; i++) Programs.Add(data.Programs[i]);
                Games.Clear();
                if (data.Games != null)
                {
                    for (int i = 0; i < data.Games.Count; i++)
                    {
                        Games.Add(data.Games[i]);
                    }
                }
                Pads.Clear();
                if (data.Pads != null)
                {
                    for (int i = 0; i < data.Pads.Count; i++)
                    {
                        Pads.Add(data.Pads[i]);
                    }
                }
            }
            // Check if current app doesn't exist in the list then...
            var currentFile = new System.IO.FileInfo(Application.ExecutablePath);
            var currentGame = Games.FirstOrDefault(x => x.FileName == currentFile.Name);

            if (currentGame == null)
            {
                // Add x360ce.exe
                var item    = x360ce.Engine.Data.Game.FromDisk(currentFile.Name);
                var program = Programs.FirstOrDefault(x => x.FileName == currentFile.Name);
                item.LoadDefault(program);
                SettingsFile.Current.Games.Add(item);
            }
            else
            {
                currentGame.FullPath = currentFile.FullName;
            }
        }
 /// <summary>
 /// This method updates the games collection.
 /// </summary>
 public void UpdateGames()
 {
     Games.Clear();
     try
     {
         server.GetGames();
     }
     catch (CommunicationObjectFaultedException ex)
     {
         Console.WriteLine(ex.ToString());
         CustomMessageBox.ShowOK(Properties.Resources.ServerIsOff, Properties.Resources.ServerIsOff, Properties.Resources.GoBack_Button);
         ClickGoBack(this, new RoutedEventArgs());
     }
 }
        private void ReceivedActiveGames(List <Game> games)
        {
            IsLoading  = false;
            HasNoGames = games.Count == 0;
            App.Current.Dispatcher.BeginInvoke((Action) delegate
            {
                Games.Clear();
                GamesByID.Clear();

                foreach (var game in games)
                {
                    SetGamesList(game);
                }
            });
        }
Esempio n. 21
0
 public void QueryGameList(string gameName, Action callback)
 {
     lock (lockSearch)
     {
         Games.Clear();
         jsonGames.games.Where(game => game.name.ToLower().StartsWith(gameName.ToLower())).Select(game => new Game()
         {
             Id = game.id, Name = game.name
         }).ToList().ForEach(game => Games.Add(game));
         if (callback != null)
         {
             UI.Dispatch(() => callback());
         }
     }
 }
Esempio n. 22
0
        public void CreateGUI()
        {
            GUI.RootComponent.ClearChildren();
            Games.Clear();
            const int edgePadding = 32;
            Panel     mainWindow  = new Panel(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(edgePadding, edgePadding, Game.GraphicsDevice.Viewport.Width - edgePadding * 2, Game.GraphicsDevice.Viewport.Height - edgePadding * 2)
            };
            GridLayout layout = new GridLayout(GUI, mainWindow, 10, 4);

            Label title = new Label(GUI, layout, "Load Game", GUI.TitleFont);

            layout.SetComponentPosition(title, 0, 0, 1, 1);

            scroller = new ScrollView(GUI, layout);
            layout.SetComponentPosition(scroller, 0, 1, 3, 8);

            LoadWorlds();

            layout.UpdateSizes();

            int cols = Math.Max(scroller.LocalBounds.Width / 256, 1);
            int rows = Math.Max(Math.Max(scroller.LocalBounds.Height / 256, 1), (int)Math.Ceiling((float)Games.Count / (float)cols));

            scrollGrid = new GridLayout(GUI, scroller, rows, cols)
            {
                LocalBounds    = new Rectangle(edgePadding, edgePadding, scroller.LocalBounds.Width - edgePadding, rows * 256),
                WidthSizeMode  = GUIComponent.SizeMode.Fixed,
                HeightSizeMode = GUIComponent.SizeMode.Fixed
            };

            CreateGamePictures(scrollGrid, cols);


            CreateLoadThreads(4);

            PropertiesPanel = new GroupBox(GUI, layout, "Selected");

            layout.SetComponentPosition(PropertiesPanel, 3, 1, 1, 8);

            Button back = new Button(GUI, layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));

            layout.SetComponentPosition(back, 3, 9, 1, 1);
            back.OnClicked += back_OnClicked;
        }
Esempio n. 23
0
        private void GenerateGames()
        {
            ////TODO: Read XML File
            Games.Clear();
            using (var sr = new StreamReader(Settings.Default.SemaphoreGamesFilePath))
            {
                string gameline = sr.ReadLine();
                while (gameline != null)
                {
                    var game = new SemaphoreGame();
                    foreach (char semaphore in gameline)
                    {
                        game.Semaphores.Add(new SemaphoreImage(semaphore));
                    }

                    Games.Add(game);
                    gameline = sr.ReadLine();
                }
            }
        }
Esempio n. 24
0
        public void LoadDescriptor(GameLoadDescriptor descriptor)
        {
            lock (descriptor.Lock)
            {
                if (!descriptor.IsLoaded)
                {
                    return;
                }


                PlayState state = (PlayState)(StateManager.States["PlayState"]);
                state.ExistingFile = descriptor.FileName;
                GUI.MouseMode      = GUISkin.MousePointer.Wait;

                JoinThreads();
                StateManager.PopState();
                StateManager.PushState("PlayState");
                Games.Clear();
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Resets this Match's score and finished status.
        /// Manually set winners are also reversed.
        /// All Games are removed.
        /// </summary>
        /// <returns>Models (list) of all removed Games</returns>
        public List <GameModel> ResetScore()
        {
            if (null == Score)
            {
                Score = new int[2];
            }

            IsFinished = IsManualWin = false;
            Score[0]   = Score[1] = 0;
            WinnerSlot = PlayerSlot.unspecified;

            List <GameModel> modelList = new List <GameModel>();

            foreach (IGame game in Games)
            {
                modelList.Add(GetGameModel(game));
            }
            Games.Clear();
            return(modelList);
        }
Esempio n. 26
0
        public void LoadDescriptor(GameLoadDescriptor descriptor)
        {
            lock (descriptor.Lock)
            {
                if (!descriptor.IsLoaded)
                {
                    return;
                }

                GUI.MouseMode = GUISkin.MousePointer.Wait;

                JoinThreads();
                StateManager.ClearState();
                StateManager.PushState(new LoadState(Game, Game.StateManager, new WorldSettings()
                {
                    ExistingFile = descriptor.FileName, Name = descriptor.FileName
                }));
                Games.Clear();
            }
        }
Esempio n. 27
0
 /// <summary>
 ///		Convierte la librería en ViewModels
 /// </summary>
 private void ConvertToViewModel(LibraryModel library)
 {
     // Asigna el archivo
     Library = library;
     // Limpia la lista
     Games.Clear();
     // Carga los juegos
     foreach (GameModel game in library.Games)
     {
         Games.Add(new PgnGameInfoViewModel(this, game));
     }
     // Selecciona un elemento
     if (Games.Count > 0)
     {
         SelectedGame = Games[0];
     }
     else
     {
         SelectedGame = new PgnGameInfoViewModel(this, new GameModel());
     }
 }
 /// <summary>
 ///		Carga los datos de un juego
 /// </summary>
 private void Load(ChessGameModel chessGame)
 {
     // Asigna el archivo
     ChessGame = chessGame;
     // Limpia la lista
     Games.Clear();
     // Carga los juegos
     foreach (GameModel game in chessGame.Games)
     {
         Games.Add(new GameViewModel(this, game));
     }
     // Selecciona un elemento
     if (Games.Count > 0)
     {
         SelectedGame = Games[0];
     }
     else
     {
         SelectedGame = new GameViewModel(this, new GameModel());
     }
 }
Esempio n. 29
0
        public void QueryGameList(string gameName, Action callback)
        {
            lock (lockSearch)
            {
                Log.WriteInfo("Searching hitbox game {0}", gameName);
                Games.Clear();
                Games.Add(new Game()
                {
                    Name = "Loading..."
                });

                if (callback != null)
                {
                    UI.Dispatch(() => callback());
                }

                var jsonGames = GetHitboxGameList(gameName);

                if (jsonGames == null)
                {
                    Log.WriteInfo("Hitbox search returned empty result", gameName);
                    return;
                }

                Games.Clear();
                foreach (var obj in jsonGames)
                {
                    Games.Add(new Game()
                    {
                        Id   = obj.category_id,
                        Name = obj.category_name,
                    });
                }

                if (callback != null)
                {
                    UI.Dispatch(() => callback());
                }
            }
        }
Esempio n. 30
0
        private void RefreshGames()
        {
            SystemTray.ProgressIndicator.IsVisible = true;

            Context.PlayerGames(Player.Name, games =>
                                Dispatcher.BeginInvoke(() =>
            {
                Games.Clear();
                foreach (var game in games.Select(g => new GameVM(g)))
                {
                    Games.Add(game);
                }

                var settings      = IsolatedStorageSettings.ApplicationSettings;
                settings["games"] = Games.ToArray();

                SystemTray.ProgressIndicator.IsVisible = false;
            })
                                , () =>
            {
            });
        }