Compare commits

..

6 Commits

Author SHA1 Message Date
3b73c69030 CustomTextBox Fix 2024-09-06 11:13:04 +04:00
8197103098 Fixes 2024-09-06 11:10:37 +04:00
5262be530e LabWork02 Done 2024-09-06 09:50:22 +04:00
4a4727d83a LabWork02 Bug fixes 2024-09-06 09:28:35 +04:00
ee5ec2e1a5 LabWork02 WiP 2024-09-06 04:27:34 +04:00
1d7d23e749 LabWork01 2024-09-05 18:58:41 +04:00
34 changed files with 2576 additions and 56 deletions

View File

@ -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>

View 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
}
}

View File

@ -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);
}
}
}

View 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
}
}

View 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);
}
}
}

View File

@ -0,0 +1,42 @@
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 ColumnInfo
{
/// <summary>
/// Название поля объекта
/// </summary>
public string FieldName { get; set; } = string.Empty;
/// <summary>
/// Заголовок колонки
/// </summary>
public string Header { get; set; } = string.Empty;
/// <summary>
/// Ширина колонки
/// </summary>
public int Width { get; set; }
/// <summary>
/// Конструктор
/// </summary>
/// <param name="fieldName"></param>
/// <param name="header"></param>
/// <param name="width"></param>
public ColumnInfo(string fieldName, string header, int width)
{
FieldName = fieldName;
Header = header;
Width = width;
}
}
}

View File

@ -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,
}
}

View File

@ -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; }
}
}

View File

@ -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;
}
}
}

View 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
}
}

View File

@ -0,0 +1,189 @@
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<ColumnInfo> columns,
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 || columns == null || columns.Count == 0)
{
throw new ArgumentNullException("Не заполнена информация по колонкам!");
}
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 <= columns.Count; i++)
{
if (string.IsNullOrEmpty(columns[i - 1].Header))
{
throw new Exception("Заголовок не имеет данных!");
}
worksheet.Cells[2, i] = columns[i - 1].Header;
Excel.Range column = (Excel.Range)worksheet.Columns[i];
column.ColumnWidth = columns[i - 1].Width;
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 <= columns.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.FieldName == property.Name)
{
columnIndex = columns.IndexOf(column) + 1;
break;
}
}
if (columnIndex != 0)
{
worksheet.Cells[row, columnIndex] = propertyValue;
}
}
row++;
}
// Границы таблицы
for (int i = 2; i <= (data.Count() + 3); i++)
{
for (int j = 1; j <= columns.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);
}
}
}

View File

@ -0,0 +1,72 @@
namespace Components.VisualComponents
{
partial class CustomComboBox
{
/// <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()
{
comboBox = new ComboBox();
labelComboBox = new Label();
SuspendLayout();
//
// comboBox
//
comboBox.Dock = DockStyle.Bottom;
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox.FormattingEnabled = true;
comboBox.Location = new Point(0, 30);
comboBox.Name = "comboBox";
comboBox.Size = new Size(170, 23);
comboBox.TabIndex = 0;
comboBox.SelectedValueChanged += comboBox_SelectedValueChanged;
//
// labelComboBox
//
labelComboBox.AutoSize = true;
labelComboBox.Location = new Point(10, 10);
labelComboBox.Name = "labelComboBox";
labelComboBox.Size = new Size(125, 15);
labelComboBox.TabIndex = 1;
labelComboBox.Text = "Выпадающий список";
//
// CustomComboBox
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(labelComboBox);
Controls.Add(comboBox);
Name = "CustomComboBox";
Size = new Size(170, 53);
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBox;
private Label labelComboBox;
}
}

View File

@ -0,0 +1,107 @@
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 Components.VisualComponents
{
/// <summary>
/// Визуальный компонент для выбора из выпадающего списка
/// </summary>
public partial class CustomComboBox : UserControl
{
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
private EventHandler _onValueChangedEvent;
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
public event EventHandler ValueChanged
{
add
{
_onValueChangedEvent += value;
}
remove
{
_onValueChangedEvent -= value;
}
}
/// <summary>
/// Выбранный элемент
/// </summary>
public string SelectedItem
{
get
{
if (comboBox.Items.Count == 0)
{
return "";
}
if (comboBox.SelectedItem == null)
{
return "";
}
return comboBox.SelectedItem.ToString()!;
}
set
{
if (comboBox.Items.Contains(value))
{
comboBox.SelectedItem = value;
}
}
}
/// <summary>
/// Конструктор
/// </summary>
public CustomComboBox()
{
InitializeComponent();
}
/// <summary>
/// Добавить элемент
/// </summary>
/// <param name="item"></param>
public void AddItem(string item)
{
if (item == null)
{
return;
}
comboBox.Items.Add(item);
}
/// <summary>
/// Очистить список
/// </summary>
public void Clear()
{
comboBox.Items.Clear();
}
/// <summary>
/// Смена значения
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBox_SelectedValueChanged(object sender, EventArgs e)
{
_onValueChangedEvent?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,58 @@
namespace Components.VisualComponents
{
partial class CustomListBox
{
/// <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()
{
listBox = new ListBox();
SuspendLayout();
//
// listBox
//
listBox.Dock = DockStyle.Fill;
listBox.FormattingEnabled = true;
listBox.ItemHeight = 15;
listBox.Location = new Point(0, 0);
listBox.Name = "listBox";
listBox.Size = new Size(300, 150);
listBox.TabIndex = 0;
//
// CustomListBox
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBox);
Name = "CustomListBox";
Size = new Size(300, 150);
ResumeLayout(false);
}
#endregion
private ListBox listBox;
}
}

View File

@ -0,0 +1,162 @@
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 Components.VisualComponents
{
/// <summary>
/// Визуальный компонент для вывода списка в виде списка записей
/// </summary>
public partial class CustomListBox : UserControl
{
/// <summary>
/// Макетная строка
/// </summary>
private string _layoutString;
/// <summary>
/// Символ начала имени свойства
/// </summary>
private string _startSymbol;
/// <summary>
/// Символ конца имени свойства
/// </summary>
private string _endSymbol;
/// <summary>
/// Индекс выбранной строки
/// </summary>
public int SelectedIndex
{
get
{
if (listBox.SelectedIndex == -1)
{
return -1;
}
return listBox.SelectedIndex;
}
set
{
if (listBox.SelectedItems.Count != 0)
{
listBox.SelectedIndex = value;
}
}
}
/// <summary>
/// Конструктор
/// </summary>
public CustomListBox()
{
InitializeComponent();
}
/// <summary>
/// Установить макетную строку
/// </summary>
/// <param name="layoutString"></param>
/// <param name="startSymbol"></param>
/// <param name="endSymbol"></param>
public void SetLayoutInfo(string layoutString, string startSymbol, string endSymbol)
{
if (string.IsNullOrEmpty(layoutString) || string.IsNullOrEmpty(startSymbol) || string.IsNullOrEmpty(endSymbol))
{
throw new Exception("Заполните макетную строку!");
}
if (!layoutString.Contains(startSymbol) || !layoutString.Contains(endSymbol))
{
throw new Exception("Макетная строка не содержит нужные элементы!");
}
_layoutString = layoutString;
_startSymbol = startSymbol;
_endSymbol = endSymbol;
}
/// <summary>
/// Получить объект из выбранной строки
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public T? GetObject<T>() where T : class, new()
{
if (listBox.SelectedIndex == -1)
{
return null;
}
string selectedString = listBox.SelectedItem.ToString()!;
StringBuilder sb = new StringBuilder(selectedString);
T obj = new T();
foreach (var property in obj.GetType().GetProperties())
{
if (!property.CanWrite)
{
continue;
}
int firstBorder = sb.ToString().IndexOf(_startSymbol);
if (firstBorder == -1)
{
break;
}
int secondBorder = sb.ToString().IndexOf(_endSymbol, firstBorder + 1);
if (secondBorder == -1)
{
break;
}
string propertyValue = sb.ToString(firstBorder + 1, secondBorder - firstBorder - 1);
sb.Remove(0, secondBorder + 1);
property.SetValue(obj, Convert.ChangeType(propertyValue, property.PropertyType));
}
return obj;
}
/// <summary>
/// Добавить объект в список
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="Exception"></exception>
public void AddObject<T>(T obj)
{
if (obj == null)
{
throw new ArgumentNullException("Добавляемый объект не существует!");
}
if (string.IsNullOrEmpty(_layoutString) || string.IsNullOrEmpty(_startSymbol) || string.IsNullOrEmpty(_endSymbol))
{
throw new Exception("Заполните макетную строку!");
}
if (!_layoutString.Contains(_startSymbol) || !_layoutString.Contains(_endSymbol))
{
throw new Exception("Макетная строка не содержит нужные элементы!");
}
string processedString = _layoutString;
foreach (var property in obj.GetType().GetProperties())
{
string placeholder = $"{_startSymbol}{property.Name}{_endSymbol}";
processedString = processedString.Replace(placeholder, $"{_startSymbol}{property.GetValue(obj)}{_endSymbol}");
}
listBox.Items.Add(processedString);
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,71 @@
namespace Components.VisualComponents
{
partial class CustomTextBox
{
/// <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()
{
textBox = new TextBox();
label = new Label();
SuspendLayout();
//
// textBox
//
textBox.Dock = DockStyle.Bottom;
textBox.Location = new Point(0, 30);
textBox.Name = "textBox";
textBox.Size = new Size(170, 23);
textBox.TabIndex = 0;
textBox.TextChanged += textBox_TextChanged;
textBox.Enter += textBox_Enter;
//
// label
//
label.AutoSize = true;
label.Location = new Point(10, 10);
label.Name = "label";
label.Size = new Size(32, 15);
label.TabIndex = 1;
label.Text = "Дата";
//
// CustomTextBox
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(label);
Controls.Add(textBox);
Name = "CustomTextBox";
Size = new Size(170, 53);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox;
private Label label;
}
}

View File

@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using Components.VisualComponents.Exceptions;
namespace Components.VisualComponents
{
/// <summary>
/// Текстовый визуальный компонент для ввода значения с проверкой по шаблону
/// </summary>
public partial class CustomTextBox : UserControl
{
/// <summary>
/// Шаблон вводимого значения
/// </summary>
private string? _datePattern;
/// <summary>
/// Шаблон вводимого значения
/// </summary>
public string? DatePattern
{
get { return _datePattern; }
set { _datePattern = value; }
}
/// <summary>
/// Пример вводимого значения
/// </summary>
private string _dateExample = "01.01.1970";
/// <summary>
/// Введенное значение
/// </summary>
public string? TextBoxValue
{
get
{
if (DatePattern == null)
{
throw new NullPatternException("Шаблон не заполнен!");
}
Regex regex = new Regex(DatePattern);
bool isValid = regex.IsMatch(textBox.Text);
if (isValid)
{
return textBox.Text;
}
else
{
throw new InvalidInputException(textBox.Text);
}
}
set
{
Regex regex = new Regex(DatePattern!);
bool isValid = regex.IsMatch(value);
if (isValid)
{
textBox.Text = value;
}
}
}
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
private EventHandler _onValueChangedEvent;
/// <summary>
/// Событие, вызываемое при смене значения
/// </summary>
public event EventHandler ValueChanged
{
add
{
_onValueChangedEvent += value;
}
remove
{
_onValueChangedEvent -= value;
}
}
/// <summary>
/// Конструктор
/// </summary>
public CustomTextBox()
{
InitializeComponent();
}
/// <summary>
/// Заполнить пример вводимого значения
/// </summary>
/// <param name="date"></param>
public bool SetDateExample(string date)
{
Regex regex = new Regex(DatePattern!);
bool isValid = regex.IsMatch(date);
if (isValid)
{
_dateExample = date;
return true;
}
return false;
}
/// <summary>
/// Вывод подсказки с примером правильного ввода
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textBox_Enter(object sender, EventArgs e)
{
int visibleTime = 2000;
ToolTip tooltip = new ToolTip();
tooltip.Show(_dateExample, textBox, 30, -20, visibleTime);
}
/// <summary>
/// Смена значения
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textBox_TextChanged(object sender, EventArgs e)
{
_onValueChangedEvent?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.VisualComponents.Exceptions
{
/// <summary>
/// Исключение, вызываемое, когда введенное значение не соответствует шаблону
/// </summary>
public class InvalidInputException : Exception
{
/// <summary>
/// Конструктор по умолчанию
/// </summary>
public InvalidInputException() { }
/// <summary>
/// Констурктор с сообщением
/// </summary>
/// <param name="message"></param>
public InvalidInputException(string message) : base($"{message} не соответствует шаблону!") { }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.VisualComponents.Exceptions
{
/// <summary>
/// Исключение, вызываемое, когда шаблон не установлен
/// </summary>
public class NullPatternException : Exception
{
/// <summary>
/// Конструктор по умолчанию
/// </summary>
public NullPatternException() { }
/// <summary>
/// Констурктор с сообщением
/// </summary>
/// <param name="message"></param>
public NullPatternException(string message) : base(message) { }
}
}

View 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;
}
}
}

View File

@ -1,45 +0,0 @@
namespace WinForms
{
partial class FormComponents
{
/// <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()
{
SuspendLayout();
//
// FormComponents
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Name = "FormComponents";
Text = "Компоненты";
ResumeLayout(false);
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace WinForms
{
public partial class FormComponents : Form
{
public FormComponents()
{
InitializeComponent();
}
}
}

View 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;
}
}

View File

@ -0,0 +1,123 @@
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.xlsx";
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.xlsx";
string title = "Документ с таблицей";
List<MergeCells> mergeCells = new List<MergeCells>()
{
new MergeCells("Личные данные", new int[] { 2, 3, 4 }),
new MergeCells("Работа", new int[] { 7, 8 })
};
List<ColumnInfo> columns = new List<ColumnInfo>()
{
new ColumnInfo("Id", "Идент.", 10),
new ColumnInfo("Status", "Статус", 10),
new ColumnInfo("Name", "Имя", 20),
new ColumnInfo("Surname", "Фамилия", 20),
new ColumnInfo("Age", "Возраст", 20),
new ColumnInfo("Kids", "Дети", 20),
new ColumnInfo("Car", "Машина", 20),
new ColumnInfo("Department", "Подразделение", 30),
new ColumnInfo("Post", "Должность", 30),
new ColumnInfo("Prize", "Премия", 10)
};
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, columns,
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.xlsx";
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);
}
}
}

View 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>

View File

@ -0,0 +1,272 @@
namespace WinForms
{
partial class FormVisualComponents
{
/// <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()
{
groupBox1 = new GroupBox();
labelItem = new Label();
buttonGetItem = new Button();
buttonClearItems = new Button();
buttonAddItems = new Button();
customComboBox = new Components.VisualComponents.CustomComboBox();
groupBox2 = new GroupBox();
buttonSetDateExample = new Button();
textBoxDateExample = new TextBox();
checkBoxValidate = new CheckBox();
buttonValidate = new Button();
customTextBox = new Components.VisualComponents.CustomTextBox();
groupBox3 = new GroupBox();
labelObjectInfo = new Label();
buttonGetObject = new Button();
buttonAddObjects = new Button();
customListBox = new Components.VisualComponents.CustomListBox();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
groupBox3.SuspendLayout();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(labelItem);
groupBox1.Controls.Add(buttonGetItem);
groupBox1.Controls.Add(buttonClearItems);
groupBox1.Controls.Add(buttonAddItems);
groupBox1.Controls.Add(customComboBox);
groupBox1.Dock = DockStyle.Left;
groupBox1.Location = new Point(0, 0);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(275, 461);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Тест для ComboBox";
//
// labelItem
//
labelItem.AutoSize = true;
labelItem.BorderStyle = BorderStyle.Fixed3D;
labelItem.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point);
labelItem.Location = new Point(143, 140);
labelItem.Name = "labelItem";
labelItem.Size = new Size(70, 22);
labelItem.TabIndex = 4;
labelItem.Text = "Элемент";
//
// buttonGetItem
//
buttonGetItem.Location = new Point(12, 139);
buttonGetItem.Name = "buttonGetItem";
buttonGetItem.Size = new Size(125, 23);
buttonGetItem.TabIndex = 3;
buttonGetItem.Text = "Получить элемент";
buttonGetItem.UseVisualStyleBackColor = true;
buttonGetItem.Click += buttonGetItem_Click;
//
// buttonClearItems
//
buttonClearItems.Location = new Point(12, 110);
buttonClearItems.Name = "buttonClearItems";
buttonClearItems.Size = new Size(125, 23);
buttonClearItems.TabIndex = 2;
buttonClearItems.Text = "Очистить элементы";
buttonClearItems.UseVisualStyleBackColor = true;
buttonClearItems.Click += buttonClearItems_Click;
//
// buttonAddItems
//
buttonAddItems.Location = new Point(12, 81);
buttonAddItems.Name = "buttonAddItems";
buttonAddItems.Size = new Size(125, 23);
buttonAddItems.TabIndex = 1;
buttonAddItems.Text = "Добавить элементы";
buttonAddItems.UseVisualStyleBackColor = true;
buttonAddItems.Click += buttonAddItems_Click;
//
// customComboBox
//
customComboBox.Location = new Point(12, 22);
customComboBox.Name = "customComboBox";
customComboBox.SelectedItem = "";
customComboBox.Size = new Size(257, 53);
customComboBox.TabIndex = 0;
//
// groupBox2
//
groupBox2.Controls.Add(buttonSetDateExample);
groupBox2.Controls.Add(textBoxDateExample);
groupBox2.Controls.Add(checkBoxValidate);
groupBox2.Controls.Add(buttonValidate);
groupBox2.Controls.Add(customTextBox);
groupBox2.Dock = DockStyle.Left;
groupBox2.Location = new Point(275, 0);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(253, 461);
groupBox2.TabIndex = 1;
groupBox2.TabStop = false;
groupBox2.Text = "Тест для TextBox";
//
// buttonSetDateExample
//
buttonSetDateExample.Location = new Point(64, 168);
buttonSetDateExample.Name = "buttonSetDateExample";
buttonSetDateExample.Size = new Size(125, 23);
buttonSetDateExample.TabIndex = 4;
buttonSetDateExample.Text = "Изменить пример";
buttonSetDateExample.UseVisualStyleBackColor = true;
buttonSetDateExample.Click += buttonSetDateExample_Click;
//
// textBoxDateExample
//
textBoxDateExample.Location = new Point(6, 139);
textBoxDateExample.Name = "textBoxDateExample";
textBoxDateExample.PlaceholderText = "01.01.1970";
textBoxDateExample.Size = new Size(241, 23);
textBoxDateExample.TabIndex = 3;
//
// checkBoxValidate
//
checkBoxValidate.AutoSize = true;
checkBoxValidate.Enabled = false;
checkBoxValidate.Location = new Point(167, 84);
checkBoxValidate.Name = "checkBoxValidate";
checkBoxValidate.RightToLeft = RightToLeft.No;
checkBoxValidate.Size = new Size(80, 19);
checkBoxValidate.TabIndex = 2;
checkBoxValidate.Text = "Проверка";
checkBoxValidate.UseVisualStyleBackColor = true;
//
// buttonValidate
//
buttonValidate.Location = new Point(6, 81);
buttonValidate.Name = "buttonValidate";
buttonValidate.Size = new Size(75, 23);
buttonValidate.TabIndex = 1;
buttonValidate.Text = "Проверка";
buttonValidate.UseVisualStyleBackColor = true;
buttonValidate.Click += buttonValidate_Click;
//
// customTextBox
//
customTextBox.DatePattern = null;
customTextBox.Location = new Point(6, 22);
customTextBox.Name = "customTextBox";
customTextBox.Size = new Size(241, 53);
customTextBox.TabIndex = 0;
//
// groupBox3
//
groupBox3.Controls.Add(labelObjectInfo);
groupBox3.Controls.Add(buttonGetObject);
groupBox3.Controls.Add(buttonAddObjects);
groupBox3.Controls.Add(customListBox);
groupBox3.Dock = DockStyle.Right;
groupBox3.Location = new Point(534, 0);
groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(350, 461);
groupBox3.TabIndex = 2;
groupBox3.TabStop = false;
groupBox3.Text = "Тест для ListBox";
//
// labelObjectInfo
//
labelObjectInfo.AutoSize = true;
labelObjectInfo.BorderStyle = BorderStyle.Fixed3D;
labelObjectInfo.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point);
labelObjectInfo.Location = new Point(132, 426);
labelObjectInfo.Name = "labelObjectInfo";
labelObjectInfo.Size = new Size(190, 22);
labelObjectInfo.TabIndex = 3;
labelObjectInfo.Text = " Информация об объекте";
//
// buttonGetObject
//
buttonGetObject.Location = new Point(6, 426);
buttonGetObject.Name = "buttonGetObject";
buttonGetObject.Size = new Size(120, 23);
buttonGetObject.TabIndex = 2;
buttonGetObject.Text = "Получить объект";
buttonGetObject.UseVisualStyleBackColor = true;
buttonGetObject.Click += buttonGetObject_Click;
//
// buttonAddObjects
//
buttonAddObjects.Location = new Point(6, 397);
buttonAddObjects.Name = "buttonAddObjects";
buttonAddObjects.Size = new Size(120, 23);
buttonAddObjects.TabIndex = 1;
buttonAddObjects.Text = "Добавить объекты";
buttonAddObjects.UseVisualStyleBackColor = true;
buttonAddObjects.Click += buttonAddObjects_Click;
//
// customListBox
//
customListBox.Location = new Point(6, 22);
customListBox.Name = "customListBox";
customListBox.SelectedIndex = -1;
customListBox.Size = new Size(332, 369);
customListBox.TabIndex = 0;
//
// FormVisualComponents
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(884, 461);
Controls.Add(groupBox3);
Controls.Add(groupBox2);
Controls.Add(groupBox1);
Name = "FormVisualComponents";
Text = "Визуальные компоненты";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
groupBox2.ResumeLayout(false);
groupBox2.PerformLayout();
groupBox3.ResumeLayout(false);
groupBox3.PerformLayout();
ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private GroupBox groupBox2;
private GroupBox groupBox3;
private Button buttonAddObjects;
private Components.VisualComponents.CustomListBox customListBox;
private Label labelObjectInfo;
private Button buttonGetObject;
private Button buttonAddItems;
private Components.VisualComponents.CustomComboBox customComboBox;
private Button buttonGetItem;
private Button buttonClearItems;
private Label labelItem;
private CheckBox checkBoxValidate;
private Button buttonValidate;
private Components.VisualComponents.CustomTextBox customTextBox;
private Button buttonSetDateExample;
private TextBox textBoxDateExample;
}
}

View File

@ -0,0 +1,134 @@
namespace WinForms
{
/// <summary>
/// Ôîðìà äëÿ âèçóàëüíûõ êîìïîíåíòîâ
/// </summary>
public partial class FormVisualComponents : Form
{
/// <summary>
/// Êîíñòðóêòîð
/// </summary>
public FormVisualComponents()
{
InitializeComponent();
customComboBox.AddItem("Ýëåìåíò 1");
customComboBox.AddItem("Ýëåìåíò 2");
customComboBox.AddItem("Ýëåìåíò 3");
customTextBox.DatePattern = @"^(\d{2}.\d{2}.\d{4})$";
customListBox.SetLayoutInfo("Èìÿ *Name* Ôàìèëèÿ *Surname*", "*", "*");
}
/// <summary>
/// Äîáàâèòü ýäåìåíòû â customComboBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddItems_Click(object sender, EventArgs e)
{
customComboBox.AddItem("Ýëåìåíò 3");
customComboBox.AddItem("Ýëåìåíò 4");
customComboBox.AddItem("Ýëåìåíò 5");
}
/// <summary>
/// Î÷èñòèòü ñïèñîê ýëåìåíòîâ customComboBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonClearItems_Click(object sender, EventArgs e)
{
customComboBox.Clear();
}
/// <summary>
/// Ïîëó÷èòü âûáðàííûé ýëåìåíò èç customComboBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonGetItem_Click(object sender, EventArgs e)
{
labelItem.Text = customComboBox.SelectedItem.ToString();
}
/// <summary>
/// Ïðîâåðêà ââåäåííîãî çíà÷åíèÿ ñ çàäàííûì øàáëîíîì customTextBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonValidate_Click(object sender, EventArgs e)
{
try
{
if (customTextBox.TextBoxValue != null)
{
checkBoxValidate.Text = "Ïîäõîäèò";
checkBoxValidate.Checked = true;
checkBoxValidate.BackColor = Color.LightGreen;
}
}
catch (Exception ex)
{
checkBoxValidate.Text = "Íå ïîäõîäèò";
checkBoxValidate.Checked = false;
checkBoxValidate.BackColor = Color.Red;
MessageBox.Show(ex.Message);
}
}
/// <summary>
/// Èçìåíèòü ïðèìåð çàäàííîãî øàáëîíà customTextBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonSetDateExample_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxDateExample.Text))
{
return;
}
if (customTextBox.SetDateExample(textBoxDateExample.Text))
{
MessageBox.Show("Ïðèìåð çàäàííîãî øàáëîíà óñïåøíî èçìåí¸í!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Ïðèìåð çàäàííîãî øàáëîíà íå ïîäõîäèò!", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
/// <summary>
/// Äîáàâèòü îáúåêòû â customListBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonAddObjects_Click(object sender, EventArgs e)
{
customListBox.AddObject<Person>(new Person("Åâãåíèé", "Ýãîâ"));
customListBox.AddObject<Person>(new Person("Àíòîí", "Ñêàëêèí"));
customListBox.AddObject<Person>(new Person("Ìàêñèì", "Ìàñåíüêèí"));
}
/// <summary>
/// Ïîëó÷èòü îáúåêò èç customListBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonGetObject_Click(object sender, EventArgs e)
{
Employee person = customListBox.GetObject<Employee>();
if (person == null)
{
labelObjectInfo.Text = "Îáúåêò íå íàéäåí";
return;
}
string objectInfo = person.Name + " " + person.Surname;
labelObjectInfo.Text = objectInfo;
}
}
}

View File

@ -0,0 +1,120 @@
<?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>
</root>

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinForms
{
/// <summary>
/// Сущность "Человек"
/// </summary>
public class Person
{
/// <summary>
/// Имя
/// </summary>
public string Name { get; set; }
/// <summary>
/// Фамилия
/// </summary>
public string Surname { get; set; }
/// <summary>
/// Конструктор по умолчанию
/// </summary>
public Person() { }
/// <summary>
/// Конструктор с параметрами
/// </summary>
/// <param name="name"></param>
/// <param name="surname"></param>
public Person(string name, string surname)
{
Name = name;
Surname = surname;
}
}
}

View File

@ -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());
} }
} }
} }

View File

@ -8,4 +8,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Components\Components.csproj" />
</ItemGroup>
</Project> </Project>