Пример #1
0
        protected bool EditIntHexValue(TagNode tag)
        {
            if (FormRegistry.EditByteArray != null)
            {
                TagNodeIntArray iatag    = tag.ToTagIntArray();
                byte[]          byteData = new byte[iatag.Length * 4];
                for (int i = 0; i < iatag.Length; i++)
                {
                    byte[] buf = BitConverter.GetBytes(iatag.Data[i]);
                    Array.Copy(buf, 0, byteData, 4 * i, 4);
                }

                ByteArrayFormData data = new ByteArrayFormData()
                {
                    NodeName        = NodeName,
                    BytesPerElement = 4,
                    Data            = byteData,
                };

                if (FormRegistry.EditByteArray(data))
                {
                    iatag.Data = new int[data.Data.Length / 4];
                    for (int i = 0; i < iatag.Length; i++)
                    {
                        iatag.Data[i] = BitConverter.ToInt32(data.Data, i * 4);
                    }

                    IsDataModified = true;
                    return(true);
                }
            }

            return(false);
        }
        static string GetTagNodeText(TagNode tag)
        {
            if (tag == null)
                return null;

            switch (tag.GetTagType())
            {
                case TagType.TAG_BYTE:
                case TagType.TAG_SHORT:
                case TagType.TAG_INT:
                case TagType.TAG_LONG:
                case TagType.TAG_FLOAT:
                case TagType.TAG_DOUBLE:
                case TagType.TAG_STRING:
                    return tag.ToString();

                case TagType.TAG_BYTE_ARRAY:
                    return tag.ToTagByteArray().Length + " bytes";

                case TagType.TAG_INT_ARRAY:
                    return tag.ToTagIntArray().Length + " integers";

                case TagType.TAG_LIST:
                    return tag.ToTagList().Count + " entries";

                case TagType.TAG_COMPOUND:
                    return tag.ToTagCompound().Count + " entries";
            }

            return null;
        }
Пример #3
0
        protected bool EditIntHexValue (TagNode tag)
        {
            if (FormRegistry.EditByteArray != null) {
                TagNodeIntArray iatag = tag.ToTagIntArray();
                byte[] byteData = new byte[iatag.Length * 4];
                for (int i = 0; i < iatag.Length; i++) {
                    byte[] buf = BitConverter.GetBytes(iatag.Data[i]);
                    Array.Copy(buf, 0, byteData, 4 * i, 4);
                }

                ByteArrayFormData data = new ByteArrayFormData() {
                    NodeName = NodeName,
                    BytesPerElement = 4,
                    Data = byteData,
                };

                if (FormRegistry.EditByteArray(data)) {
                    iatag.Data = new int[data.Data.Length / 4];
                    for (int i = 0; i < iatag.Length; i++) {
                        iatag.Data[i] = BitConverter.ToInt32(data.Data, i * 4);
                    }

                    IsDataModified = true;
                    return true;
                }
            }

            return false;
        }