using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LunarSF.SHomeWorkshop.LunarMarkdownEditor;

namespace LunarSF.SHomeWorkshop.LunarMarkdownEditor
{
    /// <summary>
    /// 二维文字表的列的定义。
    /// </summary>
    public class TableColumnDefinition
    {
        /// <summary>
        /// 列的对齐方式。
        /// </summary>
        public ColumnAlignment Align { get; set; }

        private int maxTextWidth = 3;
        /// <summary>
        /// 表示此列中各单元格文本最长的文本长度。
        /// 格式化二维文字表时,其它单元格长度不及此单元格文本长度时,
        /// 需要根据对齐方式用半角空格补齐。
        /// </summary>
        public int MaxTextWidth
        {
            get
            {
                switch (Align)
                {
                    case ColumnAlignment.LEFT:
                    case ColumnAlignment.RIGHT:
                        {
                            return Math.Max(this.maxTextWidth, 2);
                            //考虑到列定义的需要,每个单元格最小也需要2或3的宽度。:-或者-:
                        }
                    default:
                        {
                            return Math.Max(this.maxTextWidth, 3);
                            //考虑到列定义的需要,每个单元格最小也需要2或3的宽度。:-:
                        }
                }
            }
            set
            {
                this.maxTextWidth = value;
            }
        }

        private int? startNumber = null;
        /// <summary>
        /// 对列进行自动编号时,从哪个数字开始。
        /// </summary>
        public int? StartNumber
        {
            get { return startNumber; }
            set { startNumber = value; }
        }
    }
}