Пример #1
0
        protected virtual void EditProperty()
        {
            using (var form = new DynamicPropertyForm())
            {
                form.Text = "Edit Dynamic Property".Localize();
                form.PropertyName.Text = Descriptor.DisplayName;
                form.Category.Text     = Descriptor.Category;
                form.Description.Text  = Descriptor.Description;

                string valueType = Descriptor.AttributeInfo.Name;
                if (valueType == "stringValue")
                {
                    form.StringType.Checked = true;
                }
                else if (valueType == "floatValue")
                {
                    form.FloatingPointType.Checked = true;
                }
                else if (valueType == "vector3Value")
                {
                    form.VectorType.Checked = true;
                }
                else if (valueType == "boolValue")
                {
                    form.BooleanType.Checked = true;
                }
                else if (valueType == "intValue")
                {
                    form.IntegerType.Checked = true;
                }
                else
                {
                    throw new InvalidOperationException("Unknown type of dynamic property: " +
                                                        valueType);
                }

                // Don't let the user change the type of the dynamic property; this currently
                //  can cause a crash because PropertyView will use the old UI property editor
                //  which won't be compatible with the new value.
                form.StringType.Enabled        = false;
                form.FloatingPointType.Enabled = false;
                form.VectorType.Enabled        = false;
                form.BooleanType.Enabled       = false;
                form.IntegerType.Enabled       = false;

                do
                {
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.OK)
                    {
                        ApplyDialogResults(form, false);
                    }
                } while (form.DialogResult == DialogResult.Retry);
            }
        }
Пример #2
0
 protected virtual void AddNewProperty()
 {
     using (var form = new DynamicPropertyForm())
     {
         do
         {
             form.ShowDialog();
             if (form.DialogResult == DialogResult.OK)
             {
                 ApplyDialogResults(form, true);
             }
         } while (form.DialogResult == DialogResult.Retry);
     }
 }
Пример #3
0
        protected virtual void ApplyDialogResults(DynamicPropertyForm form, bool add)
        {
            string propertyName = form.PropertyName.Text;

            if (string.IsNullOrEmpty(propertyName))
            {
                MessageBox.Show("The property name can't be empty".Localize(), "", MessageBoxButtons.OK);
                form.DialogResult = DialogResult.Retry;
                return;
            }

            string description = form.Description.Text;
            string category = form.Category.Text;
            bool success;

            if (form.StringType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "", //type converter
                    "", //UI editor
                    Schema.dynamicPropertyType.stringValueAttribute.Name,
                    add);
            }
            else if (form.FloatingPointType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "", //type converter
                    "", //UI editor
                    Schema.dynamicPropertyType.floatValueAttribute.Name,
                    add);
            }
            else if (form.IntegerType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "", //type converter
                    "", //UI editor
                    Schema.dynamicPropertyType.intValueAttribute.Name,
                    add);
            }
            else if (form.BooleanType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "", //type converter
                    "Sce.Atf.Controls.PropertyEditing.BoolEditor, Atf.Gui.WinForms", //UI editor
                    Schema.dynamicPropertyType.boolValueAttribute.Name,
                    add);
            }
            else if (form.VectorType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "Sce.Atf.Controls.PropertyEditing.FloatArrayConverter, Atf.Gui", //type converter
                    "Sce.Atf.Controls.PropertyEditing.NumericTupleEditor, Atf.Gui.WinForms:System.Single,x,y,z", //UI editor
                    Schema.dynamicPropertyType.vector3ValueAttribute.Name,
                    add);
            }
            else
                throw new InvalidOperationException("A radio button wasn't handled");

            if (!success)
                form.DialogResult = DialogResult.Retry;
        }
Пример #4
0
        protected virtual void EditProperty()
        {
            using (var form = new DynamicPropertyForm())
            {
                form.Text = "Edit Dynamic Property".Localize();
                form.PropertyName.Text = Descriptor.DisplayName;
                form.Category.Text = Descriptor.Category;
                form.Description.Text = Descriptor.Description;

                string valueType = Descriptor.AttributeInfo.Name;
                if (valueType == "stringValue")
                    form.StringType.Checked = true;
                else if (valueType == "floatValue")
                    form.FloatingPointType.Checked = true;
                else if (valueType == "vector3Value")
                    form.VectorType.Checked = true;
                else if (valueType == "boolValue")
                    form.BooleanType.Checked = true;
                else if (valueType == "intValue")
                    form.IntegerType.Checked = true;
                else
                    throw new InvalidOperationException("Unknown type of dynamic property: " +
                        valueType);

                // Don't let the user change the type of the dynamic property; this currently
                //  can cause a crash because PropertyView will use the old UI property editor
                //  which won't be compatible with the new value.
                form.StringType.Enabled = false;
                form.FloatingPointType.Enabled = false;
                form.VectorType.Enabled = false;
                form.BooleanType.Enabled = false;
                form.IntegerType.Enabled = false;
                
                do
                {

                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.OK)
                        ApplyDialogResults(form, false);
                } while (form.DialogResult == DialogResult.Retry);
            }
        }
Пример #5
0
 protected virtual void AddNewProperty()
 {
     using (var form = new DynamicPropertyForm())
     {
         do
         {
             form.ShowDialog();
             if (form.DialogResult == DialogResult.OK)
                 ApplyDialogResults(form, true);
         } while (form.DialogResult == DialogResult.Retry);
     }
 }
Пример #6
0
        protected virtual void ApplyDialogResults(DynamicPropertyForm form, bool add)
        {
            string propertyName = form.PropertyName.Text;

            if (string.IsNullOrEmpty(propertyName))
            {
                MessageBox.Show("The property name can't be empty".Localize(), "", MessageBoxButtons.OK);
                form.DialogResult = DialogResult.Retry;
                return;
            }

            string description = form.Description.Text;
            string category    = form.Category.Text;
            bool   success;

            if (form.StringType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "", //type converter
                    "", //UI editor
                    Schema.dynamicPropertyType.stringValueAttribute.Name,
                    add);
            }
            else if (form.FloatingPointType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "", //type converter
                    "", //UI editor
                    Schema.dynamicPropertyType.floatValueAttribute.Name,
                    add);
            }
            else if (form.IntegerType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "", //type converter
                    "", //UI editor
                    Schema.dynamicPropertyType.intValueAttribute.Name,
                    add);
            }
            else if (form.BooleanType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "",                                                              //type converter
                    "Sce.Atf.Controls.PropertyEditing.BoolEditor, Atf.Gui.WinForms", //UI editor
                    Schema.dynamicPropertyType.boolValueAttribute.Name,
                    add);
            }
            else if (form.VectorType.Checked)
            {
                success = AddOrSetDynamicPropertyDomNode(
                    propertyName,
                    category,
                    description,
                    "Sce.Atf.Controls.PropertyEditing.FloatArrayConverter, Atf.Gui",                             //type converter
                    "Sce.Atf.Controls.PropertyEditing.NumericTupleEditor, Atf.Gui.WinForms:System.Single,x,y,z", //UI editor
                    Schema.dynamicPropertyType.vector3ValueAttribute.Name,
                    add);
            }
            else
            {
                throw new InvalidOperationException("A radio button wasn't handled");
            }

            if (!success)
            {
                form.DialogResult = DialogResult.Retry;
            }
        }