private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.IndexAsync(); // Example of how to sort the database output using a linq query. // Sort the list dataset = SortDataset(dataset); foreach (var data in dataset) { // Make a Copy of the Item Model to add to the List Dataset.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// <summary> /// Command to load the data /// </summary> /// <returns></returns> // [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<Pending>")] private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.IndexAsync(); dataset = SortDataSet(dataset); foreach (var data in dataset) { Dataset.Add(data); } } catch (Exception e) { Debug.WriteLine(e); } finally { IsBusy = false; } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var items = await DataStore.GetAllAsync_Item(true); foreach (var item in items) { Dataset.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; SetNeedsRefresh(false); } }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Score(true); //Order the scores by descending order dataset = dataset .OrderByDescending(a => a.ScoreTotal) .ToList(); foreach (var data in dataset) { Dataset.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void LoadData() { Dataset.Clear(); if (CharactersViewModel.Instance.Dataset.Count == 0) { CharactersViewModel.Instance.LoadDataCommand.Execute(null); } else if (CharactersViewModel.Instance.NeedsRefresh()) { CharactersViewModel.Instance.LoadDataCommand.Execute(null); } var dataset = CharactersViewModel.Instance.GetAllCreatures(); int teamCount = 0; foreach (var data in dataset) { if ((data.Type == 0) && (teamCount < 6))//&& data.OnTeam)//the creature is a character, the team is not full, and it is on the current team { teamCount++; Creature newOne = new Creature(); newOne.Update(data); newOne.Id = Guid.NewGuid().ToString(); Dataset.Add(newOne); } } }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Item(true); foreach (var data in dataset) { Dataset.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
// Command that Loads the Data private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.IndexAsync(true); // Example of how to sort the database output using a linq query. // Sort the list dataset = dataset .OrderBy(a => a.Name) .ThenBy(a => a.Description) .ToList(); foreach (var data in dataset) { Dataset.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
// Command to load data into collection private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Score(true); // Load the data structure foreach (var data in dataset) { Dataset.Add(data); } SetNeedsRefresh(false); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Creature(true); foreach (var data in dataset) { if (data.Type == 0)// just Characters { Dataset.Add(data); } } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
// Add characters playing the game from the list of players in battle. public void InitializeCharacterCollection(List <Character> characters) { Dataset.Clear(); foreach (var charNew in characters) { Dataset.Add(charNew); } }
public void setMonsters() { Dataset.Clear(); //LoadDataCommand = new Command(async () => await ExecuteLoadDataCommand()); if (MonstersViewModel.Instance.Dataset.Count == 0) { MonstersViewModel.Instance.LoadDataCommand.Execute(null); } else if (MonstersViewModel.Instance.NeedsRefresh()) { MonstersViewModel.Instance.LoadDataCommand.Execute(null); } var dataset = MonstersViewModel.Instance.GetAllCreatures(); var tempDataset = new List <Creature>(); int dateSeed = DateTime.Now.Millisecond; Random rand = new Random(dateSeed); foreach (var data in dataset) { if (data.Type == 1)// just Monsters { Creature newOne = new Creature(); newOne.Update(data); tempDataset.Add(newOne); } } for (int i = 0; i < 6; i++) { int index = rand.Next(tempDataset.Count); if (GameGlobals.DisableRandomNumbers) { index = 0; } Creature monster = new Creature(); monster.Update(tempDataset[index]); //get a random monster type monster.Id = "monster" + i.ToString(); //Guid.NewGuid().ToString(); monster.Alive = true; monster.Level = round; monster.XP = lp[round].XP; monster.Attack = lp[round].Attack; monster.Defense = lp[round].Defense; monster.Speed = lp[round].Speed; int healthRand = rand.Next(11); if (GameGlobals.DisableRandomNumbers) { healthRand = 1; } monster.MaxHealth = healthRand * round; monster.CurrHealth = monster.MaxHealth; monster.RHandItemID = "bow";// ***temp for demo*** monster.BodyItemID = "helmet"; monster.FeetItemID = "boots"; Dataset.Add(monster); } }
public bool FindRecord(IRadarParameters key) { if (key != null) { lastKey = key; Dataset.Clear(); return(FindRecursiveDataAdapter(key, masterDataAdapterProperties)); } return(false); }
public void clean() { List <Item> clean = Dataset.ToList(); Dataset.Clear(); foreach (var data in clean.Where(x => x != null)) { Dataset.Add(data); } }
/// <summary> /// Wipes the current Data from the Data Store /// </summary> public async Task <bool> DataStoreWipeDataListAsync() { Dataset.Clear(); await DataStore.WipeDataListAsync(); // Load the Sample Data var result = await LoadDefaultDataAsync(); return(result); }
//Resets the dataset to an empty party public void NewParty() { Dataset.Clear(); // creates new characters to update from the master list of characters for (int i = 0; i < MaxPartySize; i++) { Dataset.Add(new Character { name = "Select Character", description = "", characterClass = "" }); } }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); DatasetParty.Clear(); var dataset = await DataStore.GetAllAsync_Character(true); dataset = dataset .OrderBy(a => a.Level) .ThenBy(a => a.Name) .ThenBy(a => a.Speed) .ThenByDescending(a => a.MaximumHealth) .ToList(); // var datasett = await DataStore.GetPartyAsync_Character(true); foreach (var data in dataset) { Dataset.Add(data); } Dataset = new ObservableCollection <Character>(Dataset.OrderBy(a => a.Level) .ThenBy(a => a.Name) .ThenBy(a => a.Speed) .ThenByDescending(a => a.MaximumHealth) .ToList()); foreach (var data in dataset) { if (PartyList.Contains(data.Id)) { DatasetParty.Add(data); } //DatasetParty = new ObservableCollection<Character>(DatasetParty.OrderBy(a => a.Level) //.ThenBy(a => a.Name) //.ThenBy(a => a.Speed) //.ThenByDescending(a => a.MaximumHealth) //.ToList()); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// <summary> /// Wipes the current Data from the Data Store /// </summary> public async Task <bool> WipeDataListAsync() { Dataset.Clear(); await DataStore.WipeDataListAsync(); // Load the Sample Data await LoadDefaultDataAsync(); SetNeedsRefresh(true); return(await Task.FromResult(true)); }
async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); //var dataset = await DataStore.GetAllAsync_Creature(true); var dataset = MonstersViewModel.Instance.GetAllCreatures(); var tempDataset = new List <Creature>(); int dateSeed = DateTime.Now.Millisecond; Random rand = new Random(dateSeed); foreach (var data in dataset) { if (data.Type == 1)// just Monsters { tempDataset.Add(data); } } for (int i = 0; i < 6; i++) { int index = rand.Next(tempDataset.Count); Creature monster = tempDataset[index];//get a random monster type monster.Alive = true; monster.Level = round; monster.XP = lp[round].XP; monster.Attack = lp[round].Attack; monster.Defense = lp[round].Defense; monster.Speed = lp[round].Speed; monster.MaxHealth = rand.Next(11) * round; monster.CurrHealth = monster.MaxHealth; monster.RHandItemID = "bow";// ***temp for demo*** Dataset.Add(monster); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
//_________________MONSTER GENERATOR_________________________________________________ //POPULATE RANDOM MONSTERS___________________ //possible gloal round int round public void newRoundMonsters() { if (Dataset.Count != 0) { Dataset.Clear(); Debug.WriteLine("Dataset was not empty when new round Monster appear"); } for (int i = 0; i < 6; i++) { int monsterType = randomMonster.Next(1, 16);//possible test Monster _monster = new Monster(monsterType); Dataset.Add(_monster); } }
/// <summary> /// Load the Data from the Index Call into the Data List /// </summary> /// <returns></returns> public async Task LoadDataFromIndexAsync() { Dataset.Clear(); var dataset = await DataStore.IndexAsync(); // Example of how to sort the database output using a linq query. // Sort the list dataset = SortDataset(dataset); foreach (var data in dataset) { // Make a Copy of the Item Model to add to the List Dataset.Add(data); } }
//_________________AUTO BATTLE FILL CHARS__________________________________________________ public async void FillParty() { if (Dataset.Count != 0) { Dataset.Clear(); Debug.WriteLine("DatasetParty-Character was not empty when created"); } for (int i = 0; i < 6; i++) { //await Task.Delay(1000); int charType = randomCharacter.Next(1, 7);//possible test Character _character = new Character(charType); Dataset.Add(_character); } _needsRefresh = true; }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Monster(true); // Example of how to sort the database output using a linq query. //Sort the list dataset = dataset .OrderBy(a => a.Name) .ThenBy(a => a.Level) .ThenBy(a => a.Speed) .ThenByDescending(a => a.MaximumHealth) .ToList(); foreach (var data in dataset) { Dataset.Add(data); } Dataset = new ObservableCollection <Monster>(Dataset.OrderBy(a => a.Level) .ThenBy(a => a.Name) .ThenBy(a => a.Speed) .ThenByDescending(a => a.MaximumHealth) .ToList()); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); DatasetCharacter.Clear(); var dataset = BattleViewModel.Instance.Pool; var datasett = BattleViewModel.Instance.DatasetCharacter; foreach (var data in datasett) { DatasetCharacter.Add(data); } foreach (var data in dataset) { Dataset.Add(data); } Dataset = new ObservableCollection <Item>(Dataset.OrderBy(a => a.Name) .ThenBy(a => a.Value) .ThenBy(a => a.Attribute) .ThenByDescending(a => a.Range) .ToList()); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Item(true); // Example of how to sort the database output using a linq query. //Sort the list by Name. What else to add here??? dataset = dataset .OrderBy(a => a.Name) .ThenBy(a => a.Location) .ThenBy(a => a.Attribute) .ThenByDescending(a => a.Value) .ToList(); // Then load the data structure foreach (var data in dataset) { Dataset.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task ExecuteLoadDataCommand() { // Implement if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Monster(true); // Example of how to sort the database output using a linq query. //Sort the list dataset = dataset .OrderBy(a => a.Name) .ThenBy(a => a.Description) .ThenByDescending(a => a.Level) .ToList(); // Then load the data structure foreach (var data in dataset) { Dataset.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } return; }
public bool AddNew() { if (masterBinding == null) { return(false); } if (!OnBeforeAddNew()) { return(false); } Dataset.Clear(); masterBinding.CancelEdit(); masterBinding.AddNew(); slaveBindingCollection.AllowNew = true; Status = DBMode.Edit; dbOperation = DBOperation.New; UpdateFiscalControl(DBOperation.Get); return(OnAfterAddNew()); }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); var dataset = await DataStore.GetAllAsync_Score(true); // Example of how to sort the database output using a linq query. //Sort the list dataset = dataset .OrderBy(a => a.ExperienceGainedTotal) .ThenBy(a => a.ScoreTotal) .ThenBy(a => a.GameDate) .ThenByDescending(a => a.TurnCount) .ToList(); // Then load the data structure foreach (var data in dataset) { Dataset.Add(data); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); if (DataStore == null) { SetDataStore(DataStoreEnum.Sql); // initialize to sql } // Get all characters from database var dataset = await DataStore.GetAllAsync_Character(true); foreach (var data in dataset) { Dataset.Add(data); } DatasetItems.Clear(); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
/// <summary> /// Load the DefaultData /// </summary> /// <returns></returns> public async Task <bool> LoadDefaultDataAsync() { if (await DataStore.GetNeedsInitializationAsync()) { Dataset.Clear(); // Load the Data from the DataStore await ExecuteLoadDataCommand(); } // If data exists, do not run if (Dataset.Count > 0) { return(false); } // Take all the items and add them if they don't already exist foreach (var data in GetDefaultData()) { await CreateUpdateAsync(data); } return(true); }
async Task ExecuteLoadDataCommand() { if (IsBusy) { return; } IsBusy = true; try { Dataset.Clear(); //var dataset = await SQLDataStore.GetAllAsync_Creature(true); if (CharactersViewModel.Instance.Dataset.Count == 0) { CharactersViewModel.Instance.LoadDataCommand.Execute(null); } else if (CharactersViewModel.Instance.NeedsRefresh()) { CharactersViewModel.Instance.LoadDataCommand.Execute(null); } var dataset = CharactersViewModel.Instance.GetAllCreatures(); int teamCount = 0; foreach (var data in dataset) { if ((data.Type == 0) && (teamCount < 6) && data.OnTeam)//the creature is a character, the team is not full, and it is on the current team { teamCount++; Dataset.Add(data); } } if (teamCount < 6) { foreach (var data in dataset) //if the team is not full more characters must be added { if ((data.Type == 0) && (teamCount < 6) && !Dataset.Contains(data)) //the creature is a character, the team is not full, and the character is not in the team { teamCount++; data.OnTeam = true; Dataset.Add(data); } } } if (teamCount < 6)//if you didn't make enough characters you get some sucky ones { int numOfSuckyCharacters = 0; for (int i = teamCount; i < 6; i++) { numOfSuckyCharacters++; Creature character = new Creature(); character.Type = 0; character.OnTeam = true; character.Name = "Sucky Character " + numOfSuckyCharacters.ToString(); character.Attack = 1; character.Defense = 1; character.Speed = 1; character.MaxHealth = 1; character.CurrHealth = character.MaxHealth; Dataset.Add(character); await DataStore.AddAsync_Creature(character); } } // ***temp for demo*** foreach (var data in Dataset) { data.RHandItemID = "bow"; data.LHandItemID = "bow"; } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }