LabWork02 WiP
This commit is contained in:
parent
1d7d23e749
commit
ee5ec2e1a5
@ -7,4 +7,9 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Excel-DNA.Interop" Version="15.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Office.Excel" Version="14.0.4760.1000" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
36
Components/Components/NonVisualComponents/BigTextComponent.Designer.cs
generated
Normal file
36
Components/Components/NonVisualComponents/BigTextComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace Components.NonVisualComponents
|
||||||
|
{
|
||||||
|
partial class BigTextComponent
|
||||||
|
{
|
||||||
|
/// <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,81 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Excel = Microsoft.Office.Interop.Excel;
|
||||||
|
|
||||||
|
namespace Components.NonVisualComponents
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Не визуальный компонент для создания документа Excel с большим текстом
|
||||||
|
/// </summary>
|
||||||
|
public partial class BigTextComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public BigTextComponent()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="container"></param>
|
||||||
|
public BigTextComponent(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать документ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <param name="title"></param>
|
||||||
|
/// <param name="rows"></param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
public void CreateDocument(string filepath, string title, string[] rows)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(filepath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не указан путь к файлу!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не указан заголовок документа!");
|
||||||
|
}
|
||||||
|
if (rows == null || rows.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Массив с текстом не заполнен!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Excel.Application excelApp = new Excel.Application();
|
||||||
|
Excel.Workbook workbook = excelApp.Workbooks.Add();
|
||||||
|
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Sheets[1];
|
||||||
|
|
||||||
|
worksheet.Cells[1, 1] = title;
|
||||||
|
for (int index = 0; index < rows.Length; index++)
|
||||||
|
{
|
||||||
|
worksheet.Cells[index + 3, 1] = rows[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(filepath))
|
||||||
|
{
|
||||||
|
File.Delete(filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
excelApp.Application.ActiveWorkbook.SaveAs(filepath);
|
||||||
|
workbook.Close(true);
|
||||||
|
excelApp.Quit();
|
||||||
|
|
||||||
|
Marshal.ReleaseComObject(excelApp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
Components/Components/NonVisualComponents/DiagramComponent.Designer.cs
generated
Normal file
36
Components/Components/NonVisualComponents/DiagramComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace Components.NonVisualComponents
|
||||||
|
{
|
||||||
|
partial class DiagramComponent
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
140
Components/Components/NonVisualComponents/DiagramComponent.cs
Normal file
140
Components/Components/NonVisualComponents/DiagramComponent.cs
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
using Components.NonVisualComponents.HelperModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Excel = Microsoft.Office.Interop.Excel;
|
||||||
|
|
||||||
|
namespace Components.NonVisualComponents
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Не визуальный компонент для создания документа Excel с линейной диаграммой
|
||||||
|
/// </summary>
|
||||||
|
public partial class DiagramComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public DiagramComponent()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="container"></param>
|
||||||
|
public DiagramComponent(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать документ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config"></param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
public void CreateDocument(LineChartConfig config)
|
||||||
|
{
|
||||||
|
if (config == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не задана конфигурация для построения линйеной диаграммы!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(config.Filepath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не указан путь к файлу!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(config.Header))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не указан заголовок документа!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(config.ChartTitle))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не указано название диаграммы!");
|
||||||
|
}
|
||||||
|
if (config.Values == null || config.Values.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не заданы значения для отображения на диаграмме!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Excel.Application excelApp = new Excel.Application();
|
||||||
|
Excel.Workbook workbook = excelApp.Workbooks.Add();
|
||||||
|
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Sheets[1];
|
||||||
|
|
||||||
|
worksheet.Cells[1, 1] = config.Header;
|
||||||
|
|
||||||
|
// Создание диаграммы
|
||||||
|
Excel.ChartObjects chartObjs = (Excel.ChartObjects)worksheet.ChartObjects();
|
||||||
|
Excel.ChartObject chartObj = chartObjs.Add(5, 50, 300, 300);
|
||||||
|
Excel.Chart excelChart = chartObj.Chart;
|
||||||
|
excelChart.ChartType = Excel.XlChartType.xlLine;
|
||||||
|
|
||||||
|
// Запись данных
|
||||||
|
Excel.Range[] valuesRange = new Excel.Range[config.Values.Count];
|
||||||
|
int leftTopI = 2, leftTopJ = 1;
|
||||||
|
for (int i = 0; i < config.Values.Count; i++)
|
||||||
|
{
|
||||||
|
string key = config.Values.Keys.ToList()[i];
|
||||||
|
for (int j = 0; j < config.Values[key].Count; j++)
|
||||||
|
{
|
||||||
|
worksheet.Cells[leftTopI + i, leftTopJ + j] = config.Values[key][j];
|
||||||
|
}
|
||||||
|
|
||||||
|
valuesRange[i] = worksheet.Range
|
||||||
|
[worksheet.Cells[leftTopI + i, leftTopJ],
|
||||||
|
worksheet.Cells[leftTopI + i, leftTopJ + config.Values[key].Count - 1]];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Задание данных
|
||||||
|
Excel.SeriesCollection seriesCollection = (Excel.SeriesCollection)excelChart.SeriesCollection();
|
||||||
|
for (int i = 0; i < config.Values.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
Excel.Series series = seriesCollection.NewSeries();
|
||||||
|
series.Name = config.Values.Keys.ToList()[i];
|
||||||
|
series.Values = valuesRange[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Задание заголовка
|
||||||
|
excelChart.HasTitle = true;
|
||||||
|
excelChart.ChartTitle.Text = config.ChartTitle;
|
||||||
|
|
||||||
|
// Задание легенды
|
||||||
|
excelChart.HasLegend = true;
|
||||||
|
switch (config.LegendPosition)
|
||||||
|
{
|
||||||
|
case LegendPosition.Top:
|
||||||
|
excelChart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionTop;
|
||||||
|
break;
|
||||||
|
case LegendPosition.Right:
|
||||||
|
excelChart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionRight;
|
||||||
|
break;
|
||||||
|
case LegendPosition.Bottom:
|
||||||
|
excelChart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom;
|
||||||
|
break;
|
||||||
|
case LegendPosition.Left:
|
||||||
|
excelChart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionLeft;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
excelChart.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(config.Filepath))
|
||||||
|
{
|
||||||
|
File.Delete(config.Filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
excelApp.Application.ActiveWorkbook.SaveAs(config.Filepath);
|
||||||
|
workbook.Close(true);
|
||||||
|
excelApp.Quit();
|
||||||
|
|
||||||
|
Marshal.ReleaseComObject(excelApp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.NonVisualComponents.HelperModels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Положение легенды на графике
|
||||||
|
/// </summary>
|
||||||
|
public enum LegendPosition
|
||||||
|
{
|
||||||
|
Top,
|
||||||
|
|
||||||
|
Right,
|
||||||
|
|
||||||
|
Bottom,
|
||||||
|
|
||||||
|
Left,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
using Microsoft.Office.Interop.Excel;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.NonVisualComponents.HelperModels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Вспомогательный класс конфигурации для построения линейной диаграммы
|
||||||
|
/// </summary>
|
||||||
|
public class LineChartConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Путь к файлу
|
||||||
|
/// </summary>
|
||||||
|
public string Filepath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Заголовок
|
||||||
|
/// </summary>
|
||||||
|
public string Header { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Название диаграммы
|
||||||
|
/// </summary>
|
||||||
|
public string ChartTitle { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Значения для отображения на диаграмме
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, List<int>> Values { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Положение легенды на диаграмме
|
||||||
|
/// </summary>
|
||||||
|
public LegendPosition LegendPosition { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.NonVisualComponents.HelperModels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Вспомогательный класс для объединения ячеек в Excel
|
||||||
|
/// </summary>
|
||||||
|
public class MergeCells
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Заголовок
|
||||||
|
/// </summary>
|
||||||
|
public string Header;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Индексы ячеек
|
||||||
|
/// </summary>
|
||||||
|
public int[] CellIndexes;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="header"></param>
|
||||||
|
/// <param name="cellIndexes"></param>
|
||||||
|
public MergeCells(string header, int[] cellIndexes)
|
||||||
|
{
|
||||||
|
Header = header;
|
||||||
|
CellIndexes = cellIndexes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
Components/Components/NonVisualComponents/TableComponent.Designer.cs
generated
Normal file
36
Components/Components/NonVisualComponents/TableComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace Components.NonVisualComponents
|
||||||
|
{
|
||||||
|
partial class TableComponent
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
198
Components/Components/NonVisualComponents/TableComponent.cs
Normal file
198
Components/Components/NonVisualComponents/TableComponent.cs
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
using Components.NonVisualComponents.HelperModels;
|
||||||
|
using Microsoft.Office.Interop.Excel;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Excel = Microsoft.Office.Interop.Excel;
|
||||||
|
|
||||||
|
namespace Components.NonVisualComponents
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Не визуальный компонент для создания документа Excel с настраиваемой таблицей
|
||||||
|
/// </summary>
|
||||||
|
public partial class TableComponent : Component
|
||||||
|
{
|
||||||
|
private char[] _columnIndexes = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public TableComponent()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="container"></param>
|
||||||
|
public TableComponent(IContainer container)
|
||||||
|
{
|
||||||
|
container.Add(this);
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать документ
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="filepath"></param>
|
||||||
|
/// <param name="title"></param>
|
||||||
|
/// <param name="mergeCells"></param>
|
||||||
|
/// <param name="columnsWidth"></param>
|
||||||
|
/// <param name="columns"></param>
|
||||||
|
/// <param name="headers"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
public void CreateDocument<T>(string filepath, string title,
|
||||||
|
List<MergeCells> mergeCells, List<int> columnsWidth,
|
||||||
|
List<string> columns, List<string> headers,
|
||||||
|
List<T> data) where T : class, new()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(filepath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не указан путь к файлу!");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не указан заголовок документа!");
|
||||||
|
}
|
||||||
|
if (mergeCells == null || mergeCells.Count == 0 || columnsWidth == null || columnsWidth.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не заполнена информация по колонкам!");
|
||||||
|
}
|
||||||
|
if (columns == null || columns.Count == 0 || headers == null || headers.Count == 0 || columns.Count != headers.Count)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Не заполнена информация по заголовкам!");
|
||||||
|
}
|
||||||
|
if (columnsWidth.Count != columns.Count)
|
||||||
|
{
|
||||||
|
throw new Exception("Количество заголовков не соответствует количеству размеров столбцов!");
|
||||||
|
}
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Данные не заполнены!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Excel.Application excelApp = new Excel.Application();
|
||||||
|
Excel.Workbook workbook = excelApp.Workbooks.Add();
|
||||||
|
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Sheets[1];
|
||||||
|
|
||||||
|
worksheet.Cells[1, 1] = title;
|
||||||
|
|
||||||
|
// Заголовки таблицы
|
||||||
|
for (int i = 1; i <= headers.Count; i++)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(headers[i - 1]))
|
||||||
|
{
|
||||||
|
throw new Exception("Заголовок не имеет данных!");
|
||||||
|
}
|
||||||
|
|
||||||
|
worksheet.Cells[2, i] = headers[i - 1];
|
||||||
|
|
||||||
|
Excel.Range column = (Excel.Range)worksheet.Columns[i];
|
||||||
|
//column.ColumnWidth = columnsWidth[i - 1];
|
||||||
|
|
||||||
|
Excel.Range cell = (Excel.Range)worksheet.Cells[2, i];
|
||||||
|
cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
|
||||||
|
cell.VerticalAlignment = Excel.XlHAlign.xlHAlignGeneral;
|
||||||
|
cell.Font.Bold = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Объединение ячеек по столбцам
|
||||||
|
List<int> mergeIndexes = new List<int>();
|
||||||
|
foreach (var merge in mergeCells)
|
||||||
|
{
|
||||||
|
mergeIndexes.AddRange(merge.CellIndexes);
|
||||||
|
|
||||||
|
Excel.Range rangeToCopy = worksheet.get_Range($"{_columnIndexes[merge.CellIndexes[0]]}2", $"{_columnIndexes[merge.CellIndexes[merge.CellIndexes.Length - 1]]}2").Cells;
|
||||||
|
Excel.Range rangeToInsert = worksheet.get_Range($"{_columnIndexes[merge.CellIndexes[0]]}3", $"{_columnIndexes[merge.CellIndexes[merge.CellIndexes.Length - 1]]}3").Cells;
|
||||||
|
rangeToInsert.Insert(Excel.XlInsertShiftDirection.xlShiftToRight, rangeToCopy.Cut());
|
||||||
|
|
||||||
|
Excel.Range rangeMerge = worksheet.get_Range($"{_columnIndexes[merge.CellIndexes[0]]}2", $"{_columnIndexes[merge.CellIndexes[merge.CellIndexes.Length - 1]]}2").Cells;
|
||||||
|
rangeMerge.Merge();
|
||||||
|
worksheet.Cells[2, merge.CellIndexes[0] + 1] = merge.Header;
|
||||||
|
Excel.Range cell = (Excel.Range)worksheet.Cells[2, merge.CellIndexes[0] + 1];
|
||||||
|
cell.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
|
||||||
|
cell.VerticalAlignment = Excel.XlHAlign.xlHAlignCenter;
|
||||||
|
cell.Font.Bold = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Объединение ячеек по строкам, которые не объединяются по столбцам
|
||||||
|
for (int i = 1; i <= headers.Count; i++)
|
||||||
|
{
|
||||||
|
if (!mergeIndexes.Contains(i - 1))
|
||||||
|
{
|
||||||
|
Excel.Range range = worksheet.get_Range($"{_columnIndexes[i - 1]}2", $"{_columnIndexes[i - 1]}3").Cells;
|
||||||
|
range.Merge();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Заполнение данных
|
||||||
|
int row = 4;
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
var properties = item.GetType().GetProperties();
|
||||||
|
if (properties.Count() != columns.Count)
|
||||||
|
{
|
||||||
|
throw new Exception("Количество полей объекта не соответствует количеству столбцов в таблице!");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < properties.Count(); i++)
|
||||||
|
{
|
||||||
|
int columnIndex = 0;
|
||||||
|
var property = properties[i];
|
||||||
|
var propertyValue = property.GetValue(item);
|
||||||
|
if (propertyValue == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Поле имеет пустое значение!");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
if (column == property.Name)
|
||||||
|
{
|
||||||
|
columnIndex = columns.IndexOf(column) + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (columnIndex != 0)
|
||||||
|
{
|
||||||
|
worksheet.Cells[i, columnIndex] = propertyValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Границы таблицы
|
||||||
|
for (int i = 2; i <= (data.Count() + 3); i++)
|
||||||
|
{
|
||||||
|
for (int j = 1; j <= headers.Count(); j++)
|
||||||
|
{
|
||||||
|
Excel.Range cell = (Excel.Range)worksheet.Cells[i, j];
|
||||||
|
cell.BorderAround(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(filepath))
|
||||||
|
{
|
||||||
|
File.Delete(filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
excelApp.Application.ActiveWorkbook.SaveAs(filepath);
|
||||||
|
workbook.Close(true);
|
||||||
|
excelApp.Quit();
|
||||||
|
|
||||||
|
Marshal.ReleaseComObject(excelApp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
Components/WinForms/Employee.cs
Normal file
96
Components/WinForms/Employee.cs
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Сущность "Человек"
|
||||||
|
/// </summary>
|
||||||
|
public class Employee
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Идентификатор
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Статус
|
||||||
|
/// </summary>
|
||||||
|
public string Status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Имя
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Фамилия
|
||||||
|
/// </summary>
|
||||||
|
public string Surname { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Возраст
|
||||||
|
/// </summary>
|
||||||
|
public int Age { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Наличие детей
|
||||||
|
/// </summary>
|
||||||
|
public string Kids { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Наличие личного автомобиля
|
||||||
|
/// </summary>
|
||||||
|
public string Car { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Подразделение
|
||||||
|
/// </summary>
|
||||||
|
public string Department { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Должность
|
||||||
|
/// </summary>
|
||||||
|
public string Post { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Премия
|
||||||
|
/// </summary>
|
||||||
|
public double Prize { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор по умолчанию
|
||||||
|
/// </summary>
|
||||||
|
public Employee() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор с параметрами
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="status"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="surname"></param>
|
||||||
|
/// <param name="age"></param>
|
||||||
|
/// <param name="kids"></param>
|
||||||
|
/// <param name="car"></param>
|
||||||
|
/// <param name="department"></param>
|
||||||
|
/// <param name="post"></param>
|
||||||
|
/// <param name="prize"></param>
|
||||||
|
public Employee(int id, string status, string name, string surname, int age, string kids, string car, string department, string post, double prize)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
Status = status;
|
||||||
|
Name = name;
|
||||||
|
Surname = surname;
|
||||||
|
Age = age;
|
||||||
|
Kids = kids;
|
||||||
|
Car = car;
|
||||||
|
Department = department;
|
||||||
|
Post = post;
|
||||||
|
Prize = prize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
92
Components/WinForms/FormNonVisualComponents.Designer.cs
generated
Normal file
92
Components/WinForms/FormNonVisualComponents.Designer.cs
generated
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
partial class FormNonVisualComponents
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
buttonCreateTextDocument = new Button();
|
||||||
|
buttonCreateTableDocument = new Button();
|
||||||
|
buttonCreateDiagramDocument = new Button();
|
||||||
|
bigTextComponent1 = new Components.NonVisualComponents.BigTextComponent(components);
|
||||||
|
tableComponent1 = new Components.NonVisualComponents.TableComponent(components);
|
||||||
|
diagramComponent1 = new Components.NonVisualComponents.DiagramComponent(components);
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonCreateTextDocument
|
||||||
|
//
|
||||||
|
buttonCreateTextDocument.Location = new Point(12, 30);
|
||||||
|
buttonCreateTextDocument.Name = "buttonCreateTextDocument";
|
||||||
|
buttonCreateTextDocument.Size = new Size(125, 50);
|
||||||
|
buttonCreateTextDocument.TabIndex = 0;
|
||||||
|
buttonCreateTextDocument.Text = "Создать документ с текстом";
|
||||||
|
buttonCreateTextDocument.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateTextDocument.Click += buttonCreateTextDocument_Click;
|
||||||
|
//
|
||||||
|
// buttonCreateTableDocument
|
||||||
|
//
|
||||||
|
buttonCreateTableDocument.Location = new Point(180, 30);
|
||||||
|
buttonCreateTableDocument.Name = "buttonCreateTableDocument";
|
||||||
|
buttonCreateTableDocument.Size = new Size(125, 50);
|
||||||
|
buttonCreateTableDocument.TabIndex = 1;
|
||||||
|
buttonCreateTableDocument.Text = "Создать документ с таблицей";
|
||||||
|
buttonCreateTableDocument.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateTableDocument.Click += buttonCreateTableDocument_Click;
|
||||||
|
//
|
||||||
|
// buttonCreateDiagramDocument
|
||||||
|
//
|
||||||
|
buttonCreateDiagramDocument.Location = new Point(347, 30);
|
||||||
|
buttonCreateDiagramDocument.Name = "buttonCreateDiagramDocument";
|
||||||
|
buttonCreateDiagramDocument.Size = new Size(125, 50);
|
||||||
|
buttonCreateDiagramDocument.TabIndex = 2;
|
||||||
|
buttonCreateDiagramDocument.Text = "Создать документ с диаграммой";
|
||||||
|
buttonCreateDiagramDocument.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreateDiagramDocument.Click += buttonCreateDiagramDocument_Click;
|
||||||
|
//
|
||||||
|
// FormNonVisualComponents
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(484, 111);
|
||||||
|
Controls.Add(buttonCreateDiagramDocument);
|
||||||
|
Controls.Add(buttonCreateTableDocument);
|
||||||
|
Controls.Add(buttonCreateTextDocument);
|
||||||
|
Name = "FormNonVisualComponents";
|
||||||
|
Text = "Не визуальные компоненты";
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonCreateTextDocument;
|
||||||
|
private Button buttonCreateTableDocument;
|
||||||
|
private Button buttonCreateDiagramDocument;
|
||||||
|
private Components.NonVisualComponents.BigTextComponent bigTextComponent1;
|
||||||
|
private Components.NonVisualComponents.TableComponent tableComponent1;
|
||||||
|
private Components.NonVisualComponents.DiagramComponent diagramComponent1;
|
||||||
|
}
|
||||||
|
}
|
124
Components/WinForms/FormNonVisualComponents.cs
Normal file
124
Components/WinForms/FormNonVisualComponents.cs
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
using Components.NonVisualComponents;
|
||||||
|
using Components.NonVisualComponents.HelperModels;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace WinForms
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Форма для не визуальных компонентов
|
||||||
|
/// </summary>
|
||||||
|
public partial class FormNonVisualComponents : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormNonVisualComponents()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать документ с текстом
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonCreateTextDocument_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\BigTextDocumentExcel.xls";
|
||||||
|
string title = "Документ с большим текстом";
|
||||||
|
|
||||||
|
string[] rows =
|
||||||
|
{
|
||||||
|
"Съешь еще",
|
||||||
|
"этих мягких",
|
||||||
|
"французских булок",
|
||||||
|
"да выпей чаю"
|
||||||
|
};
|
||||||
|
|
||||||
|
bigTextComponent1.CreateDocument(filepath, title, rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать документ с таблицей
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonCreateTableDocument_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\TableDocumentExcel.xls";
|
||||||
|
string title = "Документ с таблицей";
|
||||||
|
|
||||||
|
List<MergeCells> mergeCells = new List<MergeCells>()
|
||||||
|
{
|
||||||
|
new MergeCells("Личные данные", new int[] { 2, 3, 4 }),
|
||||||
|
new MergeCells("Работа", new int[] { 7, 8 })
|
||||||
|
};
|
||||||
|
List<int> columnsWidth = new List<int>()
|
||||||
|
{
|
||||||
|
20, 20, 30, 30, 30, 30, 30, 50, 50, 30
|
||||||
|
};
|
||||||
|
|
||||||
|
List<string> columns = new List<string>()
|
||||||
|
{
|
||||||
|
"Id", "Status", "Name", "Surname", "Age", "Kids", "Car", "Department", "Post", "Prize"
|
||||||
|
};
|
||||||
|
List<string> headers = new List<string>()
|
||||||
|
{
|
||||||
|
"Идент.", "Статус", "Имя", "Фамилия", "Возраст", "Дети", "Машина", "Подразделение", "Должность", "Премия"
|
||||||
|
};
|
||||||
|
|
||||||
|
List<Employee> data = new List<Employee>()
|
||||||
|
{
|
||||||
|
new Employee(1, "нет", "Иван", "Иванов", 34, "нет", "есть", "Департамент 1", "Инженер", 2000.1),
|
||||||
|
new Employee(2, "нет", "Петр", "Петров", 44, "есть", "есть", "Департамент 1", "Инженер", 2000.1),
|
||||||
|
new Employee(3, "да", "Сергей", "Сепгеев", 55, "нет", "есть", "Департамент 1", "Руководитель", 5000.5),
|
||||||
|
new Employee(4, "нет", "Ольга", "Иванва", 34, "есть", "нет", "Бухгалтерия", "Бухгалтер", 2000.1),
|
||||||
|
new Employee(5, "да", "Татьяна", "Петрова", 44, "нет", "нет", "Бухгалтерия", "Старший бухгалтер", 7000.6)
|
||||||
|
};
|
||||||
|
|
||||||
|
tableComponent1.CreateDocument(filepath, title,
|
||||||
|
mergeCells, columnsWidth,
|
||||||
|
columns, headers,
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Создать документ с диаграммой
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void buttonCreateDiagramDocument_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LineChartConfig config = new LineChartConfig();
|
||||||
|
config.Filepath = "C:\\Users\\masen\\OneDrive\\Рабочий стол\\DiagramDocumentExcel.xls";
|
||||||
|
config.Header = "Документ с диаграммой";
|
||||||
|
config.ChartTitle = "Моя диаграмма";
|
||||||
|
string[] charts = { "График 1", "График 2" };
|
||||||
|
|
||||||
|
var data = new Dictionary<string, List<int>>();
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
var row = new List<int>();
|
||||||
|
for (var j = 0; j < 5; j++)
|
||||||
|
{
|
||||||
|
row.Add(5 * i + j + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.Add(charts[i], row);
|
||||||
|
}
|
||||||
|
config.Values = data;
|
||||||
|
|
||||||
|
config.LegendPosition = LegendPosition.Bottom;
|
||||||
|
|
||||||
|
diagramComponent1.CreateDocument(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
129
Components/WinForms/FormNonVisualComponents.resx
Normal file
129
Components/WinForms/FormNonVisualComponents.resx
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<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="bigTextComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="tableComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>179, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="diagramComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>329, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
@ -1,6 +1,6 @@
|
|||||||
namespace WinForms
|
namespace WinForms
|
||||||
{
|
{
|
||||||
partial class FormComponents
|
partial class FormVisualComponents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -230,7 +230,7 @@
|
|||||||
customListBox.Size = new Size(332, 369);
|
customListBox.Size = new Size(332, 369);
|
||||||
customListBox.TabIndex = 0;
|
customListBox.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// FormComponents
|
// FormVisualComponents
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
@ -238,8 +238,8 @@
|
|||||||
Controls.Add(groupBox3);
|
Controls.Add(groupBox3);
|
||||||
Controls.Add(groupBox2);
|
Controls.Add(groupBox2);
|
||||||
Controls.Add(groupBox1);
|
Controls.Add(groupBox1);
|
||||||
Name = "FormComponents";
|
Name = "FormVisualComponents";
|
||||||
Text = "Компоненты";
|
Text = "Визуальные компоненты";
|
||||||
groupBox1.ResumeLayout(false);
|
groupBox1.ResumeLayout(false);
|
||||||
groupBox1.PerformLayout();
|
groupBox1.PerformLayout();
|
||||||
groupBox2.ResumeLayout(false);
|
groupBox2.ResumeLayout(false);
|
@ -1,14 +1,14 @@
|
|||||||
namespace WinForms
|
namespace WinForms
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Îñíîâíàÿ ôîðìà
|
/// Ôîðìà äëÿ âèçóàëüíûõ êîìïîíåíòîâ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FormComponents : Form
|
public partial class FormVisualComponents : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Êîíñòðóêòîð
|
/// Êîíñòðóêòîð
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FormComponents()
|
public FormVisualComponents()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ namespace WinForms
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void buttonGetObject_Click(object sender, EventArgs e)
|
private void buttonGetObject_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Person person = customListBox.GetObject<Person>();
|
Employee person = customListBox.GetObject<Employee>();
|
||||||
if (person == null)
|
if (person == null)
|
||||||
{
|
{
|
||||||
labelObjectInfo.Text = "Îáúåêò íå íàéäåí";
|
labelObjectInfo.Text = "Îáúåêò íå íàéäåí";
|
@ -11,7 +11,7 @@ namespace WinForms
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormComponents());
|
Application.Run(new FormNonVisualComponents());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user