public Widget_Builder_DataEditor(umbraco.interfaces.IData Data, Widget_Builder_Options Configuration) { //load the prevalues savedOptions = Configuration; //ini the savedData object savedData = Data; jsonSerializer = new JavaScriptSerializer(); }
protected void renderGrid(HtmlTextWriter writer, Widget_Builder_Options renderingOptions) { HtmlGenericControl gridWrapper=new HtmlGenericControl(); gridWrapper.TagName = "div"; gridWrapper.Attributes["class"]="gridWrapperDiv"; HtmlTable gridTable; foreach (WidgetElement element in renderingOptions.elements) { gridTable = new HtmlTable(); gridTable.Attributes["class"] = "widgetGridTable"; gridTable.Attributes["type"] = element.type; gridWrapper.Controls.Add(gridTable); //call each method dynamically based on the element type MethodInfo elementMethod = this.GetType().GetMethod(element.type); elementMethod.Invoke(this, new object[] { element, gridTable }); } gridWrapper.RenderControl(writer); }
protected void renderGlobalOptions(HtmlTextWriter writer, Widget_Builder_Options renderingOptions) { HtmlTable globalOptionsTable = new HtmlTable(); HtmlTableRow tr; HtmlTableCell td; TextBox textBox; tr = new HtmlTableRow(); globalOptionsTable.Rows.Add(tr); //max widgets td = new HtmlTableCell(); tr.Cells.Add(td); td.InnerText = "Max Widgets Per Property"; td = new HtmlTableCell(); tr.Cells.Add(td); textBox = new TextBox(); textBox.CssClass = "maxWidgets"; textBox.Text = renderingOptions.maxWidgets.ToString(); td.Controls.Add(textBox); tr = new HtmlTableRow(); globalOptionsTable.Rows.Add(tr); //js include td = new HtmlTableCell(); tr.Cells.Add(td); td.InnerText = "JS Include Path"; td = new HtmlTableCell(); tr.Cells.Add(td); textBox = new TextBox(); textBox.CssClass = "jsInclude"; textBox.Text = renderingOptions.jsIncludePath; td.Controls.Add(textBox); tr = new HtmlTableRow(); globalOptionsTable.Rows.Add(tr); //css include td = new HtmlTableCell(); tr.Cells.Add(td); td.InnerText = "CSS Include Path"; td = new HtmlTableCell(); tr.Cells.Add(td); textBox = new TextBox(); textBox.CssClass = "cssInclude"; textBox.Text = renderingOptions.cssIncludePath; td.Controls.Add(textBox); globalOptionsTable.RenderControl(writer); }
protected override void Render(HtmlTextWriter writer) { base.Render(writer); Widget_Builder_Options renderingOptions; //test for postback, decide to use db or saveBox for rendering if (Page.IsPostBack) { //test for saveBox having a value, default if not if (saveBox.Text != "") { renderingOptions = jsonSerializer.Deserialize<Widget_Builder_Options>(saveBox.Text); } else { renderingOptions = new Widget_Builder_Options(); } } else { renderingOptions = savedOptions; } renderToolbar(writer); renderGrid(writer, renderingOptions); renderGlobalOptions(writer, renderingOptions); debug.RenderControl(writer); }
public Widget_Builder_PrevalueEditor(umbraco.cms.businesslogic.datatype.BaseDataType DataType) { _datatype = DataType; jsonSerializer = new JavaScriptSerializer(); savedOptions = Configuration; }