Compare commits
11 Commits
main
...
LabWork_02
Author | SHA1 | Date | |
---|---|---|---|
|
c3424531c1 | ||
c7b0db4fa3 | |||
a17f19981a | |||
bc128a354f | |||
4c0882df61 | |||
4a5e7f9c0d | |||
2bfe317437 | |||
c90b181d85 | |||
5b17be9211 | |||
82f6fc6e49 | |||
c5f307ec81 |
36
WinFormsProject/WinFormsLibrary/CircleDiagram.Designer.cs
generated
Normal file
36
WinFormsProject/WinFormsLibrary/CircleDiagram.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
partial class CircleDiagram
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
105
WinFormsProject/WinFormsLibrary/CircleDiagram.cs
Normal file
105
WinFormsProject/WinFormsLibrary/CircleDiagram.cs
Normal file
@ -0,0 +1,105 @@
|
||||
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)
|
||||
{
|
||||
int count = Math.Min(simpleCircleDiagram.NameData.Length, data.Data.Length);
|
||||
|
||||
// Создаем временный массив для данных и имен, содержащий только необходимое количество элементов.
|
||||
string seriesNames = data.NameSeries;
|
||||
double[] seriesData = data.Data.Take(count).ToArray();
|
||||
string[] categoryNames = simpleCircleDiagram.NameData.Take(count).ToArray();
|
||||
|
||||
// Добавляем только непустые серии с данными в график.
|
||||
if (seriesData.Length > 0)
|
||||
{
|
||||
seriesColl.Add(seriesNames, categoryNames, seriesData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ChartLegend legend = chart.Legend;
|
||||
|
||||
legend.Position = (LegendPosition)simpleCircleDiagram.AreaLegend;
|
||||
|
||||
legend.Overlay = true;
|
||||
|
||||
doc.Save(simpleCircleDiagram.FilePath);
|
||||
}
|
||||
|
||||
static bool CheckData(List<DataCircleDiagram> data)
|
||||
{
|
||||
foreach (var _data in data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_data.NameSeries) || string.IsNullOrEmpty(_data.Data.ToString()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
6
WinFormsProject/WinFormsLibrary/Class1.cs
Normal file
6
WinFormsProject/WinFormsLibrary/Class1.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
58
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.Designer.cs
generated
Normal file
58
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
partial class CustomCheckedListBox
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.checkedListBox = new System.Windows.Forms.CheckedListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkedListBox
|
||||
//
|
||||
this.checkedListBox.FormattingEnabled = true;
|
||||
this.checkedListBox.Location = new System.Drawing.Point(31, 16);
|
||||
this.checkedListBox.Name = "checkedListBox";
|
||||
this.checkedListBox.Size = new System.Drawing.Size(262, 94);
|
||||
this.checkedListBox.TabIndex = 0;
|
||||
this.checkedListBox.SelectedValueChanged += new System.EventHandler(this.checkedListBox_SelectedValueChanged);
|
||||
//
|
||||
// CustomCheckedListBox
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.checkedListBox);
|
||||
this.Name = "CustomCheckedListBox";
|
||||
this.Size = new System.Drawing.Size(333, 141);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBox;
|
||||
}
|
||||
}
|
78
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.cs
Normal file
78
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.cs
Normal file
@ -0,0 +1,78 @@
|
||||
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;
|
||||
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
|
||||
public partial class CustomCheckedListBox : UserControl
|
||||
{
|
||||
public CustomCheckedListBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
checkedListBox.Items.Clear();
|
||||
}
|
||||
|
||||
public CheckedListBox.ObjectCollection Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return checkedListBox.Items;
|
||||
}
|
||||
}
|
||||
|
||||
public string Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
if (checkedListBox.SelectedItem != null)
|
||||
{
|
||||
return checkedListBox.SelectedItem.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
for (int i = 0; i < checkedListBox.Items.Count; ++i)
|
||||
{
|
||||
if (checkedListBox.Items[i].ToString() == value)
|
||||
{
|
||||
checkedListBox.SetItemChecked(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private EventHandler onValueChanged;
|
||||
public event EventHandler ValueChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
onValueChanged += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
onValueChanged -= value;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkedListBox_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
onValueChanged?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
60
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.resx
Normal file
60
WinFormsProject/WinFormsLibrary/CustomCheckedListBox.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
36
WinFormsProject/WinFormsLibrary/DocumentWithImage.Designer.cs
generated
Normal file
36
WinFormsProject/WinFormsLibrary/DocumentWithImage.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
partial class DocumentWithImage
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
151
WinFormsProject/WinFormsLibrary/DocumentWithImage.cs
Normal file
151
WinFormsProject/WinFormsLibrary/DocumentWithImage.cs
Normal file
@ -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);
|
||||
|
||||
// Добавляем изображения
|
||||
mainPart.Document.Append(body);
|
||||
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}' не найдено.");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Word-документ успешно создан в файле '{imageClass.Path}'.");
|
||||
}
|
||||
}
|
||||
|
||||
private void AddImageToBody(WordprocessingDocument wordDoc, string relationshipId)
|
||||
{
|
||||
var element =
|
||||
new Drawing(
|
||||
new DW.Inline(
|
||||
new DW.Extent() { Cx = 1990000L, Cy = 1792000L },
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
59
WinFormsProject/WinFormsLibrary/NumberTextBox.Designer.cs
generated
Normal file
59
WinFormsProject/WinFormsLibrary/NumberTextBox.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
partial class NumberTextBox
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
numericUpDown = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// numericUpDown
|
||||
//
|
||||
numericUpDown.Location = new Point(117, 37);
|
||||
numericUpDown.Maximum = new decimal(new int[] { 110, 0, 0, 0 });
|
||||
numericUpDown.Minimum = new decimal(new int[] { 50, 0, 0, int.MinValue });
|
||||
numericUpDown.Name = "numericUpDown";
|
||||
numericUpDown.Size = new Size(120, 23);
|
||||
numericUpDown.TabIndex = 0;
|
||||
//
|
||||
// NumberTextBox
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(numericUpDown);
|
||||
Name = "NumberTextBox";
|
||||
Size = new Size(364, 106);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDown).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private NumericUpDown numericUpDown;
|
||||
}
|
||||
}
|
92
WinFormsProject/WinFormsLibrary/NumberTextBox.cs
Normal file
92
WinFormsProject/WinFormsLibrary/NumberTextBox.cs
Normal file
@ -0,0 +1,92 @@
|
||||
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 WinFormsLibrary
|
||||
{
|
||||
public partial class NumberTextBox : UserControl
|
||||
{
|
||||
public int? maxValue = null;
|
||||
public int? minValue = null;
|
||||
public string errorText = "";
|
||||
|
||||
public NumberTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
public int? MinValue
|
||||
{
|
||||
get { return minValue; }
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
minValue = value;
|
||||
numericUpDown.Minimum = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
public int? MaxValue
|
||||
{
|
||||
get { return maxValue; }
|
||||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
maxValue = value;
|
||||
numericUpDown.Maximum = (int)value;
|
||||
}
|
||||
}
|
||||
|
||||
public decimal? Value
|
||||
{
|
||||
get {
|
||||
if (CheckRanges(numericUpDown.Value))
|
||||
{
|
||||
return numericUpDown.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (CheckRanges(value))
|
||||
{
|
||||
numericUpDown.Value = (decimal)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckRanges(decimal? value)
|
||||
{
|
||||
if (MinValue == null || MaxValue == null)
|
||||
{
|
||||
errorText = "Ошибка, диапазоны не заданы.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value < MinValue || value > MaxValue)
|
||||
{
|
||||
errorText = "Ошибка, значение не входит в заданный диапазон.";
|
||||
return false;
|
||||
}
|
||||
|
||||
errorText = "Ошибок нет.";
|
||||
return true;
|
||||
}
|
||||
|
||||
public event EventHandler DateChanged
|
||||
{
|
||||
add { numericUpDown.ValueChanged += value; }
|
||||
remove { numericUpDown.ValueChanged -= value; }
|
||||
}
|
||||
}
|
||||
}
|
60
WinFormsProject/WinFormsLibrary/NumberTextBox.resx
Normal file
60
WinFormsProject/WinFormsLibrary/NumberTextBox.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
31
WinFormsProject/WinFormsLibrary/SupportClasses/BigTable.cs
Normal file
31
WinFormsProject/WinFormsLibrary/SupportClasses/BigTable.cs
Normal file
@ -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<T>
|
||||
{
|
||||
public string FilePath = string.Empty;
|
||||
|
||||
public string DocumentTitle = string.Empty;
|
||||
|
||||
public List<ColumnDefinition> ColumnDefinitions;
|
||||
public List<ColumnDefinition> ColumnDefinitions2;
|
||||
|
||||
public List<T> Data;
|
||||
|
||||
public List<int[]> MergedColumns;
|
||||
public BigTable(string filePath, string documentTitle, List<ColumnDefinition> columnDefinitions, List<ColumnDefinition> columnDefinitions2, List<T> data, List<int[]> mergedColumns)
|
||||
{
|
||||
FilePath = filePath;
|
||||
DocumentTitle = documentTitle;
|
||||
ColumnDefinitions = columnDefinitions;
|
||||
Data = data;
|
||||
MergedColumns = mergedColumns;
|
||||
ColumnDefinitions2 = columnDefinitions2;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
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 double[] Data { get; set; }
|
||||
|
||||
public DataCircleDiagram(string nameSeries, double[] data)
|
||||
{
|
||||
NameSeries = nameSeries;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
26
WinFormsProject/WinFormsLibrary/SupportClasses/ImageClass.cs
Normal file
26
WinFormsProject/WinFormsLibrary/SupportClasses/ImageClass.cs
Normal file
@ -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<string> files;
|
||||
public string Path { get { return path; } set { path = value; } }
|
||||
public string Title { get { return title; } set { title = value; } }
|
||||
public List<string> Files { get { return files; } set { files = value; } }
|
||||
public ImageClass() { }
|
||||
|
||||
public ImageClass(string filePath, string documentTitle, List<string> textData)
|
||||
{
|
||||
Path = filePath;
|
||||
Title = documentTitle;
|
||||
Files = textData;
|
||||
}
|
||||
}
|
||||
}
|
@ -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<DataCircleDiagram> DataList { get; set; } = new();
|
||||
public string FilePath { get; set; } = string.Empty;
|
||||
public EnumAreaLegend AreaLegend { get; set; }
|
||||
public string[] NameData { get; set; }
|
||||
public SimpleCircleDiagram(string filePath, string fileHeader, string circleDiagramName, EnumAreaLegend areaLegend, List<DataCircleDiagram> dataList)
|
||||
{
|
||||
FilePath = filePath;
|
||||
FileHeader = fileHeader;
|
||||
CircleDiagramName = circleDiagramName;
|
||||
AreaLegend = areaLegend;
|
||||
DataList = dataList;
|
||||
}
|
||||
}
|
||||
}
|
27
WinFormsProject/WinFormsLibrary/SupportClasses/Student.cs
Normal file
27
WinFormsProject/WinFormsLibrary/SupportClasses/Student.cs
Normal file
@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
36
WinFormsProject/WinFormsLibrary/Table2column.Designer.cs
generated
Normal file
36
WinFormsProject/WinFormsLibrary/Table2column.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
partial class Table2column
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
134
WinFormsProject/WinFormsLibrary/Table2column.cs
Normal file
134
WinFormsProject/WinFormsLibrary/Table2column.cs
Normal file
@ -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<T>(BigTable<T> 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);
|
||||
}
|
||||
}
|
||||
}
|
56
WinFormsProject/WinFormsLibrary/TreeClass.Designer.cs
generated
Normal file
56
WinFormsProject/WinFormsLibrary/TreeClass.Designer.cs
generated
Normal file
@ -0,0 +1,56 @@
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
partial class TreeClass
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.treeView = new System.Windows.Forms.TreeView();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// treeView
|
||||
//
|
||||
this.treeView.Location = new System.Drawing.Point(0, 0);
|
||||
this.treeView.Name = "treeView";
|
||||
this.treeView.Size = new System.Drawing.Size(292, 224);
|
||||
this.treeView.TabIndex = 0;
|
||||
//
|
||||
// TreeClass
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.treeView);
|
||||
this.Name = "TreeClass";
|
||||
this.Size = new System.Drawing.Size(292, 224);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TreeView treeView;
|
||||
}
|
||||
}
|
133
WinFormsProject/WinFormsLibrary/TreeClass.cs
Normal file
133
WinFormsProject/WinFormsLibrary/TreeClass.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace WinFormsLibrary
|
||||
{
|
||||
public partial class TreeClass : UserControl
|
||||
{
|
||||
private List<string> hierarchy;
|
||||
public bool hasError = false;
|
||||
|
||||
public TreeClass()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void setHierarchy(List<string> h)
|
||||
{
|
||||
hierarchy = h;
|
||||
}
|
||||
|
||||
private bool hasValue(TreeNodeCollection nodes, string value)
|
||||
{
|
||||
foreach (TreeNode node in nodes)
|
||||
{
|
||||
if (node.Text == value) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool addData<T>(T t, string propertyName)
|
||||
{
|
||||
TreeNodeCollection current = treeView.Nodes;
|
||||
TreeNode newNode = null;
|
||||
|
||||
foreach (string h in hierarchy)
|
||||
{
|
||||
if (h == propertyName)
|
||||
{
|
||||
var field = t.GetType().GetField(h);
|
||||
|
||||
if (field == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string value = field.GetValue(t)?.ToString();
|
||||
|
||||
if (!hasValue(current, value))
|
||||
{
|
||||
newNode = current.Add(value); // Добавляем новый узел и сохраняем его в переменной newNode
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Аналогично добавляем новый узел и сохраняем его в переменной newNode
|
||||
if (!hasValue(current, h))
|
||||
{
|
||||
newNode = current.Add(h);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Находим существующий узел с нужным значением
|
||||
foreach (TreeNode child in current)
|
||||
{
|
||||
if (child.Text == h)
|
||||
{
|
||||
newNode = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
current = newNode.Nodes; // Переходим к дочерним узлам нового узла
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public bool setData<T>(T data, string propertyName)
|
||||
{
|
||||
bool status = addData<T>(data, propertyName);
|
||||
if (!status) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public T GetSelectedClass<T>() where T : new()
|
||||
{
|
||||
T res = default(T);
|
||||
TreeNode node = treeView.SelectedNode;
|
||||
|
||||
if (node.Nodes.Count != 0)
|
||||
{
|
||||
hasError = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int i = hierarchy.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (node == null)
|
||||
{
|
||||
hasError = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
var curr = res.GetType().GetField(hierarchy[i]);
|
||||
if (curr == null)
|
||||
{
|
||||
hasError = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
curr.SetValue(res, node.Text);
|
||||
node = node.Parent;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
60
WinFormsProject/WinFormsLibrary/TreeClass.resx
Normal file
60
WinFormsProject/WinFormsLibrary/TreeClass.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
16
WinFormsProject/WinFormsLibrary/WinFormsLibrary.csproj
Normal file
16
WinFormsProject/WinFormsLibrary/WinFormsLibrary.csproj
Normal file
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="23.10.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
31
WinFormsProject/WinFormsProject.sln
Normal file
31
WinFormsProject/WinFormsProject.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32819.101
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsProject", "WinFormsProject\WinFormsProject.csproj", "{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsLibrary", "WinFormsLibrary\WinFormsLibrary.csproj", "{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {2774D1CA-C461-4F94-89BF-C2FD28AC4024}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
97
WinFormsProject/WinFormsProject/Form1.Designer.cs
generated
Normal file
97
WinFormsProject/WinFormsProject/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,97 @@
|
||||
namespace WinFormsProject
|
||||
{
|
||||
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()
|
||||
{
|
||||
this.customCheckedListBox1 = new WinFormsLibrary.CustomCheckedListBox();
|
||||
this.Button_Fill = new System.Windows.Forms.Button();
|
||||
this.Button_Clear = new System.Windows.Forms.Button();
|
||||
this.Button_GetChosenValues = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// customCheckedListBox1
|
||||
//
|
||||
this.customCheckedListBox1.Location = new System.Drawing.Point(21, 21);
|
||||
this.customCheckedListBox1.Name = "customCheckedListBox1";
|
||||
this.customCheckedListBox1.Selected = "";
|
||||
this.customCheckedListBox1.Size = new System.Drawing.Size(333, 141);
|
||||
this.customCheckedListBox1.TabIndex = 0;
|
||||
//
|
||||
// Button_Fill
|
||||
//
|
||||
this.Button_Fill.Location = new System.Drawing.Point(130, 141);
|
||||
this.Button_Fill.Name = "Button_Fill";
|
||||
this.Button_Fill.Size = new System.Drawing.Size(106, 45);
|
||||
this.Button_Fill.TabIndex = 1;
|
||||
this.Button_Fill.Text = "Заполнить";
|
||||
this.Button_Fill.UseVisualStyleBackColor = true;
|
||||
this.Button_Fill.Click += new System.EventHandler(this.Button_Fill_Click);
|
||||
//
|
||||
// Button_Clear
|
||||
//
|
||||
this.Button_Clear.Location = new System.Drawing.Point(130, 206);
|
||||
this.Button_Clear.Name = "Button_Clear";
|
||||
this.Button_Clear.Size = new System.Drawing.Size(106, 53);
|
||||
this.Button_Clear.TabIndex = 2;
|
||||
this.Button_Clear.Text = "Очистить";
|
||||
this.Button_Clear.UseVisualStyleBackColor = true;
|
||||
this.Button_Clear.Click += new System.EventHandler(this.Button_Clear_Click);
|
||||
//
|
||||
// Button_GetChosenValues
|
||||
//
|
||||
this.Button_GetChosenValues.Location = new System.Drawing.Point(130, 277);
|
||||
this.Button_GetChosenValues.Name = "Button_GetChosenValues";
|
||||
this.Button_GetChosenValues.Size = new System.Drawing.Size(106, 52);
|
||||
this.Button_GetChosenValues.TabIndex = 3;
|
||||
this.Button_GetChosenValues.Text = "Выбранные значения";
|
||||
this.Button_GetChosenValues.UseVisualStyleBackColor = true;
|
||||
this.Button_GetChosenValues.Click += new System.EventHandler(this.Button_GetChosenValues_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.Button_GetChosenValues);
|
||||
this.Controls.Add(this.Button_Clear);
|
||||
this.Controls.Add(this.Button_Fill);
|
||||
this.Controls.Add(this.customCheckedListBox1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private WinFormsLibrary.CustomCheckedListBox customCheckedListBox1;
|
||||
private Button Button_Fill;
|
||||
private Button Button_Clear;
|
||||
private Button Button_GetChosenValues;
|
||||
}
|
||||
}
|
41
WinFormsProject/WinFormsProject/Form1.cs
Normal file
41
WinFormsProject/WinFormsProject/Form1.cs
Normal file
@ -0,0 +1,41 @@
|
||||
namespace WinFormsProject
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
List<string> list = new List<string> { "Ìàðàò", "Áóðàê", "Ðîâøàê" };
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
//customCheckedListBox1.FillCheckedListBox(list);
|
||||
customCheckedListBox1.ValueChanged += CustomEventHandler;
|
||||
}
|
||||
|
||||
private void CustomEventHandler(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("Çíà÷åíèå áûëî èçìåíåíî.");
|
||||
}
|
||||
|
||||
private void Button_Clear_Click(object sender, EventArgs e)
|
||||
{
|
||||
customCheckedListBox1.Clear();
|
||||
}
|
||||
|
||||
private void Button_Fill_Click(object sender, EventArgs e)
|
||||
{
|
||||
// customCheckedListBox1.FillCheckedListBox(list);
|
||||
}
|
||||
|
||||
private void Button_GetChosenValues_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (customCheckedListBox1.Selected == null || customCheckedListBox1.Selected == "")
|
||||
{
|
||||
MessageBox.Show("Íåòó âûáðàííûõ ýëåìåíòîâ.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(customCheckedListBox1.Selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
WinFormsProject/WinFormsProject/Form1.resx
Normal file
60
WinFormsProject/WinFormsProject/Form1.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
128
WinFormsProject/WinFormsProject/Form2.Designer.cs
generated
Normal file
128
WinFormsProject/WinFormsProject/Form2.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
||||
namespace WinFormsProject
|
||||
{
|
||||
partial class Form2
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
137
WinFormsProject/WinFormsProject/Form2.cs
Normal file
137
WinFormsProject/WinFormsProject/Form2.cs
Normal file
@ -0,0 +1,137 @@
|
||||
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<string> 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<string>() {
|
||||
"C:\\Users\\user\\Desktop\\images\\car_img1.png",
|
||||
"C:\\Users\\user\\Desktop\\images\\car_img2.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<int[]> mergedColumns = new()
|
||||
{
|
||||
new int[] { 0, 1, 2 }
|
||||
};
|
||||
|
||||
List<ColumnDefinition> columnDefinitions = new List<ColumnDefinition>
|
||||
{
|
||||
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<ColumnDefinition> columnDefinitions2 = new List<ColumnDefinition>
|
||||
{
|
||||
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<Student> data = new List<Student>
|
||||
{
|
||||
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<Student> 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
|
||||
{
|
||||
double[] profit1 = { 300, 324, 500 };
|
||||
SimpleCircleDiagram simpleCircleDiagram = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List<DataCircleDiagram> {
|
||||
new DataCircleDiagram("Компания Первая", profit1)});
|
||||
|
||||
simpleCircleDiagram.NameData = new string[] { "Январь", "Февраль", "Март" };
|
||||
|
||||
circleDiagram.AddCircleDiagram(simpleCircleDiagram);
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
WinFormsProject/WinFormsProject/Form2.resx
Normal file
60
WinFormsProject/WinFormsProject/Form2.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
17
WinFormsProject/WinFormsProject/Program.cs
Normal file
17
WinFormsProject/WinFormsProject/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace WinFormsProject
|
||||
{
|
||||
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 Form2());
|
||||
}
|
||||
}
|
||||
}
|
15
WinFormsProject/WinFormsProject/WinFormsProject.csproj
Normal file
15
WinFormsProject/WinFormsProject/WinFormsProject.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WinFormsLibrary\WinFormsLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user