Compare commits

...

3 Commits
main ... lab3

Author SHA1 Message Date
e10dd34475 Привет, я лаба 3, я готова) 2023-10-26 16:26:41 +03:00
8f8f0ab6c1 готово 2023-10-13 17:33:04 +03:00
cbdf90f3ee Исправление лаб1 2023-09-27 12:07:44 +03:00
87 changed files with 4123 additions and 507 deletions

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\DataContracts\DataContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,117 @@
using DatabaseImplement.Implements;
using DataContracts.bindingModels;
using DataContracts.BLs;
using DataContracts.searchModels;
using DataContracts.storages;
using DataContracts.viewModels;
namespace BusinessLogic
{
public class ClientBL : IClientBL
{
private readonly ClientStorage _clientStorage;
private readonly ProductBL productBL;
public ClientBL()
{
_clientStorage = new();
productBL = new ProductBL();
}
public bool Create(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Insert(model) == null)
{
return false;
}
return true;
}
public List<(string title, int count)> FindDataDiagram()
{
List<(string, int)> list = new List<(string, int)>();
List<ClientViewModel> clients = ReadList();
List<ProductViewModel> products = productBL.ReadList();
foreach(ProductViewModel product in products)
{
int count = 0;
foreach(ClientViewModel client in clients)
{
if(client.products.Contains(product.title))
count++;
}
list.Add((product.title, count));
}
return list;
}
public bool Delete(ClientBindingModel model)
{
CheckModel(model, false);
if (_clientStorage.Delete(model) == null)
{
return false;
}
return true;
}
public ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _clientStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<ClientViewModel>? ReadList()
{
var list = _clientStorage.GetFullList();
if (list == null)
{
return null;
}
return list;
}
public bool Update(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Update(model) == null)
{
return false;
}
return true;
}
private void CheckModel(ClientBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.FIO))
{
throw new ArgumentNullException("Нет имени клиента", nameof(model.FIO));
}
if (string.IsNullOrEmpty(model.email))
{
throw new ArgumentNullException("Нет почты клиента", nameof(model.email));
}
if (string.IsNullOrEmpty(model.products))
{
throw new ArgumentNullException("Нет продуктов клиента", nameof(model.products));
}
}
}
}

View File

@ -0,0 +1,90 @@
using DatabaseImplement.Implements;
using DataContracts.bindingModels;
using DataContracts.BLs;
using DataContracts.searchModels;
using DataContracts.viewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic
{
public class ProductBL : IProductBL
{
private readonly ProductStorage _productStorage = new();
public bool Create(ProductBindingModel model)
{
CheckModel(model);
if (_productStorage.Insert(model) == null)
{
return false;
}
return true;
}
public bool Delete(ProductBindingModel model)
{
CheckModel(model, false);
if (_productStorage.Delete(model) == null)
{
return false;
}
return true;
}
public ProductViewModel? ReadElement(ProductSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _productStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public List<ProductViewModel>? ReadList()
{
var list = _productStorage.GetFullList();
if (list == null)
{
return null;
}
return list;
}
public bool Update(ProductBindingModel model)
{
CheckModel(model);
if (_productStorage.Update(model) == null)
{
return false;
}
return true;
}
private void CheckModel(ProductBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.title))
{
throw new ArgumentNullException("Нет имени клиента", nameof(model.title));
}
}
}
}

145
VisEl/ClientForms/Client.Designer.cs generated Normal file
View File

@ -0,0 +1,145 @@
namespace ClientForms
{
partial class Client
{
/// <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.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.textBoxFIO = new System.Windows.Forms.TextBox();
this.myEmailTextBox = new VisualCompLib.MyEmailTextBox();
this.buttonPhoto = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.myCheckListProducts = new VisableComponents.MyCheckList();
this.openFileDialogPath = new System.Windows.Forms.OpenFileDialog();
this.tableLayoutPanel.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel
//
this.tableLayoutPanel.ColumnCount = 1;
this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel.Controls.Add(this.textBoxFIO, 0, 0);
this.tableLayoutPanel.Controls.Add(this.myEmailTextBox, 0, 1);
this.tableLayoutPanel.Controls.Add(this.buttonPhoto, 0, 2);
this.tableLayoutPanel.Controls.Add(this.buttonSave, 0, 4);
this.tableLayoutPanel.Controls.Add(this.myCheckListProducts, 0, 3);
this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel.Name = "tableLayoutPanel";
this.tableLayoutPanel.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel.RowCount = 5;
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 47.05882F));
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 52.94118F));
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 56F));
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 310F));
this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 48F));
this.tableLayoutPanel.Size = new System.Drawing.Size(363, 517);
this.tableLayoutPanel.TabIndex = 0;
//
// textBoxFIO
//
this.textBoxFIO.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBoxFIO.Location = new System.Drawing.Point(6, 6);
this.textBoxFIO.Name = "textBoxFIO";
this.textBoxFIO.Size = new System.Drawing.Size(351, 27);
this.textBoxFIO.TabIndex = 0;
this.textBoxFIO.TextChanged += new System.EventHandler(this.textBoxFIO_TextChanged);
//
// myEmailTextBox
//
this.myEmailTextBox.Location = new System.Drawing.Point(6, 52);
this.myEmailTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.myEmailTextBox.Name = "myEmailTextBox";
this.myEmailTextBox.Pattern = null;
this.myEmailTextBox.Size = new System.Drawing.Size(221, 43);
this.myEmailTextBox.TabIndex = 1;
//
// buttonPhoto
//
this.buttonPhoto.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonPhoto.Location = new System.Drawing.Point(6, 102);
this.buttonPhoto.Name = "buttonPhoto";
this.buttonPhoto.Size = new System.Drawing.Size(351, 50);
this.buttonPhoto.TabIndex = 2;
this.buttonPhoto.Text = "Выбрать фото";
this.buttonPhoto.UseVisualStyleBackColor = true;
this.buttonPhoto.Click += new System.EventHandler(this.buttonPhoto_Click);
//
// buttonSave
//
this.buttonSave.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonSave.Location = new System.Drawing.Point(6, 468);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(351, 43);
this.buttonSave.TabIndex = 3;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// myCheckListProducts
//
this.myCheckListProducts.AutoSize = true;
this.myCheckListProducts.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.myCheckListProducts.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
this.myCheckListProducts.Location = new System.Drawing.Point(6, 159);
this.myCheckListProducts.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.myCheckListProducts.Name = "myCheckListProducts";
this.myCheckListProducts.selectedValue = "";
this.myCheckListProducts.Size = new System.Drawing.Size(285, 298);
this.myCheckListProducts.TabIndex = 4;
//
// openFileDialogPath
//
this.openFileDialogPath.FileName = "openFileDialog1";
//
// Client
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(363, 517);
this.Controls.Add(this.tableLayoutPanel);
this.Name = "Client";
this.Text = "Client";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Client_FormClosing);
this.Load += new System.EventHandler(this.Client_Load);
this.tableLayoutPanel.ResumeLayout(false);
this.tableLayoutPanel.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private TableLayoutPanel tableLayoutPanel;
private TextBox textBoxFIO;
private VisualCompLib.MyEmailTextBox myEmailTextBox;
private Button buttonPhoto;
private Button buttonSave;
private OpenFileDialog openFileDialogPath;
private VisableComponents.MyCheckList myCheckListProducts;
}
}

173
VisEl/ClientForms/Client.cs Normal file
View File

@ -0,0 +1,173 @@
using BusinessLogic;
using DataContracts.bindingModels;
using DataContracts.searchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ClientForms
{
public partial class Client : Form
{
private readonly ClientBL clientBL = new ClientBL();
private readonly ProductBL productBL = new ProductBL();
private int? _id;
private bool fioFlag = false;
private bool emailFlag = false;
private bool photoFlag = false;
private bool EditfioFlag = false;
private bool EditemailFlag = false;
private bool EditphotoFlag = false;
private bool close = false;
private byte[] image;
private List<string> oldProducts = new List<string>();
public int? Id { get { return _id; } set { _id = value; } }
public Client()
{
InitializeComponent();
myEmailTextBox.ValueChanged += EmailTextBox_TextChanged;
myEmailTextBox.Pattern = "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$";
}
private void Client_Load(object sender, EventArgs e)
{
LoadData();
if (Id.HasValue)
{
var current_client = clientBL.ReadElement(new ClientSearchModel { Id = Id });
if(current_client != null)
{
textBoxFIO.Text = current_client.FIO;
myEmailTextBox.TextBoxValue = current_client.email;
image = current_client.photo;
oldProducts = current_client.products.Split(',').ToList();
buttonPhoto.BackColor = Color.DarkOliveGreen;
myCheckListProducts.setValues(current_client.products.Split(',').ToList());
EditfioFlag = false;
EditemailFlag = false;
EditphotoFlag = false;
fioFlag = true;
emailFlag = true;
photoFlag = true;
}
}
}
private bool checkProducts()
{
if(oldProducts.Count != myCheckListProducts.getSelectedItems().Count)
return true;
foreach(var oldProd in oldProducts)
{
if(!myCheckListProducts.getSelectedItems().Contains(oldProd))
return true;
}
return false;
}
private void LoadData()
{
myCheckListProducts.LoadValues(productBL.ReadList().Select(x => x.title).ToList());
}
private void textBoxFIO_TextChanged(object sender, EventArgs e)
{
EditfioFlag = true;
if (textBoxFIO.Text.Length != 0)
{
fioFlag = true;
textBoxFIO.BackColor = Color.DarkOliveGreen;
}
else
{
fioFlag = false;
textBoxFIO.BackColor = Color.IndianRed;
}
}
private void EmailTextBox_TextChanged(object sender, EventArgs e)
{
EditemailFlag = true;
if (myEmailTextBox.TextBoxValue != null)
{
emailFlag = true;
myEmailTextBox.BackColor = Color.DarkOliveGreen;
}
else
{
emailFlag = false;
myEmailTextBox.BackColor = Color.IndianRed;
}
}
private void buttonPhoto_Click(object sender, EventArgs e)
{
EditphotoFlag = true;
if (openFileDialogPath.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialogPath.FileName;
Image img = Image.FromFile(filename);
byte[] bA;
using (MemoryStream mStream = new MemoryStream())
{
img.Save(mStream, img.RawFormat);
bA = mStream.ToArray();
}
image = bA;
photoFlag = true;
buttonPhoto.BackColor = Color.DarkOliveGreen;
}
private void buttonSave_Click(object sender, EventArgs e)
{
if(fioFlag & emailFlag & photoFlag & myCheckListProducts.selectedValuesCount != 0)
{
if(!Id.HasValue)
clientBL.Create(new ClientBindingModel {
FIO = textBoxFIO.Text,
email = myEmailTextBox.TextBoxValue,
photo = image,
products = string.Join(",", myCheckListProducts.getSelectedItems().ToArray())
});
else
clientBL.Update(new ClientBindingModel
{
Id = (int)Id,
FIO = textBoxFIO.Text,
email = myEmailTextBox.TextBoxValue,
photo = image,
products = string.Join(",", myCheckListProducts.getSelectedItems())
});
close = true;
this.Close();
}
else
{
MessageBox.Show("Не заполнены поля");
}
}
private void Client_FormClosing(object sender, FormClosingEventArgs e)
{
if (close)
{
e.Cancel = false;
return;
}
if ((EditfioFlag || EditemailFlag || EditphotoFlag || checkProducts()))
{
DialogResult dialogResult = MessageBox.Show("Вы забыли сохранить изменения! Желаете выйти?", "Важно", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
e.Cancel = false;
else
e.Cancel = true;
}
}
}
}

View File

@ -0,0 +1,63 @@
<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>
<metadata name="openFileDialogPath.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,33 @@
<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>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="UnvisableComponents" Version="1.0.0" />
<PackageReference Include="VisableComponents" Version="1.0.6" />
<PackageReference Include="VisualCompLib" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessLogic\BusinessLogic.csproj" />
<ProjectReference Include="..\DataContracts\DataContracts.csproj" />
</ItemGroup>
</Project>

157
VisEl/ClientForms/Main.Designer.cs generated Normal file
View File

@ -0,0 +1,157 @@
namespace ClientForms
{
partial class Main
{
/// <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.components = new System.ComponentModel.Container();
this.controlDataTableTable = new ControlsLibraryNet60.Data.ControlDataTableTable();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.добавитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.редактироватьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.удалитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.сохранитьВВордToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.сохранитьВЭксельToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.сохранитьВПдфToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.обновитьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.imageExcel1 = new UnvisableComponents.ImageExcel(this.components);
this.wordTable1 = new VisualCompLib.Components.WordTable(this.components);
this.componentDocumentWithChartBarPdf1 = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf(this.components);
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// controlDataTableTable
//
this.controlDataTableTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.controlDataTableTable.Dock = System.Windows.Forms.DockStyle.Fill;
this.controlDataTableTable.Location = new System.Drawing.Point(0, 0);
this.controlDataTableTable.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.controlDataTableTable.Name = "controlDataTableTable";
this.controlDataTableTable.SelectedRowIndex = -1;
this.controlDataTableTable.Size = new System.Drawing.Size(800, 450);
this.controlDataTableTable.TabIndex = 0;
//
// contextMenuStrip1
//
this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.добавитьToolStripMenuItem,
this.редактироватьToolStripMenuItem,
this.удалитьToolStripMenuItem,
this.сохранитьВВордToolStripMenuItem,
this.сохранитьВЭксельToolStripMenuItem,
this.сохранитьВПдфToolStripMenuItem,
this.обновитьToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(216, 172);
//
// добавитьToolStripMenuItem
//
this.добавитьToolStripMenuItem.Name = обавитьToolStripMenuItem";
this.добавитьToolStripMenuItem.Size = new System.Drawing.Size(215, 24);
this.добавитьToolStripMenuItem.Text = "Добавить";
this.добавитьToolStripMenuItem.Click += new System.EventHandler(this.добавитьToolStripMenuItem_Click);
//
// редактироватьToolStripMenuItem
//
this.редактироватьToolStripMenuItem.Name = "редактироватьToolStripMenuItem";
this.редактироватьToolStripMenuItem.Size = new System.Drawing.Size(215, 24);
this.редактироватьToolStripMenuItem.Text = "Редактировать";
this.редактироватьToolStripMenuItem.Click += new System.EventHandler(this.редактироватьToolStripMenuItem_Click);
//
// удалитьToolStripMenuItem
//
this.удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem";
this.удалитьToolStripMenuItem.Size = new System.Drawing.Size(215, 24);
this.удалитьToolStripMenuItem.Text = "Удалить";
this.удалитьToolStripMenuItem.Click += new System.EventHandler(this.удалитьToolStripMenuItem_Click);
//
// сохранитьВВордToolStripMenuItem
//
this.сохранитьВВордToolStripMenuItem.Name = "сохранитьВВордToolStripMenuItem";
this.сохранитьВВордToolStripMenuItem.Size = new System.Drawing.Size(215, 24);
this.сохранитьВВордToolStripMenuItem.Text = "Сохранить в Ворд";
this.сохранитьВВордToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВВордToolStripMenuItem_Click);
//
// сохранитьВЭксельToolStripMenuItem
//
this.сохранитьВЭксельToolStripMenuItem.Name = "сохранитьВЭксельToolStripMenuItem";
this.сохранитьВЭксельToolStripMenuItem.Size = new System.Drawing.Size(215, 24);
this.сохранитьВЭксельToolStripMenuItem.Text = "Сохранить в Эксель";
this.сохранитьВЭксельToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВЭксельToolStripMenuItem_Click);
//
// сохранитьВПдфToolStripMenuItem
//
this.сохранитьВПдфToolStripMenuItem.Name = "сохранитьВПдфToolStripMenuItem";
this.сохранитьВПдфToolStripMenuItem.Size = new System.Drawing.Size(215, 24);
this.сохранитьВПдфToolStripMenuItem.Text = "Сохранить в пдф";
this.сохранитьВПдфToolStripMenuItem.Click += new System.EventHandler(this.сохранитьВПдфToolStripMenuItem_Click);
//
// обновитьToolStripMenuItem
//
this.обновитьToolStripMenuItem.Name = "обновитьToolStripMenuItem";
this.обновитьToolStripMenuItem.Size = new System.Drawing.Size(215, 24);
this.обновитьToolStripMenuItem.Text = "Обновить";
this.обновитьToolStripMenuItem.Click += new System.EventHandler(this.обновитьToolStripMenuItem_Click);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.controlDataTableTable);
this.Name = "Main";
this.Text = "Main";
this.Load += new System.EventHandler(this.Main_Load);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Main_KeyDown);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTableTable;
private ContextMenuStrip contextMenuStrip1;
private ToolStripMenuItem добавитьToolStripMenuItem;
private ToolStripMenuItem редактироватьToolStripMenuItem;
private ToolStripMenuItem удалитьToolStripMenuItem;
private ToolStripMenuItem сохранитьВВордToolStripMenuItem;
private ToolStripMenuItem сохранитьВЭксельToolStripMenuItem;
private ToolStripMenuItem сохранитьВПдфToolStripMenuItem;
private ToolStripMenuItem обновитьToolStripMenuItem;
private UnvisableComponents.ImageExcel imageExcel1;
private VisualCompLib.Components.WordTable wordTable1;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf componentDocumentWithChartBarPdf1;
private OpenFileDialog openFileDialog1;
}
}

227
VisEl/ClientForms/Main.cs Normal file
View File

@ -0,0 +1,227 @@
using BusinessLogic;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
using DataContracts.bindingModels;
using DataContracts.viewModels;
using OfficeOpenXml.LoadFunctions.Params;
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 UnvisableComponents;
using VisualCompLib.Components;
using VisualCompLib.Components.SupportClasses;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
using VisualCompLib.Object;
using ComponentsLibraryNet60.DocumentWithChart;
using ComponentsLibraryNet60.Models;
namespace ClientForms
{
public partial class Main : Form
{
private readonly ClientBL clientBl = new();
public Main()
{
InitializeComponent();
this.KeyPreview = true;
controlDataTableTable.ContextMenuStrip = contextMenuStrip1;
}
private void Main_Load(object sender, EventArgs e)
{
List<DataTableColumnConfig> columns = new List<DataTableColumnConfig>();
columns.Add(new DataTableColumnConfig
{
ColumnHeader = "Id",
PropertyName = "Id",
Visible = false
});
columns.Add(new DataTableColumnConfig
{
ColumnHeader = "ФИО",
PropertyName = "FIO",
Visible = true
});
columns.Add(new DataTableColumnConfig
{
ColumnHeader = "Почта",
PropertyName = "email",
Visible = true
});
columns.Add(new DataTableColumnConfig
{
ColumnHeader = "Продукты",
PropertyName = "products",
Visible = true
});
controlDataTableTable.LoadColumns(columns);
controlDataTableTable.AddTable<ClientViewModel>(clientBl.ReadList());
}
private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
{
Client client = new Client();
client.Show();
}
private void обновитьToolStripMenuItem_Click(object sender, EventArgs e)
{
UpdateTable();
}
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
{
var client = controlDataTableTable.GetSelectedObject<ClientViewModel>();
if (client != null)
{
Client clientForm = new Client();
clientForm.Id = client.Id;
clientForm.Show();
}
else
MessageBox.Show("Выберите запись!!");
UpdateTable();
}
private void UpdateTable()
{
controlDataTableTable.Clear();
controlDataTableTable.AddTable<ClientViewModel>(clientBl.ReadList());
}
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
{
var client = controlDataTableTable.GetSelectedObject<ClientViewModel>();
if (client != null)
{
DialogResult dialogResult = MessageBox.Show("Sure", "Some Title", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
clientBl.Delete(new ClientBindingModel { Id = client.Id });
}
else
MessageBox.Show("Выберите запись!!");
UpdateTable();
}
private void сохранитьВВордToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Word files (*.docx)|*.docx";
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialog1.FileName;
string titleTable = "Клиенты";
List<ColumnDefinition> columnDefinitionsUp = new List<ColumnDefinition> {
new ColumnDefinition{Header = "#", PropertyName = "Id", Weight = 30},
new ColumnDefinition{Header = "Личные данные", PropertyName = "FioEmail", Weight = 30},
new ColumnDefinition{Header = "", PropertyName = "FioEmail", Weight = 30},
new ColumnDefinition{Header = "Продукты", PropertyName = "products", Weight = 30},
};
List<ColumnDefinition> columnDefinitionsDown = new List<ColumnDefinition> {
new ColumnDefinition{Header = "#", PropertyName = "Id", Weight = 30},
new ColumnDefinition{Header = "ФИО", PropertyName = "FIO", Weight = 30},
new ColumnDefinition{Header = "Почта", PropertyName = "email", Weight = 30},
new ColumnDefinition{Header = "Продукты", PropertyName = "products", Weight = 30},
};
List<int[]> mergedColums = new() { new int[] { 1, 2 } };
List<ClientViewModel> clients = clientBl.ReadList();
BigTable<ClientViewModel> bigTable = new(filename, titleTable, columnDefinitionsUp, columnDefinitionsDown, clients, mergedColums);
wordTable1.CreateTable(bigTable);
MessageBox.Show("Готово");
}
private void сохранитьВЭксельToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Excel files (*.xlsx)|*.xlsx";
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialog1.FileName;
string title = "Отчет о клиентах";
List<byte[]> bytes = clientBl.ReadList().Select(x => x.photo).ToList();
ImageInfo info = new ImageInfo();
info.Title = title;
info.Path = filename;
info.Files = bytes;
imageExcel1.Load(info);
MessageBox.Show("Готово");
}
private void сохранитьВПдфToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
openFileDialog1.Filter = "Pdf files (*.pdf)|*.pdf";
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialog1.FileName;
Dictionary<string, List<(int Date, double Value)>> data = new Dictionary<string, List<(int Date, double Value)>>();
foreach(var item in clientBl.FindDataDiagram())
{
data.Add(
item.title,
new List<(int Date, double Value)> { (1, item.count) }
);
}
componentDocumentWithChartBarPdf1.CreateDoc(new ComponentDocumentWithChartConfig
{
FilePath = filename,
Header = "Категории и клиенты",
ChartTitle = "Соотношение",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = data
});
MessageBox.Show("Готово");
}
private void Main_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.A)
{
добавитьToolStripMenuItem_Click(sender, e);
}
if (e.Control && e.KeyCode == Keys.U)
{
редактироватьToolStripMenuItem_Click(sender, e);
}
if (e.Control && e.KeyCode == Keys.Z)
{
UpdateTable();
}
if (e.Control && e.KeyCode == Keys.D)
{
удалитьToolStripMenuItem_Click(sender, e);
}
if (e.Control && e.KeyCode == Keys.S)
{
сохранитьВЭксельToolStripMenuItem_Click(sender,e);
}
if (e.Control && e.KeyCode == Keys.T)
{
сохранитьВВордToolStripMenuItem_Click(sender, e);
}
if (e.Control && e.KeyCode == Keys.C)
{
сохранитьВПдфToolStripMenuItem_Click(sender, e);
}
if (e.KeyCode == Keys.Tab)
{
Products products = new();
products.Show();
}
}
}
}

View File

@ -0,0 +1,75 @@
<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>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="imageExcel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>203, 17</value>
</metadata>
<metadata name="wordTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>340, 17</value>
</metadata>
<metadata name="componentDocumentWithChartBarPdf1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>472, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>796, 17</value>
</metadata>
</root>

68
VisEl/ClientForms/Products.Designer.cs generated Normal file
View File

@ -0,0 +1,68 @@
namespace ClientForms
{
partial class Products
{
/// <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.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(5, 5);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(317, 268);
this.dataGridView.TabIndex = 0;
this.dataGridView.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEndEdit);
this.dataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Products_KeyDown);
//
// Products
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(327, 278);
this.Controls.Add(this.dataGridView);
this.Name = "Products";
this.Padding = new System.Windows.Forms.Padding(5);
this.Text = "Products";
this.Load += new System.EventHandler(this.Products_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,96 @@
using BusinessLogic;
using DatabaseImplement.models;
using DataContracts.bindingModels;
using DataContracts.viewModels;
using DocumentFormat.OpenXml.Bibliography;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
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 ClientForms
{
public partial class Products : Form
{
private readonly ProductBL productBl = new();
BindingList<ProductViewModel> list ;
public Products()
{
InitializeComponent();
}
public void LoadData()
{
list = productBl.ReadList() != null ? new BindingList<ProductViewModel>(productBl.ReadList()) : new BindingList<ProductViewModel>();
dataGridView.DataSource = list;
dataGridView.MultiSelect = false;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["title"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
private void Products_Load(object sender, EventArgs e)
{
LoadData();
}
private void Products_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Insert)
{
dataGridView.Rows[^1].Cells["title"].Selected = true;
dataGridView.BeginEdit(true);
}
if (e.KeyCode == Keys.Delete)
{
if(dataGridView.CurrentCell != null)
{
DialogResult dialogResult = MessageBox.Show("Sure", "Some Title", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
productBl.Delete(new ProductBindingModel { Id = (int)dataGridView.Rows[dataGridView.CurrentCell.RowIndex].Cells["Id"].Value });
LoadData();
}
}
}
private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView.Rows[e.RowIndex].Cells["title"].Value == null || string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells["title"].Value.ToString()) )
{
return;
}
else
{
if((int)dataGridView.Rows[e.RowIndex].Cells["Id"].Value != 0)
{
productBl.Update(new ProductBindingModel
{
Id = (int)dataGridView.Rows[e.RowIndex].Cells["Id"].Value,
title = dataGridView.Rows[e.RowIndex].Cells["title"].Value.ToString()
});
}
else
{
productBl.Create(new ProductBindingModel
{
title = dataGridView.Rows[e.RowIndex].Cells["title"].Value.ToString()
});
}
LoadData();
}
}
}
}

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>

View File

@ -0,0 +1,17 @@
namespace ClientForms
{
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 Main());
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataContracts.bindingModels;
using DataContracts.searchModels;
using DataContracts.viewModels;
namespace DataContracts.BLs
{
public interface IClientBL
{
List<ClientViewModel>? ReadList();
ClientViewModel? ReadElement(ClientSearchModel model);
List<(string title, int count)> FindDataDiagram();
bool Create(ClientBindingModel model);
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,21 @@

using DataContracts.bindingModels;
using DataContracts.searchModels;
using DataContracts.viewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.BLs
{
public interface IProductBL
{
List<ProductViewModel>? ReadList();
ProductViewModel? ReadElement(ProductSearchModel model);
bool Create(ProductBindingModel model);
bool Update(ProductBindingModel model);
bool Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataContracts.models;
namespace DataContracts.bindingModels
{
public class ClientBindingModel : IClient
{
public int Id { get; set; }
public string FIO { get; set; } = string.Empty;
public byte[] photo { get; set; }
public string email { get; set; } = string.Empty;
public string products { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,16 @@
using DataContracts.models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.bindingModels
{
public class ProductBindingModel : IProduct
{
public int Id { get; set; }
public string title {get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.models
{
public interface IClient
{
public int Id { get; }
public string FIO { get; set; }
public byte[] photo { get; set; }
public string email { get; set; }
public string products { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.models
{
public interface IProduct
{
int Id { get; }
string title { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.searchModels
{
public class ClientSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.searchModels
{
public class ProductSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataContracts.bindingModels;
using DataContracts.searchModels;
using DataContracts.viewModels;
namespace DataContracts.storages
{
public interface IClientStorage
{
List<ClientViewModel> GetFullList();
ClientViewModel? GetElement(ClientSearchModel model);
ClientViewModel? Insert(ClientBindingModel model);
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,20 @@
using DataContracts.bindingModels;
using DataContracts.searchModels;
using DataContracts.viewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.storages
{
public interface IProductStorage
{
List<ProductViewModel> GetFullList();
ProductViewModel? GetElement(ProductSearchModel model);
ProductViewModel? Insert(ProductBindingModel model);
ProductViewModel? Update(ProductBindingModel model);
ProductViewModel? Delete(ProductBindingModel model);
}
}

View File

@ -0,0 +1,22 @@
using DataContracts.models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.viewModels
{
public class ClientViewModel : IClient
{
public int Id { get; set; }
[DisplayName("ФИО")]
public string FIO { get; set; } = string.Empty;
public byte[] photo { get; set; }
[DisplayName("Почта")]
public string email { get; set; } = string.Empty;
[DisplayName("Категории продуктов")]
public string products { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,18 @@
using DataContracts.models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataContracts.viewModels
{
public class ProductViewModel : IProduct
{
public int Id { get; set; }
[DisplayName("Название")]
public string title { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,28 @@
using DatabaseImplement.models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.ConstrainedExecution;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement
{
public class AppDataBase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql("Server=PostgreSQL;Host=localhost;Port=5432;Database=ClientsAndProducts;Username=postgres;Password=123456");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<Product> Products { set; get; }
}
}

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataContracts\DataContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,75 @@
using DatabaseImplement.models;
using DataContracts.bindingModels;
using DataContracts.searchModels;
using DataContracts.storages;
using DataContracts.viewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class ClientStorage : IClientStorage
{
public ClientViewModel? Delete(ClientBindingModel model)
{
using var context = new AppDataBase();
var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Clients.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public ClientViewModel? GetElement(ClientSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new AppDataBase();
return context.Clients
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public List<ClientViewModel> GetFullList()
{
using var context = new AppDataBase();
return context.Clients
.Select(x => x.GetViewModel)
.ToList();
}
public ClientViewModel? Insert(ClientBindingModel model)
{
var newClient = Client.Create(model);
if (newClient == null)
{
return null;
}
using var context = new AppDataBase();
context.Clients.Add(newClient);
context.SaveChanges();
return newClient.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new AppDataBase();
var client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
if (client == null)
{
return null;
}
client.Update(model);
context.SaveChanges();
return client.GetViewModel;
}
}
}

View File

@ -0,0 +1,75 @@
using DatabaseImplement.models;
using DataContracts.bindingModels;
using DataContracts.searchModels;
using DataContracts.storages;
using DataContracts.viewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class ProductStorage : IProductStorage
{
public ProductViewModel? Delete(ProductBindingModel model)
{
using var context = new AppDataBase();
var element = context.Products.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Products.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public ProductViewModel? GetElement(ProductSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new AppDataBase();
return context.Products
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
}
public List<ProductViewModel> GetFullList()
{
using var context = new AppDataBase();
return context.Products
.Select(x => x.GetViewModel)
.ToList();
}
public ProductViewModel? Insert(ProductBindingModel model)
{
var newProduct = Product.Create(model);
if (newProduct == null)
{
return null;
}
using var context = new AppDataBase();
context.Products.Add(newProduct);
context.SaveChanges();
return newProduct.GetViewModel;
}
public ProductViewModel? Update(ProductBindingModel model)
{
using var context = new AppDataBase();
var product = context.Products.FirstOrDefault(x => x.Id == model.Id);
if (product == null)
{
return null;
}
product.Update(model);
context.SaveChanges();
return product.GetViewModel;
}
}
}

View File

@ -0,0 +1,75 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(AppDataBase))]
[Migration("20231025110458_initial")]
partial class initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("email")
.IsRequired()
.HasColumnType("text");
b.Property<byte[]>("photo")
.IsRequired()
.HasColumnType("bytea");
b.Property<string>("products")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("DatabaseImplement.models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,54 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
FIO = table.Column<string>(type: "text", nullable: false),
photo = table.Column<byte[]>(type: "bytea", nullable: false),
email = table.Column<string>(type: "text", nullable: false),
products = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
title = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Products");
}
}
}

View File

@ -0,0 +1,75 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(AppDataBase))]
[Migration("20231025152005_initial2")]
partial class initial2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("email")
.IsRequired()
.HasColumnType("text");
b.Property<byte[]>("photo")
.IsRequired()
.HasColumnType("bytea");
b.Property<string>("products")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("DatabaseImplement.models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class initial2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,72 @@
// <auto-generated />
using DatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(AppDataBase))]
partial class AppDataBaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("text");
b.Property<string>("email")
.IsRequired()
.HasColumnType("text");
b.Property<byte[]>("photo")
.IsRequired()
.HasColumnType("bytea");
b.Property<string>("products")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("DatabaseImplement.models.Product", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("title")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Products");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,51 @@
using DataContracts.bindingModels;
using DataContracts.models;
using DataContracts.viewModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection;
namespace DatabaseImplement.models
{
public class Client : IClient
{
public int Id { get; set; }
[Required]
public string FIO { get; set; } = string.Empty;
[Required]
public byte[] photo { get; set; } = new byte[0];
[Required]
public string email { get; set; } = string.Empty;
public string products { get; set; } = string.Empty;
public static Client Create(ClientBindingModel model)
{
return new Client()
{
Id = model.Id,
FIO = model.FIO,
photo = model.photo,
email = model.email,
products = model.products
};
}
public void Update(ClientBindingModel model)
{
FIO = model.FIO;
email = model.email;
photo = model.photo;
products = model.products;
}
public ClientViewModel GetViewModel => new()
{
Id = Id,
FIO = FIO,
photo = photo,
email = email,
products = products
};
}
}

View File

@ -0,0 +1,40 @@
using DataContracts.bindingModels;
using DataContracts.models;
using DataContracts.viewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.models
{
public class Product : IProduct
{
public int Id { get; set; }
[Required]
public string title { get; set; } = string.Empty;
public static Product Create(ProductBindingModel model)
{
return new Product()
{
Id = model.Id,
title = model.title
};
}
public void Update(ProductBindingModel model)
{
title = model.title;
}
public ProductViewModel GetViewModel => new()
{
Id = Id,
title = title,
};
}
}

View File

@ -3,9 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248 VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisEl", "VisEl\VisEl.csproj", "{471DE73A-592F-45F0-8249-9F6DD539682C}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnvisableComponents", "UnvisableComponents\UnvisableComponents.csproj", "{B720A881-1A22-48BB-B0C6-23F616E6D10D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{D173D582-D0AE-45DF-88FC-0DE0A8183E82}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestForm", "TestForm\TestForm.csproj", "{53DEA306-E3B4-4662-A337-7076CF636F6A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisableComponents", "VisableComponents\VisableComponents.csproj", "{B0E42147-22BB-4B22-AB76-3C7DB2BF5353}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataContracts", "DataContracts\DataContracts.csproj", "{F0B8E9FD-AAEF-4F1A-87E5-4361F22BA00A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{AE492748-D76A-40D0-B3B0-FAE321F6DA91}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BusinessLogic", "BusinessLogic\BusinessLogic.csproj", "{5CA23F59-94F6-4A49-B114-F9B1A3D147CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientForms", "ClientForms\ClientForms.csproj", "{A1EE2F68-9359-4377-AFDB-3223F6DF5F40}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -13,14 +23,34 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{471DE73A-592F-45F0-8249-9F6DD539682C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B720A881-1A22-48BB-B0C6-23F616E6D10D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{471DE73A-592F-45F0-8249-9F6DD539682C}.Debug|Any CPU.Build.0 = Debug|Any CPU {B720A881-1A22-48BB-B0C6-23F616E6D10D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{471DE73A-592F-45F0-8249-9F6DD539682C}.Release|Any CPU.ActiveCfg = Release|Any CPU {B720A881-1A22-48BB-B0C6-23F616E6D10D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{471DE73A-592F-45F0-8249-9F6DD539682C}.Release|Any CPU.Build.0 = Release|Any CPU {B720A881-1A22-48BB-B0C6-23F616E6D10D}.Release|Any CPU.Build.0 = Release|Any CPU
{D173D582-D0AE-45DF-88FC-0DE0A8183E82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {53DEA306-E3B4-4662-A337-7076CF636F6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D173D582-D0AE-45DF-88FC-0DE0A8183E82}.Debug|Any CPU.Build.0 = Debug|Any CPU {53DEA306-E3B4-4662-A337-7076CF636F6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D173D582-D0AE-45DF-88FC-0DE0A8183E82}.Release|Any CPU.ActiveCfg = Release|Any CPU {53DEA306-E3B4-4662-A337-7076CF636F6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D173D582-D0AE-45DF-88FC-0DE0A8183E82}.Release|Any CPU.Build.0 = Release|Any CPU {53DEA306-E3B4-4662-A337-7076CF636F6A}.Release|Any CPU.Build.0 = Release|Any CPU
{B0E42147-22BB-4B22-AB76-3C7DB2BF5353}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0E42147-22BB-4B22-AB76-3C7DB2BF5353}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0E42147-22BB-4B22-AB76-3C7DB2BF5353}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0E42147-22BB-4B22-AB76-3C7DB2BF5353}.Release|Any CPU.Build.0 = Release|Any CPU
{F0B8E9FD-AAEF-4F1A-87E5-4361F22BA00A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0B8E9FD-AAEF-4F1A-87E5-4361F22BA00A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0B8E9FD-AAEF-4F1A-87E5-4361F22BA00A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0B8E9FD-AAEF-4F1A-87E5-4361F22BA00A}.Release|Any CPU.Build.0 = Release|Any CPU
{AE492748-D76A-40D0-B3B0-FAE321F6DA91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE492748-D76A-40D0-B3B0-FAE321F6DA91}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE492748-D76A-40D0-B3B0-FAE321F6DA91}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE492748-D76A-40D0-B3B0-FAE321F6DA91}.Release|Any CPU.Build.0 = Release|Any CPU
{5CA23F59-94F6-4A49-B114-F9B1A3D147CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CA23F59-94F6-4A49-B114-F9B1A3D147CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CA23F59-94F6-4A49-B114-F9B1A3D147CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CA23F59-94F6-4A49-B114-F9B1A3D147CB}.Release|Any CPU.Build.0 = Release|Any CPU
{A1EE2F68-9359-4377-AFDB-3223F6DF5F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1EE2F68-9359-4377-AFDB-3223F6DF5F40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1EE2F68-9359-4377-AFDB-3223F6DF5F40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1EE2F68-9359-4377-AFDB-3223F6DF5F40}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test
{
internal static class Program
{
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("d173d582-d0ae-45df-88fc-0de0a8183e82")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,71 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Test.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
// класс с помощью таких средств, как ResGen или Visual Studio.
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
// с параметром /str или заново постройте свой VS-проект.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Переопределяет свойство CurrentUICulture текущего потока для всех
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -1,30 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Test.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -1,93 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D173D582-D0AE-45DF-88FC-0DE0A8183E82}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Test</RootNamespace>
<AssemblyName>Test</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestClasses\Sportsmen.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VisEl\VisEl.csproj">
<Project>{471DE73A-592F-45F0-8249-9F6DD539682C}</Project>
<Name>VisEl</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,4 +1,4 @@
namespace Test namespace TestForm
{ {
partial class Form1 partial class Form1
{ {
@ -45,55 +45,62 @@
this.labelChecked = new System.Windows.Forms.Label(); this.labelChecked = new System.Windows.Forms.Label();
this.buttonStart = new System.Windows.Forms.Button(); this.buttonStart = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox(); this.comboBox1 = new System.Windows.Forms.ComboBox();
this.myTreeView1 = new VisEl.MyTreeView();
this.myTextBoxDate = new VisEl.MyTextBoxDate();
this.newCheckList1 = new VisEl.MyCheckList();
this.buttonAddHier = new System.Windows.Forms.Button(); this.buttonAddHier = new System.Windows.Forms.Button();
this.labelHier = new System.Windows.Forms.Label(); this.labelHier = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox(); this.listBox1 = new System.Windows.Forms.ListBox();
this.buttonGen = new System.Windows.Forms.Button(); this.buttonGen = new System.Windows.Forms.Button();
this.buttonTakeNode = new System.Windows.Forms.Button(); this.buttonTakeNode = new System.Windows.Forms.Button();
this.labelNode = new System.Windows.Forms.Label(); this.labelNode = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.lab2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.labelChange = new System.Windows.Forms.Label();
this.labelDateChange = new System.Windows.Forms.Label();
this.myTreeView1 = new VisableComponents.MyTreeView();
this.newCheckList1 = new VisableComponents.MyCheckList();
this.myTextBoxDate = new VisableComponents.MyTextBoxDate();
this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// textBoxList // textBoxList
// //
this.textBoxList.Location = new System.Drawing.Point(492, 12); this.textBoxList.Location = new System.Drawing.Point(492, 15);
this.textBoxList.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxList.Name = "textBoxList"; this.textBoxList.Name = "textBoxList";
this.textBoxList.Size = new System.Drawing.Size(261, 22); this.textBoxList.Size = new System.Drawing.Size(261, 27);
this.textBoxList.TabIndex = 1; this.textBoxList.TabIndex = 1;
// //
// labelList // labelList
// //
this.labelList.AutoSize = true; this.labelList.AutoSize = true;
this.labelList.Location = new System.Drawing.Point(336, 12); this.labelList.Location = new System.Drawing.Point(336, 15);
this.labelList.Name = "labelList"; this.labelList.Name = "labelList";
this.labelList.Size = new System.Drawing.Size(120, 16); this.labelList.Size = new System.Drawing.Size(127, 20);
this.labelList.TabIndex = 2; this.labelList.TabIndex = 2;
this.labelList.Text = "Создание списка"; this.labelList.Text = "Создание списка";
// //
// labelListEl // labelListEl
// //
this.labelListEl.AutoSize = true; this.labelListEl.AutoSize = true;
this.labelListEl.Location = new System.Drawing.Point(336, 94); this.labelListEl.Location = new System.Drawing.Point(336, 118);
this.labelListEl.Name = "labelListEl"; this.labelListEl.Name = "labelListEl";
this.labelListEl.Size = new System.Drawing.Size(83, 16); this.labelListEl.Size = new System.Drawing.Size(91, 20);
this.labelListEl.TabIndex = 3; this.labelListEl.TabIndex = 3;
this.labelListEl.Text = "ListElements"; this.labelListEl.Text = "ListElements";
// //
// elemetsOfList // elemetsOfList
// //
this.elemetsOfList.AutoSize = true; this.elemetsOfList.AutoSize = true;
this.elemetsOfList.Location = new System.Drawing.Point(425, 94); this.elemetsOfList.Location = new System.Drawing.Point(425, 118);
this.elemetsOfList.Name = "elemetsOfList"; this.elemetsOfList.Name = "elemetsOfList";
this.elemetsOfList.Size = new System.Drawing.Size(0, 16); this.elemetsOfList.Size = new System.Drawing.Size(0, 20);
this.elemetsOfList.TabIndex = 4; this.elemetsOfList.TabIndex = 4;
// //
// buttonAdd // buttonAdd
// //
this.buttonAdd.Location = new System.Drawing.Point(492, 55); this.buttonAdd.Location = new System.Drawing.Point(492, 69);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonAdd.Name = "buttonAdd"; this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(145, 23); this.buttonAdd.Size = new System.Drawing.Size(145, 29);
this.buttonAdd.TabIndex = 5; this.buttonAdd.TabIndex = 5;
this.buttonAdd.Text = "Добавить в список"; this.buttonAdd.Text = "Добавить в список";
this.buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.UseVisualStyleBackColor = true;
@ -101,9 +108,10 @@
// //
// LoadInBox // LoadInBox
// //
this.LoadInBox.Location = new System.Drawing.Point(666, 55); this.LoadInBox.Location = new System.Drawing.Point(666, 69);
this.LoadInBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.LoadInBox.Name = "LoadInBox"; this.LoadInBox.Name = "LoadInBox";
this.LoadInBox.Size = new System.Drawing.Size(87, 23); this.LoadInBox.Size = new System.Drawing.Size(87, 29);
this.LoadInBox.TabIndex = 6; this.LoadInBox.TabIndex = 6;
this.LoadInBox.Text = "Загрузить"; this.LoadInBox.Text = "Загрузить";
this.LoadInBox.UseVisualStyleBackColor = true; this.LoadInBox.UseVisualStyleBackColor = true;
@ -111,9 +119,10 @@
// //
// buttonClear // buttonClear
// //
this.buttonClear.Location = new System.Drawing.Point(339, 55); this.buttonClear.Location = new System.Drawing.Point(339, 69);
this.buttonClear.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonClear.Name = "buttonClear"; this.buttonClear.Name = "buttonClear";
this.buttonClear.Size = new System.Drawing.Size(120, 23); this.buttonClear.Size = new System.Drawing.Size(120, 29);
this.buttonClear.TabIndex = 7; this.buttonClear.TabIndex = 7;
this.buttonClear.Text = "Очистить"; this.buttonClear.Text = "Очистить";
this.buttonClear.UseVisualStyleBackColor = true; this.buttonClear.UseVisualStyleBackColor = true;
@ -121,16 +130,18 @@
// //
// textBoxTakeValue // textBoxTakeValue
// //
this.textBoxTakeValue.Location = new System.Drawing.Point(339, 147); this.textBoxTakeValue.Location = new System.Drawing.Point(339, 184);
this.textBoxTakeValue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.textBoxTakeValue.Name = "textBoxTakeValue"; this.textBoxTakeValue.Name = "textBoxTakeValue";
this.textBoxTakeValue.Size = new System.Drawing.Size(321, 22); this.textBoxTakeValue.Size = new System.Drawing.Size(321, 27);
this.textBoxTakeValue.TabIndex = 8; this.textBoxTakeValue.TabIndex = 8;
// //
// buttonTake // buttonTake
// //
this.buttonTake.Location = new System.Drawing.Point(339, 193); this.buttonTake.Location = new System.Drawing.Point(339, 241);
this.buttonTake.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonTake.Name = "buttonTake"; this.buttonTake.Name = "buttonTake";
this.buttonTake.Size = new System.Drawing.Size(75, 23); this.buttonTake.Size = new System.Drawing.Size(75, 29);
this.buttonTake.TabIndex = 9; this.buttonTake.TabIndex = 9;
this.buttonTake.Text = "Взять"; this.buttonTake.Text = "Взять";
this.buttonTake.UseVisualStyleBackColor = true; this.buttonTake.UseVisualStyleBackColor = true;
@ -138,9 +149,10 @@
// //
// buttonReplace // buttonReplace
// //
this.buttonReplace.Location = new System.Drawing.Point(461, 192); this.buttonReplace.Location = new System.Drawing.Point(461, 240);
this.buttonReplace.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonReplace.Name = "buttonReplace"; this.buttonReplace.Name = "buttonReplace";
this.buttonReplace.Size = new System.Drawing.Size(92, 23); this.buttonReplace.Size = new System.Drawing.Size(92, 29);
this.buttonReplace.TabIndex = 10; this.buttonReplace.TabIndex = 10;
this.buttonReplace.Text = "Пяоменять"; this.buttonReplace.Text = "Пяоменять";
this.buttonReplace.UseVisualStyleBackColor = true; this.buttonReplace.UseVisualStyleBackColor = true;
@ -148,16 +160,18 @@
// //
// dateTimePicker // dateTimePicker
// //
this.dateTimePicker.Location = new System.Drawing.Point(428, 321); this.dateTimePicker.Location = new System.Drawing.Point(428, 401);
this.dateTimePicker.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.dateTimePicker.Name = "dateTimePicker"; this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(200, 22); this.dateTimePicker.Size = new System.Drawing.Size(200, 27);
this.dateTimePicker.TabIndex = 12; this.dateTimePicker.TabIndex = 12;
// //
// buttonTakeTime // buttonTakeTime
// //
this.buttonTakeTime.Location = new System.Drawing.Point(701, 286); this.buttonTakeTime.Location = new System.Drawing.Point(701, 358);
this.buttonTakeTime.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonTakeTime.Name = "buttonTakeTime"; this.buttonTakeTime.Name = "buttonTakeTime";
this.buttonTakeTime.Size = new System.Drawing.Size(75, 23); this.buttonTakeTime.Size = new System.Drawing.Size(75, 29);
this.buttonTakeTime.TabIndex = 13; this.buttonTakeTime.TabIndex = 13;
this.buttonTakeTime.Text = "Взять"; this.buttonTakeTime.Text = "Взять";
this.buttonTakeTime.UseVisualStyleBackColor = true; this.buttonTakeTime.UseVisualStyleBackColor = true;
@ -165,9 +179,10 @@
// //
// buttonGiveTime // buttonGiveTime
// //
this.buttonGiveTime.Location = new System.Drawing.Point(428, 358); this.buttonGiveTime.Location = new System.Drawing.Point(428, 448);
this.buttonGiveTime.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonGiveTime.Name = "buttonGiveTime"; this.buttonGiveTime.Name = "buttonGiveTime";
this.buttonGiveTime.Size = new System.Drawing.Size(75, 23); this.buttonGiveTime.Size = new System.Drawing.Size(75, 29);
this.buttonGiveTime.TabIndex = 14; this.buttonGiveTime.TabIndex = 14;
this.buttonGiveTime.Text = "Загрузить"; this.buttonGiveTime.Text = "Загрузить";
this.buttonGiveTime.UseVisualStyleBackColor = true; this.buttonGiveTime.UseVisualStyleBackColor = true;
@ -176,25 +191,26 @@
// labelTitle // labelTitle
// //
this.labelTitle.AutoSize = true; this.labelTitle.AutoSize = true;
this.labelTitle.Location = new System.Drawing.Point(428, 286); this.labelTitle.Location = new System.Drawing.Point(394, 358);
this.labelTitle.Name = "labelTitle"; this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(88, 16); this.labelTitle.Size = new System.Drawing.Size(98, 20);
this.labelTitle.TabIndex = 15; this.labelTitle.TabIndex = 15;
this.labelTitle.Text = "Вы выбрали:"; this.labelTitle.Text = "Вы выбрали:";
// //
// labelChecked // labelChecked
// //
this.labelChecked.AutoSize = true; this.labelChecked.AutoSize = true;
this.labelChecked.Location = new System.Drawing.Point(508, 285); this.labelChecked.Location = new System.Drawing.Point(508, 356);
this.labelChecked.Name = "labelChecked"; this.labelChecked.Name = "labelChecked";
this.labelChecked.Size = new System.Drawing.Size(0, 16); this.labelChecked.Size = new System.Drawing.Size(0, 20);
this.labelChecked.TabIndex = 16; this.labelChecked.TabIndex = 16;
// //
// buttonStart // buttonStart
// //
this.buttonStart.Location = new System.Drawing.Point(684, 743); this.buttonStart.Location = new System.Drawing.Point(684, 929);
this.buttonStart.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonStart.Name = "buttonStart"; this.buttonStart.Name = "buttonStart";
this.buttonStart.Size = new System.Drawing.Size(75, 23); this.buttonStart.Size = new System.Drawing.Size(75, 29);
this.buttonStart.TabIndex = 18; this.buttonStart.TabIndex = 18;
this.buttonStart.Text = "Поехали"; this.buttonStart.Text = "Поехали";
this.buttonStart.UseVisualStyleBackColor = true; this.buttonStart.UseVisualStyleBackColor = true;
@ -203,47 +219,18 @@
// comboBox1 // comboBox1
// //
this.comboBox1.FormattingEnabled = true; this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(525, 412); this.comboBox1.Location = new System.Drawing.Point(517, 540);
this.comboBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.comboBox1.Name = "comboBox1"; this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 24); this.comboBox1.Size = new System.Drawing.Size(121, 28);
this.comboBox1.TabIndex = 19; this.comboBox1.TabIndex = 19;
// //
// myTreeView1
//
this.myTreeView1.AutoSize = true;
this.myTreeView1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.myTreeView1.BackColor = System.Drawing.SystemColors.ControlDark;
this.myTreeView1.Location = new System.Drawing.Point(12, 412);
this.myTreeView1.Name = "myTreeView1";
this.myTreeView1.Size = new System.Drawing.Size(427, 403);
this.myTreeView1.TabIndex = 17;
//
// myTextBoxDate
//
this.myTextBoxDate.DateMaximum = new System.DateTime(2025, 12, 31, 0, 0, 0, 0);
this.myTextBoxDate.DateMinimum = new System.DateTime(2000, 1, 1, 0, 0, 0, 0);
this.myTextBoxDate.Location = new System.Drawing.Point(31, 286);
this.myTextBoxDate.Name = "myTextBoxDate";
this.myTextBoxDate.Size = new System.Drawing.Size(316, 150);
this.myTextBoxDate.TabIndex = 11;
this.myTextBoxDate.Value = "13.09.2023";
//
// newCheckList1
//
this.newCheckList1.AutoSize = true;
this.newCheckList1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.newCheckList1.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.newCheckList1.Location = new System.Drawing.Point(31, 12);
this.newCheckList1.Name = "newCheckList1";
this.newCheckList1.selectedValue = "";
this.newCheckList1.Size = new System.Drawing.Size(285, 248);
this.newCheckList1.TabIndex = 0;
//
// buttonAddHier // buttonAddHier
// //
this.buttonAddHier.Location = new System.Drawing.Point(678, 412); this.buttonAddHier.Location = new System.Drawing.Point(678, 515);
this.buttonAddHier.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonAddHier.Name = "buttonAddHier"; this.buttonAddHier.Name = "buttonAddHier";
this.buttonAddHier.Size = new System.Drawing.Size(75, 23); this.buttonAddHier.Size = new System.Drawing.Size(75, 29);
this.buttonAddHier.TabIndex = 20; this.buttonAddHier.TabIndex = 20;
this.buttonAddHier.Text = "Добавить"; this.buttonAddHier.Text = "Добавить";
this.buttonAddHier.UseVisualStyleBackColor = true; this.buttonAddHier.UseVisualStyleBackColor = true;
@ -252,25 +239,27 @@
// labelHier // labelHier
// //
this.labelHier.AutoSize = true; this.labelHier.AutoSize = true;
this.labelHier.Location = new System.Drawing.Point(446, 460); this.labelHier.Location = new System.Drawing.Point(446, 575);
this.labelHier.Name = "labelHier"; this.labelHier.Name = "labelHier";
this.labelHier.Size = new System.Drawing.Size(0, 16); this.labelHier.Size = new System.Drawing.Size(0, 20);
this.labelHier.TabIndex = 21; this.labelHier.TabIndex = 21;
// //
// listBox1 // listBox1
// //
this.listBox1.FormattingEnabled = true; this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 16; this.listBox1.ItemHeight = 20;
this.listBox1.Location = new System.Drawing.Point(517, 477); this.listBox1.Location = new System.Drawing.Point(517, 596);
this.listBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.listBox1.Name = "listBox1"; this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(242, 260); this.listBox1.Size = new System.Drawing.Size(242, 324);
this.listBox1.TabIndex = 22; this.listBox1.TabIndex = 22;
// //
// buttonGen // buttonGen
// //
this.buttonGen.Location = new System.Drawing.Point(678, 448); this.buttonGen.Location = new System.Drawing.Point(678, 560);
this.buttonGen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonGen.Name = "buttonGen"; this.buttonGen.Name = "buttonGen";
this.buttonGen.Size = new System.Drawing.Size(75, 23); this.buttonGen.Size = new System.Drawing.Size(75, 29);
this.buttonGen.TabIndex = 23; this.buttonGen.TabIndex = 23;
this.buttonGen.Text = "Генерир"; this.buttonGen.Text = "Генерир";
this.buttonGen.UseVisualStyleBackColor = true; this.buttonGen.UseVisualStyleBackColor = true;
@ -278,9 +267,10 @@
// //
// buttonTakeNode // buttonTakeNode
// //
this.buttonTakeNode.Location = new System.Drawing.Point(511, 743); this.buttonTakeNode.Location = new System.Drawing.Point(511, 929);
this.buttonTakeNode.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonTakeNode.Name = "buttonTakeNode"; this.buttonTakeNode.Name = "buttonTakeNode";
this.buttonTakeNode.Size = new System.Drawing.Size(75, 23); this.buttonTakeNode.Size = new System.Drawing.Size(75, 29);
this.buttonTakeNode.TabIndex = 24; this.buttonTakeNode.TabIndex = 24;
this.buttonTakeNode.Text = "Достать"; this.buttonTakeNode.Text = "Достать";
this.buttonTakeNode.UseVisualStyleBackColor = true; this.buttonTakeNode.UseVisualStyleBackColor = true;
@ -289,16 +279,88 @@
// labelNode // labelNode
// //
this.labelNode.AutoSize = true; this.labelNode.AutoSize = true;
this.labelNode.Location = new System.Drawing.Point(514, 778); this.labelNode.Location = new System.Drawing.Point(514, 972);
this.labelNode.Name = "labelNode"; this.labelNode.Name = "labelNode";
this.labelNode.Size = new System.Drawing.Size(0, 16); this.labelNode.Size = new System.Drawing.Size(0, 20);
this.labelNode.TabIndex = 25; this.labelNode.TabIndex = 25;
// //
// menuStrip1
//
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lab2ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(800, 28);
this.menuStrip1.TabIndex = 26;
this.menuStrip1.Text = "menuStrip1";
//
// lab2ToolStripMenuItem
//
this.lab2ToolStripMenuItem.Name = "lab2ToolStripMenuItem";
this.lab2ToolStripMenuItem.Size = new System.Drawing.Size(55, 24);
this.lab2ToolStripMenuItem.Text = "Lab2";
this.lab2ToolStripMenuItem.Click += new System.EventHandler(this.lab2ToolStripMenuItem_Click);
//
// labelChange
//
this.labelChange.AutoSize = true;
this.labelChange.ForeColor = System.Drawing.Color.Red;
this.labelChange.Location = new System.Drawing.Point(336, 160);
this.labelChange.Name = "labelChange";
this.labelChange.Size = new System.Drawing.Size(0, 20);
this.labelChange.TabIndex = 27;
//
// labelDateChange
//
this.labelDateChange.AutoSize = true;
this.labelDateChange.Location = new System.Drawing.Point(22, 524);
this.labelDateChange.Name = "labelDateChange";
this.labelDateChange.Size = new System.Drawing.Size(0, 20);
this.labelDateChange.TabIndex = 28;
//
// myTreeView1
//
this.myTreeView1.AutoSize = true;
this.myTreeView1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.myTreeView1.BackColor = System.Drawing.SystemColors.ControlDark;
this.myTreeView1.Location = new System.Drawing.Point(13, 552);
this.myTreeView1.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
this.myTreeView1.Name = "myTreeView1";
this.myTreeView1.Size = new System.Drawing.Size(427, 503);
this.myTreeView1.TabIndex = 17;
//
// newCheckList1
//
this.newCheckList1.AutoSize = true;
this.newCheckList1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.newCheckList1.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.newCheckList1.Location = new System.Drawing.Point(12, 40);
this.newCheckList1.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
this.newCheckList1.Name = "newCheckList1";
this.newCheckList1.selectedValue = "";
this.newCheckList1.Size = new System.Drawing.Size(285, 298);
this.newCheckList1.TabIndex = 0;
//
// myTextBoxDate
//
this.myTextBoxDate.DateMaximum = null;
this.myTextBoxDate.DateMinimum = null;
this.myTextBoxDate.Location = new System.Drawing.Point(20, 358);
this.myTextBoxDate.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
this.myTextBoxDate.Name = "myTextBoxDate";
this.myTextBoxDate.Size = new System.Drawing.Size(316, 119);
this.myTextBoxDate.TabIndex = 29;
this.myTextBoxDate.Value = null;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 867); this.ClientSize = new System.Drawing.Size(800, 1055);
this.Controls.Add(this.myTextBoxDate);
this.Controls.Add(this.labelDateChange);
this.Controls.Add(this.labelChange);
this.Controls.Add(this.labelNode); this.Controls.Add(this.labelNode);
this.Controls.Add(this.buttonTakeNode); this.Controls.Add(this.buttonTakeNode);
this.Controls.Add(this.buttonGen); this.Controls.Add(this.buttonGen);
@ -313,7 +375,6 @@
this.Controls.Add(this.buttonGiveTime); this.Controls.Add(this.buttonGiveTime);
this.Controls.Add(this.buttonTakeTime); this.Controls.Add(this.buttonTakeTime);
this.Controls.Add(this.dateTimePicker); this.Controls.Add(this.dateTimePicker);
this.Controls.Add(this.myTextBoxDate);
this.Controls.Add(this.buttonReplace); this.Controls.Add(this.buttonReplace);
this.Controls.Add(this.buttonTake); this.Controls.Add(this.buttonTake);
this.Controls.Add(this.textBoxTakeValue); this.Controls.Add(this.textBoxTakeValue);
@ -325,8 +386,13 @@
this.Controls.Add(this.labelList); this.Controls.Add(this.labelList);
this.Controls.Add(this.textBoxList); this.Controls.Add(this.textBoxList);
this.Controls.Add(this.newCheckList1); this.Controls.Add(this.newCheckList1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -334,7 +400,7 @@
#endregion #endregion
private VisEl.MyCheckList newCheckList1; private VisableComponents.MyCheckList newCheckList1;
private System.Windows.Forms.TextBox textBoxList; private System.Windows.Forms.TextBox textBoxList;
private System.Windows.Forms.Label labelList; private System.Windows.Forms.Label labelList;
private System.Windows.Forms.Label labelListEl; private System.Windows.Forms.Label labelListEl;
@ -345,13 +411,12 @@
private System.Windows.Forms.TextBox textBoxTakeValue; private System.Windows.Forms.TextBox textBoxTakeValue;
private System.Windows.Forms.Button buttonTake; private System.Windows.Forms.Button buttonTake;
private System.Windows.Forms.Button buttonReplace; private System.Windows.Forms.Button buttonReplace;
private VisEl.MyTextBoxDate myTextBoxDate;
private System.Windows.Forms.DateTimePicker dateTimePicker; private System.Windows.Forms.DateTimePicker dateTimePicker;
private System.Windows.Forms.Button buttonTakeTime; private System.Windows.Forms.Button buttonTakeTime;
private System.Windows.Forms.Button buttonGiveTime; private System.Windows.Forms.Button buttonGiveTime;
private System.Windows.Forms.Label labelTitle; private System.Windows.Forms.Label labelTitle;
private System.Windows.Forms.Label labelChecked; private System.Windows.Forms.Label labelChecked;
private VisEl.MyTreeView myTreeView1; private VisableComponents.MyTreeView myTreeView1;
private System.Windows.Forms.Button buttonStart; private System.Windows.Forms.Button buttonStart;
private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Button buttonAddHier; private System.Windows.Forms.Button buttonAddHier;
@ -360,6 +425,11 @@
private System.Windows.Forms.Button buttonGen; private System.Windows.Forms.Button buttonGen;
private System.Windows.Forms.Button buttonTakeNode; private System.Windows.Forms.Button buttonTakeNode;
private System.Windows.Forms.Label labelNode; private System.Windows.Forms.Label labelNode;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem lab2ToolStripMenuItem;
private System.Windows.Forms.Label labelChange;
private System.Windows.Forms.Label labelDateChange;
private VisableComponents.MyTextBoxDate myTextBoxDate;
} }
} }

View File

@ -4,15 +4,14 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Management.Instrumentation;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using TestLib; using TestLib;
using VisEl; using VisableComponents;
using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Test namespace TestForm
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
@ -30,6 +29,18 @@ namespace Test
InitializeComponent(); InitializeComponent();
comboBox1.Items.AddRange(typeof(Sportsmen).GetFields().Select(x => x.Name).ToArray()); comboBox1.Items.AddRange(typeof(Sportsmen).GetFields().Select(x => x.Name).ToArray());
comboBox1.Items.AddRange(typeof(Sportsmen).GetProperties().Select(x => x.Name).ToArray()); comboBox1.Items.AddRange(typeof(Sportsmen).GetProperties().Select(x => x.Name).ToArray());
myTextBoxDate.DateMax = new DateTime(2019, 12, 1);
myTextBoxDate.DateMin = new DateTime(2012, 12, 1);
newCheckList1.ValueChanged += CustomEvent_Handler;
myTextBoxDate.ValueChanged += CustomEvent_HandlerDate;
}
private void CustomEvent_Handler(object sender, EventArgs e)
{
MessageBox.Show("Данные поменялись");
}
private void CustomEvent_HandlerDate(object sender, EventArgs e)
{
labelDateChange.Text = "Ку-ку";
} }
private void buttonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
@ -64,19 +75,17 @@ namespace Test
private void buttonTakeTime_Click(object sender, EventArgs e) private void buttonTakeTime_Click(object sender, EventArgs e)
{ {
labelChecked.Text = myTextBoxDate.Value; labelChecked.Text = myTextBoxDate.Value.ToString();
} }
private void buttonGiveTime_Click(object sender, EventArgs e) private void buttonGiveTime_Click(object sender, EventArgs e)
{ {
myTextBoxDate.Value = dateTimePicker.Value.ToString(); myTextBoxDate.Value = dateTimePicker.Value;
} }
private void buttonGO_Click(object sender, EventArgs e) private void buttonGO_Click(object sender, EventArgs e)
{ {
foreach(string step in stringToHierachy) myTreeView1.addToHierarchy(stringToHierachy);
myTreeView1.addToHierarchy(step, false);
myTreeView1.LoadTree(sportsmens); myTreeView1.LoadTree(sportsmens);
labelHier.Text = ""; labelHier.Text = "";
stringToHierachy.Clear(); stringToHierachy.Clear();
@ -106,7 +115,15 @@ namespace Test
private void buttonTakeNode_Click(object sender, EventArgs e) private void buttonTakeNode_Click(object sender, EventArgs e)
{ {
labelNode.Text = myTreeView1.GetNode(); var f = typeof(Sportsmen);
var res = myTreeView1.GetNode(typeof(Sportsmen));
labelNode.Text = res.ToString();
}
private void lab2ToolStripMenuItem_Click(object sender, EventArgs e)
{
Lab2 lab2 = new Lab2();
lab2.Show();
} }
} }
} }

63
VisEl/TestForm/Form1.resx Normal file
View File

@ -0,0 +1,63 @@
<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>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

197
VisEl/TestForm/Lab2.Designer.cs generated Normal file
View File

@ -0,0 +1,197 @@
namespace TestForm
{
partial class Lab2
{
/// <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.components = new System.ComponentModel.Container();
this.imageExcel1 = new UnvisableComponents.ImageExcel(this.components);
this.buttonOne = new System.Windows.Forms.Button();
this.labelPathTitle = new System.Windows.Forms.Label();
this.labelImages = new System.Windows.Forms.Label();
this.buttonTakePath = new System.Windows.Forms.Button();
this.openFileDialogPath = new System.Windows.Forms.OpenFileDialog();
this.labelPath = new System.Windows.Forms.Label();
this.textBoxTitle = new System.Windows.Forms.TextBox();
this.labelTitle = new System.Windows.Forms.Label();
this.buttonTakeImage = new System.Windows.Forms.Button();
this.labelTakenImages = new System.Windows.Forms.Label();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.excelHead1 = new UnvisableComponents.ExcelHead(this.components);
this.buttonHead = new System.Windows.Forms.Button();
this.excelChart1 = new UnvisableComponents.ExcelChart(this.components);
this.buttonPaint = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonOne
//
this.buttonOne.Location = new System.Drawing.Point(584, 40);
this.buttonOne.Name = "buttonOne";
this.buttonOne.Size = new System.Drawing.Size(94, 29);
this.buttonOne.TabIndex = 0;
this.buttonOne.Text = "Загрузить";
this.buttonOne.UseVisualStyleBackColor = true;
this.buttonOne.Click += new System.EventHandler(this.buttonOne_Click);
//
// labelPathTitle
//
this.labelPathTitle.AutoSize = true;
this.labelPathTitle.Location = new System.Drawing.Point(12, 40);
this.labelPathTitle.Name = "labelPathTitle";
this.labelPathTitle.Size = new System.Drawing.Size(41, 20);
this.labelPathTitle.TabIndex = 1;
this.labelPathTitle.Text = "Путь";
//
// labelImages
//
this.labelImages.AutoSize = true;
this.labelImages.Location = new System.Drawing.Point(12, 75);
this.labelImages.Name = "labelImages";
this.labelImages.Size = new System.Drawing.Size(75, 20);
this.labelImages.TabIndex = 2;
this.labelImages.Text = "Картинки";
//
// buttonTakePath
//
this.buttonTakePath.Location = new System.Drawing.Point(12, 8);
this.buttonTakePath.Name = "buttonTakePath";
this.buttonTakePath.Size = new System.Drawing.Size(121, 29);
this.buttonTakePath.TabIndex = 3;
this.buttonTakePath.Text = "ВыбратьПуть";
this.buttonTakePath.UseVisualStyleBackColor = true;
this.buttonTakePath.Click += new System.EventHandler(this.buttonTakePath_Click);
//
// openFileDialogPath
//
this.openFileDialogPath.FileName = "openFileDialogPath";
//
// labelPath
//
this.labelPath.AutoSize = true;
this.labelPath.Location = new System.Drawing.Point(59, 40);
this.labelPath.Name = "labelPath";
this.labelPath.Size = new System.Drawing.Size(0, 20);
this.labelPath.TabIndex = 4;
//
// textBoxTitle
//
this.textBoxTitle.Location = new System.Drawing.Point(337, 42);
this.textBoxTitle.Name = "textBoxTitle";
this.textBoxTitle.Size = new System.Drawing.Size(125, 27);
this.textBoxTitle.TabIndex = 5;
this.textBoxTitle.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// labelTitle
//
this.labelTitle.AutoSize = true;
this.labelTitle.Location = new System.Drawing.Point(254, 45);
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(81, 20);
this.labelTitle.TabIndex = 6;
this.labelTitle.Text = "Заголовок";
//
// buttonTakeImage
//
this.buttonTakeImage.Location = new System.Drawing.Point(12, 98);
this.buttonTakeImage.Name = "buttonTakeImage";
this.buttonTakeImage.Size = new System.Drawing.Size(121, 29);
this.buttonTakeImage.TabIndex = 7;
this.buttonTakeImage.Text = "ВыбратьФото";
this.buttonTakeImage.UseVisualStyleBackColor = true;
this.buttonTakeImage.Click += new System.EventHandler(this.buttonTakeImage_Click);
//
// labelTakenImages
//
this.labelTakenImages.AutoSize = true;
this.labelTakenImages.Location = new System.Drawing.Point(93, 75);
this.labelTakenImages.Name = "labelTakenImages";
this.labelTakenImages.Size = new System.Drawing.Size(0, 20);
this.labelTakenImages.TabIndex = 8;
//
// buttonHead
//
this.buttonHead.Location = new System.Drawing.Point(12, 189);
this.buttonHead.Name = "buttonHead";
this.buttonHead.Size = new System.Drawing.Size(94, 29);
this.buttonHead.TabIndex = 9;
this.buttonHead.Text = "Go";
this.buttonHead.UseVisualStyleBackColor = true;
this.buttonHead.Click += new System.EventHandler(this.buttonHead_Click);
//
// buttonPaint
//
this.buttonPaint.Location = new System.Drawing.Point(12, 280);
this.buttonPaint.Name = "buttonPaint";
this.buttonPaint.Size = new System.Drawing.Size(94, 29);
this.buttonPaint.TabIndex = 10;
this.buttonPaint.Text = "Paint";
this.buttonPaint.UseVisualStyleBackColor = true;
this.buttonPaint.Click += new System.EventHandler(this.buttonPaint_Click);
//
// Lab2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonPaint);
this.Controls.Add(this.buttonHead);
this.Controls.Add(this.labelTakenImages);
this.Controls.Add(this.buttonTakeImage);
this.Controls.Add(this.labelTitle);
this.Controls.Add(this.textBoxTitle);
this.Controls.Add(this.labelPath);
this.Controls.Add(this.buttonTakePath);
this.Controls.Add(this.labelImages);
this.Controls.Add(this.labelPathTitle);
this.Controls.Add(this.buttonOne);
this.Name = "Lab2";
this.Text = "Lab2";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private UnvisableComponents.ImageExcel imageExcel1;
private Button buttonOne;
private Label labelPathTitle;
private Label labelImages;
private Button buttonTakePath;
private OpenFileDialog openFileDialogPath;
private Label labelPath;
private TextBox textBoxTitle;
private Label labelTitle;
private Button buttonTakeImage;
private Label labelTakenImages;
private SaveFileDialog saveFileDialog1;
private UnvisableComponents.ExcelHead excelHead1;
private Button buttonHead;
private UnvisableComponents.ExcelChart excelChart1;
private Button buttonPaint;
}
}

117
VisEl/TestForm/Lab2.cs Normal file
View File

@ -0,0 +1,117 @@
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 TestLib;
using UnvisableComponents;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace TestForm
{
public partial class Lab2 : Form
{
ImageInfo info;
List<byte[]> files;
string[] names = { "Vova M", "Sasha A", "Dima D", "Danila L" };
string[] sports = { "Run", "Swim", "Cycle", "Race", "Box" };
string[] cities = { "Moskow", "Samara", "Piter", "Kazan", "Kyrsk" };
string[] countries = { "Russia", "Spain", "China", "India", "Brazil" };
string[] rewards = { "#1", "#2", "KMS", "Olymp", "MS" };
List<Sportsmen> sportsmens = new List<Sportsmen>();
public Lab2()
{
InitializeComponent();
info = new ImageInfo();
files = new List<byte[]>();
}
private void buttonOne_Click(object sender, EventArgs e)
{
info.Files = files;
imageExcel1.Load(info);
}
private void buttonTakePath_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = saveFileDialog1.FileName;
labelPath.Text = filename;
info.Path = filename;
MessageBox.Show("Файл открыт");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
info.Title = textBoxTitle.Text;
}
private void buttonTakeImage_Click(object sender, EventArgs e)
{
if (openFileDialogPath.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialogPath.FileName;
Image img = Image.FromFile(filename);
byte[] bA;
using (MemoryStream mStream = new MemoryStream())
{
img.Save(mStream, img.RawFormat);
bA = mStream.ToArray();
}
files.Add(bA);
labelTakenImages.Text +=" " + openFileDialogPath.FileName;
MessageBox.Show("Файл открыт");
}
private void buttonHead_Click(object sender, EventArgs e)
{
string path = @"C:\Users\Вова\Documents\WriteToExcel2.xlsx";
string title = "title";
ExcelInfo<Sportsmen> ei = new ExcelInfo<Sportsmen>();
ei.Title = title;
ei.Path = path;
ei.Dates = new List<Sportsmen>();
Dictionary<string, int> aloneFields = new Dictionary<string, int>();
ei.addDictionary("Personal", "name", 10);
ei.addDictionaryAlone("awards", 15);
ei.addDictionary("Personal", "city", 20);
ei.addDictionary("Proffesion", "Region", 30);
ei.addDictionary("Proffesion", "sport", 70);
sportsmens.Clear();
Random rn = new Random();
for (int i = 0; i < 10; i++)
{
Sportsmen sm = new Sportsmen(names[rn.Next(0, 4)], sports[rn.Next(0, 5)], cities[rn.Next(0, 5)], countries[rn.Next(0, 5)], rewards[rn.Next(0, 5)]);
sportsmens.Add(sm);
}
ei.Dates = sportsmens;
excelHead1.Load(ei);
}
private void buttonPaint_Click(object sender, EventArgs e)
{
string path = @"C:\Users\Вова\Documents\WriteToExcel2.xlsx";
string title = "title";
ChartInfo ci = new ChartInfo();
ci.Title = title;
ci.Path = path;
List<(string, int)> dates = new List<(string,int)>();
ci.DiagrammTitle = "CHARTTOP";
Random rn = new Random();
for (int i = 0; i < 5; i++)
{
dates.Add((names[rn.Next(0, 4)],rn.Next(1,10)));
}
ci.Dates = dates;
excelChart1.Load(ci);
}
}
}

75
VisEl/TestForm/Lab2.resx Normal file
View File

@ -0,0 +1,75 @@
<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>
<metadata name="imageExcel1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>206, 17</value>
</metadata>
<metadata name="openFileDialogPath.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>343, 17</value>
</metadata>
<metadata name="excelHead1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>505, 17</value>
</metadata>
<metadata name="excelChart1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>636, 17</value>
</metadata>
</root>

17
VisEl/TestForm/Program.cs Normal file
View File

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

View File

@ -22,5 +22,10 @@ namespace TestLib
this.country = country; this.country = country;
this.awards = awards; this.awards = awards;
} }
public Sportsmen() { }
public override string ToString()
{
return country + " " + city + " " + name + " " + sport + " " + awards;
}
} }
} }

View File

@ -0,0 +1,25 @@
<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="..\UnvisableComponents\UnvisableComponents.csproj" />
<ProjectReference Include="..\VisableComponents\VisableComponents.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Lab2.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@ -1,23 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace TestLib
{
public class Car
{
string model;
string Model { get { return model; } set { model = value; } }
string year;
string color;
public Car(string model, string year, string color)
{
this.model = model;
this.year = year;
this.color = color;
}
}
}

View File

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestLib
{
public class Employer
{
string name;
string proffesion;
string office;
public Employer(string name, string proffesion, string office)
{
this.name = name;
this.proffesion = proffesion;
this.office = office;
}
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestLib
{
public class Sportsmen
{
string name;
string sport;
string city;
string country;
string Region { get { return city; } set { city = value; } }
int awards;
public Sportsmen(string name, string sport, string city, string country, int awards)
{
this.name = name;
this.sport = sport;
this.city = city;
this.country = country;
this.awards = awards;
}
}
}

Binary file not shown.

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnvisableComponents
{
public class ChartInfo
{
private string path;
private string title;
private string diagrammTitle;
private List<(string,int)> dates = new List<(string, int)>();
private DirectionLegend dir = 0;
public string Path { get { return path; } set { path = value; } }
public string Title { get { return title; } set { title = value; } }
public string DiagrammTitle { get { return diagrammTitle; } set { diagrammTitle = value; } }
public DirectionLegend DirLegend { get { return dir; } set { dir = value; } }
public List<(string, int)> Dates { get { return dates; } set { dates = value; } }
public ChartInfo() { }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnvisableComponents
{
public enum DirectionLegend
{
Up,
Left,
Right,
Bottom,
}
}

View File

@ -0,0 +1,36 @@
namespace UnvisableComponents
{
partial class ExcelChart
{
/// <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
}
}

View File

@ -0,0 +1,76 @@
using OfficeOpenXml.Style;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LicenseContext = OfficeOpenXml.LicenseContext;
using OfficeOpenXml.Drawing.Chart;
namespace UnvisableComponents
{
public partial class ExcelChart : Component
{
public ExcelChart()
{
InitializeComponent();
}
public ExcelChart(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void Load(ChartInfo info)
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
Check(info);
List<string> fields = new List<string>();
using (ExcelPackage excelPackage = new ExcelPackage())
{
excelPackage.Workbook.Properties.Author = "Qawithexperts";
excelPackage.Workbook.Properties.Title = "test Excel";
excelPackage.Workbook.Properties.Subject = "Write in Excel";
excelPackage.Workbook.Properties.Created = DateTime.Now;
ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1");
worksheet.Cells["A1"].Value = info.Title;
int posString = 2;
int endColumn = 1;
int startColumn = 1;
foreach(var step in info.Dates)
{
worksheet.Cells[posString,endColumn].Value = step.Item1;
worksheet.Cells[posString+1, endColumn].Value = step.Item2;
endColumn++;
}
ExcelPieChart pieChart = worksheet.Drawings.AddChart("pieChart", eChartType.Pie3D) as ExcelPieChart;
pieChart.Title.Text = info.DiagrammTitle;
pieChart.Series.Add(ExcelRange.GetAddress(posString+1, startColumn, posString + 1, endColumn-1), ExcelRange.GetAddress(posString, startColumn, posString, endColumn-1));
pieChart.Legend.Position = (eLegendPosition)(int)info.DirLegend;
pieChart.DataLabel.ShowPercent = true;
pieChart.SetPosition(1, 0, 0, 0);
FileInfo fi = new FileInfo(info.Path);
excelPackage.SaveAs(fi);
}
}
public void Check(ChartInfo info)
{
if (string.IsNullOrEmpty(info.Title))
throw new Exception("Забыли заглавие");
if (string.IsNullOrEmpty(info.Path))
throw new Exception("Забыли путь");
if (!info.Path.EndsWith(".xlsx"))
info.Path += ".xlsx";
if (info.Dates.Count == 0)
throw new Exception("забыли данные");
}
}
}

View File

@ -0,0 +1,36 @@
namespace UnvisableComponents
{
partial class ExcelHead
{
/// <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
}
}

View File

@ -0,0 +1,145 @@
using OfficeOpenXml.Drawing;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LicenseContext = OfficeOpenXml.LicenseContext;
using System.Reflection;
using System.Xml.Linq;
using OfficeOpenXml.Style;
using System.Data.Common;
namespace UnvisableComponents
{
public partial class ExcelHead : Component
{
public ExcelHead()
{
InitializeComponent();
}
public ExcelHead(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void Load<T>(ExcelInfo<T> info) where T:class
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
Check<T>(info);
List<string> fields = new List<string>();
using (ExcelPackage excelPackage = new ExcelPackage())
{
excelPackage.Workbook.Properties.Author = "Qawithexperts";
excelPackage.Workbook.Properties.Title = "test Excel";
excelPackage.Workbook.Properties.Subject = "Write in Excel";
excelPackage.Workbook.Properties.Created = DateTime.Now;
ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1");
worksheet.Cells["A1"].Value = info.Title;
int posString = 2;
int posColumn = 1;
foreach(var step in info.Filds)
{
if(step.Value.Item1.Count == 1)
{
worksheet.Cells[posString, posColumn, posString, posColumn+1].Merge = true;
worksheet.Cells[posString, posColumn].Value = step.Key;
worksheet.Cells[posString, posColumn].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[posString, posColumn].Style.Fill.BackgroundColor.SetColor(Color.LightGreen);
fields.Add(step.Key);
posString++;
continue;
}
worksheet.Cells[posString, posColumn, posString + step.Value.Item1.Count-1, posColumn].Merge = true;
worksheet.Cells[posString, posColumn].Value = step.Key;
worksheet.Cells[posString, posColumn].Style.TextRotation = 180;
worksheet.Cells[posString, posColumn].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[posString, posColumn].Style.Fill.BackgroundColor.SetColor(Color.AliceBlue);
worksheet.Column(posColumn).BestFit = true;
posColumn++;
foreach(var field in step.Value.Item1)
{
int id = step.Value.Item1.IndexOf(field);
worksheet.Cells[posString, posColumn].Value = field;
worksheet.Cells[posString, posColumn].Style.Fill.PatternType = ExcelFillStyle.Solid;
worksheet.Cells[posString, posColumn].Style.Fill.BackgroundColor.SetColor(Color.AliceBlue);
worksheet.Row(posString).Height = step.Value.Item2[id];
fields.Add(field);
posString++;
}
posColumn--;
}
posColumn = 3;
foreach (var step in info.Dates)
{
posString = 2;
var type = step.GetType();
foreach(var field in fields)
{
worksheet.Cells[posString, posColumn].Value =
type.GetField(field) == null ? type.GetProperty(field).GetValue(step) : type.GetField(field).GetValue(step);
posString++;
}
posColumn++;
}
CheckTable(worksheet, fields.Count, info.Dates.Count);
FileInfo fi = new FileInfo(info.Path);
excelPackage.SaveAs(fi);
}
}
public void Check<T>(ExcelInfo<T> info) where T : class
{
if (string.IsNullOrEmpty(info.Title))
throw new Exception("Забыли заглавие");
if (string.IsNullOrEmpty(info.Path))
throw new Exception("Забыли путь");
if (!info.Path.EndsWith(".xlsx"))
info.Path += ".xlsx";
if (info.Dates.Count == 0)
throw new Exception("забыли данные");
}
public void CheckTable(ExcelWorksheet worksheet, int rows, int columns)
{
int posString = 2;
int posColumn = 1;
rows += posString;
columns += posColumn;
while(posString < rows)
{
while (posColumn < columns)
{
if (worksheet.Cells[posString, posColumn].Value == null && !worksheet.Cells[posString, posColumn - 1 ,posString, posColumn].Merge)
throw new Exception("Пустая ячейка");
posColumn++;
}
posString++;
}
posString = 2;
posColumn = 3 + columns;
while(posString < rows )
{
if (worksheet.Cells[posString, posColumn].Value != null)
throw new Exception("Выход за границы");
posString++;
}
posString = 2 + rows;
posColumn = 1;
while (posColumn < columns)
{
if (worksheet.Cells[posString, posColumn].Value != null)
throw new Exception("Выход за границы");
posColumn++;
}
}
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace UnvisableComponents
{
public class ExcelInfo<T> where T: class
{
private string path;
private string title;
private List<T> dates;
private Dictionary<string, (List<string>, List<int>)> fields = new Dictionary<string, (List<string>, List<int>)>();
public string Path { get { return path; } set { path = value; } }
public string Title { get { return title; } set { title = value; } }
public List<T> Dates { get { return dates; } set { dates = value; } }
public Dictionary<string, (List<string>, List<int>)> Filds { get { return fields; } }
public void addDictionary(string name, string field, int height)
{
if (fields.ContainsKey(name))
{
fields[name].Item1.Add(field);
fields[name].Item2.Add(height);
}
else
{
fields.Add(name, (new List<string>(), new List<int>()));
fields[name].Item1.Add(field);
fields[name].Item2.Add(height);
}
}
public void addDictionaryAlone(string field, int height)
{
fields.Add(field, (new List<string>(), new List<int>()));
fields[field].Item1.Add(field);
fields[field].Item2.Add(height);
}
public ExcelInfo() { }
}
}

View File

@ -0,0 +1,36 @@
namespace UnvisableComponents
{
partial class ImageExcel
{
/// <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
}
}

View File

@ -0,0 +1,76 @@
using OfficeOpenXml;
using OfficeOpenXml.Drawing;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Design;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LicenseContext = OfficeOpenXml.LicenseContext;
namespace UnvisableComponents
{
public partial class ImageExcel : Component
{
public ImageExcel()
{
InitializeComponent();
}
public ImageExcel(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void Load(ImageInfo info)
{
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
Check(info);
using (ExcelPackage excelPackage = new ExcelPackage())
{
excelPackage.Workbook.Properties.Author = "Qawithexperts";
excelPackage.Workbook.Properties.Title = "test Excel";
excelPackage.Workbook.Properties.Subject = "Write in Excel";
excelPackage.Workbook.Properties.Created = DateTime.Now;
ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1");
worksheet.Cells["A1"].Value = info.Title ;
int posString = 1;
int posColumn = 0;
int i = 1;
foreach(var image in info.Files)
{
ExcelPicture excelImage = null;
Stream stream = new MemoryStream(image);
excelImage = worksheet.Drawings.AddPicture("image" + i, stream);
excelImage.SetPosition(posString, 0, posColumn, 0);
excelImage.SetSize(100, 100);
i++;
posString += 10;
}
FileInfo fi = new FileInfo(info.Path);
excelPackage.SaveAs(fi);
}
}
public void Check(ImageInfo info)
{
if (string.IsNullOrEmpty(info.Title))
throw new Exception("Забыли заглавие");
if(string.IsNullOrEmpty(info.Path))
throw new Exception("Забыли путь");
if (!info.Path.EndsWith(".xlsx"))
info.Path += ".xlsx";
if (info.Files.Count == 0)
throw new Exception("забыли фото");
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnvisableComponents
{
public class ImageInfo
{
private string path;
private string title;
private List<byte[]> files;
public string Path { get { return path; } set { path = value; } }
public string Title { get { return title; } set { title = value; } }
public List<byte[]> Files { get { return files; } set { files = value; } }
public ImageInfo() { }
}
}

View File

@ -0,0 +1,29 @@
<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>
<None Remove="appSettings.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="appSettings.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EPPlus" Version="6.2.10" />
</ItemGroup>
<ItemGroup>
<Compile Update="ImageExcel.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
{
{
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial" //The license context used
}
}
}
}

View File

@ -12,6 +12,18 @@ namespace VisEl
{ {
public partial class MyCheckList : UserControl public partial class MyCheckList : UserControl
{ {
private EventHandler onValueChanged;
public event EventHandler ValueChanged
{
add
{
onValueChanged += value;
}
remove
{
onValueChanged -= value;
}
}
public MyCheckList() public MyCheckList()
{ {
InitializeComponent(); InitializeComponent();
@ -43,6 +55,7 @@ namespace VisEl
{ {
Random rn = new Random(); Random rn = new Random();
checkedList.BackColor = Color.FromArgb(rn.Next(0,255), rn.Next(0, 255), rn.Next(0, 255)); checkedList.BackColor = Color.FromArgb(rn.Next(0,255), rn.Next(0, 255), rn.Next(0, 255));
onValueChanged?.Invoke(this,e);
} }
} }
} }

View File

@ -29,7 +29,6 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.dateTimePicker = new System.Windows.Forms.DateTimePicker(); this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.labelEr = new System.Windows.Forms.Label();
this.labelMin = new System.Windows.Forms.Label(); this.labelMin = new System.Windows.Forms.Label();
this.labelMax = new System.Windows.Forms.Label(); this.labelMax = new System.Windows.Forms.Label();
this.panel = new System.Windows.Forms.Panel(); this.panel = new System.Windows.Forms.Panel();
@ -46,14 +45,6 @@
this.dateTimePicker.TabIndex = 0; this.dateTimePicker.TabIndex = 0;
this.dateTimePicker.ValueChanged += new System.EventHandler(this.dateTimePicker_ValueChanged); this.dateTimePicker.ValueChanged += new System.EventHandler(this.dateTimePicker_ValueChanged);
// //
// labelEr
//
this.labelEr.AutoSize = true;
this.labelEr.Location = new System.Drawing.Point(27, 105);
this.labelEr.Name = "labelEr";
this.labelEr.Size = new System.Drawing.Size(0, 16);
this.labelEr.TabIndex = 1;
//
// labelMin // labelMin
// //
this.labelMin.AutoSize = true; this.labelMin.AutoSize = true;
@ -87,7 +78,6 @@
this.Controls.Add(this.panel); this.Controls.Add(this.panel);
this.Controls.Add(this.labelMax); this.Controls.Add(this.labelMax);
this.Controls.Add(this.labelMin); this.Controls.Add(this.labelMin);
this.Controls.Add(this.labelEr);
this.Name = "MyTextBoxDate"; this.Name = "MyTextBoxDate";
this.Size = new System.Drawing.Size(316, 150); this.Size = new System.Drawing.Size(316, 150);
this.panel.ResumeLayout(false); this.panel.ResumeLayout(false);
@ -99,7 +89,6 @@
#endregion #endregion
private System.Windows.Forms.DateTimePicker dateTimePicker; private System.Windows.Forms.DateTimePicker dateTimePicker;
private System.Windows.Forms.Label labelEr;
private System.Windows.Forms.Label labelMin; private System.Windows.Forms.Label labelMin;
private System.Windows.Forms.Label labelMax; private System.Windows.Forms.Label labelMax;
private System.Windows.Forms.Panel panel; private System.Windows.Forms.Panel panel;

View File

@ -1,9 +1,10 @@
using System; using Microsoft.Build.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -12,46 +13,65 @@ namespace VisEl
{ {
public partial class MyTextBoxDate : UserControl public partial class MyTextBoxDate : UserControl
{ {
public DateTime DateMin = new DateTime(1999, 1, 1); private EventHandler onValueChanged;
public DateTime DateMax = new DateTime(2025, 12, 31); public event EventHandler ValueChanged
{
add
{
onValueChanged += value;
}
remove
{
onValueChanged -= value;
}
}
public string TextEr;
public string Err { get { return TextEr; } private set { TextEr = value; } }
public DateTime? DateMin = null;
public DateTime? DateMax = null;
public MyTextBoxDate() public MyTextBoxDate()
{ {
InitializeComponent(); InitializeComponent();
labelMin.Text = DateMin.ToShortDateString();
labelMax.Text = DateMax.ToShortDateString();
} }
public DateTime DateMaximum { public DateTime? DateMaximum {
get { return DateMax; } get { return DateMax ; }
set { set {
DateMax = value;
labelMax.Text = DateMax.ToString(); DateMax = value;
} }
} }
public DateTime DateMinimum public DateTime? DateMinimum
{ {
get { return DateMin; } get { return DateMin; }
set set
{ {
DateMin = value;
labelMin.Text = DateMin.ToString(); DateMin = value;
} }
} }
public string Value public DateTime? Value
{ {
get get
{ {
if(DateMin is null || DateMax is null) {
Err = "Ошибка: НЕТ диапазона";
return null;
}
if (dateTimePicker.Value > DateMax || dateTimePicker.Value < DateMin) if (dateTimePicker.Value > DateMax || dateTimePicker.Value < DateMin)
{ {
labelEr.ForeColor = Color.Red; Err = "Ошибка: Выход за допустимые пределы!!!";
labelEr.Text = "Ошибка: Выход за допустимые пределы!!!"; return null;
return null; } }
labelEr.Text = ""; return dateTimePicker.Value;
return dateTimePicker.Value.ToShortDateString();
} }
set set
{ {
if (DateTime.Parse(value) > DateMax || DateTime.Parse(value) < DateMin) return; if (value == null) return;
dateTimePicker.Value = DateTime.Parse(value); if (value > DateMax || value < DateMin) return;
dateTimePicker.Value = (DateTime)value;
} }
} }
@ -59,6 +79,7 @@ namespace VisEl
{ {
if (dateTimePicker.Value >= DateMinimum && dateTimePicker.Value <= DateMaximum) panel.BackColor = Color.LightBlue; if (dateTimePicker.Value >= DateMinimum && dateTimePicker.Value <= DateMaximum) panel.BackColor = Color.LightBlue;
else panel.BackColor = Color.Red; else panel.BackColor = Color.Red;
onValueChanged?.Invoke(this,e);
} }
} }
} }

View File

@ -8,27 +8,45 @@ using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml.Linq;
namespace VisEl namespace VisEl
{ {
public partial class MyTreeView : UserControl public partial class MyTreeView : UserControl
{ {
List<(string, bool)> hierarchy = new List<(string, bool)>(); List<string> hierarchy = new List<string>();
public MyTreeView() public MyTreeView()
{ {
InitializeComponent(); InitializeComponent();
} }
public void addToHierarchy(string member , bool isolation) { hierarchy.Add((member, isolation)); } public void addToHierarchy(List<string> list) { hierarchy = list; }
public int GetId public int GetId
{ {
get { return treeView.SelectedNode.Index; } get {
if(treeView.SelectedNode.FirstNode == null)
return treeView.SelectedNode.Index;
return -1;
}
} }
public string GetNode() public object GetNode<T>(T nodeClass) where T: Type
{ {
var res = Activator.CreateInstance(nodeClass);
T child;
if (treeView.SelectedNode.FirstNode == null) if (treeView.SelectedNode.FirstNode == null)
return treeView.SelectedNode.Text.ToString(); {
TreeNode parent = treeView.SelectedNode;
do
{
if (nodeClass.GetField(parent.Name) == null)
nodeClass.GetProperty(parent.Name).SetValue(res, parent.Text);
else nodeClass.GetField(parent.Name).SetValue(res, parent.Text);
parent = parent.Parent;
} while(parent != null);
return res;
}
return null; return null;
} }
public void LoadTree<T>(List<T> nodes) public void LoadTree<T>(List<T> nodes)
@ -38,30 +56,23 @@ namespace VisEl
{ {
TreeNode parent = null; TreeNode parent = null;
Type type = node.GetType(); Type type = node.GetType();
foreach((string, bool) step in hierarchy) foreach(string step in hierarchy)
{ {
var aa = type.GetFields(); var aa = type.GetFields();
if (type.GetField(step.Item1) != null || type.GetProperty(step.Item1) != null) if (type.GetField(step) != null || type.GetProperty(step) != null)
{ {
var value = type.GetField(step.Item1) == null ? type.GetProperty(step.Item1).GetValue(node) : type.GetField(step.Item1).GetValue(node); var value = type.GetField(step) == null ? type.GetProperty(step).GetValue(node) : type.GetField(step).GetValue(node);
TreeNode[] nodesLevel; TreeNode[] nodesLevel;
if (parent == null) if (parent == null)
{ {
if (step.Item2)
{ nodesLevel = treeView.Nodes.Find(step, false);
TreeNode newNode = new TreeNode(value.ToString());
newNode.Name = step.Item1;
treeView.Nodes.Add(newNode);
parent = newNode;
continue;
}
nodesLevel = treeView.Nodes.Find(step.Item1, false);
TreeNode currentNode = nodesLevel.FirstOrDefault(x => x.Text.Equals(value)); TreeNode currentNode = nodesLevel.FirstOrDefault(x => x.Text.Equals(value));
if (currentNode is null) if (currentNode is null)
{ {
TreeNode newNode = new TreeNode(value.ToString()); TreeNode newNode = new TreeNode(value.ToString());
newNode.Name = step.Item1; newNode.Name = step;
treeView.Nodes.Add(newNode); treeView.Nodes.Add(newNode);
parent = newNode; parent = newNode;
}else }else
@ -72,20 +83,13 @@ namespace VisEl
} }
else else
{ {
if (step.Item2)
{ nodesLevel = parent.Nodes.Find(step, false);
TreeNode newNode = new TreeNode(value.ToString());
newNode.Name = step.Item1;
parent.Nodes.Add(newNode);
parent = newNode;
continue;
}
nodesLevel = parent.Nodes.Find(step.Item1, false);
TreeNode currentNode = nodesLevel.FirstOrDefault(x => x.Text.Equals(value)); TreeNode currentNode = nodesLevel.FirstOrDefault(x => x.Text.Equals(value));
if (currentNode is null) if (currentNode is null)
{ {
TreeNode newNode = new TreeNode(value.ToString()); TreeNode newNode = new TreeNode(value.ToString());
newNode.Name = step.Item1; newNode.Name = step;
parent.Nodes.Add(newNode); parent.Nodes.Add(newNode);
parent = newNode; parent = newNode;
}else }else

View File

@ -30,6 +30,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />

View File

@ -0,0 +1,65 @@
using System.Drawing;
namespace VisableComponents
{
partial class MyCheckList
{
/// <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.checkedList = new System.Windows.Forms.CheckedListBox();
this.SuspendLayout();
//
// checkedList
//
this.checkedList.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(123)))), ((int)(((byte)(200)))), ((int)(((byte)(246)))));
this.checkedList.FormattingEnabled = true;
this.checkedList.HorizontalScrollbar = true;
this.checkedList.Location = new System.Drawing.Point(3, 3);
this.checkedList.Name = "checkedList";
this.checkedList.Size = new System.Drawing.Size(279, 242);
this.checkedList.TabIndex = 0;
this.checkedList.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedList_ItemCheck);
//
// MyCheckList
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.BackColor = Color.FromArgb(0,0,0);
this.Controls.Add(this.checkedList);
this.Name = "MyCheckList";
this.Size = new System.Drawing.Size(285, 248);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.CheckedListBox checkedList;
}
}

View File

@ -0,0 +1,88 @@
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 VisableComponents
{
public partial class MyCheckList : UserControl
{
private EventHandler onValueChanged;
public event EventHandler ValueChanged
{
add
{
onValueChanged += value;
}
remove
{
onValueChanged -= value;
}
}
public MyCheckList()
{
InitializeComponent();
}
public void LoadValues(List<string> Values)
{
checkedList.Items.AddRange(Values.ToArray());
}
public void RemoveAll()
{
checkedList.Items.Clear();
}
public string selectedValue {
get
{
if(checkedList.SelectedItem is null)
return "";
else
return checkedList.SelectedItem.ToString();
}
set {
if (checkedList.SelectedItem is null)
return;
checkedList.Items[checkedList.SelectedIndex] = value;
}
}
public int selectedValuesCount
{
get
{
if (checkedList.CheckedItems != null)
return checkedList.CheckedItems.Count;
return 0;
}
}
public void setValues(List<string> Values)
{
foreach(string Value in Values)
if(checkedList.Items.Contains(Value))
checkedList.SetItemCheckState(checkedList.Items.IndexOf(Value), CheckState.Checked);
}
public List<string> getSelectedItems()
{
List<string> values = new List<string>();
if (checkedList.CheckedItems != null)
{
foreach(var item in checkedList.CheckedItems)
values.Add(item.ToString());
return values;
}
return null;
}
private void checkedList_ItemCheck(object sender, ItemCheckEventArgs e)
{
Random rn = new Random();
checkedList.BackColor = Color.FromArgb(rn.Next(0,255), rn.Next(0, 255), rn.Next(0, 255));
onValueChanged?.Invoke(this,e);
}
}
}

View File

@ -0,0 +1,96 @@
namespace VisableComponents
{
partial class MyTextBoxDate
{
/// <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.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.labelMin = new System.Windows.Forms.Label();
this.labelMax = new System.Windows.Forms.Label();
this.panel = new System.Windows.Forms.Panel();
this.panel.SuspendLayout();
this.SuspendLayout();
//
// dateTimePicker
//
this.dateTimePicker.Location = new System.Drawing.Point(12, 22);
this.dateTimePicker.MaxDate = new System.DateTime(9998, 12, 3, 0, 0, 0, 0);
this.dateTimePicker.MinDate = new System.DateTime(1753, 1, 2, 0, 0, 0, 0);
this.dateTimePicker.Name = "dateTimePicker";
this.dateTimePicker.Size = new System.Drawing.Size(200, 22);
this.dateTimePicker.TabIndex = 0;
this.dateTimePicker.ValueChanged += new System.EventHandler(this.dateTimePicker_ValueChanged);
//
// labelMin
//
this.labelMin.AutoSize = true;
this.labelMin.Location = new System.Drawing.Point(27, 0);
this.labelMin.Name = "labelMin";
this.labelMin.Size = new System.Drawing.Size(28, 16);
this.labelMin.TabIndex = 2;
this.labelMin.Text = "Min";
//
// labelMax
//
this.labelMax.AutoSize = true;
this.labelMax.Location = new System.Drawing.Point(186, 0);
this.labelMax.Name = "labelMax";
this.labelMax.Size = new System.Drawing.Size(32, 16);
this.labelMax.TabIndex = 3;
this.labelMax.Text = "Max";
//
// panel
//
this.panel.Controls.Add(this.dateTimePicker);
this.panel.Location = new System.Drawing.Point(30, 19);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(226, 72);
this.panel.TabIndex = 4;
//
// MyTextBoxDate
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel);
this.Controls.Add(this.labelMax);
this.Controls.Add(this.labelMin);
this.Name = "MyTextBoxDate";
this.Size = new System.Drawing.Size(316, 150);
this.panel.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DateTimePicker dateTimePicker;
private System.Windows.Forms.Label labelMin;
private System.Windows.Forms.Label labelMax;
private System.Windows.Forms.Panel panel;
}
}

View File

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace VisableComponents
{
public partial class MyTextBoxDate : UserControl
{
private EventHandler onValueChanged;
public event EventHandler ValueChanged
{
add
{
onValueChanged += value;
}
remove
{
onValueChanged -= value;
}
}
public string TextEr;
public string Err { get { return TextEr; } private set { TextEr = value; } }
public DateTime? DateMin = null;
public DateTime? DateMax = null;
public MyTextBoxDate()
{
InitializeComponent();
}
public DateTime? DateMaximum {
get { return DateMax ; }
set {
DateMax = value;
}
}
public DateTime? DateMinimum
{
get { return DateMin; }
set
{
DateMin = value;
}
}
public DateTime? Value
{
get
{
if(DateMin is null || DateMax is null) {
Err = "Ошибка: НЕТ диапазона";
return null;
}
if (dateTimePicker.Value > DateMax || dateTimePicker.Value < DateMin)
{
Err = "Ошибка: Выход за допустимые пределы!!!";
return null;
}
return dateTimePicker.Value;
}
set
{
if (value == null) return;
if (value > DateMax || value < DateMin) return;
dateTimePicker.Value = (DateTime)value;
}
}
private void dateTimePicker_ValueChanged(object sender, EventArgs e)
{
if (dateTimePicker.Value >= DateMinimum && dateTimePicker.Value <= DateMaximum) panel.BackColor = Color.LightBlue;
else panel.BackColor = Color.Red;
onValueChanged?.Invoke(this,e);
}
}
}

View File

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <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:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <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="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
@ -109,9 +112,9 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
</root> </root>

View File

@ -0,0 +1,62 @@
namespace VisableComponents
{
partial class MyTreeView
{
/// <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.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView.Location = new System.Drawing.Point(0, 0);
this.treeView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.treeView.Name = "treeView";
this.treeView.Size = new System.Drawing.Size(600, 600);
this.treeView.TabIndex = 0;
//
// MyTreeView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.BackColor = System.Drawing.SystemColors.ControlDark;
this.Controls.Add(this.treeView);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MinimumSize = new System.Drawing.Size(200, 200);
this.Name = "MyTreeView";
this.Size = new System.Drawing.Size(600, 600);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TreeView treeView;
}
}

View File

@ -0,0 +1,118 @@
using System;
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;
using System.Xml.Linq;
namespace VisableComponents
{
public partial class MyTreeView : UserControl
{
List<string> hierarchy = new List<string>();
public MyTreeView()
{
InitializeComponent();
}
public void addToHierarchy(List<string> list) { hierarchy = list; }
public int GetId
{
get {
if(treeView.SelectedNode.FirstNode == null)
return treeView.SelectedNode.Index;
return -1;
}
}
public object GetNode<T>(T nodeClass) where T: Type
{
if (hierarchy == null || hierarchy.Count == 0)
{
throw new Exception("Не задана иерархия");
}
if (treeView.SelectedNode?.FirstNode != null)
{
throw new Exception("Выбран не крайний элемент");
}
var res = Activator.CreateInstance(nodeClass);
T child;
TreeNode? parent = treeView.SelectedNode;
do
{
if (nodeClass.GetField(parent.Name) == null)
nodeClass.GetProperty(parent.Name).SetValue(res, parent.Text);
else nodeClass.GetField(parent.Name).SetValue(res, parent.Text);
parent = parent.Parent;
} while (parent != null);
return res;
}
public void LoadTree<T>(List<T> nodes)
{
if(hierarchy == null || hierarchy.Count == 0)
{
throw new Exception("Не задана иерархия");
}
treeView.Nodes.Clear();
foreach (T node in nodes)
{
TreeNode parent = null;
Type type = node.GetType();
foreach(string step in hierarchy)
{
var aa = type.GetFields();
if (type.GetField(step) != null || type.GetProperty(step) != null)
{
var value = type.GetField(step) == null ? type.GetProperty(step).GetValue(node) : type.GetField(step).GetValue(node);
TreeNode[] nodesLevel;
if (parent == null)
{
nodesLevel = treeView.Nodes.Find(step, false);
TreeNode currentNode = nodesLevel.FirstOrDefault(x => x.Text.Equals(value));
if (currentNode is null)
{
TreeNode newNode = new TreeNode(value.ToString());
newNode.Name = step;
treeView.Nodes.Add(newNode);
parent = newNode;
}else
{
parent = currentNode;
continue;
}
}
else
{
nodesLevel = parent.Nodes.Find(step, false);
TreeNode currentNode = nodesLevel.FirstOrDefault(x => x.Text.Equals(value));
if (currentNode is null)
{
TreeNode newNode = new TreeNode(value.ToString());
newNode.Name = step;
parent.Nodes.Add(newNode);
parent = newNode;
}else
{
parent = currentNode;
continue;
}
}
}
else break;
}
}
}
}
}

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>

View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.8</Version>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<Compile Update="MyCheckList.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="MyTextBoxDate.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="MyTreeView.cs">
<SubType>UserControl</SubType>
</Compile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,24 @@
<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="..\VisEl\VisEl.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Lab2.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>