private void ArmyAddCommanderButton_Click(object sender, EventArgs e) { CCommander loadedCommander = ShowLoadJsonObjectDialog <CCommander>(); if (loadedCommander != null) { if (!ArmyCommanderList.Items.Contains(loadedCommander.Name)) { armyCreatorWorkingCopy.Commanders.Add(loadedCommander); ArmyCommanderList.Items.Add(loadedCommander.Name); } } }
private void CommanderLoadButton_Click(object sender, EventArgs e) { CCommander commanderToLoad = ShowLoadJsonObjectDialog <CCommander>(); if (commanderToLoad != default(CCommander)) { CommanderNameText.Text = commanderToLoad.Name; CommanderIntNumeric.Value = (decimal)commanderToLoad.Stats[CCommander.STAT_INT]; CommanderWisNumeric.Value = (decimal)commanderToLoad.Stats[CCommander.STAT_WIS]; CommanderChaNumeric.Value = (decimal)commanderToLoad.Stats[CCommander.STAT_CHA]; CommanderLandWarNumeric.Value = (decimal)commanderToLoad.Stats[CCommander.STAT_LAND_WAR]; CommanderMaritimeNumeric.Value = (decimal)commanderToLoad.Stats[CCommander.STAT_MARITIME]; } }
private void CommanderSaveButton_Click(object sender, EventArgs e) { CCommander commanderToSave = new CCommander() { Name = CommanderNameText.Text, Stats = new Dictionary <string, int> { [CCommander.STAT_INT] = (int)CommanderIntNumeric.Value, [CCommander.STAT_WIS] = (int)CommanderWisNumeric.Value, [CCommander.STAT_CHA] = (int)CommanderChaNumeric.Value, [CCommander.STAT_LAND_WAR] = (int)CommanderLandWarNumeric.Value, [CCommander.STAT_MARITIME] = (int)CommanderMaritimeNumeric.Value } }; ShowSaveJsonObjectDialog <CCommander>(commanderToSave); }
private void ArmyCommanderList_SelectedIndexChanged(object sender, EventArgs e) { ArmyCommanderDetailText.Text = ""; if (ArmyCommanderList.SelectedItem != null) { String selectedCommanderName = ArmyCommanderList.SelectedItem.ToString(); bool HasSelectedCommanderName(CCommander commander) { return(commander.Name == selectedCommanderName); } CCommander selectedCommander = armyCreatorWorkingCopy.Commanders.Find(HasSelectedCommanderName); ArmyCommanderDetailText.Text = CCommander.STAT_INT + ": " + selectedCommander.Stats[CCommander.STAT_INT] + " " + CCommander.STAT_WIS + ": " + selectedCommander.Stats[CCommander.STAT_WIS] + " " + CCommander.STAT_CHA + ": " + selectedCommander.Stats[CCommander.STAT_CHA] + "\r\n" + CCommander.STAT_LAND_WAR + ": " + selectedCommander.Stats[CCommander.STAT_LAND_WAR] + " " + CCommander.STAT_MARITIME + ": " + selectedCommander.Stats[CCommander.STAT_MARITIME]; } }