From b4dec0a0f433494e41fb9552899f44c058167f4a Mon Sep 17 00:00:00 2001 From: dimazhelovanov Date: Wed, 18 Oct 2023 19:08:16 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KOP_Labs.sln | 31 ++++ KOP_Labs/BooksForm.Designer.cs | 72 +++++++++ KOP_Labs/BooksForm.cs | 69 ++++++++ KOP_Labs/BooksForm.resx | 60 +++++++ KOP_Labs/Classes/Book.cs | 30 ++++ KOP_Labs/Exceptions/NotValueException.cs | 18 +++ KOP_Labs/Exceptions/WrongTypeException.cs | 20 +++ KOP_Labs/KOP_Labs.csproj | 10 ++ KOP_Labs/TableComponent.Designer.cs | 63 ++++++++ KOP_Labs/TableComponent.cs | 108 +++++++++++++ KOP_Labs/TableComponent.resx | 60 +++++++ KOP_Labs/TextBoxComponent.Designer.cs | 71 +++++++++ KOP_Labs/TextBoxComponent.cs | 127 +++++++++++++++ KOP_Labs/TextBoxComponent.resx | 60 +++++++ WinForm/Form1.Designer.cs | 182 ++++++++++++++++++++++ WinForm/Form1.cs | 75 +++++++++ WinForm/Form1.resx | 60 +++++++ WinForm/Program.cs | 17 ++ WinForm/WinForm.csproj | 15 ++ 19 files changed, 1148 insertions(+) create mode 100644 KOP_Labs.sln create mode 100644 KOP_Labs/BooksForm.Designer.cs create mode 100644 KOP_Labs/BooksForm.cs create mode 100644 KOP_Labs/BooksForm.resx create mode 100644 KOP_Labs/Classes/Book.cs create mode 100644 KOP_Labs/Exceptions/NotValueException.cs create mode 100644 KOP_Labs/Exceptions/WrongTypeException.cs create mode 100644 KOP_Labs/KOP_Labs.csproj create mode 100644 KOP_Labs/TableComponent.Designer.cs create mode 100644 KOP_Labs/TableComponent.cs create mode 100644 KOP_Labs/TableComponent.resx create mode 100644 KOP_Labs/TextBoxComponent.Designer.cs create mode 100644 KOP_Labs/TextBoxComponent.cs create mode 100644 KOP_Labs/TextBoxComponent.resx create mode 100644 WinForm/Form1.Designer.cs create mode 100644 WinForm/Form1.cs create mode 100644 WinForm/Form1.resx create mode 100644 WinForm/Program.cs create mode 100644 WinForm/WinForm.csproj diff --git a/KOP_Labs.sln b/KOP_Labs.sln new file mode 100644 index 0000000..72ab213 --- /dev/null +++ b/KOP_Labs.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33424.131 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KOP_Labs", "KOP_Labs\KOP_Labs.csproj", "{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForm", "WinForm\WinForm.csproj", "{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Release|Any CPU.Build.0 = Release|Any CPU + {099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Debug|Any CPU.Build.0 = Debug|Any CPU + {099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.ActiveCfg = Release|Any CPU + {099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F271D4C4-E869-41D9-B1A5-C66D73BA17E7} + EndGlobalSection +EndGlobal diff --git a/KOP_Labs/BooksForm.Designer.cs b/KOP_Labs/BooksForm.Designer.cs new file mode 100644 index 0000000..817f04c --- /dev/null +++ b/KOP_Labs/BooksForm.Designer.cs @@ -0,0 +1,72 @@ +namespace KOP_Labs +{ + partial class BooksForm + { + /// + /// Обязательная переменная конструктора. + /// + 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() + { + groupBoxComponent = new GroupBox(); + listBoxComponent = new ListBox(); + groupBoxComponent.SuspendLayout(); + SuspendLayout(); + // + // groupBoxComponent + // + groupBoxComponent.Controls.Add(listBoxComponent); + groupBoxComponent.Location = new Point(19, 28); + groupBoxComponent.Name = "groupBoxComponent"; + groupBoxComponent.Size = new Size(517, 183); + groupBoxComponent.TabIndex = 0; + groupBoxComponent.TabStop = false; + groupBoxComponent.Text = "Компонент"; + // + // listBoxComponent + // + listBoxComponent.FormattingEnabled = true; + listBoxComponent.ItemHeight = 20; + listBoxComponent.Location = new Point(24, 35); + listBoxComponent.Name = "listBoxComponent"; + listBoxComponent.Size = new Size(476, 124); + listBoxComponent.TabIndex = 0; + listBoxComponent.SelectedIndexChanged += listBoxComponent_SelectedIndexChanged; + // + // BooksForm + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + Controls.Add(groupBoxComponent); + Name = "BooksForm"; + Size = new Size(563, 258); + groupBoxComponent.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxComponent; + private ListBox listBoxComponent; + } +} diff --git a/KOP_Labs/BooksForm.cs b/KOP_Labs/BooksForm.cs new file mode 100644 index 0000000..d8fb97c --- /dev/null +++ b/KOP_Labs/BooksForm.cs @@ -0,0 +1,69 @@ +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 KOP_Labs +{ + public partial class BooksForm : UserControl + { + public BooksForm() + { + InitializeComponent(); + } + + public string? SelectedValue + { + get + { + if (listBoxComponent.SelectedItem == null) + { + return null; + } + return listBoxComponent.SelectedItem.ToString()!; + } + set + { + if (value != null && !listBoxComponent.Items.Contains(value)) + { + return; + } + listBoxComponent.SelectedItem = value; + } + } + + private event EventHandler? _selectChanged; + + public event EventHandler SelectChanged + { + add { _selectChanged += value; } + remove { _selectChanged -= value; } + } + + public void FillValues(string values) + { + if (values == null || values.Length == 0) + { + return; + } + listBoxComponent.Items.Add(values); + } + + + + public void ClearList() + { + listBoxComponent.Items.Clear(); + } + + private void listBoxComponent_SelectedIndexChanged(object sender, EventArgs e) + { + _selectChanged?.Invoke(this, e); + } + } +} diff --git a/KOP_Labs/BooksForm.resx b/KOP_Labs/BooksForm.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/KOP_Labs/BooksForm.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/KOP_Labs/Classes/Book.cs b/KOP_Labs/Classes/Book.cs new file mode 100644 index 0000000..81794ec --- /dev/null +++ b/KOP_Labs/Classes/Book.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KOP_Labs.Classes +{ + public class Book + { + public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; + + public string Annotation { get; private set; } = string.Empty; + + + public Book() + { + + } + public Book(int id, string name, string annotation) + { + Id = id; + Name = name; + Annotation = annotation; + + } + + } +} diff --git a/KOP_Labs/Exceptions/NotValueException.cs b/KOP_Labs/Exceptions/NotValueException.cs new file mode 100644 index 0000000..7def9fb --- /dev/null +++ b/KOP_Labs/Exceptions/NotValueException.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace KOP_Labs.Exceptions +{ + [Serializable] + public class NotValueException:Exception + { + public NotValueException() : base() { } + public NotValueException(string message) : base(message) { } + public NotValueException(string message, Exception exception) : base(message, exception) { } + protected NotValueException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } + } +} diff --git a/KOP_Labs/Exceptions/WrongTypeException.cs b/KOP_Labs/Exceptions/WrongTypeException.cs new file mode 100644 index 0000000..565b179 --- /dev/null +++ b/KOP_Labs/Exceptions/WrongTypeException.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace KOP_Labs.Exceptions +{ + [Serializable] + public class WrongTypeException: Exception + { + + public WrongTypeException() : base() { } + public WrongTypeException(string message) : base(message) { } + public WrongTypeException(string message, Exception exception) : base(message, exception) { } + protected WrongTypeException(SerializationInfo info, StreamingContext contex) : base(info, contex) { } + + } +} diff --git a/KOP_Labs/KOP_Labs.csproj b/KOP_Labs/KOP_Labs.csproj new file mode 100644 index 0000000..060aa1c --- /dev/null +++ b/KOP_Labs/KOP_Labs.csproj @@ -0,0 +1,10 @@ + + + + net6.0-windows + enable + true + enable + + + diff --git a/KOP_Labs/TableComponent.Designer.cs b/KOP_Labs/TableComponent.Designer.cs new file mode 100644 index 0000000..8443de6 --- /dev/null +++ b/KOP_Labs/TableComponent.Designer.cs @@ -0,0 +1,63 @@ +namespace KOP_Labs +{ + partial class TableComponent + { + /// + /// Обязательная переменная конструктора. + /// + 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() + { + dataGridView = new DataGridView(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(36, 29); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(300, 188); + dataGridView.TabIndex = 0; + dataGridView.SelectionChanged += SelectionChanged; + dataGridView.RowHeadersVisible = false; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + // + // TableComponent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + Controls.Add(dataGridView); + Name = "TableComponent"; + Size = new Size(542, 301); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + } +} diff --git a/KOP_Labs/TableComponent.cs b/KOP_Labs/TableComponent.cs new file mode 100644 index 0000000..065b727 --- /dev/null +++ b/KOP_Labs/TableComponent.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace KOP_Labs +{ + public partial class TableComponent : UserControl + { + public event EventHandler TaskHandler; + public int indexRow; + public int IndexRow + { + get + { + return indexRow; + } + set + { + + indexRow = value; + + } + } + public TableComponent() + { + InitializeComponent(); + } + public void TableConfiguration(int columnsQuantity, List headers, List widths, List isVisual, List names) + { + for (int i = 0; i < columnsQuantity; i++) + + { + DataGridViewColumn column = new DataGridViewColumn(); + column.Name = names[i]; + column.HeaderText = headers[i]; + column.Width = widths[i]; + column.Visible = isVisual[i]; + column.CellTemplate = new DataGridViewTextBoxCell(); + + dataGridView.Columns.Add(column); + + } + } + public void ClearRows() + { + dataGridView.Rows.Clear(); + } + public void AddRow(T newObject) + { + DataGridViewRow row = (DataGridViewRow)dataGridView.Rows[0].Clone(); + + foreach (var prop in newObject.GetType().GetProperties()) + { + object value = prop.GetValue(newObject); + + row.Cells[dataGridView.Columns[prop.Name].Index].Value = value; + } + + dataGridView.Rows.Add(row); + } + + public T GetSelectedObject() where T : new() + { + if (dataGridView.SelectedCells.Count == 0) + { + return new T(); + } + + int rowIndex = dataGridView.SelectedCells[0].RowIndex; + var targetObject = new T(); + Type objectType = typeof(T); + PropertyInfo[] properties = objectType.GetProperties(); + + foreach (PropertyInfo property in properties) + { + DataGridViewCell selectedCell = dataGridView.Rows[rowIndex].Cells[property.Name]; + + object cellValue = selectedCell.Value; + + if (cellValue != null && property.CanWrite) + { + object convertedValue = Convert.ChangeType(cellValue, property.PropertyType); + property.SetValue(targetObject, convertedValue); + } + } + + return targetObject; + } + private void SelectionChanged(object sender, EventArgs e) + { + var element = sender as DataGridView; + if (dataGridView.SelectedRows.Count == 0) + { + return; + } + IndexRow = element.SelectedRows[0].Index; + TaskHandler?.Invoke(this, e); + } + } +} diff --git a/KOP_Labs/TableComponent.resx b/KOP_Labs/TableComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/KOP_Labs/TableComponent.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/KOP_Labs/TextBoxComponent.Designer.cs b/KOP_Labs/TextBoxComponent.Designer.cs new file mode 100644 index 0000000..b9b5f16 --- /dev/null +++ b/KOP_Labs/TextBoxComponent.Designer.cs @@ -0,0 +1,71 @@ +namespace KOP_Labs +{ + partial class TextBoxComponent + { + /// + /// Обязательная переменная конструктора. + /// + 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() + { + textBox = new TextBox(); + checkBox1 = new CheckBox(); + SuspendLayout(); + // + // textBox + // + textBox.Location = new Point(141, 73); + textBox.Name = "textBox"; + textBox.Size = new Size(125, 27); + textBox.TabIndex = 0; + textBox.TextChanged += TextBox_TextChanged; + // + // checkBox1 + // + checkBox1.AutoSize = true; + checkBox1.Location = new Point(34, 73); + checkBox1.Name = "checkBox1"; + checkBox1.Size = new Size(101, 24); + checkBox1.TabIndex = 1; + checkBox1.Text = "checkBox1"; + checkBox1.UseVisualStyleBackColor = true; + checkBox1.CheckedChanged += CheckBox_CheckedChanged; + // + // TextBoxComponent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + Controls.Add(checkBox1); + Controls.Add(textBox); + Name = "TextBoxComponent"; + Size = new Size(439, 252); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TextBox textBox; + private CheckBox checkBox1; + } +} diff --git a/KOP_Labs/TextBoxComponent.cs b/KOP_Labs/TextBoxComponent.cs new file mode 100644 index 0000000..3155acc --- /dev/null +++ b/KOP_Labs/TextBoxComponent.cs @@ -0,0 +1,127 @@ +using KOP_Labs.Exceptions; +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.Button; + +namespace KOP_Labs +{ + public partial class TextBoxComponent : UserControl + { + + public TextBoxComponent() + { + InitializeComponent(); + Error = string.Empty; + } + + public string Error { get; private set; } + + public float? Value + { + get + { + if (checkBox1.Checked) + { + return null; + } + if (CheckValue()) + { + return float.Parse(textBox.Text); + } + + return null; + + } + set + { + + + if (value == null) + { + checkBox1.Checked = true; + } + textBox.Text = value.ToString(); + + + } + } + private EventHandler checkChanged; + public event EventHandler CheckChanged + { + add + { + checkChanged += value; + } + remove + { + checkChanged -= value; + } + } + + private void CheckBox_CheckedChanged(object sender, EventArgs e) + { + Error = string.Empty; + if (checkBox1.Checked) + { + textBox.Enabled = false; + textBox.Text = string.Empty; + } + else + { + textBox.Enabled = true; + + } + checkChanged?.Invoke(sender, e); + } + + private EventHandler valueChanged; + public event EventHandler ValueChanged + { + add + { + valueChanged += value; + } + remove + { + valueChanged -= value; + } + } + + public bool CheckValue() + + { + Error = string.Empty; + if (!checkBox1.Checked && (string.IsNullOrEmpty(textBox.Text))) + { + + Error = "Пусто!"; + return false; + + } + if (!checkBox1.Checked && !float.TryParse(textBox.Text, out float floatValue)) + { + + Error = "Не тот тип!"; + + return false; + } + + return true; + + } + private void TextBox_TextChanged(object sender, EventArgs e) + { + + valueChanged?.Invoke(sender, e); + } + + + } +} diff --git a/KOP_Labs/TextBoxComponent.resx b/KOP_Labs/TextBoxComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/KOP_Labs/TextBoxComponent.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/WinForm/Form1.Designer.cs b/WinForm/Form1.Designer.cs new file mode 100644 index 0000000..0cdbf17 --- /dev/null +++ b/WinForm/Form1.Designer.cs @@ -0,0 +1,182 @@ +namespace WinForm +{ + partial class Form1 + { + /// + /// 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() + { + booksForm1 = new KOP_Labs.BooksForm(); + buttonFillValues = new Button(); + buttonClear = new Button(); + textBoxComponent1 = new KOP_Labs.TextBoxComponent(); + labelCheckComponent = new Label(); + buttonTextBox = new Button(); + tableComponent = new KOP_Labs.TableComponent(); + buttonTable = new Button(); + buttonConfig = new Button(); + buttonCleatTable = new Button(); + buttonGetObj = new Button(); + SuspendLayout(); + // + // booksForm1 + // + booksForm1.Location = new Point(12, 12); + booksForm1.Name = "booksForm1"; + booksForm1.SelectedValue = null; + booksForm1.Size = new Size(563, 251); + booksForm1.TabIndex = 0; + // + // buttonFillValues + // + buttonFillValues.Location = new Point(51, 290); + buttonFillValues.Name = "buttonFillValues"; + buttonFillValues.Size = new Size(94, 29); + buttonFillValues.TabIndex = 1; + buttonFillValues.Text = "Заполнить"; + buttonFillValues.UseVisualStyleBackColor = true; + buttonFillValues.Click += buttonFillValues_Click; + // + // buttonClear + // + buttonClear.Location = new Point(180, 290); + buttonClear.Name = "buttonClear"; + buttonClear.Size = new Size(94, 29); + buttonClear.TabIndex = 2; + buttonClear.Text = "Очистить"; + buttonClear.UseVisualStyleBackColor = true; + buttonClear.Click += buttonClear_Click; + // + // textBoxComponent1 + // + textBoxComponent1.Location = new Point(280, 212); + textBoxComponent1.Name = "textBoxComponent1"; + textBoxComponent1.Size = new Size(549, 315); + textBoxComponent1.TabIndex = 3; + // + // labelCheckComponent + // + labelCheckComponent.AutoSize = true; + labelCheckComponent.Location = new Point(491, 358); + labelCheckComponent.Name = "labelCheckComponent"; + labelCheckComponent.Size = new Size(129, 20); + labelCheckComponent.TabIndex = 4; + labelCheckComponent.Text = "Введенный текст:"; + // + // buttonTextBox + // + buttonTextBox.Location = new Point(324, 349); + buttonTextBox.Name = "buttonTextBox"; + buttonTextBox.Size = new Size(142, 29); + buttonTextBox.TabIndex = 5; + buttonTextBox.Text = "Ввести значение"; + buttonTextBox.UseVisualStyleBackColor = true; + buttonTextBox.Click += buttonTextBox_Click; + // + // tableComponent + // + tableComponent.IndexRow = 0; + tableComponent.Location = new Point(649, 12); + tableComponent.Name = "tableComponent"; + tableComponent.Size = new Size(678, 242); + tableComponent.TabIndex = 6; + // + // buttonTable + // + buttonTable.Location = new Point(790, 270); + buttonTable.Name = "buttonTable"; + buttonTable.Size = new Size(94, 29); + buttonTable.TabIndex = 7; + buttonTable.Text = "Ввести"; + buttonTable.UseVisualStyleBackColor = true; + buttonTable.Click += buttonTable_Click; + // + // buttonConfig + // + buttonConfig.Location = new Point(661, 270); + buttonConfig.Name = "buttonConfig"; + buttonConfig.Size = new Size(123, 29); + buttonConfig.TabIndex = 8; + buttonConfig.Text = "Конфигурация"; + buttonConfig.UseVisualStyleBackColor = true; + buttonConfig.Click += buttonConfig_Click; + // + // buttonCleatTable + // + buttonCleatTable.Location = new Point(890, 270); + buttonCleatTable.Name = "buttonCleatTable"; + buttonCleatTable.Size = new Size(94, 29); + buttonCleatTable.TabIndex = 9; + buttonCleatTable.Text = "Очистить"; + buttonCleatTable.UseVisualStyleBackColor = true; + buttonCleatTable.Click += buttonCleatTable_Click; + // + // buttonGetObj + // + buttonGetObj.Location = new Point(990, 270); + buttonGetObj.Name = "buttonGetObj"; + buttonGetObj.Size = new Size(156, 29); + buttonGetObj.TabIndex = 10; + buttonGetObj.Text = "Получить значение"; + buttonGetObj.UseVisualStyleBackColor = true; + buttonGetObj.Click += buttonGetObj_Click; + // + // Form1 + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1153, 450); + Controls.Add(buttonGetObj); + Controls.Add(buttonCleatTable); + Controls.Add(buttonConfig); + Controls.Add(buttonTable); + Controls.Add(tableComponent); + Controls.Add(buttonTextBox); + Controls.Add(labelCheckComponent); + Controls.Add(textBoxComponent1); + Controls.Add(buttonClear); + Controls.Add(buttonFillValues); + Controls.Add(booksForm1); + Name = "Form1"; + Text = "Form1"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private KOP_Labs.BooksForm booksForm1; + private Button buttonFillValues; + private Button buttonClear; + private KOP_Labs.TextBoxComponent textBoxComponent1; + private Label labelCheckComponent; + private Button buttonTextBox; + private KOP_Labs.TableComponent tableComponent; + private Button buttonTable; + private Button buttonConfig; + private Button buttonCleatTable; + private Button buttonGetObj; + } +} \ No newline at end of file diff --git a/WinForm/Form1.cs b/WinForm/Form1.cs new file mode 100644 index 0000000..ecedf5a --- /dev/null +++ b/WinForm/Form1.cs @@ -0,0 +1,75 @@ +using KOP_Labs.Classes; +using KOP_Labs.Exceptions; +using System.Security.Principal; +using System.Text; + +namespace WinForm +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void booksForm1_Load(object sender, EventArgs e) + { + + } + + private void buttonFillValues_Click(object sender, EventArgs e) + { + + booksForm1.FillValues("fgdfgfdgd fdgdffdg adsdds"); + + } + + private void buttonClear_Click(object sender, EventArgs e) + { + booksForm1.ClearList(); + } + + private void buttonTextBox_Click(object sender, EventArgs e) + + { + labelCheckComponent.Text = " : "; + + labelCheckComponent.Text += textBoxComponent1.Value; + if (textBoxComponent1.Error.Length > 0) + { + MessageBox.Show(textBoxComponent1.Error); + } + + + } + + private void buttonTable_Click(object sender, EventArgs e) + { + tableComponent.AddRow(new Book(1, "book1", "lalala")); + tableComponent.AddRow(new Book(1, "book2", "lalala2")); + tableComponent.AddRow(new Book(1, "book3", "lalala")); + + } + + + private void buttonConfig_Click(object sender, EventArgs e) + { + tableComponent.TableConfiguration(3, + new List() { "fds", "fds", "fds" }, + new List() { 80, 80, 80 }, + new List { true, true, true }, + new List { "Id", "Name", "Annotation" }); + } + + private void buttonCleatTable_Click(object sender, EventArgs e) + { + tableComponent.ClearRows(); + } + + private void buttonGetObj_Click(object sender, EventArgs e) + { + string answer = tableComponent.GetSelectedObject().Name.ToString() + " " + tableComponent.GetSelectedObject().Annotation.ToString() + " "; + MessageBox.Show(answer); + } + } +} \ No newline at end of file diff --git a/WinForm/Form1.resx b/WinForm/Form1.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WinForm/Form1.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/WinForm/Program.cs b/WinForm/Program.cs new file mode 100644 index 0000000..a2172dc --- /dev/null +++ b/WinForm/Program.cs @@ -0,0 +1,17 @@ +namespace WinForm +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/WinForm/WinForm.csproj b/WinForm/WinForm.csproj new file mode 100644 index 0000000..ea1be9c --- /dev/null +++ b/WinForm/WinForm.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + \ No newline at end of file