diff --git a/WinFormsProject/WinFormsLibrary/CircleDiagram.Designer.cs b/WinFormsProject/WinFormsLibrary/CircleDiagram.Designer.cs new file mode 100644 index 0000000..ec31c0a --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/CircleDiagram.Designer.cs @@ -0,0 +1,36 @@ +namespace WinFormsLibrary +{ + partial class CircleDiagram + { + /// + /// Обязательная переменная конструктора. + /// + 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/WinFormsProject/WinFormsLibrary/CircleDiagram.cs b/WinFormsProject/WinFormsLibrary/CircleDiagram.cs new file mode 100644 index 0000000..c3b1675 --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/CircleDiagram.cs @@ -0,0 +1,93 @@ +using Aspose.Words.Drawing.Charts; +using Aspose.Words; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WinFormsLibrary.SupportClasses; +using Aspose.Words.Drawing; + +namespace WinFormsLibrary +{ + public partial class CircleDiagram : Component + { + public CircleDiagram() + { + InitializeComponent(); + } + + public CircleDiagram(IContainer container) + { + container.Add(this); + + InitializeComponent(); + } + + public void AddCircleDiagram(SimpleCircleDiagram simpleCircleDiagram) + { + if (!CheckData(simpleCircleDiagram.DataList)) + { + throw new Exception("Данные не заполнены"); + } + + Document doc = new Document(); + DocumentBuilder builder = new DocumentBuilder(doc); + + Aspose.Words.Font font = builder.Font; + font.Size = 24; + font.Bold = true; + font.Color = Color.Black; + font.Name = "Times New Roman"; + + ParagraphFormat paragraphFormat = builder.ParagraphFormat; + paragraphFormat.FirstLineIndent = 8; + paragraphFormat.SpaceAfter = 24; + paragraphFormat.Alignment = ParagraphAlignment.Center; + paragraphFormat.KeepTogether = true; + + builder.Writeln(simpleCircleDiagram.FileHeader); + + Shape shape = builder.InsertChart(ChartType.Pie, 500, 270); + + Chart chart = shape.Chart; + + chart.Title.Text = simpleCircleDiagram.CircleDiagramName; + + ChartSeries series = chart.Series[0]; + + ChartSeriesCollection seriesColl = chart.Series; + + Console.WriteLine(seriesColl.Count); + + seriesColl.Clear(); + + foreach (var data in simpleCircleDiagram.DataList) + { + seriesColl.Add(data.NameSeries, data.NameData, data.Data); + } + + ChartLegend legend = chart.Legend; + + legend.Position = (LegendPosition)simpleCircleDiagram.AreaLegend; + + legend.Overlay = true; + + doc.Save(simpleCircleDiagram.FilePath); + } + + static bool CheckData(List data) + { + foreach (var _data in data) + { + if (string.IsNullOrEmpty(_data.NameData.ToString()) || string.IsNullOrEmpty(_data.Data.ToString())) + { + return false; + } + } + return true; + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/DocumentWithImage.Designer.cs b/WinFormsProject/WinFormsLibrary/DocumentWithImage.Designer.cs new file mode 100644 index 0000000..6a12b7d --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/DocumentWithImage.Designer.cs @@ -0,0 +1,36 @@ +namespace WinFormsLibrary +{ + partial class DocumentWithImage + { + /// + /// Обязательная переменная конструктора. + /// + 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/WinFormsProject/WinFormsLibrary/DocumentWithImage.cs b/WinFormsProject/WinFormsLibrary/DocumentWithImage.cs new file mode 100644 index 0000000..f7dfaf7 --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/DocumentWithImage.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Drawing; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Wordprocessing; +using A = DocumentFormat.OpenXml.Drawing; +using DW = DocumentFormat.OpenXml.Drawing.Wordprocessing; +using PIC = DocumentFormat.OpenXml.Drawing.Pictures; +using Paragraph = DocumentFormat.OpenXml.Wordprocessing.Paragraph; +using Text = DocumentFormat.OpenXml.Wordprocessing.Text; +using Run = DocumentFormat.OpenXml.Wordprocessing.Run; +using WinFormsLibrary.SupportClasses; + +namespace WinFormsLibrary +{ + public partial class DocumentWithImage : Component + { + private WordprocessingDocument? _wordDocument; + + private Body? _docBody; + + public DocumentWithImage() + { + InitializeComponent(); + } + + public DocumentWithImage(IContainer container) + { + container.Add(this); + + InitializeComponent(); + } + + public void CreateDocument(ImageClass imageClass) + { + // Проверка наличия данных + if (string.IsNullOrEmpty(imageClass.Path) || string.IsNullOrEmpty(imageClass.Title) || imageClass.Files.Count == 0) + { + throw new Exception("Не все данные заполнены"); + } + + // Создаем Word-документ + using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(imageClass.Path, WordprocessingDocumentType.Document)) + { + MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); + mainPart.Document = new Document(); + Body body = new Body(); + + // Добавляем заголовок + Paragraph titleParagraph = new Paragraph(new Run(new Text(imageClass.Title))); + body.Append(titleParagraph); + + // Добавляем изображения + foreach (string imagePath in imageClass.Files) + { + if (File.Exists(imagePath)) + { + ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg); + using (FileStream stream = new FileStream(imagePath, FileMode.Open)) + { + imagePart.FeedData(stream); + } + + AddImageToBody(wordDocument, mainPart.GetIdOfPart(imagePart)); + } + else + { + Console.WriteLine($"Изображение '{imagePath}' не найдено."); + } + } + + mainPart.Document.Append(body); + Console.WriteLine($"Word-документ успешно создан в файле '{imageClass.Path}'."); + } + } + + private void AddImageToBody(WordprocessingDocument wordDoc, string relationshipId) + { + var element = + new Drawing( + new DW.Inline( + new DW.Extent() { Cx = 990000L, Cy = 792000L }, + new DW.EffectExtent() + { + LeftEdge = 0L, + TopEdge = 0L, + RightEdge = 0L, + BottomEdge = 0L + }, + new DW.DocProperties() + { + Id = (UInt32Value)1U, + Name = "Picture 1" + }, + new DW.NonVisualGraphicFrameDrawingProperties( + new A.GraphicFrameLocks() { NoChangeAspect = true }), + new A.Graphic( + new A.GraphicData( + new PIC.Picture( + new PIC.NonVisualPictureProperties( + new PIC.NonVisualDrawingProperties() + { + Id = (UInt32Value)0U, + Name = "New Bitmap Image.jpg" + }, + new PIC.NonVisualPictureDrawingProperties()), + new PIC.BlipFill( + new A.Blip( + new A.BlipExtensionList( + new A.BlipExtension() + { + Uri = + "{28A0092B-C50C-407E-A947-70E740481C1C}" + }) + ) + { + Embed = relationshipId, + CompressionState = + A.BlipCompressionValues.Print + }, + new A.Stretch( + new A.FillRectangle())), + new PIC.ShapeProperties( + new A.Transform2D( + new A.Offset() { X = 0L, Y = 0L }, + new A.Extents() { Cx = 990000L, Cy = 792000L }), + new A.PresetGeometry( + new A.AdjustValueList() + ) { Preset = A.ShapeTypeValues.Rectangle })) + ) { Uri = "http://schemas.openxmlformats.org/drawingml/2006/picture" }) + ) + { + DistanceFromTop = (UInt32Value)0U, + DistanceFromBottom = (UInt32Value)0U, + DistanceFromLeft = (UInt32Value)0U, + DistanceFromRight = (UInt32Value)0U, + EditId = "50D07946" + }); + + // Append the reference to the body. The element should be in + // a DocumentFormat.OpenXml.Wordprocessing.Run. + wordDoc.MainDocumentPart.Document.Body.AppendChild(new Paragraph(new Run(element))); + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/SupportClasses/BigTable.cs b/WinFormsProject/WinFormsLibrary/SupportClasses/BigTable.cs new file mode 100644 index 0000000..40e31ea --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/SupportClasses/BigTable.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinFormsLibrary.SupportClasses +{ + public class BigTable + { + public string FilePath = string.Empty; + + public string DocumentTitle = string.Empty; + + public List ColumnDefinitions; + public List ColumnDefinitions2; + + public List Data; + + public List MergedColumns; + public BigTable(string filePath, string documentTitle, List columnDefinitions, List columnDefinitions2, List data, List mergedColumns) + { + FilePath = filePath; + DocumentTitle = documentTitle; + ColumnDefinitions = columnDefinitions; + Data = data; + MergedColumns = mergedColumns; + ColumnDefinitions2 = columnDefinitions2; + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/SupportClasses/ColumnDefinition.cs b/WinFormsProject/WinFormsLibrary/SupportClasses/ColumnDefinition.cs new file mode 100644 index 0000000..d374bc9 --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/SupportClasses/ColumnDefinition.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinFormsLibrary.SupportClasses +{ + public class ColumnDefinition + { + public string Header; + public string PropertyName; + public double Weight; + } +} diff --git a/WinFormsProject/WinFormsLibrary/SupportClasses/DataCircleDiagram.cs b/WinFormsProject/WinFormsLibrary/SupportClasses/DataCircleDiagram.cs new file mode 100644 index 0000000..a3eb2a7 --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/SupportClasses/DataCircleDiagram.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinFormsLibrary.SupportClasses +{ + public class DataCircleDiagram + { + public string NameSeries { get; set; } = string.Empty; + public string[] NameData { get; set; } + public double[] Data { get; set; } + + public DataCircleDiagram(string nameSeries, string[] nameData, double[] data) + { + NameSeries = nameSeries; + NameData = nameData; + Data = data; + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/SupportClasses/Enums/EnumAreaLegend.cs b/WinFormsProject/WinFormsLibrary/SupportClasses/Enums/EnumAreaLegend.cs new file mode 100644 index 0000000..1a5d714 --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/SupportClasses/Enums/EnumAreaLegend.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinFormsLibrary.SupportClasses.Enums +{ + public enum EnumAreaLegend + { + None, + + Left, + + Top, + + Right, + + Bottom, + + TopRight + } +} diff --git a/WinFormsProject/WinFormsLibrary/SupportClasses/ImageClass.cs b/WinFormsProject/WinFormsLibrary/SupportClasses/ImageClass.cs new file mode 100644 index 0000000..af0af8c --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/SupportClasses/ImageClass.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinFormsLibrary.SupportClasses +{ + public class ImageClass + { + private string path; + private string title; + private List files; + public string Path { get { return path; } set { path = value; } } + public string Title { get { return title; } set { title = value; } } + public List Files { get { return files; } set { files = value; } } + public ImageClass() { } + + public ImageClass(string filePath, string documentTitle, List textData) + { + Path = filePath; + Title = documentTitle; + Files = textData; + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/SupportClasses/SimpleCircleDiagram.cs b/WinFormsProject/WinFormsLibrary/SupportClasses/SimpleCircleDiagram.cs new file mode 100644 index 0000000..26bc56b --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/SupportClasses/SimpleCircleDiagram.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WinFormsLibrary.SupportClasses.Enums; + +namespace WinFormsLibrary.SupportClasses +{ + public class SimpleCircleDiagram + { + public string FileHeader { get; set; } = string.Empty; + public string CircleDiagramName { get; set; } = string.Empty; + public List DataList { get; set; } = new(); + public string FilePath { get; set; } = string.Empty; + public EnumAreaLegend AreaLegend { get; set; } + + public SimpleCircleDiagram(string filePath, string fileHeader, string circleDiagramName, EnumAreaLegend areaLegend, List dataList) + { + FilePath = filePath; + FileHeader = fileHeader; + CircleDiagramName = circleDiagramName; + AreaLegend = areaLegend; + DataList = dataList; + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/SupportClasses/Student.cs b/WinFormsProject/WinFormsLibrary/SupportClasses/Student.cs new file mode 100644 index 0000000..b774a04 --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/SupportClasses/Student.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinFormsLibrary.SupportClasses +{ + public class Student + { + public string Name { get; set; } + public string Group { get; set; } + public string Faculty { get; set; } + public int Course { get; set; } + + public Student(string name, string group, string faculty, int course) + { + Name = name; + Group = group; + Faculty = faculty; + Course = course; + } + public Student() + { + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/Table2column.Designer.cs b/WinFormsProject/WinFormsLibrary/Table2column.Designer.cs new file mode 100644 index 0000000..916184a --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/Table2column.Designer.cs @@ -0,0 +1,36 @@ +namespace WinFormsLibrary +{ + partial class Table2column + { + /// + /// Обязательная переменная конструктора. + /// + 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/WinFormsProject/WinFormsLibrary/Table2column.cs b/WinFormsProject/WinFormsLibrary/Table2column.cs new file mode 100644 index 0000000..766c75f --- /dev/null +++ b/WinFormsProject/WinFormsLibrary/Table2column.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Words; +using Aspose.Words.Tables; +using WinFormsLibrary.SupportClasses; + +namespace WinFormsLibrary +{ + public partial class Table2column : Component + { + public Table2column() + { + InitializeComponent(); + } + + public Table2column(IContainer container) + { + container.Add(this); + + InitializeComponent(); + } + + public void CreateTable(BigTable bigTable) + { + if (bigTable.Data == null) + { + throw new ArgumentException("Не заданы все данные"); + } + + foreach (var columnDefinition in bigTable.ColumnDefinitions) + { + if (string.IsNullOrEmpty(columnDefinition.PropertyName)) + { + throw new ArgumentException($"Не задано свойство столбца: {columnDefinition.Header}"); + } + } + + Document document = new Document(); + DocumentBuilder builder = new DocumentBuilder(document); + + Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title"); + titleStyle.Font.Size = 16; + titleStyle.Font.Bold = true; + + builder.ParagraphFormat.Style = titleStyle; + builder.Writeln(bigTable.DocumentTitle); + + Table table = builder.StartTable(); + + + foreach (var columnDefinition in bigTable.ColumnDefinitions) + { + builder.InsertCell(); + builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition.Weight); + builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; + builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; + builder.Write(columnDefinition.Header); + } + + foreach (var mergedColumn in bigTable.MergedColumns) + { + int startCellIndex = mergedColumn[0]; + int endCellIndex = mergedColumn[mergedColumn.Length - 1]; + + for (int i = startCellIndex; i <= endCellIndex; i++) + { + table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.First; + table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First; + } + + for (int i = startCellIndex + 1; i <= endCellIndex; i++) + { + table.Rows[0].Cells[i].CellFormat.HorizontalMerge = CellMerge.Previous; + table.Rows[0].Cells[i].CellFormat.VerticalMerge = CellMerge.First; + } + + + } + builder.EndRow(); + + foreach (var columnDefinition2 in bigTable.ColumnDefinitions2) + { + builder.InsertCell(); + builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnDefinition2.Weight); + builder.Write(columnDefinition2.Header); + } + + builder.EndRow(); + + int columnIndex; + foreach (var columnDefinition in bigTable.ColumnDefinitions) + { + string currentPropertyName = columnDefinition.PropertyName; + columnIndex = 0; + foreach (var columnDefinition2 in bigTable.ColumnDefinitions2) + { + string currentPropertyName1 = columnDefinition2.PropertyName; + + if (currentPropertyName == currentPropertyName1) + { + table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First; + table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous; + + } + columnIndex++; + } + } + + foreach (var item in bigTable.Data) + { + foreach (var columnDefinition2 in bigTable.ColumnDefinitions2) + { + builder.InsertCell(); + var propertyValue = item.GetType() + .GetProperty(columnDefinition2.PropertyName)? + .GetValue(item)?.ToString(); + + builder.Write(propertyValue ?? ""); + } + + builder.EndRow(); + } + + builder.EndTable(); + + document.Save(bigTable.FilePath); + } + } +} diff --git a/WinFormsProject/WinFormsLibrary/WinFormsLibrary.csproj b/WinFormsProject/WinFormsLibrary/WinFormsLibrary.csproj index 060aa1c..462f673 100644 --- a/WinFormsProject/WinFormsLibrary/WinFormsLibrary.csproj +++ b/WinFormsProject/WinFormsLibrary/WinFormsLibrary.csproj @@ -7,4 +7,9 @@ enable + + + + + diff --git a/WinFormsProject/WinFormsProject/Form1.cs b/WinFormsProject/WinFormsProject/Form1.cs index 42a0b78..ea5f9d2 100644 --- a/WinFormsProject/WinFormsProject/Form1.cs +++ b/WinFormsProject/WinFormsProject/Form1.cs @@ -7,7 +7,7 @@ namespace WinFormsProject public Form1() { InitializeComponent(); - customCheckedListBox1.FillCheckedListBox(list); + //customCheckedListBox1.FillCheckedListBox(list); customCheckedListBox1.ValueChanged += CustomEventHandler; } @@ -23,7 +23,7 @@ namespace WinFormsProject private void Button_Fill_Click(object sender, EventArgs e) { - customCheckedListBox1.FillCheckedListBox(list); + // customCheckedListBox1.FillCheckedListBox(list); } private void Button_GetChosenValues_Click(object sender, EventArgs e) diff --git a/WinFormsProject/WinFormsProject/Form2.Designer.cs b/WinFormsProject/WinFormsProject/Form2.Designer.cs new file mode 100644 index 0000000..90ae7d8 --- /dev/null +++ b/WinFormsProject/WinFormsProject/Form2.Designer.cs @@ -0,0 +1,128 @@ +namespace WinFormsProject +{ + partial class Form2 + { + /// + /// 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() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.button1 = new System.Windows.Forms.Button(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.button2 = new System.Windows.Forms.Button(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.button3 = new System.Windows.Forms.Button(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.button1); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(185, 71); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Работа с изображениями"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(56, 42); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 0; + this.button1.Text = "Создать"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.button2); + this.groupBox2.Location = new System.Drawing.Point(217, 12); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(185, 71); + this.groupBox2.TabIndex = 1; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Работа с таблицей"; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(57, 42); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 0; + this.button2.Text = "Создать"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.button3); + this.groupBox3.Location = new System.Drawing.Point(437, 12); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(185, 71); + this.groupBox3.TabIndex = 2; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Работа с диаграммой"; + // + // button3 + // + this.button3.Location = new System.Drawing.Point(56, 42); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(75, 23); + this.button3.TabIndex = 0; + this.button3.Text = "Создать"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // Form2 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(649, 95); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Name = "Form2"; + this.Text = "Form2"; + this.groupBox1.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox3.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBox1; + private Button button1; + private GroupBox groupBox2; + private Button button2; + private GroupBox groupBox3; + private Button button3; + } +} \ No newline at end of file diff --git a/WinFormsProject/WinFormsProject/Form2.cs b/WinFormsProject/WinFormsProject/Form2.cs new file mode 100644 index 0000000..68f58de --- /dev/null +++ b/WinFormsProject/WinFormsProject/Form2.cs @@ -0,0 +1,141 @@ +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 WinFormsLibrary.SupportClasses.Enums; +using WinFormsLibrary.SupportClasses; +using WinFormsLibrary; + +namespace WinFormsProject +{ + public partial class Form2 : Form + { + private List testArray; + DocumentWithImage documentWithImage; + Table2column table2column; + CircleDiagram circleDiagram; + + public Form2() + { + InitializeComponent(); + documentWithImage = new DocumentWithImage(); + table2column = new Table2column(); + circleDiagram = new CircleDiagram(); + } + + private void button1_Click(object sender, EventArgs e) + { + testArray = new List() { + "C:\\Users\\aleyc\\OneDrive\\Рабочий стол\\Images For Tets\\image_1.jpg", + "C:\\Users\\aleyc\\OneDrive\\Рабочий стол\\Images For Tets\\image_2.png", + }; + + //фильтрация файлов для диалогового окна + using var dialog = new SaveFileDialog + { + Filter = "docx|*.docx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + ImageClass imageClass = new(dialog.FileName, "Любой заголовок", testArray); + documentWithImage.CreateDocument(imageClass); + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void button2_Click(object sender, EventArgs e) + { + List mergedColumns = new() + { + new int[] { 0, 1, 2 } + }; + + + + List columnDefinitions = new List + { + new ColumnDefinition { Header = "Образование", PropertyName = "Eduction", Weight = 35 }, + new ColumnDefinition { Header = "", PropertyName = "Education1", Weight = 35 }, + new ColumnDefinition { Header = "", PropertyName = "Education2", Weight = 10 }, + new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 } + }; + + List columnDefinitions2 = new List + { + new ColumnDefinition { Header = "Группа", PropertyName = "Group", Weight = 35 }, + new ColumnDefinition { Header = "Факультатив", PropertyName = "Faculty", Weight = 35 }, + new ColumnDefinition { Header = "Курс", PropertyName = "Course", Weight = 10 }, + new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 } + }; + + List data = new List + { + new Student { Group = "ПИбд-32", Faculty = "ФИСТ", Course = 3, Name = "Васильев" }, + new Student { Group = "РТбд-11", Faculty = "РТФ", Course = 1, Name = "Иванов" }, + new Student { Group = "ЛМККбд-41", Faculty = "ГФ", Course = 4, Name = "Смирнова" } + }; + + using var dialog = new SaveFileDialog + { + Filter = "docx|*.docx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + BigTable bigTable = new(dialog.FileName, "Задание 2", columnDefinitions, columnDefinitions2, data, mergedColumns); + table2column.CreateTable(bigTable); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void button3_Click(object sender, EventArgs e) + { + //фильтрация файлов для диалогового окна + using var dialog = new SaveFileDialog + { + Filter = "docx|*.docx" + }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + string[] month = { "Январь", "Февраль", "Март" }; + double[] profit1 = { 300, 440, 270 }; + double[] profit2 = { 500, 620, 310 }; + double[] profit3 = { 420, 189, 430 }; + SimpleCircleDiagram simpleCircleDiagram = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List { + new DataCircleDiagram("Компания 1", month, profit1), new DataCircleDiagram("Компания 2", month, profit2), new DataCircleDiagram("Компания 3", month, profit3), + }); + + circleDiagram.AddCircleDiagram(simpleCircleDiagram); + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/WinFormsProject/WinFormsProject/Form2.resx b/WinFormsProject/WinFormsProject/Form2.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WinFormsProject/WinFormsProject/Form2.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/WinFormsProject/WinFormsProject/Program.cs b/WinFormsProject/WinFormsProject/Program.cs index cab0e2f..556a493 100644 --- a/WinFormsProject/WinFormsProject/Program.cs +++ b/WinFormsProject/WinFormsProject/Program.cs @@ -11,7 +11,7 @@ namespace WinFormsProject // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new Form2()); } } } \ No newline at end of file