Exemplo n.º 1
0
        private void resCellValueNeeded(object sender,
                                        DataGridViewCellValueEventArgs e)
        {
            if (e.RowIndex < this.mResources.Length)
            {
                string str;
                INamedResourceIndexEntry rie = this.mResources[e.RowIndex];
                switch ((ColumnName)e.ColumnIndex)
                {
                case ColumnName.Tag:
                    str = "0x" + rie.ResourceType.ToString("X8");
                    if (ExtList.Ext.ContainsKey(str))
                    {
                        e.Value = ExtList.Ext[str][0] + " " + str;
                    }
                    else
                    {
                        e.Value = "";
                    }
                    break;

                case ColumnName.TID:
                    e.Value = "0x" + rie.ResourceType.ToString("X8");
                    break;

                case ColumnName.GID:
                    e.Value = "0x" + rie.ResourceGroup.ToString("X8");
                    break;

                case ColumnName.IID:
                    e.Value = "0x" + rie.Instance.ToString("X16");
                    break;

                case ColumnName.Comp:
                    e.Value = rie.Compressed == 0xFFFF;
                    break;

                case ColumnName.Name:
                    e.Value = rie.ResourceName;
                    break;
                }
            }
        }
Exemplo n.º 2
0
        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;
                }
            }
        }