using System;
using System.Collections.Generic;
using System.Text;

namespace QuestionSwapDoc.SwapWordModel
{
    /// <summary>
    /// 装订线
    /// </summary>
    public class ZhuanDinXian
    {
        /// <summary>
        /// 是否显示装订线
        /// </summary>
        public bool IsShow { get; set; } = false;
        /// <summary>
        /// 是否显示边框线
        /// </summary>
        public bool IsShowLine { get; set; } = true;
        /// <summary>
        /// 是否采用双面打印的方式来生成装订线
        /// （单面打印在同一个方向，双面打印奇偶页将会在不同方向）
        /// </summary>
        public bool IsDuplexPrinting { get; set; } = true;
        /// <summary>
        /// 是否每一份新的纸张页显示书写内容
        /// </summary>
        public bool IsNewPageShowWriteText { get; set; } = false;
        /// <summary>
        /// 装订线书写内容
        /// </summary>
        public string WriteText { get; set; } = "学校：______________ 班级：______________ 姓名：______________ 学号：______________";
        /// <summary>
        /// 装订线分割线
        /// </summary>
        public char Split { get; set; } = '/';
        /// <summary>
        /// 装订线线内容（最好不要超过10个字符串）
        /// </summary>
        public string AlurText { get; set; } = "装订线内请不要答题";

        /// <summary>
        /// 得到装订线的分割内容
        /// </summary>
        /// <param name="strLength">装订线的分割内容长度</param>
        /// <returns></returns>
        public string GetAlurSplitText(int strLength = 150)
        {
            string alurSplitText = new string(Split, strLength);
            if (string.IsNullOrEmpty(AlurText))
                return alurSplitText;

            //左边的开始位置
            int leftInsert = (int)((double)strLength * 0.2);
            //每个字符的间距
            int charLength = (strLength - leftInsert * 2) / (AlurText.Length + 1);

            leftInsert += charLength;
            //当前个数
            foreach (var item in AlurText)
            {
                alurSplitText = alurSplitText.Insert(leftInsert, item.ToString());
                leftInsert += charLength + 1;
            }

            return alurSplitText;
        }

    }
}
