Example #1
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;
        }
Example #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 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;
        }