private void QMMatsGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == 0) // change the default { this.defaultMETE = new METEData( double.Parse(this.QMMatsGrid.Rows[0].Cells[2].Value.ToString()), double.Parse(this.QMMatsGrid.Rows[0].Cells[3].Value.ToString()), double.Parse(this.QMMatsGrid.Rows[0].Cells[4].Value.ToString()), double.Parse(this.QMMatsGrid.Rows[0].Cells[5].Value.ToString()), double.Parse(this.QMMatsGrid.Rows[0].Cells[6].Value.ToString()), double.Parse(this.QMMatsGrid.Rows[0].Cells[7].Value.ToString()) ); refreshMatsTable(); } else if (e.RowIndex > 0) { string name = (string)this.QMMatsGrid.Rows[e.RowIndex].Cells[0].Value; name = name.Substring(name.LastIndexOf("-") + 1); invType item = MainForm._sde.GetTypeFromName(name).First(); METEData data = new METEData( (this.QMMatsGrid.Rows[e.RowIndex].Cells[2].Value == null || (string)this.QMMatsGrid.Rows[e.RowIndex].Cells[2].Value == "") ? -1 : int.Parse(this.QMMatsGrid.Rows[e.RowIndex].Cells[2].Value.ToString()), (this.QMMatsGrid.Rows[e.RowIndex].Cells[3].Value == null || (string)this.QMMatsGrid.Rows[e.RowIndex].Cells[3].Value == "") ? -1 : int.Parse(this.QMMatsGrid.Rows[e.RowIndex].Cells[3].Value.ToString()), (this.QMMatsGrid.Rows[e.RowIndex].Cells[4].Value == null || (string)this.QMMatsGrid.Rows[e.RowIndex].Cells[4].Value == "") ? -1 : int.Parse(this.QMMatsGrid.Rows[e.RowIndex].Cells[4].Value.ToString()), (this.QMMatsGrid.Rows[e.RowIndex].Cells[5].Value == null || (string)this.QMMatsGrid.Rows[e.RowIndex].Cells[5].Value == "") ? -1 : int.Parse(this.QMMatsGrid.Rows[e.RowIndex].Cells[5].Value.ToString()), (this.QMMatsGrid.Rows[e.RowIndex].Cells[6].Value == null || (string)this.QMMatsGrid.Rows[e.RowIndex].Cells[6].Value == "") ? -1 : int.Parse(this.QMMatsGrid.Rows[e.RowIndex].Cells[6].Value.ToString()), (this.QMMatsGrid.Rows[e.RowIndex].Cells[7].Value == null || (string)this.QMMatsGrid.Rows[e.RowIndex].Cells[7].Value == "") ? -1 : int.Parse(this.QMMatsGrid.Rows[e.RowIndex].Cells[7].Value.ToString()) ); this.meteDatas.Remove(item); this.meteDatas.Add(item, data); refreshMatsTable(); } }
private void addMatR(invType mat, int amount, int depth, bool start = false) { if (mat == null) { return; } if (mat.isBaseMat()) { baseMats.Add(mat, amount); } else { METEData data = null; this.meteDatas.TryGetValue(mat, out data); bool hadMEData = true; if (data == null) { data = this.defaultMETE; hadMEData = false; } string matStr = ""; for (int i = 0; i < depth; i++) { matStr += "-"; } if (!hadMEData || start) { this.QMMatsGrid.Rows.Add(matStr + mat, amount, "", "", "", "", "", ""); } else { string[] mesStrs = data.ToStrArray(); this.QMMatsGrid.Rows.Add(matStr + mat, amount, mesStrs[0], mesStrs[1], mesStrs[2], mesStrs[3], mesStrs[4], mesStrs[5]); } var matlist = mat.getMats(amount, data.TotalMEAsMultiplier); foreach (KeyValuePair <invType, int> submat in matlist) { addMatR(submat.Key, submat.Value, depth + 1); } } }