private void teamsDataGridView_NewRowNeeded(object sender, DataGridViewRowEventArgs e) { mockClass = new TeamTypeClass { Type = technoTypes.First(), Count = 0 }; classEditRow = teamsDataGridView.RowCount - 1; }
private void teamsDataGridView_CellValuePushed(object sender, DataGridViewCellValueEventArgs e) { if (SelectedTeamType == null) { return; } if (mockClass == null) { mockClass = (e.RowIndex < SelectedTeamType.Classes.Count) ? new TeamTypeClass { Type = SelectedTeamType.Classes[e.RowIndex].Type, Count = SelectedTeamType.Classes[e.RowIndex].Count } : new TeamTypeClass { Type = technoTypes.First(), Count = 0 }; } classEditRow = e.RowIndex; switch (e.ColumnIndex) { case 0: mockClass.Type = e.Value as ITechnoType; break; case 1: mockClass.Count = int.TryParse(e.Value as string, out int value) ? (byte)Math.Max(0, Math.Min(255, value)) : (byte)0; break; } }
private void teamsDataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if (SelectedTeamType == null) { return; } TeamTypeClass teamTypeClass = null; if (e.RowIndex == classEditRow) { teamTypeClass = mockClass; } else if (e.RowIndex < SelectedTeamType.Classes.Count) { teamTypeClass = SelectedTeamType.Classes[e.RowIndex]; } if (teamTypeClass == null) { return; } switch (e.ColumnIndex) { case 0: e.Value = teamTypeClass.Type; break; case 1: e.Value = teamTypeClass.Count; break; } }
private void teamTypesListView_SelectedIndexChanged(object sender, EventArgs e) { houseComboBox.DataBindings.Clear(); roundaboutCheckBox.DataBindings.Clear(); learningCheckBox.DataBindings.Clear(); suicideCheckBox.DataBindings.Clear(); autocreateCheckBox.DataBindings.Clear(); mercernaryCheckBox.DataBindings.Clear(); reinforcableCheckBox.DataBindings.Clear(); prebuiltCheckBox.DataBindings.Clear(); recruitPriorityNud.DataBindings.Clear(); initNumNud.DataBindings.Clear(); maxAllowedNud.DataBindings.Clear(); fearNud.DataBindings.Clear(); waypointComboBox.DataBindings.Clear(); triggerComboBox.DataBindings.Clear(); if (SelectedTeamType != null) { houseComboBox.DataBindings.Add("SelectedValue", SelectedTeamType, "House"); roundaboutCheckBox.DataBindings.Add("Checked", SelectedTeamType, "IsRoundAbout"); learningCheckBox.DataBindings.Add("Checked", SelectedTeamType, "IsLearning"); suicideCheckBox.DataBindings.Add("Checked", SelectedTeamType, "IsSuicide"); autocreateCheckBox.DataBindings.Add("Checked", SelectedTeamType, "IsAutocreate"); mercernaryCheckBox.DataBindings.Add("Checked", SelectedTeamType, "IsMercenary"); reinforcableCheckBox.DataBindings.Add("Checked", SelectedTeamType, "IsReinforcable"); prebuiltCheckBox.DataBindings.Add("Checked", SelectedTeamType, "IsPrebuilt"); recruitPriorityNud.DataBindings.Add("Value", SelectedTeamType, "RecruitPriority"); initNumNud.DataBindings.Add("Value", SelectedTeamType, "InitNum"); maxAllowedNud.DataBindings.Add("Value", SelectedTeamType, "MaxAllowed"); fearNud.DataBindings.Add("Value", SelectedTeamType, "Fear"); waypointComboBox.DataBindings.Add("SelectedIndex", SelectedTeamType, "Origin"); triggerComboBox.DataBindings.Add("SelectedItem", SelectedTeamType, "Trigger"); mockClass = null; mockMission = null; classEditRow = -1; missionEditRow = -1; teamsDataGridView.Rows.Clear(); missionsDataGridView.Rows.Clear(); teamsDataGridView.RowCount = SelectedTeamType.Classes.Count + 1; missionsDataGridView.RowCount = SelectedTeamType.Missions.Count + 1; updateDataGridViewAddRows(teamsDataGridView, Globals.MaxTeamClasses); updateDataGridViewAddRows(missionsDataGridView, Globals.MaxTeamMissions); teamTypeTableLayoutPanel.Visible = true; } else { teamTypeTableLayoutPanel.Visible = false; } }
private void teamsDataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { if (e.Row.Index < SelectedTeamType.Classes.Count) { SelectedTeamType.Classes.RemoveAt(e.Row.Index); } if (e.Row.Index == classEditRow) { mockClass = null; classEditRow = -1; } }
private void teamsDataGridView_CancelRowEdit(object sender, QuestionEventArgs e) { if ((classEditRow == (teamsDataGridView.Rows.Count - 2)) && (classEditRow == SelectedTeamType.Classes.Count)) { mockClass = new TeamTypeClass { Type = technoTypes.First(), Count = 0 }; } else { mockClass = null; classEditRow = -1; } }
private void teamsDataGridView_RowValidated(object sender, DataGridViewCellEventArgs e) { if ((mockClass != null) && (e.RowIndex >= SelectedTeamType.Classes.Count) && ((teamsDataGridView.Rows.Count > 1) || (e.RowIndex < (teamsDataGridView.Rows.Count - 1)))) { SelectedTeamType.Classes.Add(mockClass); mockClass = null; classEditRow = -1; } else if ((mockClass != null) && (e.RowIndex < SelectedTeamType.Classes.Count)) { SelectedTeamType.Classes[e.RowIndex] = mockClass; mockClass = null; classEditRow = -1; } else if (teamsDataGridView.ContainsFocus) { mockClass = null; classEditRow = -1; } }