public DSTDContext(Server server, string requestHeader, Action<Page, Guid> g, Action<Guid, Dictionary<string, object>, Dictionary<string, object>> o, Page.GetApplication p) { OnGrabSession += g; myServer = server; OnSetSession += o; DSTDQuery query = new DSTDQuery(getURL(requestHeader)); XmlDocument doc = getXML(requestHeader); Request = new DSTDRequest(this,query, doc,p); Request.Start(); }
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()); } }
public void GrabSession(Page p, Guid g) { OnGrabSession(p, g); }
public void TransferToPage(string Page) { DSTDQuery q = new DSTDQuery(Page); DSTDRequest r = new DSTDRequest(this.Context, q, null, getApplication); r.CurrentPage.FullRender = false; r.CurrentPage.CurrentGUID = this.CurrentPage.CurrentGUID; r.CurrentPage.IsPostBack = false; r.Start(); r.CurrentPage.PanelToUpdate = "theBody"; CurrentPage = r.CurrentPage; }
public DSTDRequest(DSTDContext that, DSTDQuery q, XmlDocument state, Page.GetApplication p) { Context = that; State = state; Query = q; getApplication = p; Page h; if (File.Exists(Context.myServer.localDirectory + Query.File.TrimStart('/') + ".dstd")) { CompileDSTD compile = CompileDSTD.CompileDSTDPage(Context, Context.myServer.localDirectory + Query.File.TrimStart('/'), Query.File.TrimStart('/')); h = (Page)compile.Compiled; } else { return; } h.UserQuery = q.UserQuery; CurrentPage = h; }
public void GraPrivatebSession(Page h, Guid guid) { if (privateSessions.ContainsKey(guid.ToString())) h.SetPrivateSession(privateSessions[guid.ToString()]); }