From 6a7c428cdb10807462b268b65fb6bd75cf477fbc Mon Sep 17 00:00:00 2001 From: dimazhelovanov Date: Thu, 30 Nov 2023 23:20:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Contracts/BindingModels/BookBindingModel.cs | 22 + Contracts/BindingModels/ShapeBindingModel.cs | 16 + Contracts/Contracts.csproj | 13 + Contracts/SearchModels/BookSearchModel.cs | 14 + Contracts/SearchModels/ShapeSearchModel.cs | 14 + Contracts/StoragesContracts/IBookStorage.cs | 21 + Contracts/StoragesContracts/IShapeStorage.cs | 21 + Contracts/ViewModels/BookViewModel.cs | 22 + Contracts/ViewModels/ShapeViewModel.cs | 23 + DataModels/DataModels.csproj | 9 + DataModels/IId.cs | 13 + DataModels/Models/IBook.cs | 16 + DataModels/Models/IShape.cs | 13 + DatabaseImplement/COPcontext.cs | 26 ++ DatabaseImplement/DatabaseImplement.csproj | 23 + DatabaseImplement/Implements/BookStorage.cs | 94 ++++ DatabaseImplement/Implements/ShapeStorage.cs | 93 ++++ .../20231116180013_Migration1.Designer.cs | 74 +++ .../Migrations/20231116180013_Migration1.cs | 50 ++ .../Migrations/COPcontextModelSnapshot.cs | 72 +++ DatabaseImplement/Models/Book.cs | 65 +++ DatabaseImplement/Models/Shape.cs | 51 +++ KOP_Labs.sln | 26 +- KOP_Labs/BooksForm.Designer.cs | 31 +- KOP_Labs/BooksForm.cs | 2 +- KOP_Labs/Classes/Book.cs | 6 +- KOP_Labs/KOP_Labs.csproj | 3 + KOP_Labs/TableComponent.Designer.cs | 11 +- KOP_Labs/TableComponent.cs | 4 +- Plugin/Class1.cs | 7 + Plugin/IPluginsConvention.cs | 65 +++ Plugin/Plugin.csproj | 9 + Plugin/PluginsConventionElement.cs | 14 + Plugin/PluginsConventionSaveDocument.cs | 13 + WinForm/Form1.cs | 6 +- WinForm/FormCreateBook.Designer.cs | 153 +++++++ WinForm/FormCreateBook.cs | 75 +++ WinForm/FormCreateBook.resx | 60 +++ WinForm/FormMain.Designer.cs | 162 +++++++ WinForm/FormMain.cs | 432 ++++++++++++++++++ WinForm/FormMain.resx | 75 +++ WinForm/FormShapes.Designer.cs | 64 +++ WinForm/FormShapes.cs | 148 ++++++ WinForm/FormShapes.resx | 60 +++ WinForm/NonVisualForm.cs | 14 +- WinForm/Program.cs | 25 +- WinForm/WinForm.csproj | 11 + 47 files changed, 2203 insertions(+), 38 deletions(-) create mode 100644 Contracts/BindingModels/BookBindingModel.cs create mode 100644 Contracts/BindingModels/ShapeBindingModel.cs create mode 100644 Contracts/Contracts.csproj create mode 100644 Contracts/SearchModels/BookSearchModel.cs create mode 100644 Contracts/SearchModels/ShapeSearchModel.cs create mode 100644 Contracts/StoragesContracts/IBookStorage.cs create mode 100644 Contracts/StoragesContracts/IShapeStorage.cs create mode 100644 Contracts/ViewModels/BookViewModel.cs create mode 100644 Contracts/ViewModels/ShapeViewModel.cs create mode 100644 DataModels/DataModels.csproj create mode 100644 DataModels/IId.cs create mode 100644 DataModels/Models/IBook.cs create mode 100644 DataModels/Models/IShape.cs create mode 100644 DatabaseImplement/COPcontext.cs create mode 100644 DatabaseImplement/DatabaseImplement.csproj create mode 100644 DatabaseImplement/Implements/BookStorage.cs create mode 100644 DatabaseImplement/Implements/ShapeStorage.cs create mode 100644 DatabaseImplement/Migrations/20231116180013_Migration1.Designer.cs create mode 100644 DatabaseImplement/Migrations/20231116180013_Migration1.cs create mode 100644 DatabaseImplement/Migrations/COPcontextModelSnapshot.cs create mode 100644 DatabaseImplement/Models/Book.cs create mode 100644 DatabaseImplement/Models/Shape.cs create mode 100644 Plugin/Class1.cs create mode 100644 Plugin/IPluginsConvention.cs create mode 100644 Plugin/Plugin.csproj create mode 100644 Plugin/PluginsConventionElement.cs create mode 100644 Plugin/PluginsConventionSaveDocument.cs create mode 100644 WinForm/FormCreateBook.Designer.cs create mode 100644 WinForm/FormCreateBook.cs create mode 100644 WinForm/FormCreateBook.resx create mode 100644 WinForm/FormMain.Designer.cs create mode 100644 WinForm/FormMain.cs create mode 100644 WinForm/FormMain.resx create mode 100644 WinForm/FormShapes.Designer.cs create mode 100644 WinForm/FormShapes.cs create mode 100644 WinForm/FormShapes.resx diff --git a/Contracts/BindingModels/BookBindingModel.cs b/Contracts/BindingModels/BookBindingModel.cs new file mode 100644 index 0000000..fb54164 --- /dev/null +++ b/Contracts/BindingModels/BookBindingModel.cs @@ -0,0 +1,22 @@ +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.BindingModels +{ + public class BookBindingModel : IBook + { + public string Name { get; set; } = string.Empty; + + public string Readers { get; set; } = string.Empty; + + public string Shape { get; set; } = string.Empty; + + public string Annotation { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Contracts/BindingModels/ShapeBindingModel.cs b/Contracts/BindingModels/ShapeBindingModel.cs new file mode 100644 index 0000000..2c98124 --- /dev/null +++ b/Contracts/BindingModels/ShapeBindingModel.cs @@ -0,0 +1,16 @@ +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.BindingModels +{ + public class ShapeBindingModel : IShape + { + public string Name { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Contracts/Contracts.csproj b/Contracts/Contracts.csproj new file mode 100644 index 0000000..2e520d2 --- /dev/null +++ b/Contracts/Contracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/Contracts/SearchModels/BookSearchModel.cs b/Contracts/SearchModels/BookSearchModel.cs new file mode 100644 index 0000000..b7bfe67 --- /dev/null +++ b/Contracts/SearchModels/BookSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.SearchModels +{ + public class BookSearchModel + { + public int? Id { get; set; } + public string? Name { get; set; } + } +} diff --git a/Contracts/SearchModels/ShapeSearchModel.cs b/Contracts/SearchModels/ShapeSearchModel.cs new file mode 100644 index 0000000..7fe2aaf --- /dev/null +++ b/Contracts/SearchModels/ShapeSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.SearchModels +{ + public class ShapeSearchModel + { + public int? Id { get; set; } + public string? Name { get; set; } + } +} diff --git a/Contracts/StoragesContracts/IBookStorage.cs b/Contracts/StoragesContracts/IBookStorage.cs new file mode 100644 index 0000000..611ac55 --- /dev/null +++ b/Contracts/StoragesContracts/IBookStorage.cs @@ -0,0 +1,21 @@ +using Contracts.BindingModels; +using Contracts.SearchModels; +using Contracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.StoragesContracts +{ + public interface IBookStorage + { + List GetFullList(); + List GetFilteredList(BookSearchModel model); + BookViewModel? GetElement(BookSearchModel model); + BookViewModel? Insert(BookBindingModel model); + BookViewModel? Update(BookBindingModel model); + BookViewModel? Delete(BookBindingModel model); + } +} diff --git a/Contracts/StoragesContracts/IShapeStorage.cs b/Contracts/StoragesContracts/IShapeStorage.cs new file mode 100644 index 0000000..ea5843b --- /dev/null +++ b/Contracts/StoragesContracts/IShapeStorage.cs @@ -0,0 +1,21 @@ +using Contracts.BindingModels; +using Contracts.SearchModels; +using Contracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.StoragesContracts +{ + public interface IShapeStorage + { + List GetFullList(); + List GetFilteredList(ShapeSearchModel model); + ShapeViewModel? GetElement(ShapeSearchModel model); + ShapeViewModel? Insert(ShapeBindingModel model); + ShapeViewModel? Update(ShapeBindingModel model); + ShapeViewModel? Delete(ShapeBindingModel model); + } +} diff --git a/Contracts/ViewModels/BookViewModel.cs b/Contracts/ViewModels/BookViewModel.cs new file mode 100644 index 0000000..69c0945 --- /dev/null +++ b/Contracts/ViewModels/BookViewModel.cs @@ -0,0 +1,22 @@ +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.ViewModels +{ + public class BookViewModel : IBook + { + public string Name { get; set; } = string.Empty; + + public string Readers { get; set; } = string.Empty; + + public string Shape { get; set; } = string.Empty; + + public string Annotation { get; set; } = string.Empty; + + public int Id { get; set; } + } +} diff --git a/Contracts/ViewModels/ShapeViewModel.cs b/Contracts/ViewModels/ShapeViewModel.cs new file mode 100644 index 0000000..a1e6bb1 --- /dev/null +++ b/Contracts/ViewModels/ShapeViewModel.cs @@ -0,0 +1,23 @@ +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.ViewModels +{ + public class ShapeViewModel : IShape + { + public string Name { get; set; } = string.Empty; + + public int Id { get; set; } + public ShapeViewModel() { } + + public ShapeViewModel(IShape shape) + { + Id = shape.Id; + Name = shape.Name; + } + } +} diff --git a/DataModels/DataModels.csproj b/DataModels/DataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/DataModels/DataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/DataModels/IId.cs b/DataModels/IId.cs new file mode 100644 index 0000000..180293b --- /dev/null +++ b/DataModels/IId.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataModels +{ + public interface IId + { + int Id { get; } + } +} diff --git a/DataModels/Models/IBook.cs b/DataModels/Models/IBook.cs new file mode 100644 index 0000000..0556640 --- /dev/null +++ b/DataModels/Models/IBook.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataModels.Models +{ + public interface IBook: IId + { + string Name { get; } + string Readers { get; } + string Shape { get; } + string Annotation { get; } + } +} diff --git a/DataModels/Models/IShape.cs b/DataModels/Models/IShape.cs new file mode 100644 index 0000000..706582a --- /dev/null +++ b/DataModels/Models/IShape.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataModels.Models +{ + public interface IShape: IId + { + string Name { get; } + } +} diff --git a/DatabaseImplement/COPcontext.cs b/DatabaseImplement/COPcontext.cs new file mode 100644 index 0000000..ad039cd --- /dev/null +++ b/DatabaseImplement/COPcontext.cs @@ -0,0 +1,26 @@ +using DatabaseImplement.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseImplement +{ + public class COPcontext: DbContext + { + protected override void OnConfiguring(DbContextOptionsBuilder +optionsBuilder) + { + if (optionsBuilder.IsConfigured == false) + { + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-ON2V3BB\SQLEXPRESS;Initial Catalog=COPDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + } + base.OnConfiguring(optionsBuilder); + } + public virtual DbSet Books { set; get; } + public virtual DbSet Shapes { set; get; } + } +} diff --git a/DatabaseImplement/DatabaseImplement.csproj b/DatabaseImplement/DatabaseImplement.csproj new file mode 100644 index 0000000..c14e2ac --- /dev/null +++ b/DatabaseImplement/DatabaseImplement.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/DatabaseImplement/Implements/BookStorage.cs b/DatabaseImplement/Implements/BookStorage.cs new file mode 100644 index 0000000..61b492d --- /dev/null +++ b/DatabaseImplement/Implements/BookStorage.cs @@ -0,0 +1,94 @@ +using Contracts.BindingModels; +using Contracts.SearchModels; +using Contracts.StoragesContracts; +using Contracts.ViewModels; +using DatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseImplement.Implements +{ + public class BookStorage : IBookStorage + { + public BookViewModel? Delete(BookBindingModel model) + { + using var context = new COPcontext(); + var element = context.Books.FirstOrDefault(rec => rec.Id == + model.Id); + if (element != null) + { + context.Books.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public BookViewModel? GetElement(BookSearchModel model) + { + if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) + { + return null; + } + using var context = new COPcontext(); + return context.Books + .FirstOrDefault(x => + (!string.IsNullOrEmpty(model.Name) && x.Name == + model.Name) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public List GetFilteredList(BookSearchModel model) + { + if (string.IsNullOrEmpty(model.Name)) + { + return new(); + } + using var context = new COPcontext(); + return context.Books + .Where(x => x.Name.Contains(model.Name)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new COPcontext(); + return context.Books + .Select(x => x.GetViewModel) + .ToList(); + } + + public BookViewModel? Insert(BookBindingModel model) + { + var newComponent = Book.Create(model); + if (newComponent == null) + { + return null; + } + using var context = new COPcontext(); + context.Books.Add(newComponent); + context.SaveChanges(); + return newComponent.GetViewModel; + } + + public BookViewModel? Update(BookBindingModel model) + { + using var context = new COPcontext(); + var component = context.Books.FirstOrDefault(x => x.Id == + model.Id); + if (component == null) + { + return null; + } + component.Update(model); + context.SaveChanges(); + return component.GetViewModel; + } + } +} diff --git a/DatabaseImplement/Implements/ShapeStorage.cs b/DatabaseImplement/Implements/ShapeStorage.cs new file mode 100644 index 0000000..a96a833 --- /dev/null +++ b/DatabaseImplement/Implements/ShapeStorage.cs @@ -0,0 +1,93 @@ +using Contracts.BindingModels; +using Contracts.SearchModels; +using Contracts.StoragesContracts; +using Contracts.ViewModels; +using DatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseImplement.Implements +{ + public class ShapeStorage : IShapeStorage + { + public ShapeViewModel? Delete(ShapeBindingModel model) + { + using var context = new COPcontext(); + var element = context.Shapes.FirstOrDefault(rec => rec.Id == + model.Id); + if (element != null) + { + context.Shapes.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + + public ShapeViewModel? GetElement(ShapeSearchModel model) + { + if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) + { + return null; + } + using var context = new COPcontext(); + return context.Shapes + .FirstOrDefault(x => + (!string.IsNullOrEmpty(model.Name) && x.Name == + model.Name) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public List GetFilteredList(ShapeSearchModel model) + { + if (string.IsNullOrEmpty(model.Name)) + { + return new(); + } + using var context = new COPcontext(); + return context.Shapes + .Where(x => x.Name.Contains(model.Name)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new COPcontext(); + return context.Shapes + .Select(x => x.GetViewModel) + .ToList(); + } + + public ShapeViewModel? Insert(ShapeBindingModel model) + { + var newComponent = Shape.Create(model); + if (newComponent == null) + { + return null; + } + using var context = new COPcontext(); + context.Shapes.Add(newComponent); + context.SaveChanges(); + return newComponent.GetViewModel; + } + + public ShapeViewModel? Update(ShapeBindingModel model) + { + using var context = new COPcontext(); + var component = context.Shapes.FirstOrDefault(x => x.Id == + model.Id); + if (component == null) + { + return null; + } + component.Update(model); + context.SaveChanges(); + return component.GetViewModel; + } + } +} diff --git a/DatabaseImplement/Migrations/20231116180013_Migration1.Designer.cs b/DatabaseImplement/Migrations/20231116180013_Migration1.Designer.cs new file mode 100644 index 0000000..8787045 --- /dev/null +++ b/DatabaseImplement/Migrations/20231116180013_Migration1.Designer.cs @@ -0,0 +1,74 @@ +// +using DatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + [DbContext(typeof(COPcontext))] + [Migration("20231116180013_Migration1")] + partial class Migration1 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.25") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("DatabaseImplement.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Annotation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Readers") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Shape") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Shape", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shapes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DatabaseImplement/Migrations/20231116180013_Migration1.cs b/DatabaseImplement/Migrations/20231116180013_Migration1.cs new file mode 100644 index 0000000..cf6ae8d --- /dev/null +++ b/DatabaseImplement/Migrations/20231116180013_Migration1.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + public partial class Migration1 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Books", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Readers = table.Column(type: "nvarchar(max)", nullable: false), + Shape = table.Column(type: "nvarchar(max)", nullable: false), + Annotation = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Books", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Shapes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Shapes", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Books"); + + migrationBuilder.DropTable( + name: "Shapes"); + } + } +} diff --git a/DatabaseImplement/Migrations/COPcontextModelSnapshot.cs b/DatabaseImplement/Migrations/COPcontextModelSnapshot.cs new file mode 100644 index 0000000..f356926 --- /dev/null +++ b/DatabaseImplement/Migrations/COPcontextModelSnapshot.cs @@ -0,0 +1,72 @@ +// +using DatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + [DbContext(typeof(COPcontext))] + partial class COPcontextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.25") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("DatabaseImplement.Models.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Annotation") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Readers") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Shape") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Shape", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Shapes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DatabaseImplement/Models/Book.cs b/DatabaseImplement/Models/Book.cs new file mode 100644 index 0000000..f105c2f --- /dev/null +++ b/DatabaseImplement/Models/Book.cs @@ -0,0 +1,65 @@ +using Contracts.BindingModels; +using Contracts.ViewModels; +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseImplement.Models +{ + public class Book : IBook + { + [Required] + public string Name { get; set; } = string.Empty; + [Required] + public string Readers { get; set; } = string.Empty; + [Required] + public string Shape { get; set; } = string.Empty; + [Required] + public string Annotation { get; set; } = string.Empty; + + public int Id { get; set; } + public static Book? Create(BookBindingModel model) + { + if (model == null) + { + return null; + } + return new Book() + { + Id = model.Id, + Annotation = model.Annotation, + Name = model.Name, + Readers = model.Readers, + Shape = model.Shape + + }; + } + + public void Update(BookBindingModel model) + { + if (model == null) + { + return; + } + Name = model.Name; + Readers = model.Readers; + Shape = model.Shape; + Annotation = model.Annotation; + + } + public BookViewModel GetViewModel => new() + { + Id = Id, + Annotation = Annotation, + Name = Name, + Readers = Readers, + Shape = Shape + + }; + } +} diff --git a/DatabaseImplement/Models/Shape.cs b/DatabaseImplement/Models/Shape.cs new file mode 100644 index 0000000..80ccbf6 --- /dev/null +++ b/DatabaseImplement/Models/Shape.cs @@ -0,0 +1,51 @@ +using Contracts.BindingModels; +using Contracts.ViewModels; +using DataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseImplement.Models +{ + + public class Shape : IShape + { + [Required] + public string Name { get; set; }=string.Empty; + + public int Id { get; set; } + + public static Shape? Create(ShapeBindingModel model) + { + if (model == null) + { + return null; + } + return new Shape() + { + Id = model.Id, + Name = model.Name + + }; + } + + public void Update(ShapeBindingModel model) + { + if (model == null) + { + return; + } + Id = model.Id; + Name = model.Name; + } + public ShapeViewModel GetViewModel => new() + { + Id = Id, + Name = Name + }; + } +} diff --git a/KOP_Labs.sln b/KOP_Labs.sln index 72ab213..030cda4 100644 --- a/KOP_Labs.sln +++ b/KOP_Labs.sln @@ -5,7 +5,15 @@ VisualStudioVersion = 17.5.33424.131 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KOP_Labs", "KOP_Labs\KOP_Labs.csproj", "{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForm", "WinForm\WinForm.csproj", "{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinForm", "WinForm\WinForm.csproj", "{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{D4DEDE5B-687B-44AD-A69E-70C374E4A62E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModels", "DataModels\DataModels.csproj", "{E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{4F141B46-CBC9-455D-8A34-27F950FD62C2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin", "Plugin\Plugin.csproj", "{CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +29,22 @@ Global {099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Debug|Any CPU.Build.0 = Debug|Any CPU {099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.ActiveCfg = Release|Any CPU {099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.Build.0 = Release|Any CPU + {D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4DEDE5B-687B-44AD-A69E-70C374E4A62E}.Release|Any CPU.Build.0 = Release|Any CPU + {E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0145CE1-A76B-423E-BBC2-00CDF48CCAF2}.Release|Any CPU.Build.0 = Release|Any CPU + {4F141B46-CBC9-455D-8A34-27F950FD62C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F141B46-CBC9-455D-8A34-27F950FD62C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F141B46-CBC9-455D-8A34-27F950FD62C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F141B46-CBC9-455D-8A34-27F950FD62C2}.Release|Any CPU.Build.0 = Release|Any CPU + {CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAB9F0CF-38F8-4A85-945E-6B271BB3C03B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/KOP_Labs/BooksForm.Designer.cs b/KOP_Labs/BooksForm.Designer.cs index 817f04c..1d87373 100644 --- a/KOP_Labs/BooksForm.Designer.cs +++ b/KOP_Labs/BooksForm.Designer.cs @@ -28,45 +28,46 @@ /// private void InitializeComponent() { - groupBoxComponent = new GroupBox(); listBoxComponent = new ListBox(); + groupBoxComponent = new GroupBox(); groupBoxComponent.SuspendLayout(); SuspendLayout(); // - // groupBoxComponent - // - groupBoxComponent.Controls.Add(listBoxComponent); - groupBoxComponent.Location = new Point(19, 28); - groupBoxComponent.Name = "groupBoxComponent"; - groupBoxComponent.Size = new Size(517, 183); - groupBoxComponent.TabIndex = 0; - groupBoxComponent.TabStop = false; - groupBoxComponent.Text = "Компонент"; - // // listBoxComponent // listBoxComponent.FormattingEnabled = true; listBoxComponent.ItemHeight = 20; - listBoxComponent.Location = new Point(24, 35); + listBoxComponent.Location = new Point(37, 48); listBoxComponent.Name = "listBoxComponent"; - listBoxComponent.Size = new Size(476, 124); + listBoxComponent.Size = new Size(196, 44); listBoxComponent.TabIndex = 0; listBoxComponent.SelectedIndexChanged += listBoxComponent_SelectedIndexChanged; // + // groupBoxComponent + // + groupBoxComponent.Controls.Add(listBoxComponent); + groupBoxComponent.Dock = DockStyle.Fill; + groupBoxComponent.Location = new Point(0, 0); + groupBoxComponent.Name = "groupBoxComponent"; + groupBoxComponent.Size = new Size(283, 132); + groupBoxComponent.TabIndex = 0; + groupBoxComponent.TabStop = false; + groupBoxComponent.Text = "Компонент"; + // // BooksForm // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; Controls.Add(groupBoxComponent); Name = "BooksForm"; - Size = new Size(563, 258); + Size = new Size(283, 132); groupBoxComponent.ResumeLayout(false); ResumeLayout(false); } #endregion - private GroupBox groupBoxComponent; private ListBox listBoxComponent; + private GroupBox groupBoxComponent; } } diff --git a/KOP_Labs/BooksForm.cs b/KOP_Labs/BooksForm.cs index d8fb97c..12c936f 100644 --- a/KOP_Labs/BooksForm.cs +++ b/KOP_Labs/BooksForm.cs @@ -63,7 +63,7 @@ namespace KOP_Labs private void listBoxComponent_SelectedIndexChanged(object sender, EventArgs e) { - _selectChanged?.Invoke(this, e); + _selectChanged?.Invoke(this, e); } } } diff --git a/KOP_Labs/Classes/Book.cs b/KOP_Labs/Classes/Book.cs index d55b2ce..b997d4b 100644 --- a/KOP_Labs/Classes/Book.cs +++ b/KOP_Labs/Classes/Book.cs @@ -10,7 +10,7 @@ namespace KOP_Labs.Classes { public string Author { get; private set; } = string.Empty; - public int Id { get; private set; } + public string Name { get; private set; } = string.Empty; public string Annotation { get; private set; } = string.Empty; @@ -20,10 +20,10 @@ namespace KOP_Labs.Classes { } - public Book(string author, int id, string name, string annotation) + public Book(string author, string name, string annotation) { Author = author; - Id = id; + Name = name; Annotation = annotation; diff --git a/KOP_Labs/KOP_Labs.csproj b/KOP_Labs/KOP_Labs.csproj index 462f673..c44b7f4 100644 --- a/KOP_Labs/KOP_Labs.csproj +++ b/KOP_Labs/KOP_Labs.csproj @@ -5,11 +5,14 @@ enable true enable + True + + diff --git a/KOP_Labs/TableComponent.Designer.cs b/KOP_Labs/TableComponent.Designer.cs index 8443de6..9062fce 100644 --- a/KOP_Labs/TableComponent.Designer.cs +++ b/KOP_Labs/TableComponent.Designer.cs @@ -34,16 +34,17 @@ // // dataGridView // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(36, 29); + dataGridView.Location = new Point(17, 22); dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersVisible = false; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(300, 188); + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(304, 200); dataGridView.TabIndex = 0; dataGridView.SelectionChanged += SelectionChanged; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; // // TableComponent // @@ -51,7 +52,7 @@ AutoScaleMode = AutoScaleMode.Font; Controls.Add(dataGridView); Name = "TableComponent"; - Size = new Size(542, 301); + Size = new Size(342, 239); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); } diff --git a/KOP_Labs/TableComponent.cs b/KOP_Labs/TableComponent.cs index 353ea81..f718a22 100644 --- a/KOP_Labs/TableComponent.cs +++ b/KOP_Labs/TableComponent.cs @@ -37,7 +37,7 @@ namespace KOP_Labs public void TableConfiguration(int countCol, List parameters) { if (parameters.Count != parameters.Count) { return; } - for (int i = 0; i < countCol; i++) + for (int i = 0; i < countCol; i++) { DataGridViewColumn column = new DataGridViewColumn(); column.Name = parameters[i]._name; @@ -67,7 +67,7 @@ namespace KOP_Labs dataGridView.Rows.Add(row); } - + public T GetSelectedObject() where T : new() { if (dataGridView.SelectedCells.Count == 0) diff --git a/Plugin/Class1.cs b/Plugin/Class1.cs new file mode 100644 index 0000000..95f40b1 --- /dev/null +++ b/Plugin/Class1.cs @@ -0,0 +1,7 @@ +namespace Plugin +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/Plugin/IPluginsConvention.cs b/Plugin/IPluginsConvention.cs new file mode 100644 index 0000000..6ea2914 --- /dev/null +++ b/Plugin/IPluginsConvention.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Plugin +{ + public interface IPluginsConvention + {/* + /// + /// Название плагина + /// + string PluginName { get; } + /// + /// Получение контрола для вывода набора данных + /// + UserControl GetControl { get; } + /// + /// Получение элемента, выбранного в контроле + /// + PluginsConventionElement GetElement { get; } + /// + /// Получение формы для создания/редактирования объекта + /// + /// + /// + Form GetForm(PluginsConventionElement element); + /// + /// Получение формы для работы со справочником + /// + /// + Form GetThesaurus(); +/// +/// Удаление элемента +3 +/// +/// +/// +bool DeleteElement(PluginsConventionElement element); + /// + /// Обновление набора данных в контроле + /// + void ReloadData(); + /// + /// Создание простого документа + /// + /// + /// + bool CreateSimpleDocument(PluginsConventionSaveDocument + saveDocument); + /// + /// Создание простого документа + /// + /// + /// + bool CreateTableDocument(PluginsConventionSaveDocument saveDocument); + /// + /// Создание документа с диаграммой + /// + /// + /// + bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);*/ + } +} diff --git a/Plugin/Plugin.csproj b/Plugin/Plugin.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/Plugin/Plugin.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/Plugin/PluginsConventionElement.cs b/Plugin/PluginsConventionElement.cs new file mode 100644 index 0000000..c989976 --- /dev/null +++ b/Plugin/PluginsConventionElement.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Plugin +{ + public class PluginsConventionElement + { + public Guid Id { get; set; } + } + +} diff --git a/Plugin/PluginsConventionSaveDocument.cs b/Plugin/PluginsConventionSaveDocument.cs new file mode 100644 index 0000000..a98d5f3 --- /dev/null +++ b/Plugin/PluginsConventionSaveDocument.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Plugin +{ + public class PluginsConventionSaveDocument + { + public string FileName { get; set; } + } +} diff --git a/WinForm/Form1.cs b/WinForm/Form1.cs index 735a59e..5d35091 100644 --- a/WinForm/Form1.cs +++ b/WinForm/Form1.cs @@ -45,9 +45,9 @@ namespace WinForm private void buttonTable_Click(object sender, EventArgs e) { - tableComponent.AddRow(new Book("gfgdf",1, "book1", "lalala")); - tableComponent.AddRow(new Book("Pushkin", 1, "book2", "lalala2")); - tableComponent.AddRow(new Book("Pushkin", 1, "book3", "lalala")); + tableComponent.AddRow(new Book("gfgdf", "book1", "lalala")); + tableComponent.AddRow(new Book("Pushkin","book2", "lalala2")); + tableComponent.AddRow(new Book("Pushkin", "book3", "lalala")); } diff --git a/WinForm/FormCreateBook.Designer.cs b/WinForm/FormCreateBook.Designer.cs new file mode 100644 index 0000000..ee7a644 --- /dev/null +++ b/WinForm/FormCreateBook.Designer.cs @@ -0,0 +1,153 @@ +namespace WinForm +{ + partial class FormCreateBook + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + textBoxReaders = new TextBox(); + booksForm1 = new KOP_Labs.BooksForm(); + textBoxAnnotation = new TextBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + buttonSave = new Button(); + input_text1 = new ViewComponents.Input_text(); + SuspendLayout(); + // + // textBoxReaders + // + textBoxReaders.Location = new Point(120, 95); + textBoxReaders.Name = "textBoxReaders"; + textBoxReaders.Size = new Size(509, 27); + textBoxReaders.TabIndex = 1; + // + // booksForm1 + // + booksForm1.Location = new Point(120, 154); + booksForm1.Name = "booksForm1"; + booksForm1.SelectedValue = null; + booksForm1.Size = new Size(509, 111); + booksForm1.TabIndex = 2; + // + // textBoxAnnotation + // + textBoxAnnotation.Location = new Point(105, 345); + textBoxAnnotation.Multiline = true; + textBoxAnnotation.Name = "textBoxAnnotation"; + textBoxAnnotation.Size = new Size(509, 138); + textBoxAnnotation.TabIndex = 3; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 34); + label1.Name = "label1"; + label1.Size = new Size(80, 20); + label1.TabIndex = 4; + label1.Text = "Название:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 95); + label2.Name = "label2"; + label2.Size = new Size(76, 20); + label2.TabIndex = 5; + label2.Text = "Читатели:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(16, 192); + label3.Name = "label3"; + label3.Size = new Size(60, 20); + label3.TabIndex = 6; + label3.Text = "Форма:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(2, 345); + label4.Name = "label4"; + label4.Size = new Size(89, 20); + label4.TabIndex = 7; + label4.Text = "Аннотация:"; + // + // buttonSave + // + buttonSave.Location = new Point(535, 489); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(94, 29); + buttonSave.TabIndex = 8; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click_1; + // + // input_text1 + // + input_text1.Element = "Range exeption"; + input_text1.Location = new Point(105, 2); + input_text1.MaxLen = -1; + input_text1.MinLen = -1; + input_text1.Name = "input_text1"; + input_text1.Size = new Size(542, 68); + input_text1.TabIndex = 9; + // + // FormCreateBook + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + AutoSize = true; + ClientSize = new Size(659, 528); + Controls.Add(input_text1); + Controls.Add(buttonSave); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(textBoxAnnotation); + Controls.Add(booksForm1); + Controls.Add(textBoxReaders); + Name = "FormCreateBook"; + Text = "FormCreateBook"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private TextBox textBoxReaders; + private KOP_Labs.BooksForm booksForm1; + private TextBox textBoxAnnotation; + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private Button buttonSave; + private ViewComponents.Input_text input_text1; + } +} \ No newline at end of file diff --git a/WinForm/FormCreateBook.cs b/WinForm/FormCreateBook.cs new file mode 100644 index 0000000..f298375 --- /dev/null +++ b/WinForm/FormCreateBook.cs @@ -0,0 +1,75 @@ +using Contracts.BindingModels; +using Contracts.StoragesContracts; +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 WinForm +{ + public partial class FormCreateBook : Form + { + + public readonly IBookStorage _bookStorage; + public readonly IShapeStorage _shapeStorage; + private int? _id; + public int Id { set { _id = value; } } + public FormCreateBook(IBookStorage bookStorage, IShapeStorage shapeStorage) + { + InitializeComponent(); + _bookStorage = bookStorage; + _shapeStorage = shapeStorage; + + input_text1.MinLen = 2; + input_text1.MaxLen = 40; + LoadData(); + + } + + + private void LoadData() + { + var list = _shapeStorage.GetFullList(); + foreach (var item in list) + { + booksForm1.FillValues(item.Name); + } + + + } + + private void buttonSave_Click_1(object sender, EventArgs e) + { + if (String.IsNullOrEmpty(input_text1.Element) || String.IsNullOrEmpty(textBoxReaders.Text) || booksForm1.SelectedValue == null) + { + MessageBox.Show("Заполните поля"); + } + else + { + var model = new BookBindingModel + { + Id = _id ?? 0, + Name = input_text1.Element, + Readers = textBoxReaders.Text, + Shape = booksForm1.SelectedValue.ToString(), + Annotation = textBoxAnnotation.Text, + }; + if (!_id.HasValue) + { + _bookStorage.Insert(model); + } + else + { + _bookStorage.Update(model); + } + + Close(); + } + } + } +} diff --git a/WinForm/FormCreateBook.resx b/WinForm/FormCreateBook.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WinForm/FormCreateBook.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinForm/FormMain.Designer.cs b/WinForm/FormMain.Designer.cs new file mode 100644 index 0000000..52da83e --- /dev/null +++ b/WinForm/FormMain.Designer.cs @@ -0,0 +1,162 @@ +namespace WinForm +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + listBoxObjects1 = new CustomComponents.ListBoxObjects(); + menuStrip1 = new MenuStrip(); + добавитьToolStripMenuItem = new ToolStripMenuItem(); + изменитьToolStripMenuItem = new ToolStripMenuItem(); + удалитьToolStripMenuItem = new ToolStripMenuItem(); + справочникToolStripMenuItem = new ToolStripMenuItem(); + отчётToolStripMenuItem = new ToolStripMenuItem(); + отчёт2ToolStripMenuItem = new ToolStripMenuItem(); + отчёт3ToolStripMenuItem = new ToolStripMenuItem(); + wordTableComponent1 = new KOP_Labs.NonVisualComponents.WordTableComponent(components); + listBoxObjects2 = new CustomComponents.ListBoxObjects(); + componentDocumentWithTableHeaderColumnPdf1 = new ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderColumnPdf(components); + pdfTable1 = new ViewComponents.NotVisualComponents.PdfTable(components); + diagramComponent1 = new CustomComponents.DiagramComponent(components); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // listBoxObjects1 + // + listBoxObjects1.Location = new Point(0, 31); + listBoxObjects1.Name = "listBoxObjects1"; + listBoxObjects1.SelectedIndex = -1; + listBoxObjects1.Size = new Size(459, 151); + listBoxObjects1.TabIndex = 0; + listBoxObjects1.KeyDown += listBoxObjects1_KeyDown; + // + // menuStrip1 + // + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { добавитьToolStripMenuItem, изменитьToolStripMenuItem, удалитьToolStripMenuItem, справочникToolStripMenuItem, отчётToolStripMenuItem, отчёт2ToolStripMenuItem, отчёт3ToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(914, 28); + menuStrip1.TabIndex = 1; + menuStrip1.Text = "menuStrip1"; + menuStrip1.KeyDown += menuStrip1_KeyDown; + // + // добавитьToolStripMenuItem + // + добавитьToolStripMenuItem.Name = "добавитьToolStripMenuItem"; + добавитьToolStripMenuItem.Size = new Size(90, 24); + добавитьToolStripMenuItem.Text = "Добавить"; + добавитьToolStripMenuItem.Click += CreateToolStripMenuItem_Click; + // + // изменитьToolStripMenuItem + // + изменитьToolStripMenuItem.Name = "изменитьToolStripMenuItem"; + изменитьToolStripMenuItem.Size = new Size(92, 24); + изменитьToolStripMenuItem.Text = "Изменить"; + изменитьToolStripMenuItem.Click += изменитьToolStripMenuItem_Click; + // + // удалитьToolStripMenuItem + // + удалитьToolStripMenuItem.Name = "удалитьToolStripMenuItem"; + удалитьToolStripMenuItem.Size = new Size(79, 24); + удалитьToolStripMenuItem.Text = "Удалить"; + удалитьToolStripMenuItem.Click += удалитьToolStripMenuItem_Click; + // + // справочникToolStripMenuItem + // + справочникToolStripMenuItem.Name = "справочникToolStripMenuItem"; + справочникToolStripMenuItem.Size = new Size(108, 24); + справочникToolStripMenuItem.Text = "Справочник"; + справочникToolStripMenuItem.Click += справочникToolStripMenuItem_Click; + // + // отчётToolStripMenuItem + // + отчётToolStripMenuItem.Name = "отчётToolStripMenuItem"; + отчётToolStripMenuItem.Size = new Size(62, 24); + отчётToolStripMenuItem.Text = "Отчёт"; + отчётToolStripMenuItem.Click += отчётToolStripMenuItem_Click; + // + // отчёт2ToolStripMenuItem + // + отчёт2ToolStripMenuItem.Name = "отчёт2ToolStripMenuItem"; + отчёт2ToolStripMenuItem.Size = new Size(70, 24); + отчёт2ToolStripMenuItem.Text = "Отчёт2"; + отчёт2ToolStripMenuItem.Click += отчёт2ToolStripMenuItem_Click; + // + // отчёт3ToolStripMenuItem + // + отчёт3ToolStripMenuItem.Name = "отчёт3ToolStripMenuItem"; + отчёт3ToolStripMenuItem.Size = new Size(70, 24); + отчёт3ToolStripMenuItem.Text = "Отчёт3"; + отчёт3ToolStripMenuItem.Click += отчёт3ToolStripMenuItem_Click; + // + // listBoxObjects2 + // + listBoxObjects2.Location = new Point(455, 31); + listBoxObjects2.Name = "listBoxObjects2"; + listBoxObjects2.SelectedIndex = -1; + listBoxObjects2.Size = new Size(572, 195); + listBoxObjects2.TabIndex = 2; + // + // FormMain + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(914, 183); + Controls.Add(listBoxObjects2); + Controls.Add(listBoxObjects1); + Controls.Add(menuStrip1); + KeyPreview = true; + MainMenuStrip = menuStrip1; + Name = "FormMain"; + Text = "FormMain"; + KeyDown += FormMain_KeyDown; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private CustomComponents.ListBoxObjects listBoxObjects1; + private MenuStrip menuStrip1; + private ToolStripMenuItem добавитьToolStripMenuItem; + private ToolStripMenuItem изменитьToolStripMenuItem; + private ToolStripMenuItem удалитьToolStripMenuItem; + private ToolStripMenuItem справочникToolStripMenuItem; + private KOP_Labs.NonVisualComponents.WordTableComponent wordTableComponent1; + private ToolStripMenuItem отчётToolStripMenuItem; + private CustomComponents.ListBoxObjects listBoxObjects2; + private ToolStripMenuItem отчёт2ToolStripMenuItem; + private ComponentsLibraryNet60.DocumentWithTable.ComponentDocumentWithTableHeaderColumnPdf componentDocumentWithTableHeaderColumnPdf1; + private ViewComponents.NotVisualComponents.PdfTable pdfTable1; + private ToolStripMenuItem отчёт3ToolStripMenuItem; + private CustomComponents.DiagramComponent diagramComponent1; + } +} \ No newline at end of file diff --git a/WinForm/FormMain.cs b/WinForm/FormMain.cs new file mode 100644 index 0000000..abafd77 --- /dev/null +++ b/WinForm/FormMain.cs @@ -0,0 +1,432 @@ +using ComponentsLibraryNet60.Models; +using Contracts.BindingModels; +using Contracts.StoragesContracts; +using Contracts.ViewModels; +using CustomComponents; +using DatabaseImplement.Models; +using DataModels.Models; +using DocumentFormat.OpenXml.Drawing.Charts; +using DocumentFormat.OpenXml.Spreadsheet; +using KOP_Labs.Classes; +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 ViewComponents.NotVisualComponents; +using Book = DatabaseImplement.Models.Book; + +namespace WinForm +{ + public partial class FormMain : Form + { + private readonly IBookStorage _bookStorage; + private readonly IShapeStorage _shapeStorage; + public FormMain(IBookStorage bookStorage, IShapeStorage shapeStorage) + { + + InitializeComponent(); + _bookStorage = bookStorage; + _shapeStorage = shapeStorage; + + LoadData(); + + } + public void LoadData() + { + listBoxObjects1.deleteAll(); + listBoxObjects2.deleteAll(); + var books = _bookStorage.GetFullList(); + listBoxObjects1.SetLayoutInfo("Название *Name* Читатели *Readers* Форма *Shape* Аннотация *Annotation* Id *Id*", "*", "*"); + listBoxObjects2.SetLayoutInfo("Форма *Shape* Аннотация *Annotation* Id *Id*", "*", "*"); + + foreach (var book in books) + { + listBoxObjects1.AddInListBox(book); + listBoxObjects2.AddInListBox(book); + + } + + } + + private void CreateToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormCreateBook)); + + if (service is FormCreateBook form) + { + form.ShowDialog(); + + LoadData(); + } + } + + + private void изменитьToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + int id = listBoxObjects1.GetObjectFromStr().Id; + + var service = Program.ServiceProvider?.GetService(typeof(FormCreateBook)); + + if (service is FormCreateBook form) + { + form.Id = id; + + form.ShowDialog(); + + LoadData(); + } + } + catch (Exception ex) + { + MessageBox.Show("Ошибка операции", "Необходимо выбрать элемент списка!", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void удалитьToolStripMenuItem_Click(object sender, EventArgs e) + { + int id = listBoxObjects1.GetObjectFromStr().Id; + + + DialogResult result = MessageBox.Show("Вы уверены, что хотите удалить выбранную запись?" + id, "Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + + if (result == DialogResult.Yes) + { + _bookStorage.Delete(new BookBindingModel + { + Id = id + + }); + + LoadData(); + } + + + } + + private void справочникToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShapes)); + + if (service is FormShapes form) + { + form.ShowDialog(); + + LoadData(); + } + } + public void CreateSimpleDocItem_Click(object sender, EventArgs e) + { + //фильтрация файлов для диалогового окна + using var dialog = new SaveFileDialog + { + Filter = "docx|*.docx" + }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + + var list = _bookStorage.GetFullList().OrderBy(l => l.Shape).ToList(); + + var disciplines = _shapeStorage.GetFullList().OrderBy(d => d.Name).ToList(); + + List totalList = new(); + + List supportList = new(); + + foreach (var discipline in disciplines) + { + + foreach (var elem in list) + { + if (elem.Shape.Equals(discipline.Name)) + { + supportList.Add(elem); + } + } + + supportList = supportList.OrderBy(sl => sl.Name).ToList(); + + totalList.Add(new string[,] { { "Форма", discipline.Name } }); + + foreach (var elem in supportList) + { + var listFCs = elem.Readers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + + string[,] newArray = { { elem.Name, listFCs[listFCs.Count - 1] } }; + + totalList.Add(newArray); + } + + supportList.Clear(); + } + + MyTable table = new(dialog.FileName, "Первое задание", totalList); + + wordTableComponent1.CreateDoc(table); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + private void отчётToolStripMenuItem_Click(object sender, EventArgs e) + { + CreateSimpleDocItem_Click(sender, e); + } + + private void отчёт2ToolStripMenuItem_Click(object sender, EventArgs e) + { + List? list = _bookStorage.GetFullList().OrderBy(l => l.Name).ToList(); + + + using var dialog = new SaveFileDialog + { + Filter = "pdf|*.pdf" + }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + + componentDocumentWithTableHeaderColumnPdf1.CreateDoc(new ComponentDocumentWithTableHeaderDataConfig + { + FilePath = dialog.FileName, + Header = "Отчет PDF", + UseUnion = true, + ColumnsRowsWidth = new List<(int, int)> { (0, 25), (0, 25), (0, 25), }, + ColumnUnion = new List<(int StartIndex, int Count)> { (1, 2) }, + Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)> + { + + (0, 0, "Название", "Name"), + (1, 0, "Описание", ""), + (1, 1, "Форма", "Shape"), + (2, 1, "Аннотация", "Annotation"), + + }, + Data = list + }); + + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void CreateReportExcel(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + + var list = _bookStorage.GetFullList(); + + var shapes = _shapeStorage.GetFullList(); + + + int[,] supportList = new int[4, shapes.Count]; + + + int c = 0; + + for (int i = 0; i < shapes.Count; i++) + { + + + foreach (var elem in list) + { + if (shapes[i].Name.Equals(elem.Shape)) + + { + c++; + if (elem.Annotation.Length >= 0 && elem.Annotation.Length < 10) + { + supportList[0, i]++; + + } + + if (elem.Annotation.Length >= 10 && elem.Annotation.Length < 150) + { + supportList[1, i]++; + + } + + if (elem.Annotation.Length >= 150 && elem.Annotation.Length < 200) + { + supportList[2, i]++; + + } + + if (elem.Annotation.Length >= 200 && elem.Annotation.Length < 250) + { + supportList[3, i]++; + } + } + + } + + } + string[] Names = { "50-150", "100-150", "150-200", "200-250" }; + + + var list2D = new Dictionary>(); + + + for (var i = 0; i < Names.Length; i++) + { + var curlist = new List(); + for (int j = 0; j < shapes.Count; j++) + { + + curlist.Add(supportList[i, j]); + + + + } + list2D.Add(Names[i], curlist); + } + + + DiagramComponent diagram = new DiagramComponent(); + + + diagram.CreateExcel(new CustomComponents.MyNonVisualComponents.LineChartConfig + { + ChartTitle = "diagramm", + FilePath = dialog.FileName, + Header = "Diagramm", + Values = list2D + }); + + MessageBox.Show(" " + c); + + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void отчёт3ToolStripMenuItem_Click(object sender, EventArgs e) + { + CreateReportExcel(sender, e); + + } + + private void FormMain_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control) + { + switch (e.KeyCode) + { + case Keys.A: + CreateToolStripMenuItem_Click(sender, e); + break; + case Keys.U: + изменитьToolStripMenuItem_Click(sender, e); + break; + case Keys.D: + удалитьToolStripMenuItem_Click(sender, e); + break; + case Keys.S: + справочникToolStripMenuItem_Click(sender, e); + break; + case Keys.T: + отчётToolStripMenuItem_Click(sender, e); + break; + case Keys.C: + отчёт2ToolStripMenuItem_Click(sender, e); + break; + case Keys.M: + отчёт3ToolStripMenuItem_Click(sender, e); + break; + } + } + } + + private void listBoxObjects1_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control) + { + switch (e.KeyCode) + { + case Keys.A: + CreateToolStripMenuItem_Click(sender, e); + break; + /*case Keys.U: + EditProviderItem_Click(sender, e); + break; + case Keys.D: + RemoveProviderItem_Click(sender, e); + break; + case Keys.S: + GetSimpleDocumentItem_Click(sender, e); + break; + case Keys.T: + GetTableDocumentItem_Click(sender, e); + break; + case Keys.C: + GetDiagramDocumentItem_Click(sender, e); + break; + case Keys.M: + OpenListToolStripMenuItem_Click(sender, e); + break;*/ + } + } + } + + private void menuStrip1_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control) + { + switch (e.KeyCode) + { + case Keys.A: + CreateToolStripMenuItem_Click(sender, e); + break; + /*case Keys.U: + EditProviderItem_Click(sender, e); + break; + case Keys.D: + RemoveProviderItem_Click(sender, e); + break; + case Keys.S: + GetSimpleDocumentItem_Click(sender, e); + break; + case Keys.T: + GetTableDocumentItem_Click(sender, e); + break; + case Keys.C: + GetDiagramDocumentItem_Click(sender, e); + break; + case Keys.M: + OpenListToolStripMenuItem_Click(sender, e); + break;*/ + } + } + } + } +} diff --git a/WinForm/FormMain.resx b/WinForm/FormMain.resx new file mode 100644 index 0000000..d8c7efe --- /dev/null +++ b/WinForm/FormMain.resx @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 152, 17 + + + 365, 17 + + + 770, 17 + + + 891, 17 + + \ No newline at end of file diff --git a/WinForm/FormShapes.Designer.cs b/WinForm/FormShapes.Designer.cs new file mode 100644 index 0000000..c741c68 --- /dev/null +++ b/WinForm/FormShapes.Designer.cs @@ -0,0 +1,64 @@ +namespace WinForm +{ + partial class FormShapes + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView1 = new DataGridView(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.Name = "dataGridView1"; + dataGridView1.RowHeadersWidth = 51; + dataGridView1.RowTemplate.Height = 29; + dataGridView1.Size = new Size(800, 450); + dataGridView1.TabIndex = 0; + dataGridView1.CellValueChanged += dataGridView1_CellValueChanged; + dataGridView1.KeyDown += dataGridView1_KeyDown; + // + // FormShapes + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridView1); + Name = "FormShapes"; + Text = "FormShapes"; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView1; + } +} \ No newline at end of file diff --git a/WinForm/FormShapes.cs b/WinForm/FormShapes.cs new file mode 100644 index 0000000..f1dd530 --- /dev/null +++ b/WinForm/FormShapes.cs @@ -0,0 +1,148 @@ +using Contracts.BindingModels; +using Contracts.SearchModels; +using Contracts.StoragesContracts; +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 WinForm +{ + public partial class FormShapes : Form + { + IShapeStorage _shapeStorage; + public FormShapes(IShapeStorage shapeStorage) + { + _shapeStorage = shapeStorage; + InitializeComponent(); + LoadData(); + } + private void LoadData() + { + + try + { + var list = _shapeStorage.GetFullList(); + + + if (list != null) + { + dataGridView1.DataSource = list; + dataGridView1.Columns["Id"].Visible = false; + dataGridView1.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void AddShape() + { + var list = _shapeStorage.GetFullList(); + list.Add(new()); + + if (list != null) + { + dataGridView1.DataSource = list; + dataGridView1.Columns["Id"].Visible = false; + dataGridView1.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + + } + + + } + + private void dataGridView1_KeyDown(object sender, KeyEventArgs e) + { + //просто найти кнопку + if (e.Control) + { + if (e.KeyCode == Keys.Delete) + { + AddShape(); + } + } + else if (e.KeyCode == Keys.Delete) + { + RemoveShape(); + } + } + private void RemoveShape() + { + if (dataGridView1.SelectedRows.Count > 0) + { + DialogResult result = MessageBox.Show( + "Вы уверены, что хотите удалить выбранные записи?", + "Подтверждение удаления", + MessageBoxButtons.YesNo, + MessageBoxIcon.Question + ); + if (result == DialogResult.Yes) + { + if (MessageBox.Show("Удалить выбранный элемент", "Удаление", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + _shapeStorage.Delete(new ShapeBindingModel() { Id = (int)dataGridView1.CurrentRow.Cells[1].Value }); + LoadData(); + } + + } + LoadData(); + } + else + { + MessageBox.Show("Выберите"); + } + } + + + private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex >= 0) + { + DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; + + int id = Convert.ToInt32(row.Cells["Id"].Value); + string? name = row.Cells["Name"].Value?.ToString(); + + if (string.IsNullOrWhiteSpace(name)) + { + + MessageBox.Show("Нельзя сохранить запись с пустым именем!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + + LoadData(); + } + else + { + var model = new ShapeBindingModel + { + Id = id, + Name = name + }; + + if (model.Id == 0) + { + _shapeStorage.Insert(model); + } + else + { + _shapeStorage.Update(model); + } + + LoadData(); + } + } + } + + + } +} + diff --git a/WinForm/FormShapes.resx b/WinForm/FormShapes.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WinForm/FormShapes.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinForm/NonVisualForm.cs b/WinForm/NonVisualForm.cs index fceafeb..2c4bd96 100644 --- a/WinForm/NonVisualForm.cs +++ b/WinForm/NonVisualForm.cs @@ -79,7 +79,7 @@ namespace WinForm wordHistogramm1.CreateHistogramm(histogram); - + } catch (Exception ex) { @@ -91,12 +91,12 @@ namespace WinForm } List books; - Book book1 = new Book("Pushkin", 1, "fgsddsdf", "fdsds"); - Book book2 = new Book("Pushkin", 2, "aa", "fdads"); - Book book3 = new Book("Pushkin", 3, "fgdf", "ffsds"); - Book book4 = new Book("Lermontov", 4, "ffsssff", "asdss"); - Book book5 = new Book("Lermontov", 5, "ffdsff", "asdsss"); - Book book6 = new Book("Pushkin", 6, "fgdf", "ffsds"); + Book book1 = new Book("Pushkin", "fgsddsdf", "fdsds"); + Book book2 = new Book("Pushkin", "aa", "fdads"); + Book book3 = new Book("Pushkin", "fgdf", "ffsds"); + Book book4 = new Book("Lermontov", "ffsssff", "asdss"); + Book book5 = new Book("Lermontov", "ffdsff", "asdsss"); + Book book6 = new Book("Pushkin", "fgdf", "ffsds"); Dictionary colData; private void buttonHead_Click(object sender, EventArgs e) diff --git a/WinForm/Program.cs b/WinForm/Program.cs index e639b4c..3beb2a6 100644 --- a/WinForm/Program.cs +++ b/WinForm/Program.cs @@ -1,7 +1,16 @@ +using Contracts.StoragesContracts; +using DatabaseImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + namespace WinForm { internal static class Program + { + private static ServiceProvider? _serviceProvider; + + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +20,21 @@ namespace WinForm // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new NonVisualForm()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + + } + private static void ConfigureServices(ServiceCollection services) + { + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/WinForm/WinForm.csproj b/WinForm/WinForm.csproj index 215edb0..428d747 100644 --- a/WinForm/WinForm.csproj +++ b/WinForm/WinForm.csproj @@ -9,10 +9,21 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + +