From fc0539b9113c7be2eeec4f09d71a8f511beb3368 Mon Sep 17 00:00:00 2001 From: Yourdax Date: Tue, 29 Oct 2024 03:48:27 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComponentHistogramToPdf.Designer.cs | 36 --- .../FormLibrary/ComponentHistogramToPdf.cs | 101 -------- KopLab1/FormLibrary/CustomListBox.Designer.cs | 58 ----- KopLab1/FormLibrary/CustomListBox.cs | 62 ----- KopLab1/FormLibrary/CustomListBox.resx | 120 ---------- .../Exceptions/EmptyValueException.cs | 13 - .../Exceptions/InvalidValueTypeException.cs | 13 - KopLab1/FormLibrary/FormLibrary.csproj | 17 -- .../FormLibrary/HelperClasses/ChartData.cs | 15 -- .../FormLibrary/HelperClasses/ColumnConfig.cs | 16 -- .../HelperClasses/LegendPositions.cs | 16 -- .../HelperClasses/PDFTableSettings.cs | 19 -- .../HelperClasses/PdfDocumentData.cs | 23 -- KopLab1/FormLibrary/HelperClasses/Student.cs | 16 -- .../IntegerInputControl.Designer.cs | 68 ------ KopLab1/FormLibrary/IntegerInputControl.cs | 82 ------- KopLab1/FormLibrary/IntegerInputControl.resx | 120 ---------- KopLab1/FormLibrary/PDFTable.Designer.cs | 36 --- KopLab1/FormLibrary/PDFTable.cs | 72 ------ .../FormLibrary/PDFTableCustom.Designer.cs | 36 --- KopLab1/FormLibrary/PDFTableCustom.cs | 95 -------- .../FormLibrary/ValueTableControl.Designer.cs | 58 ----- KopLab1/FormLibrary/ValueTableControl.cs | 107 --------- KopLab1/FormLibrary/ValueTableControl.resx | 120 ---------- KopLab1/Forms/Forms.csproj | 24 -- KopLab1/Forms/MainForm.Designer.cs | 225 ------------------ KopLab1/Forms/MainForm.cs | 219 ----------------- KopLab1/Forms/MainForm.resx | 129 ---------- KopLab1/Forms/Program.cs | 20 -- KopLab1/Lab3Form/FormMain.Designer.cs | 6 +- KopLab1/Lab3Form/FormMain.cs | 11 +- KopLab1/Lab3Form/FormMain.resx | 7 +- KopLab1/Lab3Form/FormOrder.Designer.cs | 46 ++-- KopLab1/Lab3Form/FormOrder.cs | 6 +- KopLab1/Lab3Form/Lab3Form.csproj | 1 + 35 files changed, 32 insertions(+), 1981 deletions(-) delete mode 100644 KopLab1/FormLibrary/ComponentHistogramToPdf.Designer.cs delete mode 100644 KopLab1/FormLibrary/ComponentHistogramToPdf.cs delete mode 100644 KopLab1/FormLibrary/CustomListBox.Designer.cs delete mode 100644 KopLab1/FormLibrary/CustomListBox.cs delete mode 100644 KopLab1/FormLibrary/CustomListBox.resx delete mode 100644 KopLab1/FormLibrary/Exceptions/EmptyValueException.cs delete mode 100644 KopLab1/FormLibrary/Exceptions/InvalidValueTypeException.cs delete mode 100644 KopLab1/FormLibrary/FormLibrary.csproj delete mode 100644 KopLab1/FormLibrary/HelperClasses/ChartData.cs delete mode 100644 KopLab1/FormLibrary/HelperClasses/ColumnConfig.cs delete mode 100644 KopLab1/FormLibrary/HelperClasses/LegendPositions.cs delete mode 100644 KopLab1/FormLibrary/HelperClasses/PDFTableSettings.cs delete mode 100644 KopLab1/FormLibrary/HelperClasses/PdfDocumentData.cs delete mode 100644 KopLab1/FormLibrary/HelperClasses/Student.cs delete mode 100644 KopLab1/FormLibrary/IntegerInputControl.Designer.cs delete mode 100644 KopLab1/FormLibrary/IntegerInputControl.cs delete mode 100644 KopLab1/FormLibrary/IntegerInputControl.resx delete mode 100644 KopLab1/FormLibrary/PDFTable.Designer.cs delete mode 100644 KopLab1/FormLibrary/PDFTable.cs delete mode 100644 KopLab1/FormLibrary/PDFTableCustom.Designer.cs delete mode 100644 KopLab1/FormLibrary/PDFTableCustom.cs delete mode 100644 KopLab1/FormLibrary/ValueTableControl.Designer.cs delete mode 100644 KopLab1/FormLibrary/ValueTableControl.cs delete mode 100644 KopLab1/FormLibrary/ValueTableControl.resx delete mode 100644 KopLab1/Forms/Forms.csproj delete mode 100644 KopLab1/Forms/MainForm.Designer.cs delete mode 100644 KopLab1/Forms/MainForm.cs delete mode 100644 KopLab1/Forms/MainForm.resx delete mode 100644 KopLab1/Forms/Program.cs diff --git a/KopLab1/FormLibrary/ComponentHistogramToPdf.Designer.cs b/KopLab1/FormLibrary/ComponentHistogramToPdf.Designer.cs deleted file mode 100644 index dd57dd7..0000000 --- a/KopLab1/FormLibrary/ComponentHistogramToPdf.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace FormLibrary -{ - partial class ComponentHistogramToPdf - { - /// - /// Обязательная переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором компонентов - - /// - /// Требуемый метод для поддержки конструктора — не изменяйте - /// содержимое этого метода с помощью редактора кода. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - } - - #endregion - } -} diff --git a/KopLab1/FormLibrary/ComponentHistogramToPdf.cs b/KopLab1/FormLibrary/ComponentHistogramToPdf.cs deleted file mode 100644 index 7a8bf8a..0000000 --- a/KopLab1/FormLibrary/ComponentHistogramToPdf.cs +++ /dev/null @@ -1,101 +0,0 @@ -using FormLibrary.HelperClasses; -using MigraDoc.DocumentObjectModel; -using MigraDoc.Rendering; -using OxyPlot.Series; -using OxyPlot; -using System.ComponentModel; -using OxyPlot.WindowsForms; -using OxyPlot.Legends; - - -namespace FormLibrary -{ - public partial class ComponentHistogramToPdf : Component - { - public ComponentHistogramToPdf() - { - InitializeComponent(); - System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); - } - - public ComponentHistogramToPdf(IContainer container) - { - container.Add(this); - - InitializeComponent(); - } - public void CreateHistogramPdf(string filePath, string documentTitle, string chartTitle, LegendPosition legendPosition, List chartData) - { - if (string.IsNullOrEmpty(filePath)) - throw new ArgumentException("Путь к файлу не может быть пустым."); - if (string.IsNullOrEmpty(documentTitle)) - throw new ArgumentException("Название документа не может быть пустым."); - if (string.IsNullOrEmpty(chartTitle)) - throw new ArgumentException("Заголовок диаграммы не может быть пустым."); - if (chartData == null || chartData.Count == 0) - throw new ArgumentException("Набор данных не может быть пустым."); - - foreach (var data in chartData) - { - if (string.IsNullOrEmpty(data.SeriesName) || data.Data == null || data.Data.Count == 0) - throw new ArgumentException($"Набор данных для серии '{data.SeriesName}' некорректен."); - } - - // создание графика - var plotModel = new PlotModel { Title = chartTitle }; - - foreach (var data in chartData) - { - var barSeries = new BarSeries { Title = data.SeriesName }; - foreach (var item in data.Data) - { - barSeries.Items.Add(new BarItem(item.Value)); - } - plotModel.Series.Add(barSeries); - } - - // Добавление легенды - AddLegend(plotModel, legendPosition); - - // сохранение графика в изображение - var pngExporter = new PngExporter { Width = 600, Height = 400 }; - using (var stream = new MemoryStream()) - { - pngExporter.Export(plotModel, stream); - File.WriteAllBytes("chart.png", stream.ToArray()); - } - - // создание документа - Document document = new Document(); - document.Info.Title = documentTitle; - document.Info.Subject = "Гистограмма"; - - Section section = document.AddSection(); - section.AddParagraph(chartTitle, "Heading1"); - - // вставка изображения в PDF - var image = section.AddImage("chart.png"); - image.Width = Unit.FromCentimeter(15); - - PdfDocumentRenderer renderer = new PdfDocumentRenderer(true) { Document = document }; - renderer.RenderDocument(); - renderer.PdfDocument.Save(filePath); - - File.Delete("chart.png"); - } - - //добавление легенды - private void AddLegend(PlotModel plotModel, LegendPosition legendPosition) - { - // Создание легенды - var legend = new OxyPlot.Legends.Legend - { - LegendPlacement = LegendPlacement.Outside, - LegendPosition = legendPosition, - LegendOrientation = LegendOrientation.Vertical - }; - - plotModel.Legends.Add(legend); - } - } -} diff --git a/KopLab1/FormLibrary/CustomListBox.Designer.cs b/KopLab1/FormLibrary/CustomListBox.Designer.cs deleted file mode 100644 index fc24a8e..0000000 --- a/KopLab1/FormLibrary/CustomListBox.Designer.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace FormLibrary -{ - partial class CustomListBox - { - /// - /// Обязательная переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором компонентов - - /// - /// Требуемый метод для поддержки конструктора — не изменяйте - /// содержимое этого метода с помощью редактора кода. - /// - private void InitializeComponent() - { - listBox1 = new ListBox(); - SuspendLayout(); - // - // listBox1 - // - listBox1.FormattingEnabled = true; - listBox1.ItemHeight = 15; - listBox1.Location = new Point(3, 3); - listBox1.Name = "listBox1"; - listBox1.Size = new Size(231, 169); - listBox1.TabIndex = 0; - listBox1.SelectedIndexChanged += ListBox1_SelectedIndexChanged; - // - // CustomListBox - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - Controls.Add(listBox1); - Name = "CustomListBox"; - Size = new Size(237, 179); - ResumeLayout(false); - } - - #endregion - - private ListBox listBox1; - } -} diff --git a/KopLab1/FormLibrary/CustomListBox.cs b/KopLab1/FormLibrary/CustomListBox.cs deleted file mode 100644 index 84a6cfc..0000000 --- a/KopLab1/FormLibrary/CustomListBox.cs +++ /dev/null @@ -1,62 +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; -using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header; - -namespace FormLibrary -{ - public partial class CustomListBox : UserControl - { - - public event EventHandler? SelectedItemChanged; - public CustomListBox() - { - InitializeComponent(); - } - - public string SelectedItem - { - get - { - if (listBox1.SelectedItem != null) - { - return listBox1.SelectedItem.ToString(); - } - return string.Empty; - } - set - { - int index = listBox1.Items.IndexOf(value); - if (index >= 0) - { - listBox1.SelectedIndex = index; - } - } - } - - - private void ListBox1_SelectedIndexChanged(object? sender, EventArgs e) - { - SelectedItemChanged?.Invoke(this, EventArgs.Empty); - } - public void PopulateListBox(List items) - { - listBox1.Items.Clear(); - - foreach (var item in items) - { - listBox1.Items.Add(item); - } - } - public void ClearListBox() - { - listBox1.Items.Clear(); - } - } -} diff --git a/KopLab1/FormLibrary/CustomListBox.resx b/KopLab1/FormLibrary/CustomListBox.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/KopLab1/FormLibrary/CustomListBox.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/KopLab1/FormLibrary/Exceptions/EmptyValueException.cs b/KopLab1/FormLibrary/Exceptions/EmptyValueException.cs deleted file mode 100644 index 9ac3854..0000000 --- a/KopLab1/FormLibrary/Exceptions/EmptyValueException.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.Exceptions -{ - public class EmptyValueException : Exception - { - public EmptyValueException() : base("Значение не заполнено.") { } - } -} diff --git a/KopLab1/FormLibrary/Exceptions/InvalidValueTypeException.cs b/KopLab1/FormLibrary/Exceptions/InvalidValueTypeException.cs deleted file mode 100644 index 09cc6df..0000000 --- a/KopLab1/FormLibrary/Exceptions/InvalidValueTypeException.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.Exceptions -{ - public class InvalidValueTypeException : Exception - { - public InvalidValueTypeException() : base("Значение не соответствует требуемому типу.") { } - } -} diff --git a/KopLab1/FormLibrary/FormLibrary.csproj b/KopLab1/FormLibrary/FormLibrary.csproj deleted file mode 100644 index 8a64cb8..0000000 --- a/KopLab1/FormLibrary/FormLibrary.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net8.0-windows - enable - true - enable - - - - - - - - - - diff --git a/KopLab1/FormLibrary/HelperClasses/ChartData.cs b/KopLab1/FormLibrary/HelperClasses/ChartData.cs deleted file mode 100644 index 2abfa48..0000000 --- a/KopLab1/FormLibrary/HelperClasses/ChartData.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.HelperClasses -{ - public class ChartData - { - public string SeriesName { get; set; } - public Dictionary Data { get; set; } // Ключ — категория, значение — значение для гистограммы - } - -} diff --git a/KopLab1/FormLibrary/HelperClasses/ColumnConfig.cs b/KopLab1/FormLibrary/HelperClasses/ColumnConfig.cs deleted file mode 100644 index bcf1056..0000000 --- a/KopLab1/FormLibrary/HelperClasses/ColumnConfig.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.HelperClasses -{ - public class ColumnConfig - { - public string HeaderText { get; set; } - public int Width { get; set; } - public bool IsVisible { get; set; } - public string PropertyName { get; set; } - } -} diff --git a/KopLab1/FormLibrary/HelperClasses/LegendPositions.cs b/KopLab1/FormLibrary/HelperClasses/LegendPositions.cs deleted file mode 100644 index 5d03e7f..0000000 --- a/KopLab1/FormLibrary/HelperClasses/LegendPositions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.HelperClasses -{ - public enum LegendPositions - { - Top, - Bottom, - Left, - Right - } -} diff --git a/KopLab1/FormLibrary/HelperClasses/PDFTableSettings.cs b/KopLab1/FormLibrary/HelperClasses/PDFTableSettings.cs deleted file mode 100644 index 69188fa..0000000 --- a/KopLab1/FormLibrary/HelperClasses/PDFTableSettings.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.HelperClasses -{ - public class PDFTableSettings - { - public string FilePath { get; set; } - public string DocumentTitle { get; set; } - public List<(string HeaderTitle, float Width, string PropertyName, int ColumnIndex)> Columns { get; set; } - public float HeaderRowHeight { get; set; } - public float DataRowHeight { get; set; } - public List DataList { get; set; } - } - -} diff --git a/KopLab1/FormLibrary/HelperClasses/PdfDocumentData.cs b/KopLab1/FormLibrary/HelperClasses/PdfDocumentData.cs deleted file mode 100644 index f7ad35e..0000000 --- a/KopLab1/FormLibrary/HelperClasses/PdfDocumentData.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.HelperClasses -{ - public class PdfDocumentData - { - public string FileName { get; set; } - public string DocumentTitle { get; set; } - public List Tables { get; set; } - - public PdfDocumentData(string fileName, string documentTitle, List tables) - { - FileName = fileName ?? throw new ArgumentNullException(nameof(fileName)); - DocumentTitle = documentTitle ?? throw new ArgumentNullException(nameof(documentTitle)); - Tables = tables ?? throw new ArgumentNullException(nameof(tables)); - } - } - -} diff --git a/KopLab1/FormLibrary/HelperClasses/Student.cs b/KopLab1/FormLibrary/HelperClasses/Student.cs deleted file mode 100644 index ef78de1..0000000 --- a/KopLab1/FormLibrary/HelperClasses/Student.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary.HelperClasses -{ - public class Student - { - public int Number { get; set; } - public string Group { get; set; } - public string FullName { get; set; } - public int Course { get; set; } - } -} diff --git a/KopLab1/FormLibrary/IntegerInputControl.Designer.cs b/KopLab1/FormLibrary/IntegerInputControl.Designer.cs deleted file mode 100644 index 91a5670..0000000 --- a/KopLab1/FormLibrary/IntegerInputControl.Designer.cs +++ /dev/null @@ -1,68 +0,0 @@ -namespace FormLibrary -{ - partial class IntegerInputControl - { - /// - /// Обязательная переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором компонентов - - /// - /// Требуемый метод для поддержки конструктора — не изменяйте - /// содержимое этого метода с помощью редактора кода. - /// - private void InitializeComponent() - { - checkBoxNull = new CheckBox(); - textBoxInput = new TextBox(); - SuspendLayout(); - // - // checkBoxNull - // - checkBoxNull.AutoSize = true; - checkBoxNull.Location = new Point(13, 17); - checkBoxNull.Name = "checkBoxNull"; - checkBoxNull.Size = new Size(15, 14); - checkBoxNull.TabIndex = 0; - checkBoxNull.UseVisualStyleBackColor = true; - // - // textBoxInput - // - textBoxInput.Location = new Point(34, 13); - textBoxInput.Name = "textBoxInput"; - textBoxInput.Size = new Size(100, 23); - textBoxInput.TabIndex = 1; - // - // IntegerInputControl - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - Controls.Add(textBoxInput); - Controls.Add(checkBoxNull); - Name = "IntegerInputControl"; - Size = new Size(146, 49); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private CheckBox checkBoxNull; - private TextBox textBoxInput; - } -} diff --git a/KopLab1/FormLibrary/IntegerInputControl.cs b/KopLab1/FormLibrary/IntegerInputControl.cs deleted file mode 100644 index 269c259..0000000 --- a/KopLab1/FormLibrary/IntegerInputControl.cs +++ /dev/null @@ -1,82 +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; - -using System; -using System.Windows.Forms; -using FormLibrary.Exceptions; - -namespace FormLibrary -{ - public partial class IntegerInputControl : UserControl - { - public event EventHandler? ValueChanged; - - public event EventHandler? CheckBoxChanged; - - public IntegerInputControl() - { - InitializeComponent(); - - checkBoxNull.CheckedChanged += CheckBoxNull_CheckedChanged; - textBoxInput.TextChanged += TextBoxInput_TextChanged; - } - - public int? Value - { - get - { - if (checkBoxNull.Checked) - { - return null; - } - else - { - if (string.IsNullOrWhiteSpace(textBoxInput.Text)) - { - throw new EmptyValueException(); - } - - if (int.TryParse(textBoxInput.Text, out int result)) - { - return result; - } - else - { - throw new InvalidValueTypeException(); - } - } - } - set - { - if(value is not null) - { - textBoxInput.Text = value.ToString(); - } - checkBoxNull.Checked = value is null; - } - } - - private void CheckBoxNull_CheckedChanged(object sender, EventArgs e) - { - textBoxInput.Enabled = !checkBoxNull.Checked; - if (checkBoxNull.Checked) - { - textBoxInput.Text = string.Empty; - } - CheckBoxChanged?.Invoke(this, EventArgs.Empty); - } - - private void TextBoxInput_TextChanged(object sender, EventArgs e) - { - ValueChanged?.Invoke(this, EventArgs.Empty); - } - } -} - diff --git a/KopLab1/FormLibrary/IntegerInputControl.resx b/KopLab1/FormLibrary/IntegerInputControl.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/KopLab1/FormLibrary/IntegerInputControl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/KopLab1/FormLibrary/PDFTable.Designer.cs b/KopLab1/FormLibrary/PDFTable.Designer.cs deleted file mode 100644 index 16beb31..0000000 --- a/KopLab1/FormLibrary/PDFTable.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace FormLibrary -{ - partial class PDFTable - { - /// - /// Обязательная переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором компонентов - - /// - /// Требуемый метод для поддержки конструктора — не изменяйте - /// содержимое этого метода с помощью редактора кода. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - } - - #endregion - } -} diff --git a/KopLab1/FormLibrary/PDFTable.cs b/KopLab1/FormLibrary/PDFTable.cs deleted file mode 100644 index d46223a..0000000 --- a/KopLab1/FormLibrary/PDFTable.cs +++ /dev/null @@ -1,72 +0,0 @@ -using FormLibrary.HelperClasses; -using MigraDoc.DocumentObjectModel; -using MigraDoc.DocumentObjectModel.Tables; -using MigraDoc.Rendering; -using System.ComponentModel; -using Document = MigraDoc.DocumentObjectModel.Document; - - -namespace FormLibrary -{ - public partial class PDFTable : Component - { - public PDFTable() - { - InitializeComponent(); - System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); - - } - - public PDFTable(IContainer container) - { - container.Add(this); - - InitializeComponent(); - } - - public void GeneratePdf(PdfDocumentData pdfData) - { - if (string.IsNullOrWhiteSpace(pdfData.FileName)) throw new ArgumentException("Имя файла не может быть пустым."); - if (string.IsNullOrWhiteSpace(pdfData.DocumentTitle)) throw new ArgumentException("Название документа не может быть пустым."); - if (pdfData.Tables == null || pdfData.Tables.Count == 0) throw new ArgumentException("Необходимо передать хотя бы одну таблицу."); - - Document document = new Document(); - Section section = document.AddSection(); - - Paragraph title = section.AddParagraph(); - title.AddFormattedText(pdfData.DocumentTitle, TextFormat.Bold); - title.Format.Alignment = ParagraphAlignment.Center; - section.AddParagraph(); - - foreach (var tableData in pdfData.Tables) - { - Table table = section.AddTable(); - int columnsCount = tableData.GetLength(1); - - for (int i = 0; i < columnsCount; i++) - { - Column column = table.AddColumn(Unit.FromCentimeter(3)); - } - - table.Borders.Width = 0.75; - table.Borders.Color = Colors.Black; - - for (int i = 0; i < tableData.GetLength(0); i++) - { - Row row = table.AddRow(); - for (int j = 0; j < tableData.GetLength(1); j++) - { - row.Cells[j].AddParagraph(tableData[i, j]); - } - } - - section.AddParagraph(); - } - PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true); - pdfRenderer.Document = document; - pdfRenderer.RenderDocument(); - pdfRenderer.PdfDocument.Save(pdfData.FileName); - } - - } -} diff --git a/KopLab1/FormLibrary/PDFTableCustom.Designer.cs b/KopLab1/FormLibrary/PDFTableCustom.Designer.cs deleted file mode 100644 index 9cf32a3..0000000 --- a/KopLab1/FormLibrary/PDFTableCustom.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace FormLibrary -{ - partial class PDFTableCustom - { - /// - /// Обязательная переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором компонентов - - /// - /// Требуемый метод для поддержки конструктора — не изменяйте - /// содержимое этого метода с помощью редактора кода. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - } - - #endregion - } -} diff --git a/KopLab1/FormLibrary/PDFTableCustom.cs b/KopLab1/FormLibrary/PDFTableCustom.cs deleted file mode 100644 index 3a127ce..0000000 --- a/KopLab1/FormLibrary/PDFTableCustom.cs +++ /dev/null @@ -1,95 +0,0 @@ -using FormLibrary.HelperClasses; -using MigraDoc.DocumentObjectModel.Tables; -using MigraDoc.DocumentObjectModel; -using MigraDoc.Rendering; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace FormLibrary -{ - public partial class PDFTableCustom : Component - { - public PDFTableCustom() - { - InitializeComponent(); - System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); - } - - public PDFTableCustom(IContainer container) - { - container.Add(this); - - InitializeComponent(); - } - public void GeneratePDFWithHead(PDFTableSettings settings) - { - if (settings == null || - string.IsNullOrEmpty(settings.FilePath) || - string.IsNullOrEmpty(settings.DocumentTitle) || - settings.Columns == null || settings.Columns.Count == 0 || - settings.DataList == null) - throw new ArgumentException("Заполнены не все необходимые данные для генерации документа."); - - Document document = new Document(); - Section section = document.AddSection(); - section.AddParagraph(settings.DocumentTitle, "Heading1"); - - Table table = new Table(); - table.Borders.Width = 0.75; - - // столбцы - foreach (var (_, width, _, _) in settings.Columns) - { - Column column = table.AddColumn(Unit.FromCentimeter(width)); - column.Format.Alignment = ParagraphAlignment.Center; - } - - // заголовки - Row headerRow = table.AddRow(); - headerRow.Height = Unit.FromCentimeter(settings.HeaderRowHeight); - - for (int columnIndex = 0; columnIndex < settings.Columns.Count; columnIndex++) - { - var (headerTitle, _, _, _) = settings.Columns[columnIndex]; - headerRow.Cells[columnIndex].AddParagraph(headerTitle); - headerRow.Cells[columnIndex].Format.Font.Bold = true; - headerRow.Cells[columnIndex].Format.Alignment = ParagraphAlignment.Center; - } - - // данные - foreach (var dataItem in settings.DataList) - { - Row row = table.AddRow(); - row.Height = Unit.FromCentimeter(settings.DataRowHeight); - - for (int columnIndex = 0; columnIndex < settings.Columns.Count; columnIndex++) - { - var (_, _, propertyName, _) = settings.Columns[columnIndex]; - - PropertyInfo propertyInfo = typeof(T).GetProperty(propertyName); - if (propertyInfo == null) - throw new ArgumentException($"Свойство {propertyName} не найдено в классе {typeof(T).Name}."); - - object value = propertyInfo.GetValue(dataItem); - if (columnIndex == 0) - { - row.Cells[columnIndex].Format.Font.Bold = true; - } - row.Cells[columnIndex].AddParagraph(value != null ? value.ToString() : ""); - } - } - - section.Add(table); - - PdfDocumentRenderer renderer = new PdfDocumentRenderer(true) { Document = document }; - renderer.RenderDocument(); - renderer.Save(settings.FilePath); - } - } -} diff --git a/KopLab1/FormLibrary/ValueTableControl.Designer.cs b/KopLab1/FormLibrary/ValueTableControl.Designer.cs deleted file mode 100644 index 7ae2ab2..0000000 --- a/KopLab1/FormLibrary/ValueTableControl.Designer.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace FormLibrary -{ - partial class ValueTableControl - { - /// - /// Обязательная переменная конструктора. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Освободить все используемые ресурсы. - /// - /// истинно, если управляемый ресурс должен быть удален; иначе ложно. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Код, автоматически созданный конструктором компонентов - - /// - /// Требуемый метод для поддержки конструктора — не изменяйте - /// содержимое этого метода с помощью редактора кода. - /// - private void InitializeComponent() - { - dataGridView1 = new DataGridView(); - ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); - SuspendLayout(); - // - // dataGridView1 - // - dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView1.Location = new Point(3, 3); - dataGridView1.Name = "dataGridView1"; - dataGridView1.Size = new Size(445, 363); - dataGridView1.TabIndex = 0; - // - // ValueTableControl - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - Controls.Add(dataGridView1); - Name = "ValueTableControl"; - Size = new Size(451, 369); - ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); - ResumeLayout(false); - } - - #endregion - - private DataGridView dataGridView1; - } -} diff --git a/KopLab1/FormLibrary/ValueTableControl.cs b/KopLab1/FormLibrary/ValueTableControl.cs deleted file mode 100644 index 2e582b1..0000000 --- a/KopLab1/FormLibrary/ValueTableControl.cs +++ /dev/null @@ -1,107 +0,0 @@ -using FormLibrary.HelperClasses; -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 FormLibrary -{ - public partial class ValueTableControl : UserControl - { - public ValueTableControl() - { - InitializeComponent(); - ConfigureDataGridView(); - } - - private void ConfigureDataGridView() - { - dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView1.MultiSelect = false; - dataGridView1.RowHeadersVisible = false; - dataGridView1.AllowUserToAddRows = false; - - dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - } - - - public void ConfigureColumns(List<(string HeaderText, string DataPropertyName, float FillWeight)> columns) - { - dataGridView1.Columns.Clear(); - - foreach (var column in columns) - { - dataGridView1.Columns.Add(new DataGridViewTextBoxColumn - { - HeaderText = column.HeaderText, - DataPropertyName = column.DataPropertyName, - FillWeight = column.FillWeight - }); - } - } - - public void ClearRows() - { - dataGridView1.Rows.Clear(); - } - - public int SelectedRowIndex - { - get => dataGridView1.SelectedRows[0].Index; - set - { - if (value >= 0 && value < dataGridView1.Rows.Count) - { - dataGridView1.ClearSelection(); - dataGridView1.Rows[value].Selected = true; - } - } - } - - public T GetSelectedObject() where T : new() - { - if (dataGridView1.SelectedRows.Count == 0) - throw new InvalidOperationException("Нет выбранной строки."); - - var selectedRow = dataGridView1.SelectedRows[0]; - var obj = new T(); - - foreach (DataGridViewColumn column in dataGridView1.Columns) - { - var prop = typeof(T).GetProperty(column.DataPropertyName); - if (prop != null) - { - var value = selectedRow.Cells[column.Index].Value; - prop.SetValue(obj, Convert.ChangeType(value, prop.PropertyType)); - } - } - - return obj; - } - - public void FillData(List objects) - { - dataGridView1.Rows.Clear(); - - if (objects == null || !objects.Any()) - { - return; - } - - var properties = typeof(T).GetProperties(); - - foreach (var obj in objects) - { - var values = properties.Select(p => p.GetValue(obj, null)).ToArray(); - dataGridView1.Rows.Add(values); - } - } - - - } -} diff --git a/KopLab1/FormLibrary/ValueTableControl.resx b/KopLab1/FormLibrary/ValueTableControl.resx deleted file mode 100644 index 8b2ff64..0000000 --- a/KopLab1/FormLibrary/ValueTableControl.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/KopLab1/Forms/Forms.csproj b/KopLab1/Forms/Forms.csproj deleted file mode 100644 index 764e403..0000000 --- a/KopLab1/Forms/Forms.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - WinExe - net8.0-windows - enable - true - enable - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - \ No newline at end of file diff --git a/KopLab1/Forms/MainForm.Designer.cs b/KopLab1/Forms/MainForm.Designer.cs deleted file mode 100644 index 900d0bc..0000000 --- a/KopLab1/Forms/MainForm.Designer.cs +++ /dev/null @@ -1,225 +0,0 @@ -namespace Forms -{ - partial class MainForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - components = new System.ComponentModel.Container(); - customListBox1 = new FormLibrary.CustomListBox(); - button1 = new Button(); - button2 = new Button(); - integerInputControl1 = new FormLibrary.IntegerInputControl(); - button3 = new Button(); - button4 = new Button(); - textBox1 = new TextBox(); - valueTableControl1 = new FormLibrary.ValueTableControl(); - button5 = new Button(); - button6 = new Button(); - button7 = new Button(); - pdfTable1 = new FormLibrary.PDFTable(components); - button8 = new Button(); - pdfTableCustom1 = new FormLibrary.PDFTableCustom(components); - button9 = new Button(); - button11 = new Button(); - componentHistogramToPdf1 = new FormLibrary.ComponentHistogramToPdf(components); - SuspendLayout(); - // - // customListBox1 - // - customListBox1.Location = new Point(12, 12); - customListBox1.Name = "customListBox1"; - customListBox1.city = ""; - customListBox1.Size = new Size(237, 176); - customListBox1.TabIndex = 0; - // - // button1 - // - button1.Location = new Point(12, 194); - button1.Name = "button1"; - button1.Size = new Size(237, 34); - button1.TabIndex = 1; - button1.Text = "Заполнить список"; - button1.UseVisualStyleBackColor = true; - button1.Click += ButtonLoad_Click; - // - // button2 - // - button2.Location = new Point(12, 234); - button2.Name = "button2"; - button2.Size = new Size(237, 34); - button2.TabIndex = 2; - button2.Text = "Очистить список"; - button2.UseVisualStyleBackColor = true; - button2.Click += ButtonClear_Click; - // - // integerInputControl1 - // - integerInputControl1.Location = new Point(329, 12); - integerInputControl1.Name = "integerInputControl1"; - integerInputControl1.Size = new Size(146, 56); - integerInputControl1.TabIndex = 3; - // - // button3 - // - button3.Location = new Point(361, 74); - button3.Name = "button3"; - button3.Size = new Size(103, 23); - button3.TabIndex = 4; - button3.Text = "Set"; - button3.UseVisualStyleBackColor = true; - button3.Click += buttonInput_Click; - // - // button4 - // - button4.Location = new Point(361, 103); - button4.Name = "button4"; - button4.Size = new Size(103, 23); - button4.TabIndex = 5; - button4.Text = "Get"; - button4.UseVisualStyleBackColor = true; - button4.Click += buttonOutput_Click; - // - // textBox1 - // - textBox1.Location = new Point(329, 132); - textBox1.Name = "textBox1"; - textBox1.Size = new Size(135, 23); - textBox1.TabIndex = 6; - // - // valueTableControl1 - // - valueTableControl1.Location = new Point(487, 12); - valueTableControl1.Name = "valueTableControl1"; - valueTableControl1.Size = new Size(450, 369); - valueTableControl1.TabIndex = 7; - // - // button5 - // - button5.Location = new Point(487, 387); - button5.Name = "button5"; - button5.Size = new Size(159, 51); - button5.TabIndex = 8; - button5.Text = "Заполнить таблицу"; - button5.UseVisualStyleBackColor = true; - button5.Click += ButtonFillTable_Click; - // - // button6 - // - button6.Location = new Point(652, 387); - button6.Name = "button6"; - button6.Size = new Size(134, 51); - button6.TabIndex = 9; - button6.Text = "Очистить таблицу"; - button6.UseVisualStyleBackColor = true; - button6.Click += ButtonClearTable_Click; - // - // button7 - // - button7.Location = new Point(792, 387); - button7.Name = "button7"; - button7.Size = new Size(148, 51); - button7.TabIndex = 10; - button7.Text = "Get"; - button7.UseVisualStyleBackColor = true; - button7.Click += ButtonShowData_Click; - // - // button8 - // - button8.Location = new Point(26, 481); - button8.Name = "button8"; - button8.Size = new Size(139, 23); - button8.TabIndex = 11; - button8.Text = "Create PDF"; - button8.UseVisualStyleBackColor = true; - button8.Click += GeneratePdfButton_Click; - // - // button9 - // - button9.Location = new Point(189, 481); - button9.Name = "button9"; - button9.Size = new Size(139, 23); - button9.TabIndex = 12; - button9.Text = "Create customPDF"; - button9.UseVisualStyleBackColor = true; - button9.Click += btnGeneratePDF_Click; - // - // button11 - // - button11.Location = new Point(347, 481); - button11.Name = "button11"; - button11.Size = new Size(139, 23); - button11.TabIndex = 13; - button11.Text = "Create Histogram PDF"; - button11.UseVisualStyleBackColor = true; - button11.Click += btnGenerateHistogrammPdf_Click; - // - // MainForm - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(944, 625); - Controls.Add(button11); - Controls.Add(button9); - Controls.Add(button8); - Controls.Add(button7); - Controls.Add(button6); - Controls.Add(button5); - Controls.Add(valueTableControl1); - Controls.Add(textBox1); - Controls.Add(button4); - Controls.Add(button3); - Controls.Add(integerInputControl1); - Controls.Add(button2); - Controls.Add(button1); - Controls.Add(customListBox1); - Name = "MainForm"; - Text = "MainForm"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private FormLibrary.CustomListBox customListBox1; - private Button button1; - private Button button2; - private FormLibrary.IntegerInputControl integerInputControl1; - private Button button3; - private Button button4; - private TextBox textBox1; - private FormLibrary.ValueTableControl valueTableControl1; - private Button button5; - private Button button6; - private Button button7; - private FormLibrary.PDFTable pdfTable1; - private Button button8; - private FormLibrary.PDFTableCustom pdfTableCustom1; - private Button button9; - private Button button11; - private FormLibrary.ComponentHistogramToPdf componentHistogramToPdf1; - } -} \ No newline at end of file diff --git a/KopLab1/Forms/MainForm.cs b/KopLab1/Forms/MainForm.cs deleted file mode 100644 index 80b775e..0000000 --- a/KopLab1/Forms/MainForm.cs +++ /dev/null @@ -1,219 +0,0 @@ -using FormLibrary; -using FormLibrary.Exceptions; -using FormLibrary.HelperClasses; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.Windows.Forms.VisualStyles; -using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header; -using OxyPlot.Legends; - -namespace Forms -{ - public partial class MainForm : Form - { - private int? savedValue; - public MainForm() - { - InitializeComponent(); - customListBox1.cityChanged += CustomListBox1_cityChanged; - integerInputControl1.ValueChanged += IntegerInputControl1_ValueChanged; - integerInputControl1.CheckBoxChanged += IntegerInputControl_CheckBoxChanged; - } - - private void CustomListBox1_cityChanged(object? sender, EventArgs e) - { - if (sender is CustomListBox customListBox) - { - string city = customListBox.city; - MessageBox.Show($"Выбранный элемент: {city}", "Выбор элемента", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - private void ButtonLoad_Click(object? sender, EventArgs e) - { - List items = new List(); - for (int i = 0; i <= 5; i++) - { - items.Add("Item " + i.ToString()); - } - - customListBox1.PopulateListBox(items); - } - - private void ButtonClear_Click(object? sender, EventArgs e) - { - customListBox1.ClearListBox(); - } - private void buttonInput_Click(object sender, EventArgs e) - { - try - { - savedValue = integerInputControl1.Value; - MessageBox.Show("Значение успешно сохранено.", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - catch (EmptyValueException ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - catch (InvalidValueTypeException ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void buttonOutput_Click(object sender, EventArgs e) - { - if (savedValue.HasValue) - { - MessageBox.Show($"Сохраненное значение: {savedValue}", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - else - { - MessageBox.Show("Сохраненное значение: null", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - private void IntegerInputControl1_ValueChanged(object? sender, EventArgs e) - { - textBox1.Text = "Textbox changed"; - } - - private void IntegerInputControl_CheckBoxChanged(object? sender, EventArgs e) - { - textBox1.Text = "Checkbox changed"; - } - private void ButtonFillTable_Click(object sender, EventArgs e) - { - var columns = new List<(string HeaderText, string DataPropertyName, float FillWeight)> - { - ("Группа", "Group", 30), - ("ФИО", "FullName", 50), - ("Курс", "Course", 20) - }; - valueTableControl1.ConfigureColumns(columns); - - var students = new List - { - new Student { Group = "Пибд-33", FullName = "Иванов Иван Иванович", Course = 3 }, - new Student { Group = "Пибд-33", FullName = "Петров Петр Петрович", Course = 2 }, - new Student { Group = "Пибд-33", FullName = "Антонов Антон Антонович", Course = 1 } - }; - - valueTableControl1.FillData(students); - } - - private void ButtonClearTable_Click(object sender, EventArgs e) - { - valueTableControl1.ClearRows(); - } - - private void ButtonShowData_Click(object sender, EventArgs e) - { - try - { - var selectedStudent = valueTableControl1.GetSelectedObject(); - MessageBox.Show($"Группа: {selectedStudent.Group}, ФИО: {selectedStudent.FullName}, Курс: {selectedStudent.Course}", - "Выбранный студент", - MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - catch (InvalidOperationException ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void GeneratePdfButton_Click(object sender, EventArgs e) - { - try - { - var pdfData = new PdfDocumentData( - "E:\\Отчет1.pdf", - "Название документа", - new List - { - new string[,] - { - { "Ячейка 1", "Ячейка 2", "Ячейка 3" }, - { "Ячейка 4", "Ячейка 5", "Ячейка 6" } - }, - new string[,] - { - { "Ячейка 1", "Ячейка 2" }, - { "Ячейка 1", "Ячейка 2" } - } - }); - - var documentGenerator = new PDFTable(); - documentGenerator.GeneratePdf(pdfData); - - MessageBox.Show("PDF-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - catch (Exception ex) - { - MessageBox.Show($"Произошла ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void btnGeneratePDF_Click(object sender, EventArgs e) - { - var settings = new PDFTableSettings - { - FilePath = "E:\\Отчет2.pdf", - DocumentTitle = "Отчет по студентам", - HeaderRowHeight = 1.0f, - DataRowHeight = 1.0f, - DataList = new List - { - new Student { Number = 1, Group = "Пибд-33", FullName = "Иван Иванов", Course = 3 }, - new Student { Number = 2, Group = "Пибд-33", FullName = "Петр Петров", Course = 2 }, - new Student { Number = 3, Group = "Пибд-34", FullName = "Алексей Сидоров", Course = 4 } - }, - Columns = new List<(string, float, string, int)> - { - ("№", 1.0f, nameof(Student.Number), 0), - ("Группа", 4.0f, nameof(Student.Group), 1), - ("ФИО", 6.0f, nameof(Student.FullName), 2), - ("Курс", 2.0f, nameof(Student.Course), 3) - } - }; - - try - { - pdfTableCustom1.GeneratePDFWithHead(settings); - MessageBox.Show("PDF-документ успешно создан!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - catch (Exception ex) - { - MessageBox.Show($"Ошибка: {ex.Message}"); - } - } - private void btnGenerateHistogrammPdf_Click(object sender, EventArgs e) - { - try - { - var histogramGenerator = new ComponentHistogramToPdf(); - - var chartData = new List - { - new ChartData { SeriesName = "Серияd 1", Data = new Dictionary { { "Категорияz 1", 5 }, { "Категорияx 2", 10 } } }, - new ChartData { SeriesName = "Серияs 2", Data = new Dictionary { { "Категорияa 1", 3 }, { "Категорияs 2", 8 } } }, - new ChartData { SeriesName = "Серияs 3", Data = new Dictionary { { "Категорияa 1", 3 }, { "Категорияs 2", 8 } } } - }; - - string filePath = "E:\\Гистограмма.pdf"; - - histogramGenerator.CreateHistogramPdf(filePath, "Название документа", "Заголовок гистограммы", LegendPosition.BottomCenter, chartData); - - MessageBox.Show("PDF успешно сгенерирован!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - catch (Exception ex) - { - MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } -} diff --git a/KopLab1/Forms/MainForm.resx b/KopLab1/Forms/MainForm.resx deleted file mode 100644 index 3618ad6..0000000 --- a/KopLab1/Forms/MainForm.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 122, 17 - - - 269, 17 - - \ No newline at end of file diff --git a/KopLab1/Forms/Program.cs b/KopLab1/Forms/Program.cs deleted file mode 100644 index a71be2f..0000000 --- a/KopLab1/Forms/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Text; - -namespace Forms -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - ApplicationConfiguration.Initialize(); - Application.Run(new MainForm()); - } - } -} \ No newline at end of file diff --git a/KopLab1/Lab3Form/FormMain.Designer.cs b/KopLab1/Lab3Form/FormMain.Designer.cs index fa403c5..a053cc5 100644 --- a/KopLab1/Lab3Form/FormMain.Designer.cs +++ b/KopLab1/Lab3Form/FormMain.Designer.cs @@ -40,8 +40,7 @@ документСДиаграммойToolStripMenuItem = new ToolStripMenuItem(); выбранныеТоварыToolStripMenuItem = new ToolStripMenuItem(); controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable(); - excelImagesComponent = new WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent(components); - componentDocumentWithTableMultiHeaderWord = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderWord(components); + pdfTable1 = new FormLibrary.PDFTable(components); menuStrip.SuspendLayout(); SuspendLayout(); // @@ -167,7 +166,6 @@ private ToolStripMenuItem выбранныеТоварыToolStripMenuItem; private ToolStripMenuItem документСДиаграммойToolStripMenuItem; private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable; - private WinFormsLibraryVolkov.NonVisualComponents.ExcelImagesComponent excelImagesComponent; - private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableMultiHeaderWord componentDocumentWithTableMultiHeaderWord; + private FormLibrary.PDFTable pdfTable1; } } \ No newline at end of file diff --git a/KopLab1/Lab3Form/FormMain.cs b/KopLab1/Lab3Form/FormMain.cs index e9cd1a7..2198f3a 100644 --- a/KopLab1/Lab3Form/FormMain.cs +++ b/KopLab1/Lab3Form/FormMain.cs @@ -46,18 +46,14 @@ namespace Lab3Form var orders = _logic.ReadList(null); if (orders != null) { - // Преобразуем List в строку для отображения var displayOrders = orders.Select(order => new { order.Id, order.Fullname, order.DestinationCityName, - // Преобразуем OrderStatusHistory в строку OrderStatusHistory = string.Join(", ", order.OrderStatusHistory), order.ExpectedDeliveryDate }).ToList(); - - // Передаем преобразованный список в таблицу controlDataTable.AddTable(displayOrders); } } @@ -92,22 +88,17 @@ namespace Lab3Form private void удалитьToolStripMenuItem_Click(object sender, EventArgs e) { - // Получаем выбранный объект var selectedOrder = controlDataTable.GetSelectedObject(); if (selectedOrder == null) { MessageBox.Show("Не выбрана запись для удаления."); return; } - - // Подтверждение удаления if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { - // Вызываем метод Delete, передавая модель с ID var isDeleted = _logic.Delete(new OrderBindingModel { Id = selectedOrder.Id ?? 0 }); if (isDeleted) { - // Если удаление успешно, обновляем данные LoadData(); MessageBox.Show("Запись успешно удалена."); } @@ -123,7 +114,7 @@ namespace Lab3Form { List orderImages = new List(); string path = AppDomain.CurrentDomain.BaseDirectory + "Фотокарточки заказов с интернет-магазина.xlsx"; - if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фотокарточки заказов", orderImages.ToArray()))) MessageBox.Show("Документ был создан"); + //if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Фотокарточки заказов", orderImages.ToArray()))) MessageBox.Show("Документ был создан"); } private void документСТаблицейToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/KopLab1/Lab3Form/FormMain.resx b/KopLab1/Lab3Form/FormMain.resx index 8743b19..4282b87 100644 --- a/KopLab1/Lab3Form/FormMain.resx +++ b/KopLab1/Lab3Form/FormMain.resx @@ -120,11 +120,8 @@ 17, 17 - - 138, 17 - - - 347, 18 + + 126, 17 177 diff --git a/KopLab1/Lab3Form/FormOrder.Designer.cs b/KopLab1/Lab3Form/FormOrder.Designer.cs index c590a9c..7816ff7 100644 --- a/KopLab1/Lab3Form/FormOrder.Designer.cs +++ b/KopLab1/Lab3Form/FormOrder.Designer.cs @@ -31,12 +31,12 @@ labelFIO = new Label(); textBoxFIO = new TextBox(); labelcity = new Label(); - customSelectedCheckedListBox = new WinFormsLibraryVolkov.CustomSelectedCheckedListBox(); buttonCancel = new Button(); buttonSave = new Button(); openFileDialog = new OpenFileDialog(); label1 = new Label(); label2 = new Label(); + customListBox1 = new FormLibrary.CustomListBox(); customInputRangeDate1 = new WinFormsLibraryVolkov.CustomInputRangeDate(); listBox1 = new ListBox(); SuspendLayout(); @@ -55,7 +55,7 @@ textBoxFIO.Location = new Point(10, 24); textBoxFIO.Margin = new Padding(3, 2, 3, 2); textBoxFIO.Name = "textBoxFIO"; - textBoxFIO.Size = new Size(277, 23); + textBoxFIO.Size = new Size(241, 23); textBoxFIO.TabIndex = 1; // // labelcity @@ -67,17 +67,9 @@ labelcity.TabIndex = 4; labelcity.Text = "Город назначения"; // - // customSelectedCheckedListBox - // - customSelectedCheckedListBox.Location = new Point(10, 81); - customSelectedCheckedListBox.Name = "customSelectedCheckedListBox"; - customSelectedCheckedListBox.SelectedElement = ""; - customSelectedCheckedListBox.Size = new Size(277, 65); - customSelectedCheckedListBox.TabIndex = 5; - // // buttonCancel // - buttonCancel.Location = new Point(204, 323); + buttonCancel.Location = new Point(161, 414); buttonCancel.Margin = new Padding(3, 2, 3, 2); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(83, 21); @@ -87,7 +79,7 @@ // // buttonSave // - buttonSave.Location = new Point(10, 325); + buttonSave.Location = new Point(7, 414); buttonSave.Margin = new Padding(3, 2, 3, 2); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(94, 21); @@ -104,7 +96,7 @@ // label1 // label1.AutoSize = true; - label1.Location = new Point(10, 262); + label1.Location = new Point(10, 360); label1.Name = "label1"; label1.Size = new Size(132, 15); label1.TabIndex = 10; @@ -113,43 +105,51 @@ // label2 // label2.AutoSize = true; - label2.Location = new Point(10, 172); + label2.Location = new Point(10, 264); label2.Name = "label2"; label2.Size = new Size(123, 15); label2.TabIndex = 12; label2.Text = "Точки передвижения"; // + // customListBox1 + // + customListBox1.Location = new Point(10, 80); + customListBox1.Name = "customListBox1"; + customListBox1.SelectedItem = ""; + customListBox1.Size = new Size(237, 179); + customListBox1.TabIndex = 17; + // // customInputRangeDate1 // - customInputRangeDate1.Location = new Point(10, 280); + customInputRangeDate1.Location = new Point(10, 378); customInputRangeDate1.MaxDate = new DateTime(0L); customInputRangeDate1.MinDate = new DateTime(0L); customInputRangeDate1.Name = "customInputRangeDate1"; - customInputRangeDate1.Size = new Size(277, 40); - customInputRangeDate1.TabIndex = 13; + customInputRangeDate1.Size = new Size(199, 31); + customInputRangeDate1.TabIndex = 18; // // listBox1 // listBox1.FormattingEnabled = true; listBox1.ItemHeight = 15; - listBox1.Location = new Point(10, 190); + listBox1.Location = new Point(13, 282); listBox1.Name = "listBox1"; listBox1.SelectionMode = SelectionMode.MultiExtended; - listBox1.Size = new Size(277, 64); - listBox1.TabIndex = 14; + listBox1.Size = new Size(231, 64); + listBox1.TabIndex = 19; // // FormOrder // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(299, 355); + ClientSize = new Size(256, 459); Controls.Add(listBox1); Controls.Add(customInputRangeDate1); + Controls.Add(customListBox1); Controls.Add(label2); Controls.Add(label1); Controls.Add(buttonSave); Controls.Add(buttonCancel); - Controls.Add(customSelectedCheckedListBox); Controls.Add(labelcity); Controls.Add(textBoxFIO); Controls.Add(labelFIO); @@ -165,12 +165,12 @@ private Label labelFIO; private TextBox textBoxFIO; private Label labelcity; - private WinFormsLibraryVolkov.CustomSelectedCheckedListBox customSelectedCheckedListBox; private Button buttonCancel; private Button buttonSave; private OpenFileDialog openFileDialog; private Label label1; private Label label2; + private FormLibrary.CustomListBox customListBox1; private WinFormsLibraryVolkov.CustomInputRangeDate customInputRangeDate1; private ListBox listBox1; } diff --git a/KopLab1/Lab3Form/FormOrder.cs b/KopLab1/Lab3Form/FormOrder.cs index e2238bd..df66dab 100644 --- a/KopLab1/Lab3Form/FormOrder.cs +++ b/KopLab1/Lab3Form/FormOrder.cs @@ -29,7 +29,7 @@ namespace Lab3Form _Cities = new List(); _Cities = _cityLogic.ReadList(null); var cityNames = _Cities.Select(city => city.Name).ToList(); - customSelectedCheckedListBox.PopulateList(cityNames); + customListBox1.PopulateListBox(cityNames); var orderStatuses = new List { "Создан", "Подтвержден", "Отправлен", "Доставлен" }; listBox1.Items.AddRange(orderStatuses.ToArray()); DateTime now = DateTime.Now; @@ -43,7 +43,7 @@ namespace Lab3Form { MessageBox.Show("Заполните ФИО заказчика", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } - if (customSelectedCheckedListBox.SelectedElement == null) + if (customListBox1.SelectedItem == null) { MessageBox.Show("Укажите город назначения", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -53,7 +53,7 @@ namespace Lab3Form { Id = _id ?? 0, Fullname = textBoxFIO.Text, - DestinationCityId = _Cities.First(x => x.Name == customSelectedCheckedListBox.SelectedElement).Id, + DestinationCityId = _Cities.First(x => x.Name == customListBox1.SelectedItem).Id, ExpectedDeliveryDate = customInputRangeDate1.Date, OrderStatusHistory = listBox1.SelectedItems.Cast().ToList(), }; diff --git a/KopLab1/Lab3Form/Lab3Form.csproj b/KopLab1/Lab3Form/Lab3Form.csproj index b09d564..45d1f18 100644 --- a/KopLab1/Lab3Form/Lab3Form.csproj +++ b/KopLab1/Lab3Form/Lab3Form.csproj @@ -12,6 +12,7 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive