/// <summary> /// Create a PropertyDescriptor which wraps a real property of the control /// </summary> /// <param name="keyProp"></param> /// <param name="controlDesignerInfo"></param> /// <param name="component"></param> /// <param name="nativeProp"></param> /// <returns></returns> private static PropertyDescriptor CreateDescriptorForRealProperty(KeyValuePair <string, DesignerPropertyInfo> keyProp, ControlDesignerInfo controlDesignerInfo, object component, PropertyDescriptor nativeProp, string name) { object valueItem = keyProp.Value.Value; ISetPropertyData setPropertyData = GetSetDataStrategy(ref keyProp, ref valueItem, controlDesignerInfo, component); Attribute[] attrs = GetAttribute(keyProp); RTDesignerPropertyDescriptor propertyDescriptor = new RTDesignerPropertyDescriptor(component, nativeProp, valueItem, name ?? nativeProp.DisplayName, attrs) { SetDataStrategy = setPropertyData }; propertyDescriptor.SetTranslator(GetTranslator(component, keyProp.Key)); propertyDescriptor.CanResetStrategy = GetCanRestStrategy(component, keyProp.Key); return(propertyDescriptor); }
/// <summary> /// if background color is reset then reset also the gradient style /// </summary> /// <param name="control"></param> /// <param name="propeKey"></param> private void UpdateGradientStyleProperty(Control control, string propeKey) { if (propeKey == null || propeKey.Equals(Constants.WinPropBackColor)) { if (ComponentsDictionary.ContainsKey(control) && ComponentsDictionary[control].PropertiesDescriptors[Constants.WinPropGradientStyle] != null) { RTDesignerPropertyDescriptor propertyDescriptor = ComponentsDictionary[control].PropertiesDescriptors[Constants.WinPropGradientStyle] as RTDesignerPropertyDescriptor; ((IGradientColorProperty)control).GradientStyle = (GradientStyle)propertyDescriptor.DefaultValue; // for tab control reset the panel of the tab control MgPanel mgPanel = BackgroundColorStrategy.GetMgPanelOfTabControl(control); if (mgPanel != null) { ((IGradientColorProperty)mgPanel).GradientStyle = (GradientStyle)propertyDescriptor.DefaultValue; } control.Invalidate(); } } }