00001 #if V2 00002 00003 using System; 00004 using System.ComponentModel; 00005 using System.Drawing; 00006 using System.Web.UI; 00007 using ASP = System.Web.UI.WebControls; 00008 using WebParts = System.Web.UI.WebControls.WebParts; 00009 00010 namespace Anthem 00011 { 00015 [ToolboxBitmap(typeof(WebParts.WebPartZone))] 00016 public class WebPartZone : WebParts.WebPartZone, IUpdatableControl 00017 { 00018 #region Unique Anthem control code 00019 00023 protected override void OnPreRender(EventArgs e) 00024 { 00025 base.OnPreRender(e); 00026 Page.ClientScript.RegisterStartupScript( 00027 typeof(WebPartZone), 00028 "hack", 00029 @"<script type='text/javascript'> function WebPartManager_SubmitPage(eventTarget, eventArgument) { if ((typeof(this.menu) != 'undefined') && (this.menu != null)) { this.menu.Hide(); } Anthem_FireEvent(eventTarget, eventArgument, function() { }, null, true, true); } function Zone_AddWebPart(webPartElement, webPartTitleElement, allowZoneChange) { var webPart = null; var zoneIndex = this.webParts.length; for (var i = 0; i < this.webParts.length; ++i) { if (this.webParts[i].webPartElement.id == webPartElement.id) { zoneIndex = i; break; } } if (this.allowLayoutChange && __wpm.IsDragDropEnabled()) { webPart = new WebPart(webPartElement, webPartTitleElement, this, zoneIndex, allowZoneChange); } else { webPart = new WebPart(webPartElement, null, this, zoneIndex, allowZoneChange); } this.webParts[zoneIndex] = webPart; return webPart; } function ReAddWebParts(zoneID) { for (var i = 0; i < __wpm.zones.length; ++i) { var zone = __wpm.zones[i]; if (zone.uniqueID == zoneID) { for (var j = 0; j < zone.webParts.length; ++j) { var webPartID = zone.webParts[j].webPartElement.id; var webPart = document.getElementById(webPartID); if (webPart) { zone.AddWebPart(webPart, null, false); var webPartVerbs = document.getElementById(webPartID + 'Verbs'); var webPartVerbsPopup = document.getElementById(webPartID + 'VerbsPopup'); var webPartVerbsMenu = document.getElementById(webPartID + 'VerbsMenu'); var menu = new WebPartMenu(webPartVerbs, webPartVerbsPopup, webPartVerbsMenu); menu.itemStyle = ''; menu.itemHoverStyle = ''; menu.labelHoverColor = ''; menu.labelHoverClassName = ''; } } break; } } } </script>"); 00030 } 00031 00036 protected override void MinimizeWebPart(WebParts.WebPart webPart) 00037 { 00038 base.MinimizeWebPart(webPart); 00039 UpdateAndReAddWebParts(); 00040 } 00041 00046 protected override void RestoreWebPart(WebParts.WebPart webPart) 00047 { 00048 base.RestoreWebPart(webPart); 00049 UpdateAndReAddWebParts(); 00050 } 00051 00056 protected override void CloseWebPart(System.Web.UI.WebControls.WebParts.WebPart webPart) 00057 { 00058 base.CloseWebPart(webPart); 00059 UpdateAndReAddWebParts(); 00060 } 00061 00062 private const string parentTagName = "span"; 00067 protected override void Render(HtmlTextWriter writer) 00068 { 00069 #if !V2 00070 bool DesignMode = this.Context == null; 00071 #endif 00072 if (!DesignMode) 00073 { 00074 Anthem.Manager.WriteBeginControlMarker(writer, parentTagName, this); 00075 } 00076 if (Visible) 00077 { 00078 base.Render(writer); 00079 } 00080 if (!DesignMode) 00081 { 00082 Anthem.Manager.WriteEndControlMarker(writer, parentTagName, this); 00083 } 00084 } 00085 00086 #endregion 00087 00088 #region IUpdatableControl implementation 00089 00103 [Category("Anthem")] 00104 [DefaultValue(false)] 00105 [Description("True if this control should be updated after each callback.")] 00106 public virtual bool AutoUpdateAfterCallBack 00107 { 00108 get 00109 { 00110 object obj = this.ViewState["AutoUpdateAfterCallBack"]; 00111 if (obj == null) 00112 return false; 00113 else 00114 return (bool)obj; 00115 } 00116 set 00117 { 00118 if (value) UpdateAfterCallBack = true; 00119 ViewState["AutoUpdateAfterCallBack"] = value; 00120 } 00121 } 00122 00123 private bool _updateAfterCallBack = false; 00124 00139 [Browsable(false)] 00140 [DefaultValue(false)] 00141 public virtual bool UpdateAfterCallBack 00142 { 00143 get { return _updateAfterCallBack; } 00144 set { _updateAfterCallBack = value; } 00145 } 00146 00147 #endregion 00148 00149 #region Common Anthem control code 00150 00156 protected override void OnLoad(EventArgs e) 00157 { 00158 base.OnLoad(e); 00159 Anthem.Manager.Register(this); 00160 } 00161 00162 #if V2 00166 public override void RenderControl(HtmlTextWriter writer) 00167 { 00168 base.Visible = true; 00169 base.RenderControl(writer); 00170 } 00171 #endif 00172 00180 public override bool Visible 00181 { 00182 get 00183 { 00184 #if !V2 00185 bool DesignMode = this.Context == null; 00186 #endif 00187 return Anthem.Manager.GetControlVisible(this, ViewState, DesignMode); 00188 } 00189 set { Anthem.Manager.SetControlVisible(ViewState, value); } 00190 } 00191 00192 #endregion 00193 00194 #region Private Methods 00195 00196 private void UpdateAndReAddWebParts() 00197 { 00198 UpdateAfterCallBack = true; 00199 Anthem.Manager.AddScriptForClientSideEval(string.Format("ReAddWebParts('{0}')", ID)); 00200 } 00201 00202 #endregion 00203 } 00204 } 00205 00206 #endif 00207