private void AddNewCombatant(object sender, ExecutedRoutedEventArgs e) { Combatant newCombatant = new Combatant(textBlock15.Text, "", textBlock21.Text, textBlock22.Text, textBlock19.Text, textBlock20.Text, textBlock21.Text, textBlock22.Text, textBlock23.Text, textBlock26.Text, textBlock27.Text, textBlock28.Text, textBox1.Text, textBox2.Text, (bool)isNPC.IsChecked); if (combatant == null) { CommAddCombatant addComm = new CommAddCombatant(combatants, newCombatant); addComm.Execute(); } else { int index = combatants.IndexOf(combatant); CommRemoveCombatant commRmv = new CommRemoveCombatant(combatants, combatant); commRmv.Execute(); CommAddCombatant addComm = new CommAddCombatant(combatants, newCombatant); addComm.Execute(); CommRepositionCombatant commRepos = new CommRepositionCombatant(combatants, newCombatant, index - combatants.Count); commRepos.Execute(); } this.Close(); }
private void orderByInit_Click(object sender, RoutedEventArgs e) { IEnumerable<Combatant> sortedCombatants = from combatant in listi orderby -combatant.Initiative select combatant; int count = listi.Count; for (int i = 0; i < count; i++) { Combatant combatant = sortedCombatants.ElementAt(i); int index = listi.IndexOf(combatant); CommRepositionCombatant commRps = new CommRepositionCombatant(listi, combatant, i - index); commRps.Execute(); } }
private void MoveCombatantUp(object sender, RoutedEventArgs e) { Combatant toBeShiftedCombatant = getSelectedCombatant(); if (toBeShiftedCombatant != null) { CommRepositionCombatant commRmv = new CommRepositionCombatant(listi, toBeShiftedCombatant, -1); commRmv.Execute(); } }