Compare commits
3 Commits
fa6498b47d
...
64766eabc4
Author | SHA1 | Date | |
---|---|---|---|
|
64766eabc4 | ||
|
973a9d37d2 | ||
|
502eb76c23 |
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
public enum DiagramLegendEnum
|
||||
{
|
||||
TopLeft = 0,
|
||||
TopRight = 1,
|
||||
BottomRight = 2,
|
||||
BottomLeft = 3,
|
||||
}
|
||||
}
|
36
NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordDiagramComponent.Designer.cs
generated
Normal file
36
NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordDiagramComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
partial class WordDiagramComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
public partial class WordDiagramComponent : Component
|
||||
{
|
||||
public WordDiagramComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordDiagramComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private object missing = System.Reflection.Missing.Value;
|
||||
|
||||
private string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
string columnName = "";
|
||||
|
||||
while (columnNumber > 0)
|
||||
{
|
||||
int modulo = (columnNumber - 1) % 26;
|
||||
columnName = Convert.ToChar('A' + modulo) + columnName;
|
||||
columnNumber = (columnNumber - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void createWithDiagram<T>(string path, string title, string diagramTitle, DiagramLegendEnum diagramLegendAnchor, List<T> data, string seriesNameField, string valueField)
|
||||
{
|
||||
var excelApp = new Microsoft.Office.Interop.Excel.Application { SheetsInNewWorkbook = 1 };
|
||||
Workbook workbook = excelApp.Workbooks.Add(Type.Missing);
|
||||
Worksheet worksheet = (Worksheet)workbook.Worksheets.get_Item(1);
|
||||
|
||||
FieldInfo? seriesName = typeof(T).GetField(seriesNameField);
|
||||
FieldInfo? value = typeof(T).GetField(valueField);
|
||||
if (seriesName == null || value == null) throw new ArgumentException("Переданного поля не существует");
|
||||
int offsetX = 1;
|
||||
int offsetYMax = -1;
|
||||
foreach (var item in data)
|
||||
{
|
||||
string columnChar = GetExcelColumnName(offsetX);
|
||||
var cell = worksheet.get_Range(columnChar + "2", columnChar + "2");
|
||||
cell.Font.Size = 14;
|
||||
cell.Font.Name = "Times New Roman";
|
||||
cell.ColumnWidth = 8;
|
||||
cell.RowHeight = 25;
|
||||
cell.HorizontalAlignment = Constants.xlCenter;
|
||||
cell.VerticalAlignment = Constants.xlCenter;
|
||||
cell.Value2 = seriesName.GetValue(item);
|
||||
|
||||
int offsetY = 3;
|
||||
|
||||
foreach (var val in (value.GetValue(item) as IEnumerable))
|
||||
{
|
||||
cell = worksheet.get_Range(columnChar + offsetY, columnChar + offsetY);
|
||||
cell.Value2 = val;
|
||||
|
||||
offsetY++;
|
||||
}
|
||||
if (offsetY > offsetYMax) offsetYMax = offsetY;
|
||||
|
||||
offsetX++;
|
||||
}
|
||||
|
||||
var charts = worksheet.ChartObjects() as ChartObjects;
|
||||
int chartWidth = 300;
|
||||
int chartHeight = 300;
|
||||
var chartObject = charts.Add(250, 10, chartWidth, chartHeight);
|
||||
var chart = chartObject.Chart;
|
||||
var endColumn = GetExcelColumnName(offsetX - 1);
|
||||
var range = worksheet.get_Range($"A2", endColumn + (offsetYMax - 1));
|
||||
chart.SetSourceData(range);
|
||||
chart.ChartType = XlChartType.xlLine;
|
||||
switch (diagramLegendAnchor)
|
||||
{
|
||||
case DiagramLegendEnum.TopLeft:
|
||||
chart.Legend.Top = 0;
|
||||
chart.Legend.Left = 0;
|
||||
break;
|
||||
case DiagramLegendEnum.TopRight:
|
||||
chart.Legend.Top = 0;
|
||||
chart.Legend.Left = chartWidth - chart.Legend.Width;
|
||||
break;
|
||||
case DiagramLegendEnum.BottomLeft:
|
||||
chart.Legend.Top = chartHeight - chart.Legend.Height;
|
||||
chart.Legend.Left = 0;
|
||||
break;
|
||||
case DiagramLegendEnum.BottomRight:
|
||||
chart.Legend.Top = chartHeight - chart.Legend.Height;
|
||||
chart.Legend.Left = chartWidth - chart.Legend.Width;
|
||||
break;
|
||||
}
|
||||
chart.ChartWizard(Source: range, Title: diagramTitle);
|
||||
|
||||
chart.Export(path.Substring(0, path.Length - 5) + ".jpg", "JPG", false);
|
||||
|
||||
workbook.Close(SaveChanges: false);
|
||||
excelApp.Quit();
|
||||
|
||||
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 = title;
|
||||
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();
|
||||
|
||||
document.Shapes.AddPicture(path.Substring(0, path.Length - 5) + ".jpg", Top: 200);
|
||||
|
||||
document.SaveAs(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);
|
||||
}
|
||||
}
|
||||
}
|
36
NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.Designer.cs
generated
Normal file
36
NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordLongTextComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
partial class WordLongTextComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
36
NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordTableComponent.Designer.cs
generated
Normal file
36
NevaevaLibrary/NevaevaLibrary/LogicalComponents/WordTableComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
partial class WordTableComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NevaevaLibrary.LogicalComponents
|
||||
{
|
||||
public partial class WordTableComponent : Component
|
||||
{
|
||||
public WordTableComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordTableComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private object missing = System.Reflection.Missing.Value;
|
||||
|
||||
public void createWithTable<T>(string path, string title, List<(int, int)> merges, List<int> widths, List<(string, string)> headers, List<T> items)
|
||||
{
|
||||
if (merges.Count == 0 || widths.Count == 0 || headers.Count == 0 || items.Count == 0) throw new ArgumentException("Недостаточно данных");
|
||||
int[] cellsArray = new int[widths.Count];
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
if (merge.Item1 >= merge.Item2) throw new ArgumentException("Неправильно заполнены объединения строк");
|
||||
for (int i = merge.Item1; i < merge.Item2 + 1; i++)
|
||||
{
|
||||
cellsArray[i]++;
|
||||
}
|
||||
}
|
||||
foreach (int cell in cellsArray)
|
||||
{
|
||||
if (cell > 1) throw new ArgumentException("Объединения заходят друг на друга");
|
||||
}
|
||||
|
||||
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;
|
||||
document.PageSetup.Orientation = WdOrientation.wdOrientLandscape;
|
||||
|
||||
var header = document.Content.Paragraphs.Add(Type.Missing);
|
||||
header.Range.Text = title;
|
||||
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();
|
||||
|
||||
var table = document.Tables.Add(document.Bookmarks.get_Item("\\endofdoc").Range,
|
||||
items.Count + 2, widths.Count, Type.Missing, Type.Missing);
|
||||
table.Borders.Enable = 1;
|
||||
|
||||
for (int i = 0; i < widths.Count; i++)
|
||||
{
|
||||
table.Cell(1, i + 1).Width = widths[i];
|
||||
table.Cell(1, i + 1).Height = 20;
|
||||
table.Cell(2, i + 1).Width = widths[i];
|
||||
table.Cell(2, i + 1).Height = 20;
|
||||
}
|
||||
|
||||
//checks
|
||||
List<Cell> ranges = new List<Cell>();
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
ranges.Add(table.Rows[1].Cells[merge.Item1 + 1]);
|
||||
}
|
||||
|
||||
//number of merged cell
|
||||
int rangeIndex = 0;
|
||||
//number of cell
|
||||
int headerIndex = 0;
|
||||
List<FieldInfo> cellFields = new List<FieldInfo>();
|
||||
var type = typeof(T);
|
||||
for (int i = 0; i < widths.Count; i++)
|
||||
{
|
||||
if (cellsArray[i] == 1)
|
||||
{
|
||||
//work with merge
|
||||
if (!string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
|
||||
var headerCell = ranges[rangeIndex];
|
||||
headerCell.Range.Text = headers[headerIndex].Item2;
|
||||
headerCell.Range.Font.Size = 11;
|
||||
headerIndex++;
|
||||
|
||||
//work with cells in merge
|
||||
for (; i <= merges[rangeIndex].Item2; i++)
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var cell = table.Cell(2, i + 1);
|
||||
cell.Range.Text = headers[headerIndex].Item2;
|
||||
cell.Width = widths[i];
|
||||
cell.Range.Font.Size = 11;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
i--;
|
||||
rangeIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//work with cell
|
||||
if (string.IsNullOrEmpty(headers[headerIndex].Item1)) throw new ArgumentException("Заголовки и объединения строк не совпадают");
|
||||
var field = type.GetField(headers[headerIndex].Item1);
|
||||
if (field == null) throw new ArgumentException("В заголовках указано поле, которого нет в переданном классе");
|
||||
//format header
|
||||
var cell = table.Cell(1, i + 1);
|
||||
|
||||
cell.Merge(table.Cell(2, i + 1));
|
||||
cell.Range.Text = headers[headerIndex].Item2;
|
||||
cell.Width = widths[i];
|
||||
cell.Range.Font.Size = 11;
|
||||
|
||||
cellFields.Add(field);
|
||||
headerIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
int xOffset = 0;
|
||||
foreach (var merge in merges)
|
||||
{
|
||||
table.Cell(1, merge.Item1 + 1 - xOffset).Merge(table.Cell(1, merge.Item2 + 1 - xOffset));
|
||||
xOffset += merge.Item2 - merge.Item1;
|
||||
}
|
||||
|
||||
int rowNum = 3;
|
||||
foreach (T item in items)
|
||||
{
|
||||
int columnNum = 1;
|
||||
foreach (var cellField in cellFields)
|
||||
{
|
||||
var cell = table.Cell(rowNum, columnNum);
|
||||
cell.Range.Text = cellField.GetValue(item)?.ToString();
|
||||
cell.Width = widths[columnNum - 1];
|
||||
cell.Range.Bold = 0;
|
||||
cell.Range.Font.Size = 11;
|
||||
cell.Height = 20;
|
||||
|
||||
columnNum++;
|
||||
}
|
||||
rowNum++;
|
||||
}
|
||||
|
||||
document.SaveAs(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);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,4 +7,34 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<COMReference Include="Microsoft.Office.Interop.Access.Dao">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>0</VersionMinor>
|
||||
<VersionMajor>12</VersionMajor>
|
||||
<Guid>4ac9e1da-5bad-4ac7-86e3-24f4cdceca28</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
<COMReference Include="Microsoft.Office.Interop.Word">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>7</VersionMinor>
|
||||
<VersionMajor>8</VersionMajor>
|
||||
<Guid>00020905-0000-0000-c000-000000000046</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
<COMReference Include="Microsoft.Office.Interop.Excel">
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<VersionMinor>9</VersionMinor>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<Guid>00020813-0000-0000-c000-000000000046</Guid>
|
||||
<Lcid>0</Lcid>
|
||||
<Isolated>false</Isolated>
|
||||
<EmbedInteropTypes>true</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
20
NevaevaLibrary/TestApp/Department.cs
Normal file
20
NevaevaLibrary/TestApp/Department.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestApp
|
||||
{
|
||||
public class Department
|
||||
{
|
||||
public string name;
|
||||
public List<int> sells;
|
||||
|
||||
public Department(string name, List<int> sells)
|
||||
{
|
||||
this.name = name;
|
||||
this.sells = sells;
|
||||
}
|
||||
}
|
||||
}
|
56
NevaevaLibrary/TestApp/FormTest.Designer.cs
generated
56
NevaevaLibrary/TestApp/FormTest.Designer.cs
generated
@ -28,6 +28,7 @@
|
||||
/// </summary>
|
||||
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,13 @@
|
||||
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.buttonTable = new System.Windows.Forms.Button();
|
||||
this.wordTableComponent = new NevaevaLibrary.LogicalComponents.WordTableComponent(this.components);
|
||||
this.wordDiagramComponent = new NevaevaLibrary.LogicalComponents.WordDiagramComponent(this.components);
|
||||
this.buttonDiagram = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comboBoxControl
|
||||
@ -91,7 +99,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 +144,48 @@
|
||||
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";
|
||||
//
|
||||
// buttonTable
|
||||
//
|
||||
this.buttonTable.Location = new System.Drawing.Point(178, 319);
|
||||
this.buttonTable.Name = "buttonTable";
|
||||
this.buttonTable.Size = new System.Drawing.Size(145, 29);
|
||||
this.buttonTable.TabIndex = 11;
|
||||
this.buttonTable.Text = "Word (таблица)";
|
||||
this.buttonTable.UseVisualStyleBackColor = true;
|
||||
this.buttonTable.Click += new System.EventHandler(this.buttonTable_Click);
|
||||
//
|
||||
// buttonDiagram
|
||||
//
|
||||
this.buttonDiagram.Location = new System.Drawing.Point(345, 319);
|
||||
this.buttonDiagram.Name = "buttonDiagram";
|
||||
this.buttonDiagram.Size = new System.Drawing.Size(145, 29);
|
||||
this.buttonDiagram.TabIndex = 12;
|
||||
this.buttonDiagram.Text = "Word (диаграмма)";
|
||||
this.buttonDiagram.UseVisualStyleBackColor = true;
|
||||
this.buttonDiagram.Click += new System.EventHandler(this.buttonDiagram_Click);
|
||||
//
|
||||
// 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.buttonDiagram);
|
||||
this.Controls.Add(this.buttonTable);
|
||||
this.Controls.Add(this.buttonWordText);
|
||||
this.Controls.Add(this.buttonGetSelectedList);
|
||||
this.Controls.Add(this.buttonInsertList);
|
||||
this.Controls.Add(this.listBoxControl);
|
||||
@ -169,5 +214,12 @@
|
||||
private NevaevaLibrary.ListBoxControl listBoxControl;
|
||||
private Button buttonInsertList;
|
||||
private Button buttonGetSelectedList;
|
||||
private Button buttonWordText;
|
||||
private NevaevaLibrary.LogicalComponents.WordLongTextComponent wordLongTextComponent;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Button buttonTable;
|
||||
private NevaevaLibrary.LogicalComponents.WordTableComponent wordTableComponent;
|
||||
private NevaevaLibrary.LogicalComponents.WordDiagramComponent wordDiagramComponent;
|
||||
private Button buttonDiagram;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NevaevaLibrary.LogicalComponents;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@ -66,5 +67,50 @@ namespace TestApp
|
||||
Worker? worker = listBoxControl.getSelectedItem<Worker>();
|
||||
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("Готово!");
|
||||
}
|
||||
|
||||
private void buttonTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<OfficeWorker> workers = new List<OfficeWorker>();
|
||||
|
||||
workers.Add(new OfficeWorker(1, "Иванов", "Иван", 20, "Отдел продаж", "Бухгалтер", 25, "+7(834)234-03-49"));
|
||||
workers.Add(new OfficeWorker(2, "Петров", "Петр", 25, "Отдел продаж", "Менеджер", 20, "+7(834)123-03-49"));
|
||||
workers.Add(new OfficeWorker(3, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true));
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + "test2.docx";
|
||||
List<(int, int)> merges = new List<(int, int)>();
|
||||
merges.Add((1, 3));
|
||||
merges.Add((4, 6));
|
||||
List<int> widths = Enumerable.Repeat(70, 8).ToList();
|
||||
|
||||
List<(string, string)> headers = new List<(string, string)> { ("id", "id"), ("", "Личные данные"),
|
||||
("lastName", "Фамилия"), ("firstName", "Имя"),
|
||||
("age", "Возраст"), ("", "Работа"),
|
||||
("department", "Отдел"), ("position", "Должность"),
|
||||
("boxNumber", "Номер бокса"), ("phoneNumber", "Телефон")};
|
||||
|
||||
wordTableComponent.createWithTable(path, "header", merges, widths, headers, workers);
|
||||
MessageBox.Show("Готово!");
|
||||
}
|
||||
|
||||
private void buttonDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<Department> departments = new List<Department>();
|
||||
|
||||
departments.Add(new Department("Dep 1", new List<int> { 330, 220, 400, 500 }));
|
||||
departments.Add(new Department("Dep 2", new List<int> { 400, 300, 302 }));
|
||||
departments.Add(new Department("Dep 3", new List<int> { 200, 220, 270 }));
|
||||
string path = AppDomain.CurrentDomain.BaseDirectory + "test3.docx";
|
||||
wordDiagramComponent.createWithDiagram(path, "test3", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells");
|
||||
MessageBox.Show("Готово!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,4 +57,16 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="wordLongTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>248, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordTableComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>407, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordDiagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>612, 17</value>
|
||||
</metadata>
|
||||
</root>
|
34
NevaevaLibrary/TestApp/OfficeWorker.cs
Normal file
34
NevaevaLibrary/TestApp/OfficeWorker.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestApp
|
||||
{
|
||||
public class OfficeWorker
|
||||
{
|
||||
public OfficeWorker(int id, string lastName, string firstName, int age, string department, string position, int boxNumber, string phoneNumber, bool isInVacation = false)
|
||||
{
|
||||
this.id = id;
|
||||
this.lastName = lastName;
|
||||
this.firstName = firstName;
|
||||
this.age = age;
|
||||
this.department = department;
|
||||
this.position = position;
|
||||
this.boxNumber = boxNumber;
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.isInVacation = isInVacation;
|
||||
}
|
||||
|
||||
public int id;
|
||||
public string lastName;
|
||||
public string firstName;
|
||||
public int age;
|
||||
public string department;
|
||||
public string position;
|
||||
public int boxNumber;
|
||||
public string phoneNumber;
|
||||
public bool isInVacation;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user