示例#1
0
        /// <summary>
        /// replate data to template clone
        /// </summary>
        /// <param name="obj"></param>
        ///
        #region Public Function
        public void SetRepeat(object obj)
        {
            IRepeatWord repeat = GetTableOfIT(obj, lstTemplate);

            if (repeat != null)
            {
                lstRepeat.Add(repeat);
            }
        }
示例#2
0
        /// <summary>
        /// Replate all tags in a paragraph of a cell
        /// </summary>
        /// <param name="paragraph"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        private string ReplateTempInParagraph(string paragraph, IRepeatWord iRepeat)
        {
            PropertyInfo[] pptI;
            List <string>  str = new List <string>();

            pptI = iRepeat.Data.GetType().GetProperties();
            int length = pptI.Count();

            for (int i = 0; i < length; i++)
            {
                str.Add("{" + pptI[i].Name + "}");
            }
            string[] lst = str.ToArray();
            for (int i = 0; i < lst.Length; i++)
            {
                if (paragraph.IndexOf(lst[i]) != -1)
                {
                    paragraph = paragraph.Replace(lst[i], pptI[i].GetValue(iRepeat.Data, null).ToString());
                }
            }
            return(paragraph);
        }
示例#3
0
        private void ReplateTempInCell(WTableCell cell, IRepeatWord iRepeat)
        {
            PropertyInfo[] pptI;
            pptI = iRepeat.Data.GetType().GetProperties();
            int length = pptI.Count();

            for (int i = 0, n = cell.Paragraphs.Count; i < n; i++)
            {
                string        paragraph = cell.Paragraphs[i].Text;
                List <string> str       = new List <string>();
                for (int j = 0; j < length; j++)
                {
                    str.Add("{" + pptI[j].Name + "}");
                }
                string[] lst = str.ToArray();
                for (int j = 0; j < lst.Length; j++)
                {
                    if (paragraph.IndexOf(lst[j]) != -1)
                    {
                        string tagType  = "Text";
                        string tagStyle = string.Empty;
                        for (int k = 0, l = iRepeat.ITemp.ITempTag.Count; k < l; k++)
                        {
                            if (pptI[j].Name == iRepeat.ITemp.ITempTag[k].TagName)
                            {
                                tagType  = iRepeat.ITemp.ITempTag[k].TagType;
                                tagStyle = iRepeat.ITemp.ITempTag[k].TagStyle;
                            }
                        }
                        if (tagType.ToLower() == TagWordType.Text.ToString().ToLower())
                        {
                            paragraph = paragraph.Replace(lst[j], pptI[j].GetValue(iRepeat.Data, null).ToString());
                            cell.Paragraphs[i].Text = paragraph;
                        }
                        else
                        {
                            string   strImg = pptI[j].GetValue(iRepeat.Data, null).ToString();
                            string   s      = cell.Paragraphs[i].Text;
                            string[] lsts   = s.Split(new string[] { lst[j] }, StringSplitOptions.None);
                            cell.Paragraphs[i].Text = "";
                            cell.Paragraphs[i].AppendText(lsts[0]);
                            if (strImg == "" || strImg == null)
                            {
                                if (lsts.Length != 1)
                                {
                                    cell.Paragraphs[i].AppendText(lsts[1]);
                                }
                            }
                            else
                            {
                                Image     img     = ConvertStrBase64ToImage(strImg);
                                IWPicture picture = cell.Paragraphs[i].AppendPicture(img);
                                if (lsts.Length != 1)
                                {
                                    cell.Paragraphs[i].AppendText(lsts[1]);
                                }
                                if (tagStyle != "")
                                {
                                    string[] lstStyle = tagStyle.Split(';');
                                    for (int a = 0, b = lstStyle.Length; a < b; a++)
                                    {
                                        SetStyle(picture, lstStyle[a]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }