private void PopulateProperties(ResponseScriptProperties Packet)
        {
            CustomPropertyGridObject GridObject = new CustomPropertyGridObject();

            AddPropertyChildren(Packet.Root, GridObject, "", false);

            ScriptPropertyGrid.SelectedObject = GridObject;
        }
        private void AddPropertyChildren(ScriptProperty Property, CustomPropertyGridObject Obj, string path, bool isArray)
        {
            int index = 0;

            foreach (ScriptProperty Child in Property.Children)
            {
                object value     = false;
                Type   valueType = typeof(bool);

                string nodePath = path;
                if (isArray)
                {
                    nodePath += "[" + index + "]";
                }
                else
                {
                    if (nodePath != "")
                    {
                        nodePath += ".";
                    }
                    nodePath += Child.Name;
                }

                switch (Child.TypeName)
                {
                case "Bool":
                {
                    value     = (Child.CurrentValue == "1");
                    valueType = typeof(bool);
                    break;
                }

                case "String":
                {
                    value     = Child.CurrentValue;
                    valueType = typeof(string);
                    break;
                }

                case "Float":
                {
                    value     = float.Parse(Child.CurrentValue);
                    valueType = typeof(float);
                    break;
                }

                case "Int":
                {
                    value     = int.Parse(Child.CurrentValue);
                    valueType = typeof(int);
                    break;
                }

                case "Array":
                {
                    if (Child.CurrentValue != "Null")
                    {
                        CustomPropertyGridObject SubChild = new CustomPropertyGridObject();
                        AddPropertyChildren(Child, SubChild, nodePath, true);

                        value     = SubChild;
                        valueType = typeof(CustomPropertyGridObject);
                    }
                    else
                    {
                        value     = null;
                        valueType = typeof(object);
                    }
                    break;
                }

                case "Object":
                {
                    if (Child.CurrentValue != "Null")
                    {
                        CustomPropertyGridObject SubChild = new CustomPropertyGridObject();
                        AddPropertyChildren(Child, SubChild, nodePath, false);

                        value     = SubChild;
                        valueType = typeof(CustomPropertyGridObject);
                    }
                    else
                    {
                        value     = null;
                        valueType = typeof(object);
                    }
                    break;
                }
                }

                string DisplayName = Child.Name.Replace("_", " ");
                if (DisplayName.Length > 2 && DisplayName.Substring(0, 2) == "m ")
                {
                    DisplayName = DisplayName.Substring(2);
                }
                if (DisplayName.Length > 0 && DisplayName[0] >= 'a' && DisplayName[0] <= 'z')
                {
                    DisplayName = DisplayName.Substring(0, 1).ToUpper() + DisplayName.Substring(1);
                }

                bool bReadOnly = Child.bReadOnly;
                if (DisplayName.Length > 3 && Utils.ValidationHelper.IsUppercase(DisplayName))
                {
                    bReadOnly = true;
                }

                if (isArray)
                {
                    DisplayName = "[" + index + "]";
                }

                CustomProperty Prop = new CustomProperty(DisplayName, value, valueType, bReadOnly, true, nodePath);
                Prop.Changed += Property_Changed;
                Obj.Add(Prop);

                index++;
            }
        }