private void SaveTableData() { TableData newData = new TableData(); newData.NameHash = data.NameHash; newData.Name = data.Name; newData.Unk1 = data.Unk1; newData.Unk2 = data.Unk2; for (int i = 0; i != DataGrid.ColumnCount; i++) { TableData.Column column = new TableData.Column(); MTableColumn col = (DataGrid.Columns[i] as MTableColumn); column.Type = col.TypeM2; column.Unknown2 = col.Unk2; column.Unknown3 = col.Unk3; column.NameHash = col.NameHash; newData.Columns.Add(column); } for (int i = 0; i != DataGrid.RowCount; i++) { TableData.Row row = new TableData.Row(); for (int x = 0; x != DataGrid.ColumnCount; x++) { row.Values.Add(DataGrid.Rows[i].Cells[x].Value); } newData.Rows.Add(row); } // Don't save the file if we fail to validate if (!newData.Validate()) { MessageBox.Show("Failed to validate. Not saving data.", "Toolkit", MessageBoxButtons.OK); return; } using (BinaryWriter writer = new BinaryWriter(File.Open(file.FullName, FileMode.Create))) { newData.Serialize(writer); } data = newData; Text = Language.GetString("$TABLE_EDITOR_TITLE"); bIsFileEdited = false; }
private void SaveTableData() { TableData newData = new TableData(); newData.NameHash = data.NameHash; newData.Name = data.Name; newData.Unk1 = data.Unk1; newData.Unk2 = data.Unk2; for (int i = 0; i != DataGrid.ColumnCount; i++) { TableData.Column column = new TableData.Column(); MTableColumn col = (DataGrid.Columns[i] as MTableColumn); column.Type = col.TypeM2; column.Unknown2 = col.Unk2; column.Unknown3 = col.Unk3; column.NameHash = col.NameHash; newData.Columns.Add(column); } for (int i = 0; i != DataGrid.RowCount; i++) { TableData.Row row = new TableData.Row(); for (int x = 0; x != DataGrid.ColumnCount; x++) { row.Values.Add(DataGrid.Rows[i].Cells[x].Value); } newData.Rows.Add(row); } using (BinaryWriter writer = new BinaryWriter(File.Open(file.FullName, FileMode.Create))) { newData.Serialize(writer); } data = newData; }