/// <summary>
        /// Called when a user sets a value
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        void propertyGridEx1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (comboBox1.SelectedIndex != 0)
            {
                PropertyGridEx.CustomProperty cp = (PropertyGridEx.CustomProperty)((PropertyGridEx.CustomProperty.CustomPropertyDescriptor)(e.ChangedItem.PropertyDescriptor)).CustomProperty;
                if (cp.Tag != null)
                {
                    // set the pin's Data via it's property so the Data can be transmited through the
                    // proper channels
                    DaggerBasePin pin = cp.Tag as DaggerBasePin;
                    pin.Data = cp.Value;

                    // process the graph
                    if (pin.ParentNode != null)
                    {
                        pin.ParentNode.ParentGraph.GraphScheduler.ProcessGraph(pin.ParentNode);
                    }
                    else
                    {
                        // process the entire graph if it is an imported pin
                        if (pin is DaggerOutputPin)
                        {
                            pin.ParentGraph.GraphScheduler.ProcessGraph();
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Called when a user sets a value.  Does not process the Graph
 /// </summary>
 /// <param name="s"></param>
 /// <param name="e"></param>
 void propertyGridEx1_PropertyValueChangedNoProcess(object s, PropertyValueChangedEventArgs e)
 {
     PropertyGridEx.CustomProperty cp = (PropertyGridEx.CustomProperty)((PropertyGridEx.CustomProperty.CustomPropertyDescriptor)(e.ChangedItem.PropertyDescriptor)).CustomProperty;
     if (cp.Tag != null)
     {
         // set the pin's Data via it's property so the Data can be transmited through the
         // proper channels
         DaggerBasePin pin = cp.Tag as DaggerBasePin;
         pin.Data = cp.Value;
     }
 }
Beispiel #3
0
        private void cmdAdd_Click(object sender, EventArgs e)
        {
            String propertyName = txtName.Text;

            if (pgProperties.Item[propertyName] == null)
            {
                bool   bIsReadOnly  = true;
                bool   bIsVisible   = true;
                String propertyType = cbPropertyType.Text;

                PropertyGridEx.CustomProperty propertyToAdd = new PropertyGridEx.CustomProperty(propertyName, propertyType, bIsReadOnly, "Asset Properties", "", bIsVisible);
                pgProperties.Item.Add(propertyToAdd);
                cbRemoveProperty.Items.Add(propertyName);
                m_columnsToAdd.Add(propertyName, propertyType);
            }
            else
            {
                Global.WriteOutput("Error: Property with that name already exists.");
            }
            txtName.Text = "";
            pgProperties.Refresh();
        }
        public bool LoadXml(string filename)
        {
            bool        result;
            IEnumerator enumerator = null;

            try
            {
                XmlSerializer            xmlSerializer            = new XmlSerializer(typeof(CustomPropertyCollection));
                FileStream               fileStream               = new FileStream(filename, FileMode.Open);
                CustomPropertyCollection customPropertyCollection = (CustomPropertyCollection)xmlSerializer.Deserialize(fileStream);
                try
                {
                    enumerator = customPropertyCollection.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        CustomProperty customProperty = (CustomProperty)enumerator.Current;
                        customProperty.RebuildAttributes();
                        this.Add(customProperty);
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                fileStream.Close();
                result = true;
            }
            catch (Exception expr_7A)
            {
                ProjectData.SetProjectError(expr_7A);
                result = false;
                ProjectData.ClearProjectError();
            }
            return(result);
        }
Beispiel #5
0
        [RefreshProperties(RefreshProperties.All)] public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (context == null || provider == null || context.Instance == null)
            {
                return(base.EditValue(provider, value));
            }

            oEditorService = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (oEditorService != null)
            {
                // Get the Back reference to the Custom Property
                CustomProperty.CustomPropertyDescriptor oDescriptor = (CustomProperty.CustomPropertyDescriptor)context.PropertyDescriptor;
                CustomProperty cp = (CustomProperty)oDescriptor.CustomProperty;

                // Declare attributes
                UIListboxDatasource    datasource;
                UIListboxValueMember   valuemember;
                UIListboxDisplayMember displaymember;

                // Get attributes
                datasource    = (UIListboxDatasource)context.PropertyDescriptor.Attributes[typeof(UIListboxDatasource)];
                valuemember   = (UIListboxValueMember)context.PropertyDescriptor.Attributes[typeof(UIListboxValueMember)];
                displaymember = (UIListboxDisplayMember)context.PropertyDescriptor.Attributes[typeof(UIListboxDisplayMember)];

                oList.BorderStyle    = BorderStyle.None;
                oList.IntegralHeight = true;

                if (datasource != null)
                {
                    oList.DataSource = datasource.Value;
                }

                if (displaymember != null)
                {
                    oList.DisplayMember = displaymember.Value;
                }

                if (valuemember != null)
                {
                    oList.ValueMember = valuemember.Value;
                }

                if (value != null)
                {
                    if (value.GetType().Name == "String")
                    {
                        oList.Text = (string)value;
                    }
                    else
                    {
                        oList.SelectedItem = value;
                    }
                }


                oList.SelectedIndexChanged += new System.EventHandler(this.SelectedItem);

                oEditorService.DropDownControl(oList);
                if (oList.SelectedIndices.Count == 1)
                {
                    cp.SelectedItem  = oList.SelectedItem;
                    cp.SelectedValue = oSelectedValue;
                    value            = oList.Text;
                }
                oEditorService.CloseDropDown();
            }
            else
            {
                return(base.EditValue(provider, value));
            }

            return(value);
        }
Beispiel #6
0
 public CustomPropertyDescriptor(CustomProperty customProperty, Attribute[] attrs)
     : base(customProperty.Name, attrs)
 {
     _customProperty = customProperty;
 }
 public virtual int Add(CustomProperty value)
 {
     return(base.List.Add(value));
 }
        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null);
            IEnumerator enumerator = null;

            try
            {
                enumerator = base.List.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    CustomProperty customProperty = (CustomProperty)enumerator.Current;
                    if (customProperty.Visible)
                    {
                        ArrayList arrayList = new ArrayList();
                        if (customProperty.IsBrowsable)
                        {
                            arrayList.Add(new TypeConverterAttribute(typeof(BrowsableTypeConverter)));
                        }
                        if (customProperty.UseFileNameEditor)
                        {
                            arrayList.Add(new EditorAttribute(typeof(UIFilenameEditor), typeof(UITypeEditor)));
                        }
                        if (customProperty.Choices != null)
                        {
                            arrayList.Add(new TypeConverterAttribute(typeof(CustomChoices.CustomChoicesTypeConverter)));
                        }
                        if (customProperty.IsPassword)
                        {
                            arrayList.Add(new PasswordPropertyTextAttribute(true));
                        }
                        if (customProperty.Parenthesize)
                        {
                            arrayList.Add(new ParenthesizePropertyNameAttribute(true));
                        }
                        if (customProperty.Datasource != null)
                        {
                            arrayList.Add(new EditorAttribute(typeof(UIListboxEditor), typeof(UITypeEditor)));
                        }
                        if (customProperty.CustomEditor != null)
                        {
                            arrayList.Add(new EditorAttribute(customProperty.CustomEditor.GetType(), typeof(UITypeEditor)));
                        }
                        if (customProperty.CustomTypeConverter != null)
                        {
                            arrayList.Add(new TypeConverterAttribute(customProperty.CustomTypeConverter.GetType()));
                        }
                        if (customProperty.IsPercentage)
                        {
                            arrayList.Add(new TypeConverterAttribute(typeof(OpacityConverter)));
                        }
                        if (customProperty.OnClick != null)
                        {
                            arrayList.Add(new EditorAttribute(typeof(UICustomEventEditor), typeof(UITypeEditor)));
                        }
                        if (customProperty.DefaultValue != null)
                        {
                            arrayList.Add(new DefaultValueAttribute(customProperty.Type, customProperty.Value.ToString()));
                        }
                        else if (customProperty.DefaultType != null)
                        {
                            arrayList.Add(new DefaultValueAttribute(customProperty.DefaultType, null));
                        }
                        if (customProperty.Attributes != null)
                        {
                            arrayList.AddRange(customProperty.Attributes);
                        }
                        Attribute[] attrs = (Attribute[])arrayList.ToArray(typeof(Attribute));
                        propertyDescriptorCollection.Add(new CustomProperty.CustomPropertyDescriptor(customProperty, attrs));
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            return(propertyDescriptorCollection);
        }
Beispiel #9
0
            public CustomPropertyDescriptor(CustomProperty myProperty, Attribute[] attrs)
                : base(myProperty.Name, attrs)
            {
                if (myProperty == null)
                {
                    oCustomProperty = null;
                }
                else
                {

                    oCustomProperty = myProperty;
                }
            }
		public virtual int Add(CustomProperty value)
		{
			return base.List.Add(value);
		}
Beispiel #11
0
 private static CustomProperty CreateCustomProperty(string propertyName, string propertyValue, string description)
 {
     CustomProperty cp = new CustomProperty();
     cp.Name = propertyName;
     cp.Value = propertyValue ?? String.Empty;
     cp.IsReadOnly = true;
     cp.IsBrowsable = false;
     cp.Visible = true;
     cp.Description = description;
     return cp;
 }
Beispiel #12
0
 private static CustomProperty CreateCustomProperty(DataRow row, DataColumn dc, bool readOnly, bool visible, string category)
 {
     CustomProperty cp = new CustomProperty();
     cp.Name = dc.ColumnName;
     cp.Tag = dc.ColumnName + "|" + row[0];
     cp.IsReadOnly = readOnly;
     cp.Visible = visible;
     cp.Value = row[dc];
     cp.Description = dc.Caption;
     cp.Category = category;
     cp.DefaultValue = dc.DefaultValue;
     return cp;
 }
 private static CustomProperty CreateCustomProperty(string propertyName, string propertyValue, string description)
 {
     CustomProperty cp = new CustomProperty
                             {
                                 Name = propertyName,
                                 Value = propertyValue ?? String.Empty,
                                 IsReadOnly = true,
                                 IsBrowsable = false,
                                 Visible = true,
                                 Description = description
                             };
     return cp;
 }
 private static CustomProperty CreateCustomProperty(DataRow row, DataColumn dc, bool readOnly, bool visible, string category)
 {
     CustomProperty cp = new CustomProperty
                             {
                                 Name = dc.ColumnName,
                                 Tag = dc.ColumnName + "|" + row[0],
                                 IsReadOnly = readOnly,
                                 Visible = visible,
                                 Value = row[dc],
                                 Description = dc.Caption,
                                 Category = category,
                                 DefaultValue = dc.DefaultValue
                             };
     return cp;
 }