/// <summary> /// /// </summary> /// <param name="component"></param> public override void ResetValue(object component) { object value = DefaultValue; if (SetDataStrategy != null) { value = SetDataStrategy.AdjustResettedValue(value); } SetValue(component, value); // Do other stuff which might be required when reseting a value RuntimeHostSurface surface = (RuntimeHostSurface)((Component)component).Site.GetService(typeof(DesignSurface)); surface.HandleControlValueReset(component as Control, Name); }
/// <summary> /// Set the studio values on the controls /// </summary> /// <param name="newCtrl"></param> private void SetStudioValues(Control newCtrl) { // get the control's prop descriptors PropertyDescriptorCollection originalPropDescriptors = TypeDescriptor.GetProvider(newCtrl).GetTypeDescriptor(newCtrl).GetProperties(); // get the properties dictionary from the control's tag Dictionary <string, DesignerPropertyInfo> properties = null; if (newCtrl.Tag != null) { properties = ((ControlDesignerInfo)((Control)newCtrl).Tag).Properties; } if (properties != null) { // if there's a special treatment for this control type, deal with it here runtimeHostSurface.HandleControlValueReset(newCtrl, null); if (newCtrl is Form) { newCtrl.Location = new Point(0, 0); } } }