Добавьте файлы проекта.

This commit is contained in:
dimazhelovanov 2023-10-18 19:08:16 +04:00
parent 197e5dfa56
commit b4dec0a0f4
19 changed files with 1148 additions and 0 deletions

31
KOP_Labs.sln Normal file
View File

@ -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

72
KOP_Labs/BooksForm.Designer.cs generated Normal file
View File

@ -0,0 +1,72 @@
namespace KOP_Labs
{
partial class BooksForm
{
/// <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()
{
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;
}
}

69
KOP_Labs/BooksForm.cs Normal file
View File

@ -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);
}
}
}

60
KOP_Labs/BooksForm.resx Normal file
View 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>

30
KOP_Labs/Classes/Book.cs Normal file
View File

@ -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;
}
}
}

View File

@ -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) { }
}
}

View File

@ -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) { }
}
}

10
KOP_Labs/KOP_Labs.csproj Normal file
View File

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

63
KOP_Labs/TableComponent.Designer.cs generated Normal file
View File

@ -0,0 +1,63 @@
namespace KOP_Labs
{
partial class TableComponent
{
/// <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()
{
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;
}
}

108
KOP_Labs/TableComponent.cs Normal file
View File

@ -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<string> headers, List<int> widths, List<bool> isVisual, List<string> 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>(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<T>() 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);
}
}
}

View 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>

71
KOP_Labs/TextBoxComponent.Designer.cs generated Normal file
View File

@ -0,0 +1,71 @@
namespace KOP_Labs
{
partial class TextBoxComponent
{
/// <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()
{
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;
}
}

View File

@ -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);
}
}
}

View 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>

182
WinForm/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,182 @@
namespace WinForm
{
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()
{
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;
}
}

75
WinForm/Form1.cs Normal file
View File

@ -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<string>() { "fds", "fds", "fds" },
new List<int>() { 80, 80, 80 },
new List<bool> { true, true, true },
new List<string> { "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<Book>().Name.ToString() + " " + tableComponent.GetSelectedObject<Book>().Annotation.ToString() + " ";
MessageBox.Show(answer);
}
}
}

60
WinForm/Form1.resx Normal file
View 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
WinForm/Program.cs Normal file
View File

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

15
WinForm/WinForm.csproj Normal file
View 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="..\KOP_Labs\KOP_Labs.csproj" />
</ItemGroup>
</Project>