コード例 #1
0
        private int GetHorizontalPosition(int childrenWidth)
        {
            if (Gravity.HasFlag(Gravity.Left) || Gravity.HasFlag(Gravity.Fill))
            {
                return(Position.X);
            }
            if (Gravity.HasFlag(Gravity.Right))
            {
                return(Position.X - childrenWidth);
            }
            if (Gravity.HasFlag(Gravity.CenterHorizontal))
            {
                return(Position.X + Width / 2 - childrenWidth / 2);
            }

            throw new Exception("Invalid horizontal gravity");
        }