/// <summary> /// Initialize a new instance of the PaletteDataGridViewContentStates class. /// </summary> /// <param name="inherit">Source for inheriting defaulted values.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PaletteDataGridViewContentStates(IPaletteContent inherit, NeedPaintHandler needPaint) { Debug.Assert(inherit != null); // Remember inheritance _inherit = inherit; // Store the provided paint notification delegate NeedPaint = needPaint; // Default the initial values _draw = InheritBool.Inherit; _hint = PaletteTextHint.Inherit; _trim = PaletteTextTrim.Inherit; _color1 = Color.Empty; _color2 = Color.Empty; _colorStyle = PaletteColorStyle.Inherit; _colorAlign = PaletteRectangleAlign.Inherit; _colorAngle = -1; _imageStyle = PaletteImageStyle.Inherit; _imageAlign = PaletteRectangleAlign.Inherit; _multiLine = InheritBool.Inherit; _multiLineH = PaletteRelativeAlign.Inherit; }
/// <summary> /// Gets the color alignment style. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color alignment style.</returns> public override PaletteRectangleAlign GetBackColorAlign(PaletteState state) { if (Apply) { PaletteRectangleAlign ret = _primary.GetBackColorAlign(Override ? OverrideState : state); if (ret == PaletteRectangleAlign.Inherit) { ret = _backup.GetBackColorAlign(state); } return(ret); } else { return(_backup.GetBackColorAlign(state)); } }
/// <summary> /// Initialize a new instance of the InternalStorage structure. /// </summary> public InternalStorage() { // Set to default values ContentTextHint = PaletteTextHint.Inherit; ContentTextTrim = PaletteTextTrim.Inherit; ContentTextPrefix = PaletteTextHotkeyPrefix.Inherit; ContentTextH = PaletteRelativeAlign.Inherit; ContentTextV = PaletteRelativeAlign.Inherit; ContentTextMultiLineH = PaletteRelativeAlign.Inherit; ContentTextMultiLine = InheritBool.Inherit; ContentTextColor1 = Color.Empty; ContentTextColor2 = Color.Empty; ContentTextColorStyle = PaletteColorStyle.Inherit; ContentTextColorAlign = PaletteRectangleAlign.Inherit; ContentTextColorAngle = -1; ContentTextImageStyle = PaletteImageStyle.Inherit; ContentTextImageAlign = PaletteRectangleAlign.Inherit; }
/// <summary> /// Gets the image alignment style. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public override PaletteRectangleAlign GetBorderImageAlign(PaletteState state) { if (_apply) { PaletteRectangleAlign ret = _primary.GetBorderImageAlign(_override ? _state : state); if (ret == PaletteRectangleAlign.Inherit) { ret = _backup.GetBorderImageAlign(state); } return(ret); } else { return(_backup.GetBorderImageAlign(state)); } }
/// <summary> /// Gets the image alignment for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Image alignment style.</returns> public virtual PaletteRectangleAlign GetContentShortTextImageAlign(PaletteState state) { if (_apply) { PaletteRectangleAlign ret = _primaryContent.GetContentShortTextImageAlign(_override ? _state : state); if (ret == PaletteRectangleAlign.Inherit) { ret = _backupContent.GetContentShortTextImageAlign(state); } return(ret); } else { return(_backupContent.GetContentShortTextImageAlign(state)); } }
/// <summary> /// Gets the color alignment for the long text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color alignment style.</returns> public virtual PaletteRectangleAlign GetContentLongTextColorAlign(PaletteState state) { if (Apply) { PaletteRectangleAlign ret = _primaryContent.GetContentLongTextColorAlign(Override ? OverrideState : state); if (ret == PaletteRectangleAlign.Inherit) { ret = _backupContent.GetContentLongTextColorAlign(state); } return(ret); } else { return(_backupContent.GetContentLongTextColorAlign(state)); } }
/// <summary> /// Calculate a rectangle in control coodinates that is aligned for gradient drawing. /// </summary> /// <param name="align">How to align the gradient.</param> /// <param name="local">Rectangle of the local element.</param> /// <returns></returns> public Rectangle GetAlignedRectangle(PaletteRectangleAlign align, Rectangle local) { switch (align) { case PaletteRectangleAlign.Local: // Gradient should cover just the local view element itself local.Inflate(2, 2); return(local); case PaletteRectangleAlign.Control: Rectangle clientRect = Rectangle.Empty; if (AlignControl == Control) { clientRect = Control.ClientRectangle; } else { clientRect = Control.RectangleToClient(AlignControl.RectangleToScreen(AlignControl.ClientRectangle)); } clientRect.Inflate(2, 2); return(clientRect); case PaletteRectangleAlign.Form: // Gradient should cover the owning control (most likely a Form) Rectangle formRect = Control.RectangleToClient(TopControl.RectangleToScreen(AlignControl.ClientRectangle)); formRect.Inflate(2, 2); return(formRect); case PaletteRectangleAlign.Inherit: default: // Should never call this routine with inherit value Debug.Assert(false); throw new ArgumentOutOfRangeException("align"); } }
/// <summary> /// Initialize a new instance of the InternalStorage structure. /// </summary> public InternalStorage() { // Set to default values BorderDraw = InheritBool.Inherit; BorderDrawBorders = PaletteDrawBorders.All; BorderGraphicsHint = PaletteGraphicsHint.Inherit; BorderColor1 = Color.Empty; BorderColor2 = Color.Empty; BorderColorStyle = PaletteColorStyle.Inherit; BorderColorAlign = PaletteRectangleAlign.Inherit; BorderColorAngle = -1; BorderWidth = -1; BorderRounding = -1; BorderImageStyle = PaletteImageStyle.Inherit; BorderImageAlign = PaletteRectangleAlign.Inherit; }
/// <summary> /// Initialize a new instance of the InternalStorage structure. /// </summary> public InternalStorage() { // Set to default values BackDraw = InheritBool.Inherit; BackGraphicsHint = PaletteGraphicsHint.Inherit; BackColor1 = Color.Empty; BackColor2 = Color.Empty; BackColorStyle = PaletteColorStyle.Inherit; BackColorAlign = PaletteRectangleAlign.Inherit; BackColorAngle = -1; BackImageStyle = PaletteImageStyle.Inherit; BackImageAlign = PaletteRectangleAlign.Inherit; }
/// <summary> /// Calculate a rectangle in control coodinates that is aligned for gradient drawing. /// </summary> /// <param name="align">How to align the gradient.</param> /// <param name="local">Rectangle of the local element.</param> /// <returns></returns> public Rectangle GetAlignedRectangle(PaletteRectangleAlign align, Rectangle local) { switch (align) { case PaletteRectangleAlign.Local: // Gradient should cover just the local view element itself local.Inflate(2, 2); return local; case PaletteRectangleAlign.Control: Rectangle clientRect = Rectangle.Empty; if (AlignControl == Control) clientRect = Control.ClientRectangle; else clientRect = Control.RectangleToClient(AlignControl.RectangleToScreen(AlignControl.ClientRectangle)); clientRect.Inflate(2, 2); return clientRect; case PaletteRectangleAlign.Form: // Gradient should cover the owning control (most likely a Form) Rectangle formRect = Control.RectangleToClient(TopControl.RectangleToScreen(AlignControl.ClientRectangle)); formRect.Inflate(2, 2); return formRect; case PaletteRectangleAlign.Inherit: default: // Should never call this routine with inherit value Debug.Assert(false); throw new ArgumentOutOfRangeException("align"); } }