//读写
        #region SerializeAble Members

        public void ReadObject(System.IO.Stream s)
        {
            short len = 0;
            len = IOUtil.readShort(s);

            for (int i = 0; i < len; i++)
            {
                PropertyTypeElement element = new PropertyTypeElement(this);
                addElement(element);
            }
            for (int i = 0; i < len; i++)
            {
                PropertyTypeElement element = (PropertyTypeElement)getElement(i);
                element.readObjectInit(s);
            }
            for (int i = 0; i < len; i++)
            {
                PropertyTypeElement element = (PropertyTypeElement)getElement(i);
                element.ReadObject(s);
            }
        }
 public InstancesManager(PropertyTypeElement parentT)
 {
     parent = parentT;
 }
        public void ReadObject(System.IO.Stream s)
        {
            name = IOUtil.readString(s);
            ValueType = IOUtil.readByte(s);
            if (ValueType == Consts.PARAM_PROP)
            {
                int id = IOUtil.readInt(s);
                propertyTypeElementUsed = (PropertyTypeElement)((PropertiesManager)parent).form_main.propertyTypesManager.getElement(id);
            }
            if (ValueType == Consts.PARAM_STR)
            {
                defaultValue = IOUtil.readString(s);
            }
            else
            {
                defaultValue = IOUtil.readInt(s);
            }

        }
        public void setPropertyType(Object obj)
        {
            if (obj == null || !(obj is PropertyTypeElement))
            {
                propertyTypeElementUsed = null;
            }
            else 
            {
                propertyTypeElementUsed = (PropertyTypeElement)obj;
            }

        }
 public PropertiesManager(PropertyTypeElement parentT, Form_Main form_mainT)
 {
     parent = parentT;
     form_main = form_mainT;
 }
 public override ObjectElement clone()
 {
     PropertyTypeElement newInstance = new PropertyTypeElement((PropertyTypesManager)parent);
     baseCloneTo(newInstance);
     propertiesManager.cloneTo(newInstance.propertiesManager);
     newInstance.propertiesManager.resetElementParent();
     instancesManager.cloneTo(newInstance.instancesManager);
     newInstance.instancesManager.resetElementParent();
     //设置propertiesManager
     for (int i = 0; i < newInstance.instancesManager.getElementCount(); i++)
     {
         InstanceElement inst = (InstanceElement)newInstance.instancesManager.getElement(i);
         inst.propertyValueManager.propertiesManager = newInstance.propertiesManager;
     }
     return newInstance;
 }
 //合并
 public void combine(PropertyTypeElement srcPropertyTypeElement)
 {
     if (srcPropertyTypeElement == null)
     {
         return;
     }
     propertiesManager.combine(srcPropertyTypeElement.propertiesManager);
     instancesManager.combine(srcPropertyTypeElement.instancesManager);
 }
 //增加单元
 private void addElement_ObjDefine()
 {
     if (listBox_Obj_Define.Focused)//增加对象类型单元
     {
         PropertyTypeElement element = new PropertyTypeElement(propertyTypesManager);
         element.setName(SmallDialog_WordEdit.getNewName("新对象类型单元", element.name));
         propertyTypesManager.insertElement(element, listBox_Obj_Define.SelectedIndex + 1);
     }
     else if (currentObjTypeElement != null)
     {
         if (listBox_ObjProperties.Focused)//增加属性单元
         {
             PropertyElement element = SmallDialog_PropertyDefine.createElement(currentObjTypeElement.propertiesManager);
             if (element != null)
             {
                 int index = listBox_ObjProperties.SelectedIndex+1;
                 currentObjTypeElement.propertiesManager.insertElement(element, index);
                 currentObjTypeElement.instancesManager.inseartProperty(element, index);
             }
         }
         else if (listBox_ObjInstances.Focused)//增加对象实例单元
         {
             InstanceElement element = new InstanceElement(currentObjTypeElement.instancesManager);
             element.propertyValueManager.refreshProperty();
             element.setName(SmallDialog_WordEdit.getNewName("新对象实例单元", element.name));
             currentObjTypeElement.instancesManager.insertElement(element, listBox_ObjInstances.SelectedIndex + 1);
             element.propertyValueManager.refreshUI(listBox_InstanceProperty);
         }
     }
 }
 //重新设置焦点对象类型单元
 private void resetCurrentObjTypeElement()
 {
     if (listBox_Obj_Define.SelectedIndex < 0)
     {
         currentObjTypeElement = null;
     }
     else
     {
         currentObjTypeElement = (PropertyTypeElement)propertyTypesManager.getElement(listBox_Obj_Define.SelectedIndex);
         currentObjTypeElement.instancesManager.setUI(listBox_ObjInstances);
     }
     //显示属性信息
     if (currentObjTypeElement != null)
     {
         currentObjTypeElement.propertiesManager.refreshUI(listBox_ObjProperties);
     }
     else
     {
         listBox_ObjProperties.Items.Clear();
     }
     //显示实例化对象信息
     if (currentObjTypeElement != null)
     {
         currentObjTypeElement.instancesManager.refreshUI(listBox_ObjInstances);
     }
     else
     {
         listBox_ObjInstances.Items.Clear();
     }
     resetCurrentInstanceElement();
 }