Пример #1
0
 private void buttonGenerate_Click(object sender, EventArgs e)
 {
     if (!IsFieldsFilled())
     {
         MessageBox.Show("Заполните все поля!");
     }
     else
     {
         var wp = new WorkProgram(comboBoxDiscipline.Text, comboBoxLevel.Text, comboBoxDirection.Text, int.Parse(textBoxYear.Text));
         try
         {
             DialogResult res = saveFileDialog1.ShowDialog();
             if (res == DialogResult.OK)
             {
                 var path = saveFileDialog1.FileName;
                 _Word.path             = path;
                 buttonGenerate.Enabled = false;
                 _Word.GenerateSubject(wp);
                 buttonGenerate.Enabled = true;
             }
             else
             {
                 throw new Exception("Путь не выбран");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Пример #2
0
        public static void GenerateSubject(WorkProgram wp)
        {
            foreach (var item in wp.bookmarks)
            {
                var format = new Xceed.Document.NET.Formatting();
                switch (item.Key)
                {
                case "Discipline":
                    format.Size = 14;
                    format.Bold = true;
                    break;

                case "Direction":
                    format.Size = 14;
                    break;

                case "Profile":
                    format.Size = 14;
                    break;

                default:
                    format.Size = 12;
                    break;
                }
                if (!string.IsNullOrEmpty(item.Value))
                {
                    template.Bookmarks[item.Key].SetText(item.Value, format);
                }
            }
            template.SaveAs(path);
        }