Esempio n. 1
0
        public MetaPropertyDialog(bool canBeEdited, AgentType agent, CustomizedStruct customizedStruct, PropertyDef prop, bool canBePar)
        {
            InitializeComponent();

            this.Owner = MainWindow.Instance;

            this.metaPropertyPanel.Initialize(canBeEdited, agent, customizedStruct, prop, canBePar);
        }
Esempio n. 2
0
        public void Initialize(bool canBeEdit, AgentType agent, CustomizedStruct customizedStruct, PropertyDef prop, bool canBePar)
        {
            Debug.Check(agent != null || customizedStruct != null);

            _initialized = false;
            _isModified = false;
            _isNew = (prop == null);
            _agent = agent;
            _customizedStruct = customizedStruct;
            _originalProperty = prop;

            setTypes();

            if (_isNew)
            {
                this.Text = canBeEdit ? Resources.AddProperty : Resources.ViewProperty;

                if (customizedStruct == null)
                    _property = new PropertyDef(agent, null, agent.AgentTypeName, "", "", "");
                else
                    _property = new PropertyDef(null, null, customizedStruct.Name, "", "", "");
            }
            else
            {
                this.Text = canBeEdit ? Resources.EditProperty : Resources.ViewProperty;

                resetProperty(prop, prop.IsPar);
            }

            this.isStaticCheckBox.Visible = (agent != null);
            this.isPublicCheckBox.Visible = !canBeEdit && (agent != null);
            this.isConstcheckBox.Visible = (agent != null);
            this.customizedCheckBox.Visible = !canBeEdit && !_property.IsInherited;
            this.isLocalCheckBox.Checked = customizedStruct == null && _property.IsPar;
            this.isLocalCheckBox.Visible = canBePar && customizedStruct == null && !_property.IsMember;
            this.nameTextBox.Enabled = canBeEdit;
            this.arrayCheckBox.Enabled = canBeEdit || _property.IsChangeableType;
            this.typeComboBox.Enabled = canBeEdit || _property.IsChangeableType;
            this.isStaticCheckBox.Enabled = canBeEdit;
            this.isConstcheckBox.Enabled = canBeEdit;
            this.dispTextBox.Enabled = canBeEdit;
            this.descTextBox.Enabled = canBeEdit;

            _initialized = true;
        }
Esempio n. 3
0
 public CustomizedStruct(CustomizedStruct other)
     : base(other)
 {
     if (other != null)
     {
         foreach (PropertyDef prop in other.Properties)
         {
             this.Properties.Add(new PropertyDef(prop));
         }
     }
 }
Esempio n. 4
0
        private static void LoadCustomTypes(XmlNode rootNode) {
            if (rootNode == null)
            { return; }

            CustomizedTypeManager.Instance.Enums.Clear();
            CustomizedTypeManager.Instance.Structs.Clear();

            foreach(XmlNode xmlNode in rootNode.ChildNodes) {
                if (xmlNode.Name == "enumtype") {
                    string enumName = GetAttribute(xmlNode, "Type");
                    string[] enumNames = enumName.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                    enumName = enumNames[enumNames.Length - 1];

                    string displayName = GetAttribute(xmlNode, "DisplayName");
                    string desc = GetAttribute(xmlNode, "Desc");

                    CustomizedEnum customizedEnum = new CustomizedEnum(null);
                    customizedEnum.Name = enumName;
                    customizedEnum.DisplayName = displayName;
                    customizedEnum.Description = desc;

                    foreach(XmlNode memberNode in xmlNode.ChildNodes) {
                        if (memberNode.Name == "enum") {
                            string memberName = GetAttribute(memberNode, "Value");
                            string[] memberNames = memberName.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                            memberName = memberNames[memberNames.Length - 1];

                            string memberDisplayName = GetAttribute(memberNode, "DisplayName");
                            string memberDesc = GetAttribute(memberNode, "Desc");
                            string memberValue = GetAttribute(memberNode, "MemberValue");

                            CustomizedEnum.CustomizedEnumMember enumMember = new CustomizedEnum.CustomizedEnumMember(null);
                            enumMember.Name = memberName;
                            enumMember.DisplayName = memberDisplayName;
                            enumMember.Description = memberDesc;

                            try {
                                enumMember.Value = int.Parse(memberValue);

                            } catch {
                                enumMember.Value = -1;
                            }

                            customizedEnum.Members.Add(enumMember);
                        }
                    }

                    CustomizedTypeManager.Instance.Enums.Add(customizedEnum);

                } else if (xmlNode.Name == "struct") {
                    string structName = GetAttribute(xmlNode, "Type");
                    string[] structNames = structName.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                    structName = structNames[structNames.Length - 1];

                    string displayName = GetAttribute(xmlNode, "DisplayName");
                    string desc = GetAttribute(xmlNode, "Desc");

                    CustomizedStruct customizedStruct = new CustomizedStruct(null);
                    customizedStruct.Name = structName;
                    customizedStruct.DisplayName = displayName;
                    customizedStruct.Description = desc;

                    foreach(XmlNode memberNode in xmlNode.ChildNodes) {
                        if (memberNode.Name == "Member") {
                            string memberName = GetAttribute(memberNode, "Name");
                            string[] memberNames = memberName.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                            memberName = memberNames[memberNames.Length - 1];

                            string memberType = GetAttribute(memberNode, "Type");
                            Type type = Plugin.GetTypeFromName(memberType);
                            string memberDisplayName = GetAttribute(memberNode, "DisplayName");
                            string memberDesc = GetAttribute(memberNode, "Desc");

                            PropertyDef structProp = new PropertyDef(null, type, structName, memberName, memberDisplayName, memberDesc);
                            customizedStruct.Properties.Add(structProp);
                        }
                    }

                    CustomizedTypeManager.Instance.Structs.Add(customizedStruct);
                }
            }
        }
Esempio n. 5
0
        private void moveCustomizedType(CustomizedEnum customizedEnum, CustomizedStruct customizedStruct, int sourceIndex, int targetIndex)
        {
            if (sourceIndex >= 0 && sourceIndex < this.memberListBox.Items.Count &&
                targetIndex >= 0 && targetIndex < this.memberListBox.Items.Count) {
                if (customizedEnum != null) {
                    CustomizedEnum.CustomizedEnumMember enumMember = customizedEnum.Members[sourceIndex];
                    customizedEnum.Members.RemoveAt(sourceIndex);
                    customizedEnum.Members.Insert(targetIndex, enumMember);

                    Workspace.Current.IsBlackboardDirty = true;

                } else if (customizedStruct != null) {
                    PropertyDef structMember = customizedStruct.Properties[sourceIndex];
                    customizedStruct.Properties.RemoveAt(sourceIndex);
                    customizedStruct.Properties.Insert(targetIndex, structMember);

                    Workspace.Current.IsBlackboardDirty = true;
                }

                object item = this.memberListBox.Items[sourceIndex];
                this.memberListBox.Items.RemoveAt(sourceIndex);
                this.memberListBox.Items.Insert(targetIndex, item);

                this.memberListBox.SelectedIndex = targetIndex;
            }
        }
Esempio n. 6
0
        private void typeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.GetMetaType() == MetaTypes.Agent)
            {
                if (_customizedAgent == null)
                {
                    _customizedAgent = new AgentType(this.nameTextBox.Text, null, this.dispTextBox.Text, this.descTextBox.Text);
                }
            }
            else if (this.GetMetaType() == MetaTypes.Enum)
            {
                if (_customizedEnum == null)
                {
                    _customizedEnum = new CustomizedEnum(this.nameTextBox.Text, this.dispTextBox.Text, this.descTextBox.Text);
                }
            }
            else if (this.GetMetaType() == MetaTypes.Struct)
            {
                if (_customizedStruct == null)
                {
                    _customizedStruct = new CustomizedStruct(this.nameTextBox.Text, this.dispTextBox.Text, this.descTextBox.Text);
                }
            }

            resetBaseTypes();

            if (_initialized)
                this.IsModified = true;
        }
Esempio n. 7
0
        public void Initialize(object typeObject)
        {
            _initialized = false;
            _isModified = false;
            _isNew = (typeObject == null);
            this.Text = _isNew ? Resources.AddType : Resources.EditType;

            MetaTypes metaType = MetaTypes.Agent;

            if (typeObject != null)
            {
                if (typeObject is AgentType)
                {
                    metaType = MetaTypes.Agent;
                    _customizedAgent = typeObject as AgentType;

                }
                else if (typeObject is CustomizedEnum)
                {
                    metaType = MetaTypes.Enum;
                    _customizedEnum = typeObject as CustomizedEnum;

                }
                else if (typeObject is CustomizedStruct)
                {
                    metaType = MetaTypes.Struct;
                    _customizedStruct = typeObject as CustomizedStruct;
                }
            }

            this.typeComboBox.Items.Clear();
            this.typeComboBox.Enabled = _isNew;
            foreach (string type in Enum.GetNames(typeof(MetaTypes)))
            {
                this.typeComboBox.Items.Add(type);
            }
            this.typeComboBox.SelectedIndex = (int)metaType;

            if (this.GetMetaType() == MetaTypes.Agent)
            {
                Debug.Check(_customizedAgent != null);

                if (_customizedAgent.Base != null)
                {
                    this.baseComboBox.SelectedText = _customizedAgent.Base.AgentTypeName;
                }

                this.nameTextBox.Text = _customizedAgent.AgentTypeName;
                this.dispTextBox.Text = _customizedAgent.DisplayName;
                this.descTextBox.Text = _customizedAgent.Description;

                this.typeComboBox.Enabled = _customizedAgent.IsCustomized;
                this.nameTextBox.Enabled = _customizedAgent.IsCustomized;
                this.baseComboBox.Enabled = _customizedAgent.IsCustomized;
                this.dispTextBox.Enabled = _customizedAgent.IsCustomized;
                this.descTextBox.Enabled = _customizedAgent.IsCustomized;
            }
            else
            {
                if (this.GetMetaType() == MetaTypes.Enum)
                {
                    Debug.Check(_customizedEnum != null);

                    this.nameTextBox.Text = _customizedEnum.Name;
                    this.dispTextBox.Text = _customizedEnum.DisplayName;
                    this.descTextBox.Text = _customizedEnum.Description;
                }
                else if (this.GetMetaType() == MetaTypes.Struct)
                {
                    Debug.Check(_customizedStruct != null);

                    this.nameTextBox.Text = _customizedStruct.Name;
                    this.dispTextBox.Text = _customizedStruct.DisplayName;
                    this.descTextBox.Text = _customizedStruct.Description;
                }

                this.typeComboBox.Enabled = true;
                this.nameTextBox.Enabled = true;
                this.baseComboBox.Enabled = true;
                this.dispTextBox.Enabled = true;
                this.descTextBox.Enabled = true;
            }

            this.nameTextBox.Focus();
            this.nameTextBox.SelectionStart = this.nameTextBox.TextLength;

            _initialized = true;
        }