/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { Debug.Assert(context != null); // We have no preferred size by default Size preferredSize = Size.Empty; // Apply the border width in appropriate orientation if (Orientation == Orientation.Horizontal) { preferredSize.Height = _palette.GetBorderWidth(State); } else { preferredSize.Width = _palette.GetBorderWidth(State); } return(preferredSize); }
/// <summary> /// Get the preferred size of the control based on a proposed size. /// </summary> /// <param name="proposedSize">Starting size proposed by the caller.</param> /// <returns>Calculated preferred size.</returns> public override Size GetPreferredSize(Size proposedSize) { // Let base class continue with standard calculations proposedSize = base.GetPreferredSize(proposedSize); // Do we need to apply the border width? if (AutoSize) { if (Orientation == Orientation.Horizontal) { proposedSize.Height = _stateCurrent.GetBorderWidth(_state); } else { proposedSize.Width = _stateCurrent.GetBorderWidth(_state); } } return(proposedSize); }
/// <summary> /// Gets the border width. /// </summary> /// <param name="style">Border style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Integer width.</returns> public override int GetBorderWidth(PaletteBorderStyle style, PaletteState state) { PaletteBorderEdge inherit = GetInherit(state); if (inherit != null) { return(inherit.GetBorderWidth(state)); } else { return(Target.GetBorderWidth(style, state)); } }