/// <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(); } } }
/// <summary> /// /// </summary> /// <returns></returns> internal static MgPanel GetMgPanelOfTabControl(object control) { MgPanel panel = null; if (control is MgTabControl) { Control mgTabcontrol = control as Control; // for tab control, find the panel and set its background color to the same value as the tab control foreach (Control item in mgTabcontrol.Controls) { if (item.Controls.Count > 0) { panel = (MgPanel)item.Controls[0]; break; } } } return(panel); }
private void ResetGradientStyle(Control control) { // Fixed defect #127250 : For all controls that support Gradient, while color is set in runtime designer // it's mean the Gradient color will be reset to NONE // Note in Reset command: * The solid color will be seen on the control. // * The Gradient color will be show while re execute the form again. // * It is because we don't have Gradient color property on property grid, // * PM deiced to go with that way because if it will be impotent we will add the property // to property grid but for now we will not do it if (control is IGradientColorProperty) { IGradientColorProperty gradientColorProperty = control as IGradientColorProperty; gradientColorProperty.GradientStyle = com.magicsoftware.util.GradientStyle.None; MgPanel panel = GetMgPanelOfTabControl(control); if (panel != null) { ResetGradientStyle(panel); } } }
/// <summary> paint control backgound and image</summary> /// <param name="control"></param> /// <param name="graphics"></param> /// <param name="useImageSize" - do the image will be display on all the control (for button image)></param> /// <param name="DisplayRect" - the display rect of the color></param> public static void PaintBackgoundColorAndImage(Control control, Graphics graphics, bool useImageSize, Rectangle DisplayRect) { Image backgroundImage = null; GradientColor gradientColor = ControlUtils.GetGradientColor(control); GradientStyle gradientStyle = ControlUtils.GetGradientStyle(control); ControlRenderer.FillRectAccordingToGradientStyle(graphics, DisplayRect, control.BackColor, control.ForeColor, ControlStyle.NoBorder, false, gradientColor, gradientStyle); #if !PocketPC backgroundImage = control.BackgroundImage; #else if (control is ButtonBase) { ButtonBase button = (ButtonBase)control; backgroundImage = button.BackgroundImage; } else if (control is MgPanel) { MgPanel panel = (MgPanel)control; backgroundImage = panel.BackGroundImage; } #endif if (backgroundImage != null) { Rectangle rectImage; if (useImageSize) { rectImage = new Rectangle(DisplayRect.X, DisplayRect.Y, backgroundImage.Width, backgroundImage.Height); } else { rectImage = control.ClientRectangle; } DrawImage(graphics, rectImage, backgroundImage, 0, 0); } }