/// <summary> /// Sets the render index for a given control. /// </summary> /// <param name="control">To control that needs to be rendered in /// a specific region.</param> /// <param name="renderIndex">The index of the control within its region.</param> public void SetRenderIndex(Control control, object renderIndex) { //do nothing if no region ID was set if (renderIndex == null) { return; } int index = (int)renderIndex; //get the property set, if any or create a new one RegionPropertySet propertySet = this[control]; if (propertySet == null) { //do not create a property set if the index is the default... if (index == 0) { return; } //store the control in the internal list propertySet = new RegionPropertySet(control, PortalRegion.None, index); this.propertySets.Add(propertySet); } else { //set region ID propertySet.RenderIndex = index; } //announce change NotifyHost(); }
public int GetRenderIndex(Control control) { RegionPropertySet propertySet = this[control]; if (propertySet == null) { return(0); } else { return(propertySet.RenderIndex); } }
public PortalRegion GetTargetRegionId(Control control) { //return PortalRegion.None if no region ID was assigned RegionPropertySet propertySet = this[control]; if (propertySet == null) { return(PortalRegion.None); } else { return(propertySet.TargetRegion); } }
/// <summary> /// Compares the property sets via the /// encapsulated control's <c>ID</c> property. /// </summary> /// <param name="obj">Object to compare.</param> /// <returns></returns> /// <remarks>Compares to eigher a <c>Control</c> /// or a <see cref="RegionPropertySet"/> object.</remarks> public int CompareTo(object obj) { RegionPropertySet propertySet = obj as RegionPropertySet; return(this.renderIndex.CompareTo(propertySet.RenderIndex)); // Control ctrl = obj as Control; // if (ctrl == null) // { // ctrl = ((RegionPropertySet)obj).Control; // } // // return this.control.ID.CompareTo(ctrl.ID); }
/// <summary> /// Sets the target region ID for a given control. /// </summary> /// <param name="control">To control that needs to be rendered in /// a specific region.</param> /// <param name="regionId">The ID of the target region.</param> public void SetTargetRegionId(Control control, object regionId) { //do nothing if no region ID was set if (regionId == null) { return; } //if the property was removed by the user if (regionId.ToString() == "") { //...remove the control from the internal list this.propertySets.Remove(this[control]); } else { PortalRegion region = (PortalRegion)regionId; if (region == PortalRegion.None) { //..,remove the control from the internal list this.propertySets.Remove(this[control]); } else { //get the property set, if any or create a new one RegionPropertySet propertySet = this[control]; if (propertySet == null) { propertySet = new RegionPropertySet(control, region, 0); //store the set in the internal list this.propertySets.Add(propertySet); } else { //adjust region ID propertySet.TargetRegion = region; } } } //announce change NotifyHost(); }
/// <summary> /// Provides conversion information for a property set /// through <c>InstanceDescriptor</c> objects. /// </summary> /// <param name="context"></param> /// <param name="culture"></param> /// <param name="value"></param> /// <param name="destinationType"></param> /// <returns></returns> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { RegionPropertySet propertySet = value as RegionPropertySet; if (propertySet != null) { //perform string conversion if (destinationType == typeof(string)) { return(propertySet.TargetRegion); } //convert to InstanceDescriptor if (destinationType == typeof(InstanceDescriptor)) { object[] parameters = new object[3]; Type[] types = new Type[3]; //control parameters[0] = propertySet.Control; types[0] = typeof(Control); // region parameters[1] = propertySet.TargetRegion; types[1] = typeof(PortalRegion); // index parameters[2] = propertySet.RenderIndex; types[2] = typeof(int); // Build constructor ConstructorInfo ci = typeof(RegionPropertySet).GetConstructor(types); return(new InstanceDescriptor(ci, parameters)); } } //rely on base if neither string nor InstanceDescriptor are required return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// Sets the target region ID for a given control. /// </summary> /// <param name="control">To control that needs to be rendered in /// a specific region.</param> /// <param name="regionId">The ID of the target region.</param> public void SetTargetRegionId(Control control, object regionId) { //do nothing if no region ID was set if (regionId == null) return; //if the property was removed by the user if (regionId.ToString() == "") { //...remove the control from the internal list this.propertySets.Remove(this[control]); } else { PortalRegion region = (PortalRegion)regionId; if (region == PortalRegion.None) { //..,remove the control from the internal list this.propertySets.Remove(this[control]); } else { //get the property set, if any or create a new one RegionPropertySet propertySet = this[control]; if (propertySet == null) { propertySet = new RegionPropertySet(control, region, 0); //store the set in the internal list this.propertySets.Add(propertySet); } else { //adjust region ID propertySet.TargetRegion = region; } } } //announce change NotifyHost(); }
/// <summary> /// Sets the render index for a given control. /// </summary> /// <param name="control">To control that needs to be rendered in /// a specific region.</param> /// <param name="renderIndex">The index of the control within its region.</param> public void SetRenderIndex(Control control, object renderIndex) { //do nothing if no region ID was set if (renderIndex == null) return; int index = (int)renderIndex; //get the property set, if any or create a new one RegionPropertySet propertySet = this[control]; if (propertySet == null) { //do not create a property set if the index is the default... if (index == 0) return; //store the control in the internal list propertySet = new RegionPropertySet(control, PortalRegion.None, index); this.propertySets.Add(propertySet); } else { //set region ID propertySet.RenderIndex = index; } //announce change NotifyHost(); }