using OfficeAppHelp.Help;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace QuestionSwapDoc.SwapWordModel
{
    /// <summary>
    /// 题型集合
    /// </summary>
    public class SwapTiXins
    {
        /// <summary>
        /// 题型集合
        /// </summary>
        public List<SwapTiXin> TiXinList { get; set; } = new List<SwapTiXin>();


        /// <summary>
        /// 更新编号
        /// </summary>
        public void UpdateNumber()
        {
            if (TiXinList == null)
                return;

            //题型，题
            int txn = 1, tn = 1;
            foreach (var item in TiXinList)
            {
                item.NumberStr = txn.ToCNString() + "、";

                if (item.QueList != null)
                {
                    foreach (var item2 in item.QueList)
                    {
                        item2.NumberStr = tn.ToString() + ".";
                        tn++;
                    }
                }
                txn++;
            }
        }

        /// <summary>
        /// html转为文件绝对路径
        /// </summary>
        public void QueHtmlContentToFile()
        {
            foreach (var item in TiXinList)
            {
                foreach (var que in item.QueList)
                {
                    //题
                    if (que.TiRange != null)
                    {
                        que.TiRange.HtmlTextToFile(que.ImgLinkLeftPath);
                    }
                    //答案
                    if (que.DaAnRange != null)
                    {
                        //非选择判断
                        if (!item.IsXuanZhe && !item.IsPanDuan)
                            que.DaAnRange.HtmlTextToFile(que.ImgLinkLeftPath);
                    }
                    //解析
                    if (que.JieXiRange != null)
                    {
                        que.JieXiRange.HtmlTextToFile(que.ImgLinkLeftPath);
                    }
                }
            }
        }

        /// <summary>
        /// html文件转为html内容文本
        /// </summary>
        public void QueHtmlFileToContent()
        {
            foreach (var item in TiXinList)
            {
                foreach (var que in item.QueList)
                {
                    //题
                    if (que.TiRange != null)
                    {
                        que.TiRange.HtmlFileToText();
                    }
                    //答案
                    if (que.DaAnRange != null)
                    {
                        //非选择判断
                        if (!item.IsXuanZhe && !item.IsPanDuan)
                            que.DaAnRange.HtmlFileToText();
                    }
                    //解析
                    if (que.JieXiRange != null)
                    {
                        que.JieXiRange.HtmlFileToText();
                    }
                }
            }
        }

    }
}
