示例#1
0
        private void Init()
        {
            if (_appendix == null)
            {
                _appendix = new WordsAppendix();
                return;
            }

            txtTimu.Text    = _appendix.Timu.ConContent;
            txtZhenwen.Text = _appendix.TZhenwen.ConContent;

            if (_appendix.Zhenwen != null)
            {
                InitTree(null);
                _appendix.Zhenwen.ForEach(f => id = id == 0 ? f.ID : (f.ID > id ? f.ID : id));
                treeView1.ExpandAll();
            }

            if (_appendix.Appendixs != null)
            {
                int i = 0;
                _appendix.Appendixs.ForEach(item => {
                    dDLSourceBindingSource.Add(new DDLSource()
                    {
                        Index = i++, Text = item.Title
                    });
                });
            }
        }
示例#2
0
        private void btnWord_Click(object sender, EventArgs e)
        {
            var index = (int)ddlWord.SelectedValue;

            WordsAppendix     words = null;
            FormWordsAppendix f;

            if (index >= 0)
            {
                words = (WordsAppendix)_appendix.Appendixs[index];
            }
            f = new FormWordsAppendix(words, _formIndex + 1);

            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (f.Appendix.Timu == null)
                {
                    return;
                }

                f.Appendix.Type  = 0;
                f.Appendix.Title = f.Appendix.Timu.ConContent;

                if (index == -1)
                {
                    if (_appendix.Appendixs == null)
                    {
                        _appendix.Appendixs = new List <ToWord.Appendix>();
                    }

                    dDLSourceBindingSource.List.Add(new DDLSource()
                    {
                        Index = _appendix.Appendixs.Count - 1, Text = "【文字】" + f.Appendix.Title
                    });
                    _appendix.Appendixs.Add(f.Appendix);
                }
                else
                {
                    _appendix.Appendixs[index] = f.Appendix;
                    ((DDLSource)dDLSourceBindingSource.Current).Text = "【文字】" + f.Appendix.Title;
                    BindDDL();
                }
            }
        }
示例#3
0
文件: Form1.cs 项目: jhkmnm/ToWord
        private void AddAppendixTitles(WordsAppendix wa)
        {
            Style style = config.FontStyles.Find(w => w.FontName == wa.Timu.ConType);

            word.AddContent(wa.Timu.ConContent, style);

            style = config.FontStyles.Find(w => w.FontName == wa.TZhenwen.ConType);
            word.AddContent(wa.TZhenwen.ConContent, style);

            int a, b, c, d;

            a = b = c = d = 0;

            if (wa.Zhenwen != null)
            {
                foreach (var v in wa.Zhenwen)
                {
                    style = config.FontStyles.Find(w => w.FontName == v.TContent.ConType);
                    if (v.TContent.ConType == "一级标题")
                    {
                        v.TContent.ConContent = string.Format(style.NumberFormat, titleA[a++]) + v.TContent.ConContent;
                    }
                    else if (v.TContent.ConType == "二级标题")
                    {
                        v.TContent.ConContent = string.Format(style.NumberFormat, titleA[b++]) + v.TContent.ConContent;
                    }
                    else if (v.TContent.ConType == "三级标题")
                    {
                        v.TContent.ConContent = string.Format(style.NumberFormat, titleB[c++]) + v.TContent.ConContent;
                    }
                    else if (v.TContent.ConType == "四级标题")
                    {
                        v.TContent.ConContent = string.Format(style.NumberFormat, titleB[d++]) + v.TContent.ConContent;
                    }
                    word.AddContent(v.TContent.ConContent, style);
                }
            }

            if (wa.Appendixs != null)
            {
                AddAppendixs(wa.Appendixs, 1);
            }
        }
示例#4
0
        public FormWordsAppendix(WordsAppendix appendix, int formindex = 0)
        {
            InitializeComponent();

            _appendix  = appendix;
            _formIndex = formindex;

            if (_formIndex == 1)
            {
                btnWord.Visible = false;
            }

            DDLSource source = new DDLSource {
                Index = -1, Text = "新增"
            };

            dDLSourceBindingSource.DataSource = source;

            BindDDL();

            Init();
        }
示例#5
0
文件: Form1.cs 项目: jhkmnm/ToWord
        private void btnWord_Click(object sender, EventArgs e)
        {
            DataVerifier dv = new DataVerifier();

            dv.Check(n == null, "请先添加通知模板再添加附件");

            if (dv.Pass)
            {
                var index = (int)ddlWord.SelectedValue;

                WordsAppendix     words = null;
                FormWordsAppendix f;

                if (index >= 0)
                {
                    dv.Check(n.Appendixs[index].Type != 0, "修改附件时请选择对应的附件类型");
                    if (dv.Pass)
                    {
                        words = (WordsAppendix)n.Appendixs[index];
                    }
                }

                if (dv.Pass)
                {
                    f = new FormWordsAppendix(words);

                    if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (f.Appendix.Timu == null)
                        {
                            return;
                        }

                        f.Appendix.Type  = 0;
                        f.Appendix.Title = f.Appendix.Timu.ConContent;

                        if (index == -1)
                        {
                            if (n.Appendixs == null)
                            {
                                n.Appendixs = new List <Appendix>();
                            }

                            n.Appendixs.Add(f.Appendix);
                            dDLSourceBindingSource.List.Add(new DDLSource()
                            {
                                Index = n.Appendixs.Count - 1, Text = "【文字】" + f.Appendix.Title
                            });
                        }
                        else
                        {
                            n.Appendixs[index] = f.Appendix;
                            ((DDLSource)dDLSourceBindingSource.Current).Text = "【文字】" + f.Appendix.Title;
                            BindDDL();
                        }
                    }
                }
            }

            dv.ShowMsgIfFailed();
        }