Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ImageLayer imageLayer = new ImageLayer();

            PropertyGridParameterCollection propertyGridParameters = new PropertyGridParameterCollection();
            foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(imageLayer))
            {
                object value = propertyDescriptor.GetValue(imageLayer);

                PropertyGridParameter propertyGridParameter = new PropertyGridParameter(propertyDescriptor.DisplayName, (value != null) ? value.ToString() : "[Null]");
                if (propertyDescriptor.PropertyType.IsEnum)
                {
                    ComboBox comboBox = new ComboBox { ID = "blah" + propertyDescriptor.Name, EmptyText = "Please select...", Mode = DataLoadMode.Local, TriggerAction = TriggerAction.All };
                    foreach (string enumValue in (Enum.GetNames(propertyDescriptor.PropertyType)))
                        comboBox.Items.Add(new ListItem(enumValue, enumValue));
                    propertyGridParameter.Editor.Add(comboBox);
                }
                propertyGridParameters.Add(propertyGridParameter);
            }
            prgProperties.SetSource(propertyGridParameters);
        }
Ejemplo n.º 2
0
        void BuildSource(string strSource)
        {
            if (this.dataChangedEventHandled)
            {
                return;
            }
            
            PropertyGridParameterCollection result = new PropertyGridParameterCollection();
            JObject jo = JObject.Parse(strSource);

            foreach (JProperty property in jo.Properties())
            {
                string value = property.Value.Type == JTokenType.String ? (string)property.Value : this.ChopQuotes(property.Value.ToString());
                PropertyGridParameter newP = new PropertyGridParameter(this.ChopQuotes(property.Name), value);
                PropertyGridParameter oldP = this.FindParam(property.Name);
                newP.Mode = oldP.Mode;
                
                if (oldP.Editor.Count > 0)
                {
                    newP.Editor.Add(oldP.Editor.Editor);    
                }

                newP.IsChanged = newP.Name.IsEmpty() || oldP.Value != newP.Value;

                if (newP.IsChanged)
                {
                    raiseChanged = true;
                }
                result.Add(newP);
            }

            this.Source.Clear();

            foreach (PropertyGridParameter parameter in result)
            {
                this.Source.Add(parameter);
            }

            this.dataChangedEventHandled = true;
        }
Ejemplo n.º 3
0
 public void SetSource(PropertyGridParameterCollection source)
 {
     this.Call("setSource", new JRawValue(source.ToJsonObject()));
 }
Ejemplo n.º 4
0
        void BuildSource(string strSource)
        {
            if (this.dataChangedEventHandled)
            {
                return;
            }
            
            PropertyGridParameterCollection result = new PropertyGridParameterCollection();
            JObject jo = JObject.Parse(strSource);

            foreach (JProperty property in jo.Properties())
            {
                string value = property.Value.Type == JTokenType.String ? (string)property.Value : this.ChopQuotes(property.Value.ToString());
                PropertyGridParameter newP = new PropertyGridParameter(this.ChopQuotes(property.Name), value);
                PropertyGridParameter param = this.FindParam(property.Name);

                if (param == null)
                {
                    param = new PropertyGridParameter(this.ChopQuotes(property.Name), value);
                    param.IsChanged = true;
                }
                else
                {
                    param.IsChanged = param.Value != value;
                    param.Value = value;                    
                }

                if (param.IsChanged)
                {
                    raiseChanged = true;
                }
                result.Add(param);
            }

            this.Source.Clear();
            this.Source.AddRange(result);

            this.dataChangedEventHandled = true;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the source data object containing the property data. The data object can contain one or more name/value pairs representing all of the properties of an object to display in the grid, and this data will automatically be loaded into the grid's store. The values should be supplied in the proper data type if needed, otherwise string type will be assumed. If the grid already contains data, this method will replace any existing data. See also the source config value. 
 /// </summary>
 /// <param name="source">The data object</param>
 public void SetSource(PropertyGridParameterCollection sourceConfig)
 {
     this.Call("setSource", JRawValue.From(sourceConfig.Source()), JRawValue.From(sourceConfig.Config()));
 }