protected internal override void CreateChildControls() { ControlCollection controls = this.Controls; controls.Clear(); TypeConverter converter = TypeDescriptor.GetConverter(typeof(PartChromeState)); this._chromeState = new DropDownList(); this._chromeState.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeState_Normal"), converter.ConvertToString(PartChromeState.Normal))); this._chromeState.Items.Add(new ListItem(System.Web.SR.GetString("PartChromeState_Minimized"), converter.ConvertToString(PartChromeState.Minimized))); controls.Add(this._chromeState); this._zone = new DropDownList(); WebPartManager webPartManager = base.WebPartManager; if (webPartManager != null) { WebPartZoneCollection zones = webPartManager.Zones; if (zones != null) { foreach (WebPartZoneBase base2 in zones) { ListItem item = new ListItem(base2.DisplayTitle, base2.ID); this._zone.Items.Add(item); } } } controls.Add(this._zone); this._zoneIndex = new TextBox(); this._zoneIndex.Columns = 10; controls.Add(this._zoneIndex); foreach (Control control in controls) { control.EnableViewState = false; } }
public override void SyncChanges() { WebPart webPart = WebPartToEdit; Debug.Assert(webPart != null); if (webPart != null) { WebPartZoneBase currentZone = webPart.Zone; bool allowLayoutChange = currentZone.AllowLayoutChange; EnsureChildControls(); TypeConverter chromeStateConverter = TypeDescriptor.GetConverter(typeof(PartChromeState)); _chromeState.SelectedValue = chromeStateConverter.ConvertToString(webPart.ChromeState); _chromeState.Enabled = CanChangeChromeState; WebPartManager manager = WebPartManager; Debug.Assert(manager != null); if (manager != null) { WebPartZoneCollection zones = manager.Zones; bool allowZoneChange = webPart.AllowZoneChange; _zone.ClearSelection(); foreach (ListItem item in _zone.Items) { string zoneID = item.Value; WebPartZoneBase zone = zones[zoneID]; if (zone == currentZone || (allowZoneChange && zone.AllowLayoutChange)) { item.Enabled = true; } else { item.Enabled = false; } if (zone == currentZone) { item.Selected = true; } } _zone.Enabled = CanChangeZone; } _zoneIndex.Text = webPart.ZoneIndex.ToString(CultureInfo.CurrentCulture); _zoneIndex.Enabled = CanChangeZoneIndex; } }
protected internal override void CreateChildControls() { ControlCollection controls = Controls; controls.Clear(); TypeConverter chromeStateConverter = TypeDescriptor.GetConverter(typeof(PartChromeState)); _chromeState = new DropDownList(); _chromeState.Items.Add(new ListItem(SR.GetString(SR.PartChromeState_Normal), chromeStateConverter.ConvertToString(PartChromeState.Normal))); _chromeState.Items.Add(new ListItem(SR.GetString(SR.PartChromeState_Minimized), chromeStateConverter.ConvertToString(PartChromeState.Minimized))); controls.Add(_chromeState); // Add all zones to dropdown in CreateChildControls. Items will be selected and/or disabled // in SyncChanges. Assumes no Zones are added or removed during page execution. _zone = new DropDownList(); WebPartManager manager = WebPartManager; if (manager != null) { WebPartZoneCollection zones = manager.Zones; if (zones != null) { foreach (WebPartZoneBase zone in zones) { ListItem item = new ListItem(zone.DisplayTitle, zone.ID); _zone.Items.Add(item); } } } controls.Add(_zone); _zoneIndex = new TextBox(); _zoneIndex.Columns = TextBoxColumns; controls.Add(_zoneIndex); // We don't need viewstate enabled on our child controls. Disable for perf. foreach (Control c in controls) { c.EnableViewState = false; } }
public override void SyncChanges() { WebPart webPartToEdit = base.WebPartToEdit; if (webPartToEdit != null) { WebPartZoneBase zone = webPartToEdit.Zone; bool allowLayoutChange = zone.AllowLayoutChange; this.EnsureChildControls(); this._chromeState.SelectedValue = TypeDescriptor.GetConverter(typeof(PartChromeState)).ConvertToString(webPartToEdit.ChromeState); this._chromeState.Enabled = this.CanChangeChromeState; WebPartManager webPartManager = base.WebPartManager; if (webPartManager != null) { WebPartZoneCollection zones = webPartManager.Zones; bool allowZoneChange = webPartToEdit.AllowZoneChange; this._zone.ClearSelection(); foreach (ListItem item in this._zone.Items) { string str = item.Value; WebPartZoneBase base3 = zones[str]; if ((base3 == zone) || (allowZoneChange && base3.AllowLayoutChange)) { item.Enabled = true; } else { item.Enabled = false; } if (base3 == zone) { item.Selected = true; } } this._zone.Enabled = this.CanChangeZone; } this._zoneIndex.Text = webPartToEdit.ZoneIndex.ToString(CultureInfo.CurrentCulture); this._zoneIndex.Enabled = this.CanChangeZoneIndex; } }
/// <devdoc> /// </devdoc> public WebPartManager() { _allowEventCancellation = true; _displayMode = BrowseDisplayMode; _webPartZones = new WebPartZoneCollection(); _partAndChildControlIDs = new HybridDictionary(true /* caseInsensitive */); _zoneIDs = new HybridDictionary(true /* caseInsensitive */); }