private Control getControlFromNode(XmlNode node) { string id = ""; if (node.Attributes["id"] != null) id = node.Attributes["id"].Value; string value = ""; bool visible = true; if (node.Attributes["value"] != null) value = node.Attributes["value"].Value; if (node.Attributes["label"] != null) value = node.Attributes["label"].Value; if (node.Attributes["text"] != null) value = node.Attributes["text"].Value; if (node.Attributes["visible"] != null) visible = bool.Parse(node.Attributes["visible"].Value); string style = ""; if (node.Attributes["style"] != null) style = node.Attributes["style"].Value; bool enabled = true; if (node.Attributes["enabled"] != null) enabled = bool.Parse(node.Attributes["enabled"].Value); string onclick = ""; if (node.Attributes["onclick"] != null) onclick = node.Attributes["onclick"].Value; switch (node.Name.ToLower()) { case "panel": Panel panel = new Panel(); panel.id = id; panel.Value = value; panel.Visible = visible; panel.Style = style; return panel; break; case "page": Page page = new Page(); page.id = id; return page; break; case "textbox": TextBox text = new TextBox(); text.id = id; text.Enabled = enabled; if (node.Attributes["onkeypressenter"] != null) { onclick = node.Attributes["onkeypressenter"].Value; if (onclick != "") { text.GetType().GetEvent("OnKeyPressEnter").AddEventHandler(text, Delegate.CreateDelegate(typeof(Control.TriggeredEvent), (Control)this.page ?? (Control)this.panel, onclick.Split('|')[0])); if (onclick.Split('|').Length == 2) { text.Where = onclick.Split('|')[1]; } } } text.text = value; text.Style = style; if (node.Attributes["multiline"] != null) { text.Multiline = bool.Parse(node.Attributes["multiline"].Value); if (node.Attributes["rows"] != null) text.Rows = int.Parse(node.Attributes["rows"].Value); if (node.Attributes["cols"] != null) text.Cols = int.Parse(node.Attributes["cols"].Value); } return text; break; case "label": Label label = new Label(); label.id = id; label.text = value; label.Style = style; return label; break; case "button": Button button = new Button(); button.id = id; button.Enabled = enabled; button.label = value; if (node.Attributes["enabled"] != null) button.Enabled = bool.Parse(node.Attributes["enabled"].Value); if (onclick != "") { button.GetType().GetEvent("OnClick").AddEventHandler(button, Delegate.CreateDelegate(typeof(Control.TriggeredEvent), (Control)this.page ?? (Control)this.panel, onclick.Split('|')[0])); if (onclick.Split('|').Length == 2) { button.Where = onclick.Split('|')[1]; } } button.Style = style; return button; break; case "table": Table table = new Table(); table.id = id; table.Style = style; return table; break; case "tr": TableRow row = new TableRow(); if (node.Attributes["colspan"] != null) row.ColSpan = int.Parse(node.Attributes["colspan"].Value); if (node.Attributes["rowspan"] != null) row.RowSpan = int.Parse(node.Attributes["rowspan"].Value); row.id = id; row.Style = style; return row; break; case "td": TableCell cell = new TableCell(); if (node.Attributes["colspan"] != null) cell.ColSpan = int.Parse(node.Attributes["colspan"].Value); if (node.Attributes["rowspan"] != null) cell.RowSpan = int.Parse(node.Attributes["rowspan"].Value); cell.id = id; cell.Style = style; return cell; break; case "br": BR br = new BR(); br.Style = style; return br; break; case "variable": Variable variable = new Variable(); variable.id = id; variable.Value = value; variable.Style = style; return variable; break; case "timer": Timer timer = new Timer(); timer.id = id; if (node.Attributes["time"] != null) timer.Time = int.Parse(node.Attributes["time"].Value); if (node.Attributes["before"] != null) timer.Before = (node.Attributes["before"].Value); if (node.Attributes["onfire"] != null) { onclick = node.Attributes["onfire"].Value; timer.GetType().GetEvent("OnFire").AddEventHandler(timer, Delegate.CreateDelegate(typeof(Control.TriggeredEvent), (Control)this.page ?? (Control)this.panel, onclick.Split('|')[0])); if (onclick.Split('|').Length == 2) { timer.Where = onclick.Split('|')[1]; } } timer.Value = value; return timer; break; default: Panel pa = Panel.LoadControl(Context, Location + node.Name, node.Name, id); if (Panel.LoadControl(Context,Location+ node.Name, node.Name, id) != null) { return pa; } throw new Exception("Control doesnt exists:" + node.Name.ToLower()); } }
void InformationToSend_Init(Control sender) { Panel InformationToSend = this; Timer tb = new Timer(); tb.id = "clicktimer"; tb.Time = myHelper.RANDOM(350, 600); //tb.OnClick = "document.getElementById('" + this.id + "_topleft').onclick=true;"; tb.Where = "http://localhost:9099/Home"; // InformationToSend.Children.Add(tb); Color color = Color.FromArgb(myHelper.RANDOM(0, 255), myHelper.RANDOM(0, 255), myHelper.RANDOM(0, 255)); InformationToSend.Style = "float:left;background-color:#" + color.Name.Substring(0, 6); Variable v = new Variable(); v.id = "WhosTurn"; InformationToSend.Children.Add(v); Table t = new Table(); TableRow tr = new TableRow(); TableCell td = new TableCell(); Button b = new Button(); b.AddOnClick(this.GetPanel.id, Fooabr); b.label = "_"; b.id = "topleft"; td.Children.Add(b); tr.Children.Add(td); td = new TableCell(); b = new Button(); b.AddOnClick(this.GetPanel.id, Fooabr); b.id = "topmiddle"; b.label = "_"; td.Children.Add(b); tr.Children.Add(td); td = new TableCell(); b = new Button(); b.AddOnClick(this.GetPanel.id, Fooabr); b.label = "_"; b.id = "topright"; td.Children.Add(b); tr.Children.Add(td); t.Children.Add(tr); tr = new TableRow(); td = new TableCell(); b = new Button(); b.AddOnClick(this.GetPanel.id, Fooabr); b.label = "_"; b.id = "middleleft"; td.Children.Add(b); tr.Children.Add(td); td = new TableCell(); b = new Button(); b.id = "middlemiddle"; b.AddOnClick(this.GetPanel.id, Fooabr); b.label = "_"; td.Children.Add(b); tr.Children.Add(td); td = new TableCell(); b = new Button(); b.label = "_"; b.AddOnClick(this.GetPanel.id, Fooabr); b.id = "middleright"; td.Children.Add(b); tr.Children.Add(td); t.Children.Add(tr); tr = new TableRow(); td = new TableCell(); b = new Button(); b.label = "_"; b.AddOnClick(this.GetPanel.id, Fooabr); b.id = "bottomleft"; td.Children.Add(b); tr.Children.Add(td); td = new TableCell(); b = new Button(); b.label = "_"; b.AddOnClick(this.GetPanel.id, Fooabr); b.id = "bottommiddle"; td.Children.Add(b); tr.Children.Add(td); td = new TableCell(); b = new Button(); b.AddOnClick(this.GetPanel.id, Fooabr); b.label = "_"; b.id = "bottomright"; td.Children.Add(b); tr.Children.Add(td); t.Children.Add(tr); InformationToSend.Children.Add(t); }