コード例 #1
0
 /// <summary>
 /// Constructor
 /// </summary>        
 /// <param name="property">The property description</param>
 /// <param name="attributes">Attributes of the property</param>            
 public DynamicNodePropertyDescriptor(DynamicNodeConfigProperty property, Attribute[] attributes)
     : base(property.Name, attributes)
 {
     _property = property;
 }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Type selectedType = comboBoxTypes.SelectedItem as Type;

            if (selectedType == null)
            {
                MessageBox.Show(this, Properties.Resources.EditConfigPropertyForm_SelectAType,
                    Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!IsValidName())
            {
                MessageBox.Show(this, Properties.Resources.EditConfigPropertyForm_SpecifyAName,
                    Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                object defaultValue = null;

                try
                {
                    if (selectedType == typeof(string))
                    {
                        defaultValue = textBoxStringValue.Text;
                    }
                    else if (selectedType == typeof(string[]))
                    {
                        defaultValue = textBoxStringValue.Lines;
                    }
                    else if (selectedType == typeof(byte[]))
                    {
                        defaultValue = hexEditorControl.Bytes;
                    }
                    else if (selectedType == typeof(ColorValue))
                    {
                        defaultValue = ColorValue.Parse(textBoxStringValue.Text);
                    }
                    else if (!typeof(IDocumentObject).IsAssignableFrom(selectedType))
                    {
                        defaultValue = Convert.ChangeType(textBoxStringValue.Text, selectedType, CultureInfo.CurrentUICulture);
                    }

                    Property = new DynamicNodeConfigProperty(textBoxName.Text, selectedType, defaultValue, textBoxDescription.Text);

                    DialogResult = DialogResult.OK;
                    Close();
                }
                catch (InvalidCastException ex)
                {
                    MessageBox.Show(this, ex.Message,
                        Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (OverflowException ex)
                {
                    MessageBox.Show(this, ex.Message,
                        Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (FormatException ex)
                {
                    MessageBox.Show(this, ex.Message,
                        Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
ファイル: ScriptDocument.cs プロジェクト: michyer/canape
 /// <summary>
 /// Add a new configuration property (or update old one)
 /// </summary>
 /// <param name="property">The property to add</param>
 public void AddConfiguration(DynamicNodeConfigProperty property)
 {
     _config[property.Name] = property;
     Dirty = true;
 }
コード例 #4
0
ファイル: ScriptDocument.cs プロジェクト: michyer/canape
 /// <summary>
 /// Remove a configuration property
 /// </summary>
 /// <param name="property">The property to remove</param>
 public void RemoveConfiguration(DynamicNodeConfigProperty property)
 {
     _config.Remove(property.Name);
     Dirty = true;
 }
コード例 #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="property">The property description</param>
 /// <param name="attributes">Attributes of the property</param>
 public DynamicNodePropertyDescriptor(DynamicNodeConfigProperty property, Attribute[] attributes)
     : base(property.Name, attributes)
 {
     _property = property;
 }