private void InitializeForm(string macroAlias) { //Hold selected Alias in Viewstate SelectedMacroAlias = macroAlias; //Create new property collection List <PersistableMacroProperty> props = new List <PersistableMacroProperty>(); //Clear Old Control Collection _formTable.Controls.Clear(); //Is a Macro selected if (!string.IsNullOrEmpty(macroAlias)) { Macro formMacro = Macro.GetByAlias(macroAlias); ///Only render form when macro is found if (formMacro != null) { if (formMacro.Properties.Length > 0) { propertiesHeader.Visible = true; } foreach (MacroProperty macroProperty in formMacro.Properties) { //Only add properties that people may see. if (macroProperty.Public) { PersistableMacroProperty prop = new PersistableMacroProperty(); prop.Alias = macroProperty.Alias; prop.Name = macroProperty.Name; prop.AssemblyName = macroProperty.Type.Assembly; prop.TypeName = macroProperty.Type.Type; //Assign value if specified if (DataValues[macroProperty.Alias.ToLower()] != null) { prop.Value = DataValues[macroProperty.Alias.ToLower()].ToString(); } props.Add(prop); } } } } //Hold selected properties in ViewState SelectedProperties = props; //Render the form RendeFormControls(); }
/// <summary> /// Create an instance of a Macro control and return it. /// Because the macro control uses inline client script whichs is not generated after postback /// That's why we use the Page Picker instead of the content picker of the macro. /// </summary> internal static Control GetMacroRenderControlByType(PersistableMacroProperty prop, string uniqueID) { Control macroControl; Type m = MacroControlTypes.FindLast(delegate(Type macroGuiCcontrol) { return(macroGuiCcontrol.ToString() == string.Format("{0}.{1}", prop.AssemblyName, prop.TypeName)); }); IMacroGuiRendering typeInstance; typeInstance = Activator.CreateInstance(m) as IMacroGuiRendering; if (!string.IsNullOrEmpty(prop.Value)) { ((IMacroGuiRendering)typeInstance).Value = prop.Value; } macroControl = (Control)typeInstance; macroControl.ID = uniqueID; return(macroControl); }