private void btnRemove_Click(object sender, EventArgs e) { if (selectedUnit != null) { DialogResult usersChoice = MessageBox.Show(this, "Willst Du die Einheit \'" + selectedUnit.Name + "\' wirklich löschen?", "Achtung!", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); if (usersChoice == DialogResult.Yes) { definedUnits.Remove(selectedUnit); if (foundUnits != null && foundUnits.Any()) { try { foundUnits.Remove(selectedUnit); } catch { } } selectedUnit = null; PerformSearch(); RefreshView(); RefreshDetails(); ClearDetails(); ClearEntry(); DisableListEntryPanel(); } } }
private void AddUnit(object newEntry) { try { if (newEntry != null) { ModelClasses.Unit tmpEntry = (ModelClasses.Unit)newEntry; if (newUnits.Contains(tmpEntry)) { existingUnits.Add(tmpEntry); lbExistingTemplates.Items.Add(tmpEntry); isEdited = true; } else { int idx = existingUnits.FindIndex(x => x.Name == tmpEntry.Name); if (idx > -1) { existingUnits[idx] = new ModelClasses.Unit(tmpEntry); isEdited = true; } } } } catch { } }
public UcSlot(ModelClasses.Units FilteredUnits, int number, ModelClasses.Unit existingUnit) { InitializeComponent(); PossibleUnits = FilteredUnits; this.number = number; CreatedUnit = existingUnit; IsFilled = true; }
private void lbUnits_SelectedIndexChanged(object sender, EventArgs e) { if (lbUnits.SelectedItem != null) { selectedUnit = (ModelClasses.Unit)lbUnits.SelectedItem; selected = true; RefreshDetails(); ClearEntry(); } }
private void cmbUnitTemplate_SelectedIndexChanged(object sender, EventArgs e) { if (cmbUnitTemplate.SelectedItem != null) { UnitTemplate = (ModelClasses.Unit)cmbUnitTemplate.SelectedItem; CreatedUnit = new ModelClasses.Unit(UnitTemplate); CreatedUnit.ListEntries.Clear(); InitModelTemplateList(); } }
private void btnAdd_Click(object sender, EventArgs e) { if (cmbFaction.SelectedItem != null && !String.IsNullOrWhiteSpace(txtInput.Text)) { ModelClasses.Unit newUnit = new ModelClasses.Unit(); newUnit.Faction = (ModelClasses.Faction)cmbFaction.SelectedItem; newUnit.Name = txtInput.Text; definedUnits.AddUnit(newUnit); edited = true; PerformSearch(); RefreshView(); } }
private void btnClear_Click(object sender, EventArgs e) { if (CreatedUnit != null && CreatedUnit.ListEntries.Any()) { DialogResult usersChoice = MessageBox.Show(this, "Willst Du die Einheit wirklich entfernen?", "Vorsicht", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (usersChoice == DialogResult.Yes) { cmbUnitTemplate.Enabled = true; lbActualComposition.Items.Clear(); IsFilled = false; UnitTemplate = new ModelClasses.Unit(); ClearEntry(); FireChangedEvent(); RefreshView(); } } }