Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4bcc573fbb | |||
| 96234cb606 | |||
| caca564260 |
14
WinForms/OrderBusinessLogic/OrderBusinessLogic.csproj
Normal file
14
WinForms/OrderBusinessLogic/OrderBusinessLogic.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OrdersContracts\OrdersContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
67
WinForms/OrderBusinessLogic/OrderLogic.cs
Normal file
67
WinForms/OrderBusinessLogic/OrderLogic.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using OrdersContracts.BindingModels;
|
||||
using OrdersContracts.BusinessLogicContracts;
|
||||
using OrdersContracts.StorageContracts;
|
||||
using OrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrderBusinessLogic
|
||||
{
|
||||
public class OrderLogic : IOrderLogic
|
||||
{
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(IOrderStorage orderStorage)
|
||||
{
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
public void CreateOrUpdate(OrderBindingModel model)
|
||||
{
|
||||
var element = _orderStorage.GetElement(
|
||||
new OrderBindingModel
|
||||
{
|
||||
Info = model.Info,
|
||||
Name = model.Name,
|
||||
Status = model.Status,
|
||||
Amount = model.Amount
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Такой заказ уже существует");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_orderStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_orderStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(OrderBindingModel model)
|
||||
{
|
||||
var element = _orderStorage.GetElement(new OrderBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Заказ не найден");
|
||||
}
|
||||
_orderStorage.Delete(model);
|
||||
}
|
||||
|
||||
public List<OrderViewModel> Read(OrderBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _orderStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<OrderViewModel> { _orderStorage.GetElement(model) };
|
||||
}
|
||||
return _orderStorage.GetFilteredList(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
WinForms/OrderBusinessLogic/StatusLogic.cs
Normal file
60
WinForms/OrderBusinessLogic/StatusLogic.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using OrdersContracts.BindingModels;
|
||||
using OrdersContracts.BusinessLogicContracts;
|
||||
using OrdersContracts.StorageContracts;
|
||||
using OrdersContracts.ViewModels;
|
||||
|
||||
namespace OrderBusinessLogic
|
||||
{
|
||||
public class StatusLogic : IStatusLogic
|
||||
{
|
||||
private readonly IStatusStorage _statusStorage;
|
||||
public StatusLogic(IStatusStorage statusStorage)
|
||||
{
|
||||
_statusStorage = statusStorage;
|
||||
}
|
||||
|
||||
public void CreateOrUpdate(StatusBindingModel model)
|
||||
{
|
||||
var element = _statusStorage.GetElement(
|
||||
new StatusBindingModel
|
||||
{
|
||||
Name = model.Name
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Такой статус уже существует");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_statusStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_statusStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(StatusBindingModel model)
|
||||
{
|
||||
var element = _statusStorage.GetElement(new StatusBindingModel { Id = model.Id });
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Статус не найден");
|
||||
}
|
||||
_statusStorage.Delete(model);
|
||||
}
|
||||
|
||||
public List<StatusViewModel> Read(StatusBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _statusStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<StatusViewModel> { _statusStorage.GetElement(model) };
|
||||
}
|
||||
return _statusStorage.GetFilteredList(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
WinForms/OrdersContracts/BindingModels/OrderBindingModel.cs
Normal file
17
WinForms/OrdersContracts/BindingModels/OrderBindingModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Info { get; set; }
|
||||
public string Status { get; set; }
|
||||
public int? Amount { get; set; }
|
||||
}
|
||||
}
|
||||
15
WinForms/OrdersContracts/BindingModels/StatusBindingModel.cs
Normal file
15
WinForms/OrdersContracts/BindingModels/StatusBindingModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.BindingModels
|
||||
{
|
||||
public class StatusBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using OrdersContracts.BindingModels;
|
||||
using OrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel> Read(OrderBindingModel model);
|
||||
void CreateOrUpdate(OrderBindingModel model);
|
||||
void Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using OrdersContracts.BindingModels;
|
||||
using OrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IStatusLogic
|
||||
{
|
||||
List<StatusViewModel> Read(StatusBindingModel model);
|
||||
void CreateOrUpdate(StatusBindingModel model);
|
||||
void Delete(StatusBindingModel model);
|
||||
}
|
||||
}
|
||||
10
WinForms/OrdersContracts/OrdersContracts.csproj
Normal file
10
WinForms/OrdersContracts/OrdersContracts.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
20
WinForms/OrdersContracts/StorageContracts/IOrderStorage.cs
Normal file
20
WinForms/OrdersContracts/StorageContracts/IOrderStorage.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using OrdersContracts.BindingModels;
|
||||
using OrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.StorageContracts
|
||||
{
|
||||
public interface IOrderStorage
|
||||
{
|
||||
List<OrderViewModel> GetFullList();
|
||||
List<OrderViewModel> GetFilteredList(OrderBindingModel model);
|
||||
OrderViewModel GetElement(OrderBindingModel model);
|
||||
void Insert(OrderBindingModel model);
|
||||
void Update(OrderBindingModel model);
|
||||
void Delete(OrderBindingModel model);
|
||||
}
|
||||
}
|
||||
21
WinForms/OrdersContracts/StorageContracts/IStatusStorage.cs
Normal file
21
WinForms/OrdersContracts/StorageContracts/IStatusStorage.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using OrdersContracts.BindingModels;
|
||||
using OrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.StorageContracts
|
||||
{
|
||||
public interface IStatusStorage
|
||||
{
|
||||
List<StatusViewModel> GetFullList();
|
||||
List<StatusViewModel> GetFilteredList(StatusBindingModel model);
|
||||
StatusViewModel GetElement(StatusBindingModel model);
|
||||
|
||||
void Insert(StatusBindingModel model);
|
||||
void Update(StatusBindingModel model);
|
||||
void Delete(StatusBindingModel model);
|
||||
}
|
||||
}
|
||||
24
WinForms/OrdersContracts/ViewModels/OrderViewModel.cs
Normal file
24
WinForms/OrdersContracts/ViewModels/OrderViewModel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[DisplayName("Описание")]
|
||||
public string Info { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
public string Status { get; set; }
|
||||
[DisplayName("Сумма заказа")]
|
||||
public string Amount { get; set; }
|
||||
}
|
||||
}
|
||||
14
WinForms/OrdersContracts/ViewModels/StatusViewModel.cs
Normal file
14
WinForms/OrdersContracts/ViewModels/StatusViewModel.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.ViewModels
|
||||
{
|
||||
public class StatusViewModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisualComponentsLib.Components.SupportClasses
|
||||
{
|
||||
public class BigTable<T>
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
public List<ColumnDefinition> ColumnDefinitions;
|
||||
public List<ColumnDefinition> ColumnDefinitions2;
|
||||
|
||||
public List<T> Data;
|
||||
|
||||
public List<int[]> MergedColumns;
|
||||
public BigTable(string filePath, string documentTitle, List<ColumnDefinition> columnDefinitions, List<ColumnDefinition> columnDefinitions2, List<T> data, List<int[]> mergedColumns)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
ColumnDefinitions = columnDefinitions;
|
||||
Data = data;
|
||||
MergedColumns = mergedColumns;
|
||||
ColumnDefinitions2 = columnDefinitions2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisualComponentsLib.Components.SupportClasses
|
||||
{
|
||||
public class ColumnDefinition
|
||||
{
|
||||
public string Header;
|
||||
public string PropertyName;
|
||||
public double Weight;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisualComponentsLib.Components.SupportClasses
|
||||
{
|
||||
public class DataLineChart
|
||||
{
|
||||
public string NameSeries { get; set; } = string.Empty;
|
||||
|
||||
public double[] Data { get; set; }
|
||||
|
||||
public DataLineChart(string nameSeries, double[] data)
|
||||
{
|
||||
NameSeries = nameSeries;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisualComponentsLib.Components.SupportClasses.Enums
|
||||
{
|
||||
public enum EnumAreaLegend
|
||||
{
|
||||
None,
|
||||
|
||||
Left,
|
||||
|
||||
Top,
|
||||
|
||||
Right,
|
||||
|
||||
Bottom,
|
||||
|
||||
TopRight
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VisualComponentsLib.Components.SupportClasses
|
||||
{
|
||||
public class LargeText
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
public string[] TextData;
|
||||
|
||||
public LargeText(string filePath, string documentTitle, string[] textData)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
TextData = textData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VisualComponentsLib.Components.SupportClasses.Enums;
|
||||
|
||||
namespace VisualComponentsLib.Components.SupportClasses
|
||||
{
|
||||
public class SimpleLineChart
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string FileHeader = string.Empty;
|
||||
|
||||
public string LineChartName = string.Empty;
|
||||
|
||||
public EnumAreaLegend AreaLegend;
|
||||
public string[] NameData { get; set; }
|
||||
|
||||
public List<DataLineChart> DataList = new();
|
||||
|
||||
public SimpleLineChart(string filePath, string fileHeader, string lineChartName, EnumAreaLegend areaLegend, List<DataLineChart> dataList)
|
||||
{
|
||||
FilePath = filePath;
|
||||
FileHeader = fileHeader;
|
||||
LineChartName = lineChartName;
|
||||
AreaLegend = areaLegend;
|
||||
DataList = dataList;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
WinForms/VisualComponentsLib/Components/WordLineChart.Designer.cs
generated
Normal file
36
WinForms/VisualComponentsLib/Components/WordLineChart.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
partial class WordLineChart
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
||||
84
WinForms/VisualComponentsLib/Components/WordLineChart.cs
Normal file
84
WinForms/VisualComponentsLib/Components/WordLineChart.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Drawing;
|
||||
using Aspose.Words.Drawing.Charts;
|
||||
using System.ComponentModel;
|
||||
using VisualComponentsLib.Components.SupportClasses;
|
||||
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
public partial class WordLineChart : Component
|
||||
{
|
||||
public WordLineChart()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordLineChart(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void AddLineChart(SimpleLineChart simpleLineChart)
|
||||
{
|
||||
if (!CheckData(simpleLineChart.DataList))
|
||||
{
|
||||
throw new Exception("Не данные заполнены");
|
||||
}
|
||||
Document doc = new Document();
|
||||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||||
|
||||
Aspose.Words.Font font = builder.Font;
|
||||
font.Size = 24;
|
||||
font.Bold = true;
|
||||
font.Color = Color.Black;
|
||||
font.Name = "Times New Roman";
|
||||
|
||||
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
|
||||
paragraphFormat.FirstLineIndent = 8;
|
||||
paragraphFormat.SpaceAfter = 24;
|
||||
paragraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
paragraphFormat.KeepTogether = true;
|
||||
|
||||
builder.Writeln(simpleLineChart.FileHeader);
|
||||
|
||||
Shape shape = builder.InsertChart(ChartType.Line, 500, 270);
|
||||
|
||||
Chart chart = shape.Chart;
|
||||
|
||||
chart.Title.Text = simpleLineChart.LineChartName;
|
||||
|
||||
ChartSeriesCollection seriesColl = chart.Series;
|
||||
|
||||
Console.WriteLine(seriesColl.Count);
|
||||
|
||||
seriesColl.Clear();
|
||||
|
||||
foreach (var data in simpleLineChart.DataList)
|
||||
{
|
||||
seriesColl.Add(data.NameSeries, simpleLineChart.NameData, data.Data);
|
||||
}
|
||||
|
||||
ChartLegend legend = chart.Legend;
|
||||
|
||||
legend.Position = (LegendPosition)simpleLineChart.AreaLegend;
|
||||
|
||||
legend.Overlay = true;
|
||||
|
||||
doc.Save(simpleLineChart.FilePath);
|
||||
}
|
||||
static bool CheckData(List<DataLineChart> data)
|
||||
{
|
||||
foreach (var _data in data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_data.NameSeries) || string.IsNullOrEmpty(_data.Data.ToString())) //аккуратно
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
WinForms/VisualComponentsLib/Components/WordTable.Designer.cs
generated
Normal file
36
WinForms/VisualComponentsLib/Components/WordTable.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
partial class WordTable
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
||||
128
WinForms/VisualComponentsLib/Components/WordTable.cs
Normal file
128
WinForms/VisualComponentsLib/Components/WordTable.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System.ComponentModel;
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Tables;
|
||||
using VisualComponentsLib.Components.SupportClasses;
|
||||
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
public partial class WordTable : Component
|
||||
{
|
||||
public WordTable()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordTable(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateTable<T>(BigTable<T> bigTable)
|
||||
{
|
||||
if (bigTable.Data == null)
|
||||
{
|
||||
throw new ArgumentException("Не заданы все данные");
|
||||
}
|
||||
|
||||
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||
{
|
||||
if (string.IsNullOrEmpty(columnDefinition.PropertyName))
|
||||
{
|
||||
throw new ArgumentException($"Не задано свойство столбца: {columnDefinition.Header}");
|
||||
}
|
||||
}
|
||||
|
||||
Document document = new Document();
|
||||
DocumentBuilder builder = new DocumentBuilder(document);
|
||||
|
||||
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
|
||||
titleStyle.Font.Size = 16;
|
||||
titleStyle.Font.Bold = true;
|
||||
|
||||
builder.ParagraphFormat.Style = titleStyle;
|
||||
builder.Writeln(bigTable.DocumentTitle);
|
||||
|
||||
Table table = builder.StartTable();
|
||||
|
||||
|
||||
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Weight);
|
||||
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
|
||||
builder.Write(columnDefinition.Header);
|
||||
}
|
||||
|
||||
foreach (var mergedColumn in bigTable.MergedColumns)
|
||||
{
|
||||
int startCellIndex = mergedColumn[0];
|
||||
int endCellIndex = mergedColumn[mergedColumn.Length - 1];
|
||||
|
||||
for (int i = startCellIndex; i <= endCellIndex; i++)
|
||||
{
|
||||
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.First;
|
||||
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
|
||||
}
|
||||
|
||||
for (int i = startCellIndex + 1; i <= endCellIndex; i++)
|
||||
{
|
||||
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous;
|
||||
table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
builder.EndRow();
|
||||
|
||||
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||
{
|
||||
builder.InsertCell();
|
||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition2.Weight);
|
||||
builder.Write(columnDefinition2.Header);
|
||||
}
|
||||
|
||||
builder.EndRow();
|
||||
|
||||
int columnIndex;
|
||||
foreach (var columnDefinition in bigTable.ColumnDefinitions)
|
||||
{
|
||||
string currentPropertyName = columnDefinition.PropertyName;
|
||||
columnIndex = 0;
|
||||
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||
{
|
||||
string currentPropertyName1 = columnDefinition2.PropertyName;
|
||||
|
||||
if (currentPropertyName == currentPropertyName1)
|
||||
{
|
||||
table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First;
|
||||
table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous;
|
||||
|
||||
}
|
||||
columnIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in bigTable.Data)
|
||||
{
|
||||
foreach (var columnDefinition2 in bigTable.ColumnDefinitions2)
|
||||
{
|
||||
builder.InsertCell();
|
||||
var propertyValue = item.GetType()
|
||||
.GetProperty(columnDefinition2.PropertyName)?
|
||||
.GetValue(item)?.ToString();
|
||||
|
||||
builder.Write(propertyValue ?? "");
|
||||
}
|
||||
|
||||
builder.EndRow();
|
||||
}
|
||||
|
||||
builder.EndTable();
|
||||
|
||||
document.Save(bigTable.FilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
WinForms/VisualComponentsLib/Components/WordText.Designer.cs
generated
Normal file
36
WinForms/VisualComponentsLib/Components/WordText.Designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
partial class WordText
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
||||
133
WinForms/VisualComponentsLib/Components/WordText.cs
Normal file
133
WinForms/VisualComponentsLib/Components/WordText.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml;
|
||||
using System.ComponentModel;
|
||||
using VisualComponentsLib.Components.SupportClasses;
|
||||
|
||||
namespace VisualComponentsLib.Components
|
||||
{
|
||||
public partial class WordText : Component
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
|
||||
private Body? _docBody;
|
||||
public WordText()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordText(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateWordText(LargeText largeText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(largeText.FilePath) || string.IsNullOrEmpty(largeText.DocumentTitle) || !CheckData(largeText.TextData))
|
||||
{
|
||||
throw new Exception("Не все данные заполнены");
|
||||
}
|
||||
_wordDocument = WordprocessingDocument.Create(largeText.FilePath, WordprocessingDocumentType.Document);
|
||||
|
||||
//вытаскиваем главную часть из вордовского документа
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
|
||||
mainPart.Document = new Document();
|
||||
|
||||
//генерируем тело основной части документа
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
|
||||
_wordDocument.Close();
|
||||
|
||||
AddText(largeText);
|
||||
}
|
||||
|
||||
private void AddText(LargeText largeText)
|
||||
{
|
||||
using (var document = WordprocessingDocument.Open(largeText.FilePath, true))
|
||||
{
|
||||
var doc = document.MainDocumentPart.Document;
|
||||
|
||||
#region Создание заголовка
|
||||
|
||||
ParagraphProperties paragraphProperties = new();
|
||||
|
||||
paragraphProperties.AppendChild(new Justification
|
||||
{
|
||||
Val = JustificationValues.Center
|
||||
});
|
||||
|
||||
paragraphProperties.AppendChild(new Indentation());
|
||||
|
||||
Paragraph header = new();
|
||||
|
||||
header.AppendChild(paragraphProperties);
|
||||
|
||||
var docRun = new Run();
|
||||
|
||||
var properties = new RunProperties();
|
||||
|
||||
properties.AppendChild(new FontSize
|
||||
{
|
||||
Val = "48"
|
||||
});
|
||||
|
||||
properties.AppendChild(new Bold());
|
||||
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text(largeText.DocumentTitle));
|
||||
|
||||
header.AppendChild(docRun);
|
||||
doc.Body.Append(header);
|
||||
#endregion
|
||||
|
||||
#region Создание текста
|
||||
for (int i = 0; i < largeText.TextData.Length; i++)
|
||||
{
|
||||
ParagraphProperties paragraphProperties2 = new();
|
||||
|
||||
paragraphProperties2.AppendChild(new Justification
|
||||
{
|
||||
Val = JustificationValues.Both
|
||||
});
|
||||
|
||||
paragraphProperties2.AppendChild(new Indentation());
|
||||
|
||||
Paragraph text = new();
|
||||
|
||||
text.AppendChild(paragraphProperties2);
|
||||
|
||||
var docRun2 = new Run();
|
||||
|
||||
var properties2 = new RunProperties();
|
||||
|
||||
properties2.AppendChild(new FontSize
|
||||
{
|
||||
Val = "24"
|
||||
});
|
||||
|
||||
docRun2.AppendChild(properties2);
|
||||
docRun2.AppendChild(new Text(largeText.TextData[i]));
|
||||
|
||||
text.AppendChild(docRun2);
|
||||
doc.Body.Append(text);
|
||||
}
|
||||
#endregion
|
||||
doc.Save();
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckData(string[] data)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(data[i])) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
WinForms/VisualComponentsLib/IStatusStorage.cs
Normal file
21
WinForms/VisualComponentsLib/IStatusStorage.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using OrdersContracts.BindingModels;
|
||||
using OrdersContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrdersContracts.StorageContracts
|
||||
{
|
||||
public interface IStatusStorage
|
||||
{
|
||||
List<StatusViewModel> GetFullList();
|
||||
List<StatusViewModel> GetFilteredList(StatusBindingModel model);
|
||||
StatusViewModel GetElement(StatusBindingModel model);
|
||||
|
||||
void Insert(StatusBindingModel model);
|
||||
void Update(StatusBindingModel model);
|
||||
void Delete(StatusBindingModel model);
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,10 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="23.10.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="FreeSpire.Doc" Version="11.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,7 +5,11 @@ VisualStudioVersion = 17.3.32901.215
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForms", "WinForms\WinForms.csproj", "{10D1B0BE-6B52-41E6-8B57-4AFC49A26F17}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponentsLib", "VisualComponentsLib\VisualComponentsLib.csproj", "{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsLib", "VisualComponentsLib\VisualComponentsLib.csproj", "{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrdersContracts", "OrdersContracts\OrdersContracts.csproj", "{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrderBusinessLogic", "OrderBusinessLogic\OrderBusinessLogic.csproj", "{071BD445-8513-4B12-A60C-2531F2B795F5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -21,6 +25,14 @@ Global
|
||||
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EF8D5392-CB3C-429E-BB8F-A7353F56E1D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{82FC5A5D-EA93-49E2-BC93-8AE514148FA0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{071BD445-8513-4B12-A60C-2531F2B795F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{071BD445-8513-4B12-A60C-2531F2B795F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{071BD445-8513-4B12-A60C-2531F2B795F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{071BD445-8513-4B12-A60C-2531F2B795F5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
135
WinForms/WinForms/FormWord.Designer.cs
generated
Normal file
135
WinForms/WinForms/FormWord.Designer.cs
generated
Normal file
@@ -0,0 +1,135 @@
|
||||
namespace WinForms
|
||||
{
|
||||
partial class FormWord
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.wordText = new VisualComponentsLib.Components.WordText(this.components);
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.wordLineChart = new VisualComponentsLib.Components.WordLineChart(this.components);
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.wordTable = new VisualComponentsLib.Components.WordTable(this.components);
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.button1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(136, 80);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Большой текст";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(6, 45);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(124, 29);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "Создать";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.button3);
|
||||
this.groupBox3.Location = new System.Drawing.Point(331, 12);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(141, 80);
|
||||
this.groupBox3.TabIndex = 1;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Линейная диаграмма";
|
||||
//
|
||||
// button3
|
||||
//
|
||||
this.button3.Location = new System.Drawing.Point(6, 45);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(127, 29);
|
||||
this.button3.TabIndex = 0;
|
||||
this.button3.Text = "Создать";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
this.button3.Click += new System.EventHandler(this.button3_Click);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.button2);
|
||||
this.groupBox2.Location = new System.Drawing.Point(171, 12);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(142, 80);
|
||||
this.groupBox2.TabIndex = 1;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Таблица";
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(6, 45);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(130, 29);
|
||||
this.button2.TabIndex = 0;
|
||||
this.button2.Text = "Создать";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// FormWord
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(493, 108);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Name = "FormWord";
|
||||
this.Text = "Невизуальные компоненты";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private VisualComponentsLib.Components.WordText wordText;
|
||||
private GroupBox groupBox1;
|
||||
private Button button1;
|
||||
private VisualComponentsLib.Components.WordLineChart wordLineChart;
|
||||
private GroupBox groupBox3;
|
||||
private Button button3;
|
||||
private GroupBox groupBox2;
|
||||
private Button button2;
|
||||
private VisualComponentsLib.Components.WordTable wordTable;
|
||||
}
|
||||
}
|
||||
132
WinForms/WinForms/FormWord.cs
Normal file
132
WinForms/WinForms/FormWord.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using VisualComponentsLib.Components.SupportClasses.Enums;
|
||||
using VisualComponentsLib.Components.SupportClasses;
|
||||
using VisualComponentsLib.Object;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
public partial class FormWord : Form
|
||||
{
|
||||
string[] testArray = { "Вселенная оценивается в возрасте около 13,8 миллиарда лет.", "Пчелы могут видеть ультрафиолетовый свет, что помогает им находить нектар.", "Гепард - самое быстрое наземное животное, способное развивать скорость до 100 километров в час.", "Всего 12 человек посетили Луну, и ни один человек не был там с 1972 года.", "Крокодилы существуют на Земле более 200 миллионов лет и остаются одними из самых древних видов" };
|
||||
public FormWord()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
//фильтрация файлов для диалогового окна
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
LargeText largeText = new(dialog.FileName, "Немножечко фактов.", testArray);
|
||||
wordText.CreateWordText(largeText);
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<int[]> mergedColumns = new()
|
||||
{
|
||||
new int[] { 0, 1, 2 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
List<ColumnDefinition> columnDefinitions = new List<ColumnDefinition>
|
||||
{
|
||||
new ColumnDefinition { Header = "Образование", PropertyName = "Eduction", Weight = 35 },
|
||||
new ColumnDefinition { Header = "", PropertyName = "Education1", Weight = 35 },
|
||||
new ColumnDefinition { Header = "", PropertyName = "Education2", Weight = 10 },
|
||||
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
|
||||
};
|
||||
|
||||
List<ColumnDefinition> columnDefinitions2 = new List<ColumnDefinition>
|
||||
{
|
||||
new ColumnDefinition { Header = "Группа", PropertyName = "Group", Weight = 35 },
|
||||
new ColumnDefinition { Header = "Факультатив", PropertyName = "Faculty", Weight = 35 },
|
||||
new ColumnDefinition { Header = "Курс", PropertyName = "Course", Weight = 10 },
|
||||
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
|
||||
};
|
||||
|
||||
List<Student> data = new List<Student>
|
||||
{
|
||||
new Student { Group = "ПИбд-32", Faculty = "ФИСТ", Course = 3, Name = "Багиров" },
|
||||
new Student { Group = "РТбд-11", Faculty = "РТФ", Course = 1, Name = "Ласков" },
|
||||
new Student { Group = "ЛМККбд-41", Faculty = "ГФ", Course = 4, Name = "Тейпова" }
|
||||
};
|
||||
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
BigTable<Student> bigTable = new(dialog.FileName, "Задание 2", columnDefinitions, columnDefinitions2, data, mergedColumns);
|
||||
wordTable.CreateTable(bigTable);
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
//фильтрация файлов для диалогового окна
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "docx|*.docx"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
double[] profit1 = { 300, 440, 270 };
|
||||
double[] profit2 = { 500, 620, 310 };
|
||||
double[] profit3 = { 420, 189, 430 };
|
||||
SimpleLineChart lineChart = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List<DataLineChart> {
|
||||
new DataLineChart("Компания 1", profit1),
|
||||
new DataLineChart("Компания 2", profit2),
|
||||
new DataLineChart("Компания 3", profit3),
|
||||
});
|
||||
|
||||
lineChart.NameData = new string[] { "Январь", "Февраль", "Март" };
|
||||
|
||||
wordLineChart.AddLineChart(lineChart);
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
WinForms/WinForms/FormWord.resx
Normal file
69
WinForms/WinForms/FormWord.resx
Normal file
@@ -0,0 +1,69 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="wordText.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordLineChart.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>133, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>285, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -11,7 +11,7 @@ namespace WinForms
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormForComponents());
|
||||
Application.Run(new FormWord());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user