/// <summary> /// Returns the vertical alignment portion of an alignment. /// </summary> /// <param name="align">the full alignment / anchor</param> /// <returns>the vertical part of align</returns> public static VerticalAlign Vertical(ScreenAlign align) { switch (align) { case NGAlignment.ScreenAlign.TopLeft: case NGAlignment.ScreenAlign.TopCenter: case NGAlignment.ScreenAlign.TopRight: return VerticalAlign.Top; case NGAlignment.ScreenAlign.MiddleLeft: case NGAlignment.ScreenAlign.MiddleCenter: case NGAlignment.ScreenAlign.MiddleRight: return VerticalAlign.Middle; case NGAlignment.ScreenAlign.BottomLeft: case NGAlignment.ScreenAlign.BottomCenter: case NGAlignment.ScreenAlign.BottomRight: return VerticalAlign.Bottom; } // Fallback, should never be called return VerticalAlign.Middle; }
/// <summary> /// Shortcut to quickly determine whether an alignment is bottom aligned. /// This is useful because usually, bottom aligned needs to special treatment. /// </summary> /// <param name="align">the alignment</param> /// <returns>whether align is one of BottomLeft, BottomCenter, BottomRight</returns> public static bool IsBottom(ScreenAlign align) { return Vertical(align) == VerticalAlign.Bottom; }
/// <summary> /// Shortcut to quickly determine whether an alignment is right aligned. /// This is useful because usually, right aligned needs to special treatment. /// </summary> /// <param name="align">the alignment</param> /// <returns>whether align is one of TopRight, MiddleRight, BottomRight</returns> public static bool IsRight(ScreenAlign align) { return Horizontal(align) == HorizontalAlign.Right; }
/// <summary> /// Returns the horizontal alignment portion of an alignment. /// </summary> /// <param name="align">the full alignment / anchor</param> /// <returns>the horizontal part of align</returns> public static HorizontalAlign Horizontal(ScreenAlign align) { switch (align) { case NGAlignment.ScreenAlign.TopLeft: case NGAlignment.ScreenAlign.MiddleLeft: case NGAlignment.ScreenAlign.BottomLeft: return HorizontalAlign.Left; case NGAlignment.ScreenAlign.TopCenter: case NGAlignment.ScreenAlign.MiddleCenter: case NGAlignment.ScreenAlign.BottomCenter: return HorizontalAlign.Center; case NGAlignment.ScreenAlign.TopRight: case NGAlignment.ScreenAlign.MiddleRight: case NGAlignment.ScreenAlign.BottomRight: return HorizontalAlign.Right; } // Fallback, should never be called return HorizontalAlign.Center; }