private void resCellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (e.RowIndex < this.mResources.Length) { uint val32; ulong val64; DataGridViewRow row = this.resDGV.Rows[e.RowIndex]; row.ErrorText = ""; string str = e.FormattedValue.ToString(); switch ((ColumnName)e.ColumnIndex) { case ColumnName.TID: if (!RK.TryParseUInt32(str, out val32)) { e.Cancel = true; row.ErrorText = "Type ID " + "must be a 32-bit unsigned integer"; } break; case ColumnName.GID: if (!RK.TryParseUInt32(str, out val32)) { e.Cancel = true; row.ErrorText = "Group ID " + "must be a 32-bit unsigned integer"; } break; case ColumnName.IID: if (!RK.TryParseUInt64(str, out val64)) { e.Cancel = true; row.ErrorText = "Type ID " + "must be a 64-bit unsigned integer"; } break; } } }
private void resCellValuePushed(object sender, DataGridViewCellValueEventArgs e) { if (e.RowIndex < this.mResources.Length) { uint val32; ulong val64; string str = e.Value == null ? null : e.Value.ToString(); INamedResourceIndexEntry rie = this.mResources[e.RowIndex]; switch ((ColumnName)e.ColumnIndex) { case ColumnName.Tag: string[] strs = str.Split(' '); if (RK.TryParseHex32(strs[1], out val32)) { rie.ResourceType = val32; } if (this.mColIndex == (int)ColumnName.Tag || this.mColIndex == (int)ColumnName.TID) { if (this.CheckResDGVSorted(e.RowIndex)) { this.resDGV.UpdateCellValue( (int)ColumnName.TID, e.RowIndex); } else { this.UpdateResDGV(); } } else { this.resDGV.UpdateCellValue( (int)ColumnName.TID, e.RowIndex); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.TID: if (RK.TryParseUInt32(str, out val32)) { rie.ResourceType = val32; } if (this.mColIndex == (int)ColumnName.Tag || this.mColIndex == (int)ColumnName.TID) { if (this.CheckResDGVSorted(e.RowIndex)) { this.resDGV.UpdateCellValue( (int)ColumnName.Tag, e.RowIndex); } else { this.UpdateResDGV(); } } else { this.resDGV.UpdateCellValue( (int)ColumnName.Tag, e.RowIndex); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.GID: if (RK.TryParseUInt32(str, out val32)) { rie.ResourceGroup = val32; } if (this.mColIndex == (int)ColumnName.GID && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.IID: if (RK.TryParseUInt64(str, out val64)) { rie.Instance = val64; } if (this.mColIndex == (int)ColumnName.IID && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.Comp: bool comp = (bool)e.Value; rie.Compressed = (ushort)(comp ? 0xFFFF : 0x0000); if (this.mColIndex == (int)ColumnName.Comp && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } break; case ColumnName.Name: rie.ResourceName = str; if (this.mAutoHashing != Hashing.None) { val64 = 0; if (str != null) { switch (this.mAutoHashing) { case Hashing.FNV32: val64 = FNVHash.HashString32(str); break; case Hashing.FNV64: val64 = FNVHash.HashString64(str); break; case Hashing.FNVCLIP: val64 = FNVCLIP.HashString(str); break; } } rie.Instance = val64; if (this.mColIndex == (int)ColumnName.IID || this.mColIndex == (int)ColumnName.Name) { if (this.CheckResDGVSorted(e.RowIndex)) { this.resDGV.UpdateCellValue( (int)ColumnName.IID, e.RowIndex); } else { this.UpdateResDGV(); } } else { this.resDGV.UpdateCellValue( (int)ColumnName.IID, e.RowIndex); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } } if (this.mColIndex == (int)ColumnName.Name && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } break; } } }