using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using ClientDependency.Core; using umbraco.BusinessLogic; namespace umbraco.uicontrols { [ClientDependency(ClientDependencyType.Javascript, "panel/javascript.js", "UmbracoClient")] [ClientDependency(ClientDependencyType.Css, "panel/style.css", "UmbracoClient")] public class UmbracoPanel : System.Web.UI.WebControls.Panel { private ScrollingMenu _menu = new ScrollingMenu(); public UmbracoPanel() { } // do NOT append extension to cookie name, because it is used in umbraco/presentation/umbraco_client/Panel/javascript.js static umbraco.BusinessLogic.StateHelper.Cookies.Cookie panelCookie = new StateHelper.Cookies.Cookie("UMB_PANEL", false); // was umbPanel_pWidth _pHeight protected override void OnInit(EventArgs e) { // We can grab the cached window size from cookie values if (AutoResize) { // zb-00004 #29956 : refactor cookies names & handling if (panelCookie.HasValue) { int pWidth = 0; int pHeight = 0; string[] wh = panelCookie.GetValue().Split('x'); if (wh.Length > 0 && int.TryParse(wh[0], out pWidth)) Width = Unit.Pixel(pWidth); if (wh.Length > 1 && int.TryParse(wh[1], out pHeight)) Height = Unit.Pixel(pHeight); } } setupMenu(); } protected override void OnLoad(System.EventArgs EventArguments) { _menu.Visible = hasMenu; if (_autoResize) this.Page.ClientScript.RegisterStartupScript(this.GetType(), "PanelEvents", "jQuery(document).ready(function() {jQuery(window).load(function(){ resizePanel('" + this.ClientID + "', " + this.hasMenu.ToString().ToLower() + ",true); }) });", true); //this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PanelEvents", ""); } private bool _hasMenu = false; private string _StatusBarText = ""; private string _text; private bool _autoResize = true; public bool hasMenu { get { return _hasMenu; } set { _hasMenu = value; } } public bool AutoResize { get { return _autoResize; } set { _autoResize = value; } } public string Text { get { if (_text == "") { _text = " "; } return _text; } set { _text = value; } } public string StatusBarText { get { return _StatusBarText; } set { _StatusBarText = value; } } public ScrollingMenu Menu { get { return _menu; } } internal void setupMenu() { _menu.ID = this.ID + "_menu"; if (this.Width.Value < 20) this.Width = Unit.Pixel(24); _menu.Width = (int)Unit.Pixel((int)this.Width.Value - 20).Value; this.Controls.Add(_menu); } protected override void Render(System.Web.UI.HtmlTextWriter writer) { base.CreateChildControls(); try { if (System.Web.HttpContext.Current == null) { writer.WriteLine("Number of child controls : " + this.Controls.Count); } writer.WriteLine("
"); writer.WriteLine("
"); writer.WriteLine("

" + this.Text + "

"); writer.WriteLine("
"); writer.WriteLine("
"); if (this.hasMenu) { writer.WriteLine("
"); _menu.RenderControl(writer); writer.WriteLine("
"); } int upHeight = (int)this.Height.Value - 46; int upWidth = (int)this.Width.Value - 5; if (this.hasMenu) upHeight = upHeight - 34; writer.WriteLine("
"); string styleString = ""; foreach (string key in this.Style.Keys) { styleString += key + ":" + this.Style[key] + ";"; } writer.WriteLine("
"); foreach (Control c in this.Controls) { if (!(c.ID == _menu.ID)) { c.RenderControl(writer); } } writer.WriteLine("
"); writer.WriteLine("
"); writer.WriteLine("
"); writer.WriteLine("

" + this.StatusBarText + "

"); writer.WriteLine("
"); /* if(_autoResize) writer.WriteLine(""); */ } catch (Exception ex) { this.Page.Trace.Warn("Error rendering umbracopanel control" + ex.ToString()); } } } }