diff --git a/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.Designer.cs b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.Designer.cs
new file mode 100644
index 0000000..6093466
--- /dev/null
+++ b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.Designer.cs
@@ -0,0 +1,36 @@
+namespace NevaevaLibrary.LogicalComponents
+{
+ partial class WordLongTextComponent
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Освободить все используемые ресурсы.
+ ///
+ /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Код, автоматически созданный конструктором компонентов
+
+ ///
+ /// Требуемый метод для поддержки конструктора — не изменяйте
+ /// содержимое этого метода с помощью редактора кода.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.cs b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.cs
new file mode 100644
index 0000000..eaaf8e5
--- /dev/null
+++ b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Reflection.Metadata;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Office.Interop.Word;
+using static System.Net.Mime.MediaTypeNames;
+
+namespace NevaevaLibrary.LogicalComponents
+{
+ public partial class WordLongTextComponent : Component
+ {
+ public WordLongTextComponent()
+ {
+ InitializeComponent();
+ }
+
+ public WordLongTextComponent(IContainer container)
+ {
+ container.Add(this);
+
+ InitializeComponent();
+ }
+
+ private object missing = System.Reflection.Missing.Value;
+
+ public void createWithLongText(WordLongTextInfo wordInfo)
+ {
+ var winword = new Microsoft.Office.Interop.Word.Application();
+ var document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing);
+ document.PageSetup.RightMargin = 50;
+ document.PageSetup.LeftMargin = 50;
+
+ var header = document.Content.Paragraphs.Add(Type.Missing);
+ header.Range.Text = wordInfo.header;
+ header.Format.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
+ header.Range.Font.Name = "Times New Roman";
+ header.Range.Font.Size = 22;
+ header.Range.Font.Bold = 2;
+ header.Format.SpaceAfter = 18;
+ header.Range.InsertParagraphAfter();
+
+ foreach (string text in wordInfo.paragraphs)
+ {
+ var paragraph = document.Content.Paragraphs.Add(Type.Missing);
+ paragraph.Range.Text = text;
+ paragraph.Format.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
+ paragraph.Range.Font.Name = "Times New Roman";
+ paragraph.Range.Font.Size = 14;
+ paragraph.Range.Font.Bold = 0;
+ paragraph.Format.SpaceAfter = 18;
+ paragraph.Range.InsertParagraphAfter();
+ }
+
+ document.SaveAs(wordInfo.path, Type.Missing, Type.Missing, Type.Missing,
+ Type.Missing, Type.Missing, Type.Missing, Type.Missing,
+ Type.Missing, Type.Missing, Type.Missing, Type.Missing,
+ Type.Missing, Type.Missing, Type.Missing, Type.Missing);
+ document.Close(ref missing, ref missing, ref missing);
+ document = null;
+ winword.Quit(ref missing, ref missing, ref missing);
+ }
+ }
+}
diff --git a/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextInfo.cs b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextInfo.cs
new file mode 100644
index 0000000..fc9bdfa
--- /dev/null
+++ b/NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextInfo.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace NevaevaLibrary.LogicalComponents
+{
+ public class WordLongTextInfo
+ {
+ public string path;
+ public string header;
+ public string[] paragraphs;
+
+ public WordLongTextInfo(string path, string header, string[] paragraphs)
+ {
+ this.path = path;
+ this.header = header;
+ this.paragraphs = paragraphs;
+ }
+ }
+}
diff --git a/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj b/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
index 060aa1c..3bfe1be 100644
--- a/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
+++ b/NevaevaLibrary/NevaevaLibrary/NevaevaLibrary.csproj
@@ -7,4 +7,25 @@
enable
+
+
+ tlbimp
+ 0
+ 12
+ 4ac9e1da-5bad-4ac7-86e3-24f4cdceca28
+ 0
+ false
+ true
+
+
+ tlbimp
+ 7
+ 8
+ 00020905-0000-0000-c000-000000000046
+ 0
+ false
+ true
+
+
+
diff --git a/NevaevaLibrary/TestApp/FormTest.Designer.cs b/NevaevaLibrary/TestApp/FormTest.Designer.cs
index 0b71350..3cad917 100644
--- a/NevaevaLibrary/TestApp/FormTest.Designer.cs
+++ b/NevaevaLibrary/TestApp/FormTest.Designer.cs
@@ -28,6 +28,7 @@
///
private void InitializeComponent()
{
+ this.components = new System.ComponentModel.Container();
this.comboBoxControl = new NevaevaLibrary.ComboBoxControl();
this.buttonInsert = new System.Windows.Forms.Button();
this.buttonClear = new System.Windows.Forms.Button();
@@ -38,6 +39,9 @@
this.listBoxControl = new NevaevaLibrary.ListBoxControl();
this.buttonInsertList = new System.Windows.Forms.Button();
this.buttonGetSelectedList = new System.Windows.Forms.Button();
+ this.buttonWordText = new System.Windows.Forms.Button();
+ this.wordLongTextComponent = new NevaevaLibrary.LogicalComponents.WordLongTextComponent(this.components);
+ this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.SuspendLayout();
//
// comboBoxControl
@@ -91,7 +95,7 @@
//
// mailControl
//
- this.mailControl.Email = "";
+ this.mailControl.Email = null;
this.mailControl.Location = new System.Drawing.Point(11, 95);
this.mailControl.Name = "mailControl";
this.mailControl.Size = new System.Drawing.Size(312, 94);
@@ -136,11 +140,26 @@
this.buttonGetSelectedList.UseVisualStyleBackColor = true;
this.buttonGetSelectedList.Click += new System.EventHandler(this.buttonGetSelectedList_Click);
//
+ // buttonWordText
+ //
+ this.buttonWordText.Location = new System.Drawing.Point(10, 319);
+ this.buttonWordText.Name = "buttonWordText";
+ this.buttonWordText.Size = new System.Drawing.Size(145, 29);
+ this.buttonWordText.TabIndex = 10;
+ this.buttonWordText.Text = "Word (текст)";
+ this.buttonWordText.UseVisualStyleBackColor = true;
+ this.buttonWordText.Click += new System.EventHandler(this.buttonWordText_Click);
+ //
+ // openFileDialog
+ //
+ this.openFileDialog.FileName = "openFileDialog1";
+ //
// FormTest
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1109, 316);
+ this.ClientSize = new System.Drawing.Size(1109, 363);
+ this.Controls.Add(this.buttonWordText);
this.Controls.Add(this.buttonGetSelectedList);
this.Controls.Add(this.buttonInsertList);
this.Controls.Add(this.listBoxControl);
@@ -169,5 +188,8 @@
private NevaevaLibrary.ListBoxControl listBoxControl;
private Button buttonInsertList;
private Button buttonGetSelectedList;
+ private Button buttonWordText;
+ private NevaevaLibrary.LogicalComponents.WordLongTextComponent wordLongTextComponent;
+ private OpenFileDialog openFileDialog;
}
}
\ No newline at end of file
diff --git a/NevaevaLibrary/TestApp/FormTest.cs b/NevaevaLibrary/TestApp/FormTest.cs
index d4dc2f9..46da115 100644
--- a/NevaevaLibrary/TestApp/FormTest.cs
+++ b/NevaevaLibrary/TestApp/FormTest.cs
@@ -1,4 +1,5 @@
-using System;
+using NevaevaLibrary.LogicalComponents;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -66,5 +67,15 @@ namespace TestApp
Worker? worker = listBoxControl.getSelectedItem();
if (worker is not null) MessageBox.Show(worker.ToString() + $"\n{worker.name}, {worker.department}, {worker.workYears}");
}
+
+ private void buttonWordText_Click(object sender, EventArgs e)
+ {
+ string[] paragraphs = { "test1", "Составлен в соответствии с учебным планом направления 09.03.04. Цель данного практикума – ориентировать студентов на содержание и порядок выполнения лабораторных задач во время прохождения ими курсов «Методы искусственного интеллекта» и «Машинное обучение». Даются задания на лабораторные работы. ",
+ "Работа подготовлена на кафедре «Информационные системы»." };
+ openFileDialog.Dispose();
+ string path = AppDomain.CurrentDomain.BaseDirectory + "test.docx";
+ wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Header", paragraphs));
+ MessageBox.Show("Готово!");
+ }
}
}
diff --git a/NevaevaLibrary/TestApp/FormTest.resx b/NevaevaLibrary/TestApp/FormTest.resx
index f298a7b..175a0fb 100644
--- a/NevaevaLibrary/TestApp/FormTest.resx
+++ b/NevaevaLibrary/TestApp/FormTest.resx
@@ -57,4 +57,10 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
+
+ 248, 17
+
\ No newline at end of file