Compare commits

..

No commits in common. "lab2" and "main" have entirely different histories.
lab2 ... main

52 changed files with 0 additions and 2854 deletions

63
.gitattributes vendored
View File

@ -1,63 +0,0 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

0
1.txt
View File

View File

@ -1,36 +0,0 @@
namespace MyUserControls.Components.PdfDiagram
{
partial class PdfDiagram
{
/// <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

@ -1,46 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using MyUserControls.Components.office_package.HelperModels;
using MyUserControls.Components.office_package.Implements;
using MyUserControls.Components.office_package;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.PdfDiagram
{
public partial class PdfDiagram : Component
{
ISaveToPdf SaveToPdf = new SaveToPdf();
public PdfDiagram()
{
InitializeComponent();
}
public PdfDiagram(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDiagram(PdfDiagramInfo info)
{
info.CheckFields();
SaveToPdf.CreatePdf(info);
SaveToPdf.CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
SaveToPdf.CreatePieChart(info);
SaveToPdf.SavePdf(info);
}
}
}

View File

@ -1,29 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using MyUserControls.Components.office_package.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.PdfDiagram
{
public class PdfDiagramInfo : IPdfInfo, IPdfPieChartParameters
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string ChartTitle { get; set; } = string.Empty;
public PdfDiagramLegendLocation LegendLocation { get; set; } = PdfDiagramLegendLocation.Right;
public PdfDiagramSeries Series { get; set; } = new();
public void CheckFields()
{
if (string.IsNullOrEmpty(FileName))
throw new ArgumentNullException(nameof(FileName), "File path and name cannot be null or empty.");
if (string.IsNullOrEmpty(Title))
throw new ArgumentNullException(nameof(Title), "Title cannot be null or empty.");
if (Series == null)
throw new ArgumentNullException(nameof(Series), "Series cannot be null or empty.");
}
}
}

View File

@ -1,36 +0,0 @@
namespace MyUserControls.Components.PdfImage
{
partial class PdfImage
{
/// <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

@ -1,47 +0,0 @@
using MyUserControls.Components.office_package;
using MyUserControls.Components.office_package.HelperEnums;
using MyUserControls.Components.office_package.HelperModels;
using MyUserControls.Components.office_package.Implements;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.PdfImage
{
public partial class PdfImage : Component
{
ISaveToPdf SaveToPdf = new SaveToPdf();
public PdfImage()
{
InitializeComponent();
}
public PdfImage(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreatePdf(PdfImageInfo info)
{
info.CheckFields();
SaveToPdf.CreatePdf(info);
SaveToPdf.CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var image in info.Images)
{
SaveToPdf.CreateImage(image);
}
SaveToPdf.SavePdf(info);
}
}
}

View File

@ -1,24 +0,0 @@
using MyUserControls.Components.office_package.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.PdfImage
{
public class PdfImageInfo : IPdfInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<byte[]> Images { get; set; } = new List<byte[]>();
public void CheckFields()
{
if (string.IsNullOrWhiteSpace(FileName) || string.IsNullOrWhiteSpace(Title) || Images == null || Images.Count == 0)
{
throw new ArgumentException("Все поля должны быть заполнены.");
}
}
}
}

View File

@ -1,36 +0,0 @@
namespace MyUserControls.Components.PdfTable
{
partial class PdfTable
{
/// <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

@ -1,152 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using MyUserControls.Components.office_package.HelperModels;
using MyUserControls.Components.office_package.Implements;
using MyUserControls.Components.office_package;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.PdfTable
{
public partial class PdfTable : Component
{
ISaveToPdf SaveToPdf = new SaveToPdf();
public PdfTable()
{
InitializeComponent();
}
public PdfTable(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreatePdf<T>(PdfTableInfo<T> info)
{
info.CheckFields();
SaveToPdf.CreatePdf(info);
SaveToPdf.CreateParagraph(new PdfParagraph
{
Text = info.Title,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
SaveToPdf.CreateTableWithColumns(info.Data.Count + 2);
SaveToPdf.CreateRow(new PdfRowParameters());
int rowIndex = 0;
int columnIndex = 0;
List<string> properties = new List<string>();
string? header;
foreach (var node in info.Headers)
{
if (string.IsNullOrWhiteSpace(node.Text))
{
throw new Exception("Cannot read header");
}
SaveToPdf.CreateRow(new PdfRowParameters());
SaveToPdf.InsertTextIntoCell(
rowIndex,
columnIndex,
new PdfCellParameters
{
Text = node.Text,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
if (node.Nodes.Count == 0)
{
SaveToPdf.MergeCells(new PdfCellsMergeParameters
{
RowIndex = rowIndex,
ColumnIndex = columnIndex,
Direction = PdfCellsMergeDirections.Right
});
header = node.Tag as string;
if (header == null)
{
throw new Exception("Cannot read property name");
}
properties.Add(header);
rowIndex++;
}
else
{
int mergeRowIndex = rowIndex;
int mergeColumnIndex = columnIndex;
foreach (TreeNode child in node.Nodes)
{
if (string.IsNullOrWhiteSpace(child.Text))
{
throw new Exception("Cannot read header");
}
SaveToPdf.CreateRow(new PdfRowParameters());
SaveToPdf.InsertTextIntoCell(
rowIndex,
columnIndex + 1,
new PdfCellParameters
{
Text = child.Text,
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
header = child.Tag as string;
if (header == null)
{
throw new Exception("Cannot read property name");
}
properties.Add(header);
rowIndex++;
}
SaveToPdf.MergeCells(new PdfCellsMergeParameters
{
RowIndex = mergeRowIndex,
ColumnIndex = mergeColumnIndex,
Direction = PdfCellsMergeDirections.Down,
CellNumber = node.Nodes.Count - 1
});
}
}
columnIndex = 2;
foreach (var obj in info.Data)
{
if (obj == null)
{
throw new Exception("Table Data element cannot be null");
}
List<string> cells = new List<string>();
for (int i = 0; i < properties.Count; i++)
{
string propertyName = properties[i];
var property = obj.GetType().GetProperty(propertyName);
if (property is null)
{
throw new ArgumentException($"Failed to find property {propertyName} in provided objects class");
}
var value = property.GetValue(obj)?.ToString();
if (value == null)
{
throw new ArgumentException($"Failed to find property {propertyName} in provided objects class");
}
cells.Add(value);
}
SaveToPdf.InsertTextIntoColumn(new PdfColumnParameters
{
Texts = cells,
ColumnIndex = columnIndex,
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
columnIndex++;
}
SaveToPdf.SavePdf(info);
}
}
}

View File

@ -1,29 +0,0 @@
using MyUserControls.Components.office_package.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.PdfTable
{
public class PdfTableInfo<T> : IPdfInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<TreeNode> Headers { get; set; } = new();
public List<T> Data { get; set; } = new();
public void CheckFields()
{
if (string.IsNullOrWhiteSpace(FileName))
throw new ArgumentException("Имя файла не может быть пустым.", nameof(FileName));
if (string.IsNullOrWhiteSpace(Title))
throw new ArgumentException("Название документа не может быть пустым.", nameof(Title));
if (Headers == null || Headers.Count == 0)
throw new ArgumentException("Заголовки для шапки не могут быть пустыми.", nameof(Headers));
if (Data == null || Data.Count == 0)
throw new ArgumentException("Данные для таблицы не могут быть пустыми.", nameof(Data));
}
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperEnums
{
public enum PdfCellsMergeDirections
{
Down,
Right
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperEnums
{
public enum PdfDiagramLegendLocation
{
Left,
Right,
Top,
Bottom,
}
}

View File

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperEnums
{
public enum PdfParagraphAlignmentType
{
Center,
Left,
Right
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public interface IPdfInfo
{
public string FileName { get; }
public string Title { get; }
}
}

View File

@ -1,16 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public interface IPdfPieChartParameters
{
public string ChartTitle { get; }
public PdfDiagramLegendLocation LegendLocation { get; }
public PdfDiagramSeries Series { get; }
}
}

View File

@ -1,15 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public interface ITableTextParameters
{
public string Style { get; }
public PdfParagraphAlignmentType ParagraphAlignment { get; }
}
}

View File

@ -1,16 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public class PdfCellParameters : ITableTextParameters
{
public string Text { get; set; } = string.Empty;
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,17 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public class PdfCellsMergeParameters
{
public int RowIndex = 0;
public int ColumnIndex = 0;
public PdfCellsMergeDirections Direction;
public int CellNumber = 1;
}
}

View File

@ -1,17 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public class PdfColumnParameters : ITableTextParameters
{
public List<string> Texts { get; set; } = new();
public string Style { get; set; } = string.Empty;
public int ColumnIndex = 0;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public class PdfDiagramSeries
{
public string SeriesName { get; set; } = string.Empty;
public Dictionary<string, double> Data = new();
}
}

View File

@ -1,16 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public class PdfParagraph
{
public string Text { get; set; } = string.Empty;
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,16 +0,0 @@
using MyUserControls.Components.office_package.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package.HelperModels
{
public class PdfRowParameters : ITableTextParameters
{
public List<string> Texts { get; set; } = new();
public string Style { get; set; } = string.Empty;
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
}
}

View File

@ -1,66 +0,0 @@
using MyUserControls.Components.office_package.HelperModels;
using MyUserControls.Components.PdfImage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components.office_package
{
public interface ISaveToPdf
{
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
void CreatePdf(IPdfInfo info);
/// <summary>
/// Создание параграфа с текстом
/// </summary>
void CreateParagraph(PdfParagraph paragraph);
/// <summary>
/// Создание изображения в pdf файле
/// </summary>
void CreateImage(byte[] image);
/// <summary>
/// Создание таблицы
/// определенной ширины
/// </summary>
void CreateTable();
/// <summary>
/// Создание таблицы с заданным количеством столбцов
/// определенной ширины
/// </summary>
void CreateTableWithColumns(List<string> columns);
/// <summary>
/// Создание таблицы с заданным количеством столбцов
/// </summary>
void CreateTableWithColumns(int columnNumber);
/// <summary>
/// Создание и заполнение строки
/// </summary>
/// <param name="rowParameters"></param>
void CreateRow(PdfRowParameters rowParameters);
/// <summary>
/// Создание и заполнение столбца
/// </summary>
void InsertTextIntoColumn(PdfColumnParameters columnParameters);
/// <summary>
/// Создание и заполнение ячейки
/// </summary>
void InsertTextIntoCell(int rowIndex, int columnIndex, PdfCellParameters cellParameters);
/// <summary>
/// Создание и заполнение ячейки
/// </summary>
void MergeCells(PdfCellsMergeParameters parameters);
/// <summary>
/// Создание и заполнение круговой диаграммы
/// </summary>
void CreatePieChart(IPdfPieChartParameters parameters);
/// <summary>
/// Сохранение файла
/// </summary>
void SavePdf(IPdfInfo info);
}
}

View File

@ -1,256 +0,0 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using MigraDoc.DocumentObjectModel.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Reflection;
using System.Data.Common;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MyUserControls.Components.office_package.HelperEnums;
using MyUserControls.Components.office_package.HelperModels;
namespace MyUserControls.Components.office_package.Implements
{
public class SaveToPdf : ISaveToPdf
{
private Document? _document;
private Section? _section;
private Table? _table;
private readonly Unit BORDER_WIDTH = 0.5;
private readonly Unit COLUMN_WIDTH = Unit.FromCentimeter(3.5);
private readonly Unit IMAGE_WIDTH = Unit.FromCentimeter(15);
public void CreatePdf(IPdfInfo info)
{
_document = new Document();
DefineStyles(_document);
_section = _document.AddSection();
}
public void SavePdf(IPdfInfo info)
{
if (string.IsNullOrWhiteSpace(info.FileName))
{
throw new ArgumentNullException("Имя файла не задано");
}
if (_document == null || _section == null)
{
throw new ArgumentNullException("Документ не сформирован, сохранять нечего");
}
var renderer = new PdfDocumentRenderer(true){
Document = _document
};
renderer.RenderDocument();
renderer.PdfDocument.Save(info.FileName);
}
private static ParagraphAlignment GetParagraphAlignment(
PdfParagraphAlignmentType type)
{
return type switch
{
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
_ => ParagraphAlignment.Justify,
};
}
private static void DefineStyles(Document document)
{
var style = document.Styles["Normal"];
style.Font.Name = "Times New Roman";
style.Font.Size = 14;
style = document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
}
public void CreateParagraph(PdfParagraph pdfParagraph)
{
if (_document == null)
{
return;
}
if (_section == null)
{
_section = _document.AddSection();
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
public void CreateImage(byte[] image)
{
if (image == null || image.Length == 0)
{
throw new ArgumentNullException("Картинка не загружена");
}
if (_document == null)
{
return;
}
if (_section == null)
{
_section = _document.AddSection();
}
var imageFileName = Path.GetTempFileName();
File.WriteAllBytes(imageFileName, image);
var img = _section.AddImage(imageFileName);
img.Width = IMAGE_WIDTH;
img.LockAspectRatio = true;
_section.AddParagraph();
}
public void CreateTable()
{
if (_document == null || _section == null)
{
return;
}
_table = _section.AddTable();
}
public void CreateTableWithColumns(List<string> columns)
{
if (_document == null || _section == null)
{
return;
}
_table = _section.AddTable();
foreach (var elem in columns)
{
_table.AddColumn(elem);
}
}
public void CreateTableWithColumns(int columnNumber)
{
if (_document == null || _section == null)
{
return;
}
_table = _section.AddTable();
for (int i = 0; i < columnNumber; i++)
{
_table.AddColumn(COLUMN_WIDTH);
}
}
public void CreateRow(PdfRowParameters rowParameters)
{
if (_table == null)
{
return;
}
var row = _table.AddRow();
for (int i = 0; i < rowParameters.Texts.Count; ++i)
{
if (!string.IsNullOrWhiteSpace(rowParameters.Texts[i]))
InsertTextIntoCell(row.Index, i, rowParameters, rowParameters.Texts[i]);
}
}
public void InsertTextIntoColumn(PdfColumnParameters columnParameters)
{
if (_table == null)
{
return;
}
for (int i = 0; i < columnParameters.Texts.Count; ++i)
{
if (!string.IsNullOrWhiteSpace(columnParameters.Texts[i]))
InsertTextIntoCell(i, columnParameters.ColumnIndex, columnParameters, columnParameters.Texts[i]);
}
}
public void InsertTextIntoCell(int rowIndex, int columnIndex, PdfCellParameters cellParameters)
{
InsertTextIntoCell(rowIndex, columnIndex, cellParameters, cellParameters.Text);
}
private void InsertTextIntoCell(int rowIndex, int columnIndex, ITableTextParameters parameters, string text)
{
if (_table == null)
{
return;
}
Cell cell = _table.Rows[rowIndex].Cells[columnIndex];
cell.AddParagraph(text);
if (!string.IsNullOrEmpty(parameters.Style))
{
cell.Style = parameters.Style;
}
cell.Borders.Left.Width = BORDER_WIDTH;
cell.Borders.Right.Width = BORDER_WIDTH;
cell.Borders.Top.Width = BORDER_WIDTH;
cell.Borders.Bottom.Width = BORDER_WIDTH;
cell.Format.Alignment = GetParagraphAlignment(
parameters.ParagraphAlignment);
cell.VerticalAlignment = VerticalAlignment.Center;
}
public void MergeCells(PdfCellsMergeParameters parameters)
{
if (_table == null)
{
return;
}
Cell cell = _table.Rows[parameters.RowIndex].Cells[parameters.ColumnIndex];
switch (parameters.Direction)
{
case PdfCellsMergeDirections.Down:
cell.MergeDown = parameters.CellNumber;
break;
case PdfCellsMergeDirections.Right:
cell.MergeRight = parameters.CellNumber;
break;
}
}
public void CreatePieChart(IPdfPieChartParameters parameters)
{
if (_document == null || _section == null)
throw new ArgumentNullException(nameof(_document), "Document is not created.");
Chart chart = new Chart(ChartType.Pie2D);
Series series = chart.SeriesCollection.AddSeries();
series.Name = parameters.Series.SeriesName;
series.Add(parameters.Series.Data.Select(x => x.Value).ToArray());
chart.XValues.AddXSeries().Add(parameters.Series.Data.Select(x => x.Key).ToArray());
ConfigChart(parameters, chart);
_section.Add(chart);
}
private void ConfigChart(IPdfPieChartParameters parameters, Chart chart)
{
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
chart.Width = Unit.FromCentimeter(16.0);
chart.Height = Unit.FromCentimeter(12.0);
chart.TopArea.AddParagraph(parameters.ChartTitle);
chart.XAxis.MajorTickMark = (TickMarkType)2;
chart.YAxis.MajorTickMark = (TickMarkType)2;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Width = new Unit(1);
chart.PlotArea.LineFormat.Visible = true;
switch (parameters.LegendLocation)
{
case PdfDiagramLegendLocation.Left:
chart.LeftArea.AddLegend();
break;
case PdfDiagramLegendLocation.Right:
chart.RightArea.AddLegend();
break;
case PdfDiagramLegendLocation.Top:
chart.TopArea.AddLegend();
break;
case PdfDiagramLegendLocation.Bottom:
chart.BottomArea.AddLegend();
break;
}
}
}
}

View File

@ -1,36 +0,0 @@
namespace MyUserControls.Components
{
partial class testComponent
{
/// <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

@ -1,63 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls.Components
{
public partial class testComponent : Component
{
private string _fileName;
public string FileName
{
set
{
if (string.IsNullOrEmpty(value)){
return;
}
if (!value.EndsWith(".txt"))
{
throw new ArgumentException("No txt file");
}
_fileName = value;
}
}
public testComponent()
{
InitializeComponent();
_fileName = string.Empty;
}
public testComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
_fileName = string.Empty;
}
public bool SaveToFile(string[] texts)
{
CheckFileExsists();
using var writer = new StreamWriter(_fileName, true);
foreach (var text in texts)
{
writer.WriteLine(text);
}
writer.Flush();
return true;
}
private void CheckFileExsists()
{
if (string.IsNullOrEmpty(_fileName))
{
throw new ArgumentNullException(_fileName);
}
if (!File.Exists(_fileName))
{
throw new FileNotFoundException(_fileName);
}
}
}
}

View File

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
</ItemGroup>
</Project>

View File

@ -1,55 +0,0 @@
namespace MyUserControls
{
partial class HierarchicalTreeView
{
/// <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()
{
treeView = new TreeView();
SuspendLayout();
//
// treeView
//
treeView.Location = new Point(25, 26);
treeView.Name = "treeView";
treeView.Size = new Size(213, 130);
treeView.TabIndex = 0;
//
// HierarchicalTreeView
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(treeView);
Name = "HierarchicalTreeView";
Size = new Size(280, 180);
ResumeLayout(false);
}
#endregion
private TreeView treeView;
}
}

View File

@ -1,143 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MyUserControls
{
public partial class HierarchicalTreeView : UserControl
{
private List<string> propertyHierarchy = new List<string>();
public HierarchicalTreeView()
{
InitializeComponent();
}
// Установка иерархии свойств
public void SetPropertyHierarchy(List<string> propertyNames)
{
if (propertyNames == null)
{
throw new ArgumentNullException(nameof(propertyNames), "Объект не может быть null.");
}
foreach (var name in propertyNames)
propertyHierarchy.Add(name);
}
// Параметризованный метод для заполнения дерева
public void AddObject<T>(T obj)
{
if (obj == null)
throw new ArgumentNullException(nameof(obj));
// Получаем значение первого свойства из иерархии
string initialValue = GetPropertyValue(obj, propertyHierarchy[0]);
TreeNode currentNode = FindOrCreateNode(treeView.Nodes, initialValue);
// Обходим остальные свойства и строим ветвление
for (int i = 1; i < propertyHierarchy.Count; i++)
{
string nextProperty = propertyHierarchy[i];
string nextValue = GetPropertyValue(obj, nextProperty);
currentNode = FindOrCreateNode(currentNode.Nodes, nextValue);
}
}
// Вспомогательный метод для получения значения свойства
private string GetPropertyValue<T>(T obj, string propertyName)
{
// Используем рефлексию для получения значения свойства
PropertyInfo propertyInfo = typeof(T).GetProperty(propertyName);
if (propertyInfo == null)
throw new ArgumentException($"Свойство {propertyName} не найдено в классе {typeof(T).Name}.");
object value = propertyInfo.GetValue(obj);
return value?.ToString() ?? "null"; // Возвращаем "null" вместо null
}
// Вспомогательный метод для нахождения или создания узла
private TreeNode FindOrCreateNode(TreeNodeCollection nodes, string value)
{
foreach (TreeNode node in nodes)
{
if (node.Text.Equals(value, StringComparison.OrdinalIgnoreCase))
{
return node;
}
}
TreeNode newNode = new TreeNode(value);
nodes.Add(newNode);
return newNode;
}
public T? GetSelectedItem<T>() where T : class, new()
{
if (treeView.SelectedNode == null)
{
throw new Exception("There are no selected nodes");
}
if (treeView.SelectedNode.Nodes.Count != 0)
{
throw new Exception("Node is not the end node");
}
T result = new T();
Type type = typeof(T);
TreeNode treeNode = treeView.SelectedNode;
// Перебор узлов сверху вниз, начиная с выбранного узла
for (int i = propertyHierarchy.Count - 1; i >= 0 && treeNode != null; i--, treeNode = treeNode.Parent)
{
// Получаем свойство по названию из propertyHierarchy
var property = type.GetProperty(propertyHierarchy[i]);
if (property != null && property.CanWrite)
{
// Сеттим значение свойства из текста узла
property.SetValue(result, treeNode.Text);
}
}
// Проверка на выполнение условий: если treeNode не null и i >= 0 (прекращаем заполнение)
if (treeNode != null || propertyHierarchy.Count > 0)
{
return result;
}
return null;
}
// Метод для выбора узла по его индексу
public void SelectNode(int index, string nodeNameToSelect)
{
// Получение узла по индексу
if (index >= 0 && index < treeView.Nodes.Count)
{
TreeNode currentNode = treeView.Nodes[1];
for (int i = propertyHierarchy.Count - 1; i >= 0 && currentNode != null; i--, currentNode = currentNode.FirstNode)
{
if (currentNode.FirstNode.Text == nodeNameToSelect)
{
treeView.SelectedNode = currentNode.FirstNode;
break; // Выход из цикла после выбора узла
}
}
}
else
{
throw new ArgumentOutOfRangeException("Неверный индекс или имя узла");
}
}
}
}

View File

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

@ -1,57 +0,0 @@
namespace MyUserControls
{
partial class SmartCheckedListBox
{
/// <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()
{
checkedListBox = new CheckedListBox();
SuspendLayout();
//
// checkedListBox
//
checkedListBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
checkedListBox.FormattingEnabled = true;
checkedListBox.Location = new Point(14, 13);
checkedListBox.Name = "checkedListBox";
checkedListBox.Size = new Size(322, 224);
checkedListBox.TabIndex = 2;
checkedListBox.SelectedIndexChanged += OnCheckedListBoxSelectedIndexChanged;
//
// SmartCheckedListBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(checkedListBox);
Name = "SmartCheckedListBox";
Size = new Size(350, 264);
ResumeLayout(false);
}
#endregion
private CheckedListBox checkedListBox;
}
}

View File

@ -1,68 +0,0 @@
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 MyUserControls
{
public partial class SmartCheckedListBox : UserControl
{
public event EventHandler SelectionChanged;
public SmartCheckedListBox()
{
InitializeComponent();
}
// Метод для добавления элемента в список
public void AddItem(string item)
{
if (!string.IsNullOrEmpty(item) && !checkedListBox.Items.Contains(item))
{
checkedListBox.Items.Add(item);
}
}
// Метод для очистки списка
public void ClearItems()
{
checkedListBox.Items.Clear();
}
// Публичное свойство для получения и установки выделенного значения
public string SelectedValue
{
get
{
if (checkedListBox.SelectedItem != null)
return checkedListBox.SelectedItem.ToString();
return string.Empty;
}
set
{
for (int i = 0; i < checkedListBox.Items.Count; i++)
{
checkedListBox.SetItemChecked(i, false);
if (checkedListBox.Items[i].ToString() == value)
{
checkedListBox.SetItemChecked(i, true);
checkedListBox.SelectedIndex = i;
}
}
}
}
// Метод, вызываемый при изменении выбора
protected virtual void OnCheckedListBoxSelectedIndexChanged(object sender, EventArgs e)
{
SelectionChanged?.Invoke(this, e);
SelectedValue = SelectedValue;
}
}
}

View File

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

@ -1,57 +0,0 @@
namespace MyUserControls
{
partial class SmartTextBox
{
/// <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()
{
textBox1 = new TextBox();
SuspendLayout();
//
// textBox1
//
textBox1.Location = new Point(18, 39);
textBox1.Name = "textBox1";
textBox1.Size = new Size(268, 27);
textBox1.TabIndex = 0;
textBox1.TextChanged += TextBox1_TextChanged;
//
// SmartTextBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBox1);
Name = "SmartTextBox";
Size = new Size(302, 177);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox1;
}
}

View File

@ -1,80 +0,0 @@
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 MyUserControls
{
public partial class SmartTextBox : UserControl
{
private int _minLength;
private int _maxLength;
private string _inputText;
public int MinLength
{
get => _minLength;
set => _minLength = value;
}
public int MaxLength
{
get => _maxLength;
set => _maxLength = value;
}
public string InputText
{
get
{
if (MinLength == 0 && MaxLength == 0)
{
throw new ValueOutOfRangeException("Диапазон значений не задан.");
}
if (_inputText.Length < MinLength || _inputText.Length > MaxLength)
{
throw new ValueOutOfRangeException("Введенное значение не входит в диапазон.");
}
return _inputText;
}
set
{
if (MinLength > 0 || MaxLength > 0)
{
if (value.Length < MinLength || value.Length > MaxLength)
{
return;
}
}
_inputText = value;
textBox1.Text = value;
OnInputTextChanged(EventArgs.Empty);
}
}
public event EventHandler? InputTextChanged;
public SmartTextBox()
{
InitializeComponent();
textBox1.TextChanged += TextBox1_TextChanged;
}
private void TextBox1_TextChanged(object sender, EventArgs e)
{
InputText = textBox1.Text;
}
protected virtual void OnInputTextChanged(EventArgs e)
{
InputTextChanged?.Invoke(this, e);
}
}
}

View File

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

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUserControls
{
public class ValueOutOfRangeException : Exception
{
public ValueOutOfRangeException(string message) : base(message) { }
}
}

View File

@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsApp1", "WinFormsApp1\WinFormsApp1.csproj", "{704BA8ED-4148-4432-8485-B6ED6D47B303}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyUserControls", "CheckedListBoxLibrary\MyUserControls.csproj", "{0502BB43-17A6-420A-A9D5-5B88A5A54074}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{704BA8ED-4148-4432-8485-B6ED6D47B303}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{704BA8ED-4148-4432-8485-B6ED6D47B303}.Debug|Any CPU.Build.0 = Debug|Any CPU
{704BA8ED-4148-4432-8485-B6ED6D47B303}.Release|Any CPU.ActiveCfg = Release|Any CPU
{704BA8ED-4148-4432-8485-B6ED6D47B303}.Release|Any CPU.Build.0 = Release|Any CPU
{0502BB43-17A6-420A-A9D5-5B88A5A54074}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0502BB43-17A6-420A-A9D5-5B88A5A54074}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0502BB43-17A6-420A-A9D5-5B88A5A54074}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0502BB43-17A6-420A-A9D5-5B88A5A54074}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D83E3A76-1102-4CB1-B4E2-8E076E904085}
EndGlobalSection
EndGlobal

View File

@ -1,176 +0,0 @@
namespace WinFormsApp1
{
partial class Form1
{
/// <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();
smartCheckedListBox1 = new MyUserControls.SmartCheckedListBox();
smartTextBox1 = new MyUserControls.SmartTextBox();
hierarchicalTreeView = new MyUserControls.HierarchicalTreeView();
testComponent1 = new MyUserControls.Components.testComponent(components);
buttonSave = new Button();
richTextBoxText = new RichTextBox();
pdfImage = new MyUserControls.Components.PdfImage.PdfImage(components);
listBoxImages = new ListBox();
chooseImage = new Button();
createPdfImages = new Button();
pdfTable = new MyUserControls.Components.PdfTable.PdfTable(components);
createTable = new Button();
pdfDiagram = new MyUserControls.Components.PdfDiagram.PdfDiagram(components);
createDiagram = new Button();
SuspendLayout();
//
// smartCheckedListBox1
//
smartCheckedListBox1.Location = new Point(12, 12);
smartCheckedListBox1.Name = "smartCheckedListBox1";
smartCheckedListBox1.SelectedValue = "";
smartCheckedListBox1.Size = new Size(241, 182);
smartCheckedListBox1.TabIndex = 1;
//
// smartTextBox1
//
smartTextBox1.Location = new Point(0, 329);
smartTextBox1.MaxLength = 100;
smartTextBox1.MinLength = 0;
smartTextBox1.Name = "smartTextBox1";
smartTextBox1.Size = new Size(295, 98);
smartTextBox1.TabIndex = 2;
//
// hierarchicalTreeView
//
hierarchicalTreeView.Location = new Point(0, 162);
hierarchicalTreeView.Name = "hierarchicalTreeView";
hierarchicalTreeView.Size = new Size(266, 174);
hierarchicalTreeView.TabIndex = 3;
//
// buttonSave
//
buttonSave.Location = new Point(337, 111);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(168, 32);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// richTextBoxText
//
richTextBoxText.Location = new Point(337, 26);
richTextBoxText.Name = "richTextBoxText";
richTextBoxText.Size = new Size(168, 70);
richTextBoxText.TabIndex = 5;
richTextBoxText.Text = "";
//
// listBoxImages
//
listBoxImages.FormattingEnabled = true;
listBoxImages.ItemHeight = 20;
listBoxImages.Location = new Point(330, 162);
listBoxImages.Name = "listBoxImages";
listBoxImages.Size = new Size(184, 64);
listBoxImages.TabIndex = 6;
//
// chooseImage
//
chooseImage.Location = new Point(331, 232);
chooseImage.Name = "chooseImage";
chooseImage.Size = new Size(183, 27);
chooseImage.TabIndex = 7;
chooseImage.Text = "Добавить картинку";
chooseImage.UseVisualStyleBackColor = true;
chooseImage.Click += chooseImage_Click;
//
// createPdfImages
//
createPdfImages.Location = new Point(330, 265);
createPdfImages.Name = "createPdfImages";
createPdfImages.Size = new Size(184, 29);
createPdfImages.TabIndex = 8;
createPdfImages.Text = "Создать картинки пдф";
createPdfImages.UseVisualStyleBackColor = true;
createPdfImages.Click += createPdfImages_Click;
//
// createTable
//
createTable.Location = new Point(330, 305);
createTable.Name = "createTable";
createTable.Size = new Size(184, 31);
createTable.TabIndex = 9;
createTable.Text = "создать таблицу пдф";
createTable.UseVisualStyleBackColor = true;
createTable.Click += createTable_Click;
//
// createDiagram
//
createDiagram.Location = new Point(331, 351);
createDiagram.Name = "createDiagram";
createDiagram.Size = new Size(185, 29);
createDiagram.TabIndex = 10;
createDiagram.Text = "Создать диаграмму пдф";
createDiagram.UseVisualStyleBackColor = true;
createDiagram.Click += createDiagram_Click;
//
// Form1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1120, 474);
Controls.Add(createDiagram);
Controls.Add(createTable);
Controls.Add(createPdfImages);
Controls.Add(chooseImage);
Controls.Add(listBoxImages);
Controls.Add(richTextBoxText);
Controls.Add(buttonSave);
Controls.Add(hierarchicalTreeView);
Controls.Add(smartTextBox1);
Controls.Add(smartCheckedListBox1);
Name = "Form1";
Text = "Form1";
ResumeLayout(false);
}
#endregion
private MyUserControls.SmartCheckedListBox smartCheckedListBox1;
private MyUserControls.SmartTextBox smartTextBox1;
private MyUserControls.HierarchicalTreeView hierarchicalTreeView;
private MyUserControls.Components.testComponent testComponent1;
private Button buttonSave;
private RichTextBox richTextBoxText;
private MyUserControls.Components.PdfImage.PdfImage pdfImage;
private ListBox listBoxImages;
private Button chooseImage;
private Button createPdfImages;
private MyUserControls.Components.PdfTable.PdfTable pdfTable;
private Button createTable;
private MyUserControls.Components.PdfDiagram.PdfDiagram pdfDiagram;
private Button createDiagram;
}
}

View File

@ -1,223 +0,0 @@
using MyUserControls;
using MyUserControls.Components.office_package.Implements;
using MyUserControls.Components.PdfDiagram;
using MyUserControls.Components.PdfImage;
using MyUserControls.Components.PdfTable;
using System.ComponentModel;
namespace WinFormsApp1
{
public partial class Form1 : Form
{
private List<byte[]> selectedImages = new List<byte[]>();
public Form1()
{
InitializeComponent();
InitialChekedListBox();
InitialSmartTextBox();
InitialTree();
testComponent1.FileName = "1.txt";
}
private void InitialChekedListBox()
{
smartCheckedListBox1.AddItem("Ýëåìåíò 1");
smartCheckedListBox1.AddItem("Ýëåìåíò 2");
smartCheckedListBox1.AddItem("Ýëåìåíò 3");
smartCheckedListBox1.SelectedValue = "Ýëåìåíò 3";
}
private void InitialSmartTextBox()
{
smartTextBox1.MinLength = 0;
smartTextBox1.MaxLength = 1000;
smartTextBox1.InputText = "jjjjj";
}
private void InitialTree()
{
var obj1 = new SampleClass { Name = "Item1", Category = "Category1", SubCategory = "SubCategory1" };
var obj2 = new SampleClass { Name = "Item2", Category = "Category1", SubCategory = "SubCategory2" };
List<string> properties = new List<string>
{
"Name",
"Category",
"SubCategory"
};
hierarchicalTreeView.SetPropertyHierarchy(properties);
hierarchicalTreeView.AddObject(obj1);
hierarchicalTreeView.AddObject(obj2);
hierarchicalTreeView.SelectNode(1, "SubCategory2");
smartTextBox1.InputText = hierarchicalTreeView.GetSelectedItem<SampleClass>().ToString();
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
testComponent1.SaveToFile(richTextBoxText.Lines);
MessageBox.Show("Ñîõàðíåíî óñïåøíî", "Ðåçóëüòàò",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void chooseImage_Click(object sender, EventArgs e)
{
try
{
using OpenFileDialog openFileDialog = new OpenFileDialog
{
Multiselect = true,
Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
selectedImages.Clear();
listBoxImages.Items.Clear();
foreach (string filePath in openFileDialog.FileNames)
{
selectedImages.Add(File.ReadAllBytes(filePath));
listBoxImages.Items.Add(Path.GetFileName(filePath));
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void createPdfImages_Click(object sender, EventArgs e)
{
try
{
if (selectedImages.Count == 0)
{
MessageBox.Show("Íåòó êàðòèíîê", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string currentDirectory = Directory.GetCurrentDirectory();
string filePath = Path.Combine(currentDirectory, @"..\..\..\Documents\PdfWithImage.pdf");
var info = new PdfImageInfo
{
FileName = filePath,
Title = "title",
Images = selectedImages
};
pdfImage.CreatePdf(info);
MessageBox.Show("Ïäô ñîçäàí óñïåøíî", "ôàéë ñîçäàí", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void createTable_Click(object sender, EventArgs e)
{
try
{
List<TreeNode> headers = new List<TreeNode>
{
new TreeNode
{
Text = "Name",
Tag = "Name",
},
new TreeNode("Info", new TreeNode[]
{
new TreeNode
{
Text = "Category",
Tag = "Category"
},
new TreeNode
{
Text = "SubCategory",
Tag = "SubCategory"
}
})
};
List<SampleClass> data = new List<SampleClass>
{
new SampleClass("a1", "d1", "f1"),
new SampleClass("a2", "d2", "f2"),
new SampleClass("a3", "d3", "f3")
};
string currentDirectory = Directory.GetCurrentDirectory();
string filePath = Path.Combine(currentDirectory, @"..\..\..\Documents\PdfWithTable.pdf");
var info = new PdfTableInfo<SampleClass>
{
FileName = filePath,
Title = "Title",
Headers = headers,
Data = data
};
pdfTable.CreatePdf(info);
MessageBox.Show("PDF ñîçäàí óñïåøíî!", "ïäô ñîçäàí", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void createDiagram_Click(object sender, EventArgs e)
{
try
{
string currentDirectory = Directory.GetCurrentDirectory();
string filePath = Path.Combine(currentDirectory, @"..\..\..\Documents\PdfWithPieDiagram.pdf");
pdfDiagram.CreateDiagram(new PdfDiagramInfo
{
FileName = filePath,
Title = "Title",
ChartTitle = "Brousers",
LegendLocation = MyUserControls.Components.office_package.HelperEnums.PdfDiagramLegendLocation.Bottom,
Series = new MyUserControls.Components.office_package.HelperModels.PdfDiagramSeries
{
SeriesName = "Brousers",
Data = new Dictionary<string, double>
{
{ "Chrome", 71.5 },
{ "Firefox", 15.5 },
{ "Edge", 4.5 },
{ "Yandex", 8.5 },
}
}
});
MessageBox.Show("PDF óñïåøíî ñîçäàí!", "ïäô ñîçäàí");
}
catch (Exception ex)
{
MessageBox.Show($"íå óäàëîñü ñîçäàòü ïäô: {ex.Message}");
}
}
}
}

View File

@ -1,132 +0,0 @@
<?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="testComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="pdfImage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>183, 17</value>
</metadata>
<metadata name="pdfTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>304, 17</value>
</metadata>
<metadata name="pdfDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>418, 17</value>
</metadata>
</root>

View File

@ -1,17 +0,0 @@
namespace WinFormsApp1
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

View File

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinFormsApp1
{
public class SampleClass
{
public string Name { get; set; }
public string Category { get; set; }
public string SubCategory { get; set; }
public override string ToString()
{
return Name + " " + Category + " " + SubCategory;
}
public SampleClass() {
Name = string.Empty;
Category = string.Empty;
SubCategory = string.Empty;
}
public SampleClass(string name, string category, string subCategory)
{
Name = name;
Category = category;
SubCategory = subCategory;
}
}
}

View File

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\CheckedListBoxLibrary\MyUserControls.csproj" />
</ItemGroup>
</Project>

View File

@ -1,78 +0,0 @@
namespace WinFormsLibrary1
{
partial class UserControl1
{
/// <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()
{
pictureBoxAvatar = new PictureBox();
button1 = new Button();
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).BeginInit();
SuspendLayout();
//
// pictureBoxAvatar
//
pictureBoxAvatar.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
pictureBoxAvatar.Location = new Point(6, 3);
pictureBoxAvatar.Name = "pictureBoxAvatar";
pictureBoxAvatar.Size = new Size(330, 306);
pictureBoxAvatar.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxAvatar.TabIndex = 0;
pictureBoxAvatar.TabStop = false;
pictureBoxAvatar.Click += ButtonLoad_Click;
//
// button1
//
button1.Dock = DockStyle.Bottom;
button1.Location = new Point(0, 311);
button1.Name = "button1";
button1.Size = new Size(339, 30);
button1.TabIndex = 1;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
button1.Click += ButtonLoad_Click;
//
// UserControl1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(button1);
Controls.Add(pictureBoxAvatar);
Name = "UserControl1";
Size = new Size(339, 341);
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private PictureBox pictureBoxAvatar;
private Button button1;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
}
}

View File

@ -1,64 +0,0 @@
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 WinFormsLibrary1
{
public partial class UserControl1 : UserControl
{
private event EventHandler? _avatarChanged;
private event Action? _errorOccured;
public string Error { get; private set; }
public Image Avatar
{
get
{
return pictureBoxAvatar.Image;
}
set
{
pictureBoxAvatar.Image = value;
}
}
public event EventHandler AvatarChanged
{
add { _avatarChanged += value; }
remove { _avatarChanged -= value; }
}
public event Action AnErrorOccurred
{
add { _errorOccured += value; }
remove { _errorOccured -= value; }
}
public UserControl1()
{
InitializeComponent();
Error = string.Empty;
}
private void ButtonLoad_Click(object sender, EventArgs e)
{
var ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
pictureBoxAvatar.Image =
Image.FromFile(ofd.FileName);
_avatarChanged?.Invoke(this, e);
}
catch (Exception ex)
{
Error = ex.Message;
_errorOccured?.Invoke();
}
}
}
}
}

View File

@ -1,123 +0,0 @@
<?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="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -1,10 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>