public CustomPropertyDescriptor(ref CustomProperty myProperty, Attribute[] attrs) : base(myProperty.Name, attrs) { m_Property = myProperty; }
/// <summary> /// Add CustomProperty to Collectionbase List /// </summary> /// <param name="Value"></param> public void Add(CustomProperty Value) { base.List.Add(Value); }
private void SetPluginsVariables(string strClassName, string strPluginName, List<CPluginVariable> lstVariables) { if (lstVariables != null) { foreach (CPluginVariable cpvVariable in lstVariables) { string strCategoryName = strPluginName; string strVariableName = cpvVariable.Name; bool blVariableReadOnly = cpvVariable.ReadOnly; string[] a_strVariable = cpvVariable.Name.Split(new char[] { '|' }, 2); if (a_strVariable.Length == 2) { strCategoryName = a_strVariable[0]; strVariableName = a_strVariable[1]; } Enum generatedEnum = null; Match isGeneratedEnum; if ((isGeneratedEnum = Regex.Match(cpvVariable.Type, @"enum.(?<enumname>.*?)\((?<literals>.*)\)")).Success == true) { if ((generatedEnum = this.GenerateEnum(isGeneratedEnum.Groups["enumname"].Value, isGeneratedEnum.Groups["literals"].Value.Split('|'))) != null) { string variableValue = cpvVariable.Value; if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == false) { string[] a_Names = Enum.GetNames(generatedEnum.GetType()); if (a_Names.Length > 0) { variableValue = a_Names[0]; } } if (Enum.IsDefined(generatedEnum.GetType(), variableValue) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(generatedEnum.GetType(), variableValue), generatedEnum.GetType(), blVariableReadOnly, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(generatedEnum.GetType(), variableValue); } } } } else { switch (cpvVariable.Type) { case "bool": bool blTryBool; if (bool.TryParse(cpvVariable.Value, out blTryBool) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, blTryBool, typeof(bool), blVariableReadOnly, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = blTryBool; } } break; case "onoff": if (Enum.IsDefined(typeof(enumBoolOnOff), cpvVariable.Value) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value), typeof(enumBoolOnOff), blVariableReadOnly, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolOnOff), cpvVariable.Value); } } break; case "yesno": if (Enum.IsDefined(typeof(enumBoolYesNo), cpvVariable.Value) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value), typeof(enumBoolYesNo), blVariableReadOnly, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = Enum.Parse(typeof(enumBoolYesNo), cpvVariable.Value); } } break; case "int": int iTryInt; if (int.TryParse(cpvVariable.Value, out iTryInt) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, iTryInt, typeof(int), blVariableReadOnly, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = iTryInt; } } break; case "double": double dblTryDouble; if (double.TryParse(cpvVariable.Value, out dblTryDouble) == true) { if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, dblTryDouble, typeof(double), blVariableReadOnly, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = dblTryDouble; } } break; case "string": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), blVariableReadOnly, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value; } break; case "multiline": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { CustomProperty cptNewProperty = new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.Decode(cpvVariable.Value), typeof(String), blVariableReadOnly, true); cptNewProperty.Attributes = new AttributeCollection( new EditorAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(System.ComponentModel.Design.MultilineStringEditor)) ); this.m_cscPluginVariables.Add(cptNewProperty); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = cpvVariable.Value; } break; case "stringarray": if (this.m_cscPluginVariables.ContainsKey(cpvVariable.Name) == false) { this.m_cscPluginVariables.Add(new CustomProperty(strVariableName, strCategoryName, strClassName, CPluginVariable.DecodeStringArray(cpvVariable.Value), typeof(string[]), blVariableReadOnly, true)); //this.m_cscPluginVariables.Add(new CustomProperty(cpvVariable.Name, strPluginName, strClassName, "Alaska", typeof(StatesList), false, true)); } else { this.m_cscPluginVariables[cpvVariable.Name].Value = CPluginVariable.DecodeStringArray(cpvVariable.Value); } break; } // } } } } this.ppgScriptSettings.Refresh(); }