/// <summary> /// Adds the properties of the selectedBox to the bag /// </summary> /// <param name="box">Box from where the properties should be /// loaded</param> /// <returns>A bag full of properties from the box</returns> protected PropertyTable CreatePropertiesFromBox(IBoxModule box) { //initializing a new bag PropertyTable bag = new PropertyTable(); //increasing the number of clicks of the user on the desktop bag.ClickID = IncreaseClickID(); IBoxModuleFactoryCreator creator = box.MadeInCreator; FerdaPropertySpec ps; bag.GetValue += new PropertySpecEventHandler(propertyBag_GetValue); bag.SetValue += new PropertySpecEventHandler(propertyBag_SetValue); //iterating through all the properties foreach (PropertyInfo pinfo in creator.Properties) { if (pinfo.visible) { if (box.IsPropertySetWithSettingModule(pinfo.name)) { //creating the "other" property if (IsOneBoxSelected) { CreateOtherProperty(pinfo, box, bag); } } else { //creating normal property //two known other property types - StringSeqT and CategoriesT if (pinfo.typeClassIceId == "::Ferda::Modules::StringSeqT" || pinfo.typeClassIceId == "::Ferda::Modules::CategoriesT") { CreateOtherProperty(pinfo, box, bag); continue; } //strings are also dealt with separatelly if (pinfo.typeClassIceId == "::Ferda::Modules::StringT") { CreateStringProperty(pinfo, box, bag); } else { string normalType = GetNormalType(pinfo.typeClassIceId); //This is a normal type, creating a normal property for it if (normalType != "") { //getting the displayable name of the property SocketInfo si = creator.GetSocket(pinfo.name); ps = new FerdaPropertySpec(si.label, normalType, false); ps.Category = pinfo.categoryName; //geting the socket information about the category ps.Description = si.hint; //it is readonly or it is already there as a socket - //cannot edit "socketed" value if (box.IsPropertyReadOnly(pinfo.name) || box.GetPropertySocking(pinfo.name)) { ps.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } bag.Properties.Add(ps); AddAsyncTemporary(pinfo.name, normalType, false); } else { //throw new ApplicationException("Wierd type that we dont know!!!"); } } } } } return bag; }
/// <summary> /// Creates a property for a "::Ferda::Modules::StringT". There can be not /// only string, but also types of ComboBoxes and this method decides, which /// FerdaPropertySpec will be created /// </summary> /// <param name="pinfo">Information about the property</param> /// <param name="box">Box where it finds the other property</param> /// <param name="bag">Bag where to put the FerdaPropertySpec</param> protected void CreateStringProperty(PropertyInfo pinfo, IBoxModule box, PropertyTable bag) { FerdaPropertySpec ps; SelectString[] array; //determining the type of the property array = box.GetPropertyOptions(pinfo.name); if (array.Length == 0) //it is a normal string property { SocketInfo si = box.MadeInCreator.GetSocket(pinfo.name); ps = new FerdaPropertySpec(si.label, typeof(string), false); ps.Category = pinfo.categoryName; ps.Description = si.hint; if (box.IsPropertyReadOnly(pinfo.name) || box.GetPropertySocking(pinfo.name)) { ps.Attributes = new Attribute[] { ReadOnlyAttribute.Yes }; } bag.Properties.Add(ps); //adding the asynch stuff AddAsyncTemporary(pinfo.name, "System.String", !IsOneBoxSelected); } else //a combo-box should be used { //if there are more boxes selected, the property should not be added if (!IsOneBoxSelected) { return; } if (box.ArePropertyOptionsObligatory(pinfo.name)) //this means user cannot edit values { SocketInfo si = box.MadeInCreator.GetSocket(pinfo.name); ps = new FerdaPropertySpec(si.label, typeof(StringSequence), false); ps.Category = pinfo.categoryName; ps.Description = si.hint; //atributes if (box.IsPropertyReadOnly(pinfo.name) || box.GetPropertySocking(pinfo.name)) { ps.Attributes = new Attribute[] { ReadOnlyAttribute.Yes, new EditorAttribute(typeof(StringComboEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(StringSequenceConverter)) }; } else { ps.Attributes = new Attribute[] { new EditorAttribute(typeof(StringComboEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(StringSequenceConverter)) }; } //adding to the bag bag.Properties.Add(ps); } else //user can add his own option to the string selection { SocketInfo si = box.MadeInCreator.GetSocket(pinfo.name); ps = new FerdaPropertySpec(si.label, typeof(StringSequence), false); ps.Description = si.hint; ps.Category = pinfo.categoryName; //atributes if (box.IsPropertyReadOnly(pinfo.name) || box.GetPropertySocking(pinfo.name)) { ps.Attributes = new Attribute[] { ReadOnlyAttribute.Yes, new EditorAttribute(typeof(StringComboAddingEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(StringSequenceConverter)) }; } else { ps.Attributes = new Attribute[] { new EditorAttribute(typeof(StringComboAddingEditor), typeof(System.Drawing.Design.UITypeEditor)), new TypeConverterAttribute(typeof(StringSequenceConverter)) }; } //adding to the bag bag.Properties.Add(ps); } //adding the asynch stuff if (IsOneBoxSelected) { AddAsyncTemporary(pinfo.name, "Ferda.FrontEnd.Properties.StringSequence", false); } } }
/// <summary> /// Creates a property for all other properties /// </summary> /// <param name="pinfo">Information about the property</param> /// <param name="box">Box where it finds the other property</param> /// <param name="bag">Bag where to put the propertyspec</param> protected void CreateOtherProperty(PropertyInfo pinfo, IBoxModule box, PropertyTable bag) { FerdaPropertySpec ps; SocketInfo si = box.MadeInCreator.GetSocket(pinfo.name); ps = new FerdaPropertySpec(si.label, typeof(OtherProperty), false); ps.Description = si.hint; ps.Category = pinfo.categoryName; //properties that user can set without executing the module (ODBC Connection string) if (box.IsPossibleToSetWithAbout(pinfo.name)) //using a OtherPropertyAddingConverter { if (box.IsPropertyReadOnly(pinfo.name) || box.GetPropertySocking(pinfo.name)) { ps.Attributes = new Attribute[] { ReadOnlyAttribute.Yes, new TypeConverterAttribute(typeof(OtherPropertyAddingConverter)), new EditorAttribute(typeof(OtherPropertyEditor), typeof(System.Drawing.Design.UITypeEditor)) }; } else { ps.Attributes = new Attribute[] { new TypeConverterAttribute(typeof(OtherPropertyAddingConverter)), new EditorAttribute(typeof(OtherPropertyEditor), typeof(System.Drawing.Design.UITypeEditor)) }; } } else //using a OtherPropertyConverter { if (box.IsPropertyReadOnly(pinfo.name) || box.GetPropertySocking(pinfo.name)) { ps.Attributes = new Attribute[] { ReadOnlyAttribute.Yes, new TypeConverterAttribute(typeof(OtherPropertyConverter)), new EditorAttribute(typeof(OtherPropertyEditor), typeof(System.Drawing.Design.UITypeEditor)) }; } else { ps.Attributes = new Attribute[] { new TypeConverterAttribute(typeof(OtherPropertyConverter)), new EditorAttribute(typeof(OtherPropertyEditor), typeof(System.Drawing.Design.UITypeEditor)) }; } } if (IsOneBoxSelected) { AddAsyncTemporary(pinfo.name, "Ferda.FrontEnd.Properties.OtherProperty", false); } bag.Properties.Add(ps); }