Esempio n. 1
0
 private void ApplyListTemplate(Microsoft.Office.Interop.Word.ListGallery listGallery, Microsoft.Office.Interop.Word.ListFormat listFormat, int level = 1)
 {
     listFormat.ApplyListTemplateWithLevel(
         listGallery.ListTemplates[level],
         ContinuePreviousList: true,
         ApplyTo: Microsoft.Office.Interop.Word.WdListApplyTo.wdListApplyToSelection,
         DefaultListBehavior: Microsoft.Office.Interop.Word.WdDefaultListBehavior.wdWord10ListBehavior,
         ApplyLevel: level);
 }
Esempio n. 2
0
        public Word.ListTemplate CreateListTemplate()
        {
            // выбор маркера для списка
            Word._Application app     = _application;
            Word.ListGallery  gallery = app.ListGalleries[Word.WdListGalleryType.wdBulletGallery];
            Word.ListTemplate myPreferredListTemplate = gallery.ListTemplates[1];          // номер семейства маркеров?(тире или что-то другое)
            Word.ListLevel    listLevel = myPreferredListTemplate.ListLevels[1];           //Номер семейства(чего?) только 1 работает.
            listLevel.NumberFormat      = "-";                                             // символ для маркера
            listLevel.TrailingCharacter = Word.WdTrailingCharacter.wdTrailingSpace;        // После маркера пробел.(табуляция или слитно)
            listLevel.NumberStyle       = Word.WdListNumberStyle.wdListNumberStyleBullet;  // wdListNumberStyleBullet для маркированного списка
            listLevel.Alignment         = Word.WdListLevelAlignment.wdListLevelAlignRight; // выравнивание?.
            listLevel.NumberPosition    = 0;
            listLevel.TextPosition      = 0;
            listLevel.StartAt           = 1;

            return(myPreferredListTemplate);
        }
Esempio n. 3
0
        int nToolTipIndex;                                                             // Выбранный элемент в CheckedListBox

        #endregion Variables

        #region Functions

        /// <summary>
        /// Функция для записи списка тест кейсов в Word
        /// </summary>
        private void WriteToFile(object objectClass)
        {
            try
            {
                CItemsForWriteToFile cItemsForWriteToFile = (CItemsForWriteToFile)objectClass;

                // Пока идет запись тест кейсов в файл Word
                // отключить кнопки
                btnWriteInFile.Invoke((MethodInvoker) delegate
                {
                    btnWriteInFile.Enabled = false;
                });
                btnWriteToFile_Queries.Invoke((MethodInvoker) delegate
                {
                    btnWriteToFile_Queries.Enabled = false;
                });

                progressBar2.Invoke((MethodInvoker) delegate
                {
                    progressBar2.Show();
                    progressBar2.Minimum = 0;
                    progressBar2.Maximum = 100;

                    progressBar2.Value = 0;
                });

                Word.Application application = new Word.Application();
                Word.Document    document    = application.Documents.Add();
                Word.Range       range       = document.Range();
                Word.Paragraph   paragraph   = document.Paragraphs.Add();

                progressBar2.Invoke((MethodInvoker) delegate
                {
                    progressBar2.Value = 30;
                });

                Word.ListGallery  listGallery  = application.ListGalleries[WdListGalleryType.wdOutlineNumberGallery];
                Word.ListTemplate listTemplate = listGallery.ListTemplates[5];

                listTemplate.ListLevels[1].NumberPosition = application.CentimetersToPoints(0f);
                listTemplate.ListLevels[1].Font.Size      = 11f;

                progressBar2.Invoke((MethodInvoker) delegate
                {
                    progressBar2.Value = 40;
                });

                listTemplate.ListLevels[2].NumberPosition = application.CentimetersToPoints(0.63f);
                listTemplate.ListLevels[2].Font.Size      = 11f;

                progressBar2.Invoke((MethodInvoker) delegate
                {
                    progressBar2.Value = 50;
                    progressBar2.Step  = cItemsForWriteToFile.testCaseList.Count;
                });

                // Выполнить запись в файл Word для выбранных элементов из clbTestCases
                foreach (int Index in cItemsForWriteToFile.checkedListBox.CheckedIndices)
                {
                    wordFileClass.CreateMultiLevelList(paragraph, listTemplate, cItemsForWriteToFile.testCaseList, Index);

                    progressBar2.Invoke((MethodInvoker) delegate
                    {
                        progressBar2.PerformStep();
                    });
                }
                paragraph.Range.SetListLevel(1);

                progressBar2.Invoke((MethodInvoker) delegate
                {
                    progressBar2.Value = 100;
                });

                // Показать результат записи в файл
                progressBar2.Invoke((MethodInvoker) delegate
                {
                    progressBar2.Hide();
                    application.Visible = true;
                });

                // Активировать кнопки в конце выполнения записи в файл
                btnWriteInFile.Invoke((MethodInvoker) delegate
                {
                    btnWriteInFile.Enabled = true;
                });
                btnWriteToFile_Queries.Invoke((MethodInvoker) delegate
                {
                    btnWriteToFile_Queries.Enabled = true;
                });
            }
            catch
            {
                // Показать результат записи в файл
                progressBar2.Invoke((MethodInvoker) delegate
                {
                    progressBar2.Value = 0;
                    progressBar2.Hide();
                    progressBar2.Hide();
                });

                // Активировать кнопки в конце выполнения записи в файл
                btnWriteInFile.Invoke((MethodInvoker) delegate
                {
                    btnWriteInFile.Enabled = true;
                });
                btnWriteToFile_Queries.Invoke((MethodInvoker) delegate
                {
                    btnWriteToFile_Queries.Enabled = true;
                });
            }
        }