public override string GetDesignTimeHtml(DesignerRegionCollection regions) { try { WebPartZone viewControl = (WebPartZone)base.ViewControl; bool flag = base.UseRegions(regions, this._zone.ZoneTemplate, viewControl.ZoneTemplate); if ((viewControl.ZoneTemplate == null) && !flag) { return(this.GetEmptyDesignTimeHtml()); } ((ICompositeControlDesignerAccessor)viewControl).RecreateChildControls(); if (flag) { viewControl.Controls.Clear(); WebPartEditableDesignerRegion region = new WebPartEditableDesignerRegion(viewControl, base.TemplateDefinition) { IsSingleInstanceTemplate = true, Description = System.Design.SR.GetString("ContainerControlDesigner_RegionWatermark") }; regions.Add(region); } return(base.GetDesignTimeHtml()); } catch (Exception exception) { return(this.GetErrorDesignTimeHtml(exception)); } }
public override Control GetPreviewControl(Control runtimeControl) { WebPartZone previewControl = (WebPartZone)base.GetPreviewControl(runtimeControl); if ((previewControl != null) && (previewControl.WebParts.Count == 0)) { previewControl.ZoneTemplate = new AutoFormatTemplate(); } return(previewControl); }
public override void SetTemplateContent(ITemplateEditingFrame editingFrame, string templateName, string templateContent) { if (this.templateEditingVerbs != null) { WebPartZone control = (WebPartZone)Component; ITemplate newTemplate = null; if ((templateContent != null) && (templateContent.Length > 0)) { newTemplate = this.GetTemplateFromText(templateContent); } if (templateName == "ZoneTemplate") { control.ZoneTemplate = newTemplate; } } }
public static WebPartInfo[] GetAvailableWebParts(WebPartZone zone) { return GetAvailableWebParts(zone, null); }
public static WebPartInfo[] GetAvailableWebParts(WebPartZone zone, bool? visibleByDefault) { return Array.FindAll(CurrentContextAllParts, p => p.Zone == zone && p.RequirementsMet() && (!visibleByDefault.HasValue || p.IsVisibleByDefault == visibleByDefault)); }
private IDictionary <string, IList <WebPartZone> > LoadConfig() { if (null == this.Agent) { throw new InvalidOperationException("Agent not set"); } Dictionary <string, IList <WebPartZone> > zones = new Dictionary <string, IList <WebPartZone> >(); XmlDocument doc = new XmlDocument(); if (!this.Agent.HasKey(configFile)) { CreateEmptyConfig(); } doc.LoadXml(this.Agent.Read(configFile)); XmlNode rootNode = doc.SelectSingleNode("zones"); if (null == rootNode) { throw new ApplicationException(String.Format("The config file '{0}' has no zones element", configFile)); } foreach (XmlNode node in rootNode.ChildNodes) { if (null == node.Attributes["id"]) { throw new ApplicationException("Missing attribute 'id' in zone's configuration element"); } if (null == node.Attributes["title"]) { throw new ApplicationException("Missing attribute 'title' in zone's configuration element"); } if (null == node.Attributes["screen"]) { throw new ApplicationException("Missing attribute 'screen' in zone's configuration element"); } if (null == node.Attributes["type"]) { throw new ApplicationException("Missing attribute 'type' in zone's configuration element"); } string id = node.Attributes["id"].Value; string title = node.Attributes["title"].Value; string screen = node.Attributes["screen"].Value; string type = node.Attributes["type"].Value; WebPartZone zone = ReflectionServices.CreateInstance(type) as WebPartZone; if (null == zone) { throw new ApplicationException(String.Format("Failed to create WebPartZone for zone '{0}' from type '{1}'", id, type)); } zone.ID = id; zone.HeaderText = title; if (!zones.ContainsKey(screen)) { zones.Add(screen, new List <WebPartZone>()); } zones[screen].Add(zone); if (!this.Extras.ContainsKey(zone)) { this.Extras.Add(zone, new ZoneInfo()); } ZoneInfo zoneInfo = this.Extras[zone]; foreach (XmlNode extraNode in node.ChildNodes) { if ("parent" == extraNode.Name && null != extraNode.Attributes["id"]) { zoneInfo.ParentID = extraNode.Attributes["id"].Value; } } } cache.Remove(configFile); cache.Insert(configFile, zones, new CacheDependency(configFile)); return(zones); }
public override void Initialize(IComponent component) { ControlDesigner.VerifyInitializeArgument(component, typeof(WebPartZone)); base.Initialize(component); this._zone = (WebPartZone)component; }
public override void Initialize(System.ComponentModel.IComponent component) { base.Initialize(component); this.zone = (WebPartZone)component; }