diff --git a/components/umbraco.controls/Panel.cs b/components/umbraco.controls/Panel.cs index d28db359a1..8001445d02 100644 --- a/components/umbraco.controls/Panel.cs +++ b/components/umbraco.controls/Panel.cs @@ -9,30 +9,54 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using ClientDependency.Core; +using umbraco.BusinessLogic; -namespace umbraco.uicontrols { +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 { + [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() { + public UmbracoPanel() + { } - protected override void OnInit(EventArgs e) { + protected override void OnInit(EventArgs e) + { + // We can grab the cached window size from cookie values + if (AutoResize) + { + if (!String.IsNullOrEmpty(StateHelper.GetCookieValue("umbPanel_pWidth"))) + { + int pWidth = 0; + int pHeight = 0; + if (int.TryParse(StateHelper.GetCookieValue("umbPanel_pWidth"), out pWidth)) + { + Width = Unit.Pixel(pWidth); + } + if (int.TryParse(StateHelper.GetCookieValue("umbPanel_pHeight"), out pHeight)) + { + Height = Unit.Pixel(pHeight); + } + } + } + setupMenu(); } - protected override void OnLoad(System.EventArgs EventArguments) { + protected override void OnLoad(System.EventArgs EventArguments) + { _menu.Visible = hasMenu; - if(_autoResize) + 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", ""); + //this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "PanelEvents", ""); } private bool _hasMenu = false; @@ -40,19 +64,24 @@ namespace umbraco.uicontrols { private string _text; private bool _autoResize = true; - public bool hasMenu { + public bool hasMenu + { get { return _hasMenu; } set { _hasMenu = value; } } - public bool AutoResize { + public bool AutoResize + { get { return _autoResize; } set { _autoResize = value; } } - public string Text { - get { - if (_text == "") { + public string Text + { + get + { + if (_text == "") + { _text = " "; } return _text; @@ -61,29 +90,35 @@ namespace umbraco.uicontrols { set { _text = value; } } - public string StatusBarText { + public string StatusBarText + { get { return _StatusBarText; } set { _StatusBarText = value; } } - public ScrollingMenu Menu { + 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); + 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) { + + protected override void Render(System.Web.UI.HtmlTextWriter writer) + { base.CreateChildControls(); - - try { - if (System.Web.HttpContext.Current == null) { + + try + { + if (System.Web.HttpContext.Current == null) + { writer.WriteLine("Number of child controls : " + this.Controls.Count); } writer.WriteLine("