Compare commits

..

No commits in common. "main" and "master" have entirely different histories.
main ... master

74 changed files with 4480 additions and 42 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

41
.gitignore vendored
View File

@ -1,8 +1,7 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.
## ##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files # User-specific files
*.rsuser *.rsuser
@ -30,6 +29,7 @@ x86/
bld/ bld/
[Bb]in/ [Bb]in/
[Oo]bj/ [Oo]bj/
[Oo]ut/
[Ll]og/ [Ll]og/
[Ll]ogs/ [Ll]ogs/
@ -91,7 +91,6 @@ StyleCopReport.xml
*.tmp_proj *.tmp_proj
*_wpftmp.csproj *_wpftmp.csproj
*.log *.log
*.tlog
*.vspscc *.vspscc
*.vssscc *.vssscc
.builds .builds
@ -295,17 +294,6 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw *.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output # Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts **/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts
@ -362,9 +350,6 @@ ASALocalRun/
# Local History for Visual Studio # Local History for Visual Studio
.localhistory/ .localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database # BeatPulse healthcheck temp database
healthchecksdb healthchecksdb
@ -376,25 +361,3 @@ MigrationBackup/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
FodyWeavers.xsd FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<BookViewModel> GetFullList();
List<BookViewModel> GetFilteredList(BookSearchModel model);
BookViewModel? GetElement(BookSearchModel model);
BookViewModel? Insert(BookBindingModel model);
BookViewModel? Update(BookBindingModel model);
BookViewModel? Delete(BookBindingModel model);
}
}

View File

@ -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<ShapeViewModel> GetFullList();
List<ShapeViewModel> GetFilteredList(ShapeSearchModel model);
ShapeViewModel? GetElement(ShapeSearchModel model);
ShapeViewModel? Insert(ShapeBindingModel model);
ShapeViewModel? Update(ShapeBindingModel model);
ShapeViewModel? Delete(ShapeBindingModel model);
}
}

View File

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

View File

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

View File

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

13
DataModels/IId.cs Normal file
View File

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

View File

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

View File

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

View File

@ -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<Book> Books { set; get; }
public virtual DbSet<Shape> Shapes { set; get; }
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.25" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.25">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DataModels\DataModels.csproj" />
</ItemGroup>
</Project>

View File

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

View File

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

View File

@ -0,0 +1,74 @@
// <auto-generated />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Readers")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Shape")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Books");
});
modelBuilder.Entity("DatabaseImplement.Models.Shape", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shapes");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Readers = table.Column<string>(type: "nvarchar(max)", nullable: false),
Shape = table.Column<string>(type: "nvarchar(max)", nullable: false),
Annotation = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Books", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Shapes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(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");
}
}
}

View File

@ -0,0 +1,72 @@
// <auto-generated />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Annotation")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Readers")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Shape")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Books");
});
modelBuilder.Entity("DatabaseImplement.Models.Shape", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Shapes");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

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

55
KOP_Labs.sln Normal file
View File

@ -0,0 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KOP_Labs", "KOP_Labs\KOP_Labs.csproj", "{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}"
EndProject
Project("{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
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08DA15CA-BB7D-4D5D-9BD9-46F0CCC3E779}.Release|Any CPU.Build.0 = Release|Any CPU
{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{099B4BD2-0C5E-46B0-8CE0-4E6BEB3A0E29}.Release|Any CPU.Build.0 = Release|Any CPU
{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
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F271D4C4-E869-41D9-B1A5-C66D73BA17E7}
EndGlobalSection
EndGlobal

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

@ -0,0 +1,73 @@
namespace KOP_Labs
{
partial class BooksForm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
listBoxComponent = new ListBox();
groupBoxComponent = new GroupBox();
groupBoxComponent.SuspendLayout();
SuspendLayout();
//
// listBoxComponent
//
listBoxComponent.FormattingEnabled = true;
listBoxComponent.ItemHeight = 20;
listBoxComponent.Location = new Point(37, 48);
listBoxComponent.Name = "listBoxComponent";
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(283, 132);
groupBoxComponent.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ListBox listBoxComponent;
private GroupBox groupBoxComponent;
}
}

69
KOP_Labs/BooksForm.cs Normal file
View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KOP_Labs
{
public partial class BooksForm : UserControl
{
public BooksForm()
{
InitializeComponent();
}
public string? SelectedValue
{
get
{
if (listBoxComponent.SelectedItem == null)
{
return null;
}
return listBoxComponent.SelectedItem.ToString()!;
}
set
{
if (value != null && !listBoxComponent.Items.Contains(value))
{
return;
}
listBoxComponent.SelectedItem = value;
}
}
private event EventHandler? _selectChanged;
public event EventHandler SelectChanged
{
add { _selectChanged += value; }
remove { _selectChanged -= value; }
}
public void FillValues(string values)
{
if (values == null || values.Length == 0)
{
return;
}
listBoxComponent.Items.Add(values);
}
public void ClearList()
{
listBoxComponent.Items.Clear();
}
private void listBoxComponent_SelectedIndexChanged(object sender, EventArgs e)
{
_selectChanged?.Invoke(this, e);
}
}
}

60
KOP_Labs/BooksForm.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

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

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public class Book
{
public string Author { get; private set; } = string.Empty;
public string Name { get; private set; } = string.Empty;
public string Annotation { get; private set; } = string.Empty;
public Book()
{
}
public Book(string author, string name, string annotation)
{
Author = author;
Name = name;
Annotation = annotation;
}
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public class ColumnParameters
{
public string _nameColumn { get; set; } = string.Empty;
public string _nameField { get; set; } = string.Empty;
public ColumnParameters(string nameColumn, string nameField)
{
_nameColumn = nameColumn;
_nameField = nameField;
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public class DataHistogramm
{
public string _nameData { get; set; } = string.Empty;
public double _data { get; set; }
public DataHistogramm(string nameData, int data)
{
_nameData = nameData;
_data = data;
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public enum EnumLegends
{
None = 0,
Left = 1,
Right = 2,
Top = 3,
Bottom = 4
}
}

View File

@ -0,0 +1,30 @@
using DocumentFormat.OpenXml.Drawing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public class MyHistogramm
{
public string _filePath = string.Empty;
public string _fileHeader = string.Empty;
public string _histogramName = string.Empty;
public EnumLegends _legends;
public List<DataHistogramm> _dataList = new();
public MyHistogramm(string filePath, string fileHeader, string histogramName, EnumLegends legends, List<DataHistogramm> dataList) {
_filePath = filePath;
_fileHeader = fileHeader;
_histogramName = histogramName;
_legends = legends;
_dataList = dataList;
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public class MyTable
{
public string _filePath = string.Empty;
public string _fileHeader = string.Empty;
public List<string[,]> _dataList = new();
public MyTable(string filePath, string fileHeader, List<string[,]> dataList) {
_filePath = filePath;
_fileHeader = fileHeader;
_dataList = dataList;
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public class MyTableWithHead<T>
{
public string _filePath = string.Empty;
public string _fileHeader = string.Empty;
public List<double> _heightRow = new();
public List<double> _widthCol = new();
public List<T> _dataList;
public Dictionary<int, ColumnParameters> _columnsSettings;
public MyTableWithHead(string filePath, string fileHeader, List<double> heightRow,
List<double> widthCol, List<T> dataList, Dictionary<int, ColumnParameters> columnsSettings)
{
_filePath = filePath;
_fileHeader = fileHeader;
_heightRow = heightRow;
_widthCol = widthCol;
_dataList = dataList;
_columnsSettings = columnsSettings;
}
}
}

View File

@ -0,0 +1,27 @@
using DocumentFormat.OpenXml.Bibliography;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Classes
{
public class TableParameters
{
public string? _header { get; set; }
public int _width { get; set; }
public bool _isVisual { get; set; }
public string? _name { get; set; }
public TableParameters(string header, int width, bool isVisual, string name)
{
_header = header;
_width = width;
_isVisual = isVisual;
_name = name;
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Exceptions
{
[Serializable]
public class NotValueException:Exception
{
public NotValueException() : base() { }
public NotValueException(string message) : base(message) { }
public NotValueException(string message, Exception exception) : base(message, exception) { }
protected NotValueException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.Exceptions
{
[Serializable]
public class WrongTypeException: Exception
{
public WrongTypeException() : base() { }
public WrongTypeException(string message) : base(message) { }
public WrongTypeException(string message, Exception exception) : base(message, exception) { }
protected WrongTypeException(SerializationInfo info, StreamingContext contex) : base(info, contex) { }
}
}

18
KOP_Labs/KOP_Labs.csproj Normal file
View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspose.Words" Version="23.10.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.25" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.25" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,36 @@
namespace KOP_Labs.NonVisualComponents
{
partial class WordHistogramm
{
/// <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,88 @@
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Drawing.Charts;
using KOP_Labs.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KOP_Labs.NonVisualComponents
{
public partial class WordHistogramm : Component
{
public WordHistogramm()
{
InitializeComponent();
}
public WordHistogramm(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateHistogramm(MyHistogramm myHistogramm)
{
if(!CheckData(myHistogramm._dataList)) {
return;
}
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Aspose.Words.Font font = builder.Font;
font.Size = 14;
font.Bold = true;
font.Color = System.Drawing.Color.Black;
font.Name = "Times New Roman";
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
paragraphFormat.FirstLineIndent = 8;
paragraphFormat.SpaceAfter = 24;
paragraphFormat.Alignment = ParagraphAlignment.Center;
paragraphFormat.KeepTogether = true;
builder.Writeln(myHistogramm._fileHeader);
Shape shape = builder.InsertChart(ChartType.Column, 500, 270);
Chart chart = shape.Chart;
chart.Title.Text = myHistogramm._fileHeader;
ChartSeriesCollection seriesColl = chart.Series;
seriesColl.Clear();
string[] categories = new string[] { myHistogramm._dataList[0]._nameData };
foreach (var data in myHistogramm._dataList)
{
seriesColl.Add(data._nameData, categories, new double[] { data._data });
}
ChartLegend legend = chart.Legend;
legend.Position = (LegendPosition)myHistogramm._legends;
legend.Overlay = true;
doc.Save(myHistogramm._filePath);
}
private bool CheckData(List<DataHistogramm> data)
{
foreach (var _data in data)
{
if (string.IsNullOrEmpty(_data._data.ToString()))
{
return false;
}
}
return true;
}
}
}

View File

@ -0,0 +1,36 @@
namespace KOP_Labs.NonVisualComponents
{
partial class WordTableComponent
{
/// <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,166 @@

using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.ExtendedProperties;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using KOP_Labs.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using Bold = DocumentFormat.OpenXml.Wordprocessing.Bold;
using BottomBorder = DocumentFormat.OpenXml.Wordprocessing.BottomBorder;
using LeftBorder = DocumentFormat.OpenXml.Wordprocessing.LeftBorder;
using RightBorder = DocumentFormat.OpenXml.Wordprocessing.RightBorder;
using Run = DocumentFormat.OpenXml.Wordprocessing.Run;
using RunProperties = DocumentFormat.OpenXml.Wordprocessing.RunProperties;
using Table = DocumentFormat.OpenXml.Wordprocessing.Table;
using Text = DocumentFormat.OpenXml.Wordprocessing.Text;
using TopBorder = DocumentFormat.OpenXml.Wordprocessing.TopBorder;
namespace KOP_Labs.NonVisualComponents
{
public partial class WordTableComponent : Component
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
public WordTableComponent()
{
InitializeComponent();
}
public WordTableComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDoc(MyTable myTable)
{
if(!CheckData(myTable._dataList)) return;
_wordDocument = WordprocessingDocument.Create(myTable._filePath, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
_wordDocument.Close();
using (WordprocessingDocument doc = WordprocessingDocument.Open(myTable._filePath, true))
{
var mainDoc = doc.MainDocumentPart.Document;
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph headerParagraph = new Paragraph();
Run headerRun = new Run(new Text(myTable._fileHeader));
RunProperties runProperties = new RunProperties();
Bold bold = new Bold();
runProperties.Append(bold);
headerRun.Append(runProperties);
headerParagraph.Append(headerRun);
Table table = new Table();
TableProperties props = new TableProperties(
new TableBorders(
new TopBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new BottomBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new LeftBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new RightBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideHorizontalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideVerticalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
}
));
table.AppendChild<TableProperties>(props);
for (var i = 0; i < myTable._dataList.Count; i++)
{
var tr = new TableRow();
for (var j = 0; j < myTable._dataList[i].Length; j++)
{
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = "2000"
}
));
tc.Append(new Paragraph(new Run(new Text(myTable._dataList[i][0, j]))));
tr.Append(tc);
}
table.Append(tr);
}
mainDoc.Body.Append(headerParagraph);
mainDoc.Body.Append(table);
mainDoc.Save();
}
}
private bool CheckData(List<string[,]> data)
{
for (int i = 0; i < data.Count; i++)
{
for (int j = 0; j < data[i].Length; j++)
{
if (data[i][0, j] == null) {
return false;
}
}
}
return true;
}
}
}

View File

@ -0,0 +1,36 @@
namespace KOP_Labs.NonVisualComponents
{
partial class WordTableHeaderComponent
{
/// <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,243 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml;
using KOP_Labs.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Wordprocessing;
namespace KOP_Labs.NonVisualComponents
{
public partial class WordTableHeaderComponent : Component
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
public WordTableHeaderComponent()
{
InitializeComponent();
}
public WordTableHeaderComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDoc<T>(MyTableWithHead<T> myTable)
{
if (!CheckData(myTable._dataList)) return;
_wordDocument = WordprocessingDocument.Create(myTable._filePath, WordprocessingDocumentType.Document);
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
_wordDocument.Close();
using (WordprocessingDocument doc = WordprocessingDocument.Open(myTable._filePath, true))
{
var mainDoc = doc.MainDocumentPart.Document;
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph headerParagraph = new Paragraph();
Run headerRun = new Run(new Text(myTable._fileHeader));
RunProperties runProperties = new RunProperties();
Bold bold = new Bold();
runProperties.Append(bold);
headerRun.Append(runProperties);
headerParagraph.Append(headerRun);
Table table = new Table();
TableProperties props = new TableProperties(
new TableBorders(
new TopBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new BottomBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new LeftBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new RightBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideHorizontalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideVerticalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
}
));
table.AppendChild<TableProperties>(props);
var _tr = new TableRow();
int indexHeaderHeigh = 0;
int indexHeaderWidth = 0;
foreach (var item in myTable._columnsSettings)
{
_tr.Append(new TableRowProperties(new TableRowHeight
{
Val = Convert.ToUInt32(myTable._heightRow[indexHeaderHeigh])
}));
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = myTable._widthCol[indexHeaderWidth].ToString(),
}
));
if (string.IsNullOrEmpty(myTable._columnsSettings[indexHeaderWidth]._nameField) ||
string.IsNullOrEmpty(myTable._columnsSettings[indexHeaderWidth]._nameColumn))
{
return;
}
Paragraph tableHeader = new();
var Run = new Run();
var headerProperties = new RunProperties();
headerProperties.Append(new Bold());
Run.AppendChild(headerProperties);
Run.AppendChild(new Text(item.Value._nameColumn));
tableHeader.AppendChild(Run);
tc.Append(tableHeader);
_tr.Append(tc);
indexHeaderWidth++;
}
table.Append(_tr);
indexHeaderHeigh++;
indexHeaderWidth = 0;
for (int i = 0; i < myTable._dataList.Count; i++)
{
var tr = new TableRow();
foreach (var item in myTable._columnsSettings)
{
tr.Append(new TableRowProperties(new TableRowHeight
{
Val = Convert.ToUInt32(myTable._heightRow[indexHeaderHeigh])
}));
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = myTable._widthCol[indexHeaderWidth].ToString(),
}
));
foreach (var val in myTable._dataList[i].GetType().GetProperties())
{
if (val.Name == item.Value._nameField)
{
var newParagraph = new Paragraph();
var newRun = new Run();
var runPropertiesInd = new RunProperties();
if (indexHeaderWidth == 0)
{
runPropertiesInd.Append(new Bold());
}
newRun.AppendChild(runPropertiesInd);
newRun.AppendChild(new Text(val.GetValue(myTable._dataList[i]).ToString()));
newParagraph.AppendChild(newRun);
tc.Append(newParagraph);
break;
}
}
tr.Append(tc);
indexHeaderWidth++;
}
indexHeaderWidth = 0;
table.Append(tr);
}
mainDoc.Body.Append(headerParagraph);
mainDoc.Body.Append(table);
mainDoc.Save();
}
}
private bool CheckData<T>(List<T> dataList)
{
foreach (var data in dataList)
{
foreach (var value in data.GetType().GetProperties())
{
if (string.IsNullOrEmpty(value.GetValue(data).ToString()))
{
return false;
}
}
}
return true;
}
}
}

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

@ -0,0 +1,64 @@
namespace KOP_Labs
{
partial class TableComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(17, 22);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(304, 200);
dataGridView.TabIndex = 0;
dataGridView.SelectionChanged += SelectionChanged;
//
// TableComponent
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(dataGridView);
Name = "TableComponent";
Size = new Size(342, 239);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

109
KOP_Labs/TableComponent.cs Normal file
View File

@ -0,0 +1,109 @@
using KOP_Labs.Classes;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KOP_Labs
{
public partial class TableComponent : UserControl
{
public event EventHandler TaskHandler;
public int indexRow;
public int IndexRow
{
get
{
return indexRow;
}
set
{
indexRow = value;
}
}
public TableComponent()
{
InitializeComponent();
}
public void TableConfiguration(int countCol, List<TableParameters> parameters)
{
if (parameters.Count != parameters.Count) { return; }
for (int i = 0; i < countCol; i++)
{
DataGridViewColumn column = new DataGridViewColumn();
column.Name = parameters[i]._name;
column.HeaderText = parameters[i]._header;
column.Width = parameters[i]._width;
column.Visible = parameters[i]._isVisual;
column.CellTemplate = new DataGridViewTextBoxCell();
dataGridView.Columns.Add(column);
}
}
public void ClearRows()
{
dataGridView.Rows.Clear();
}
public void AddRow<T>(T newObject)
{
DataGridViewRow row = (DataGridViewRow)dataGridView.Rows[0].Clone();
foreach (var prop in newObject.GetType().GetProperties())
{
object value = prop.GetValue(newObject);
row.Cells[dataGridView.Columns[prop.Name].Index].Value = value;
}
dataGridView.Rows.Add(row);
}
public T GetSelectedObject<T>() where T : new()
{
if (dataGridView.SelectedCells.Count == 0)
{
return new T();
}
int rowIndex = dataGridView.SelectedCells[0].RowIndex;
var targetObject = new T();
Type objectType = typeof(T);
PropertyInfo[] properties = objectType.GetProperties();
foreach (PropertyInfo property in properties)
{
DataGridViewCell selectedCell = dataGridView.Rows[rowIndex].Cells[property.Name];
object cellValue = selectedCell.Value;
if (cellValue != null && property.CanWrite)
{
object convertedValue = Convert.ChangeType(cellValue, property.PropertyType);
property.SetValue(targetObject, convertedValue);
}
}
return targetObject;
}
private void SelectionChanged(object sender, EventArgs e)
{
var element = sender as DataGridView;
if (dataGridView.SelectedRows.Count == 0)
{
return;
}
IndexRow = element.SelectedRows[0].Index;
TaskHandler?.Invoke(this, e);
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

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

@ -0,0 +1,71 @@
namespace KOP_Labs
{
partial class TextBoxComponent
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
textBox = new TextBox();
checkBox1 = new CheckBox();
SuspendLayout();
//
// textBox
//
textBox.Location = new Point(141, 73);
textBox.Name = "textBox";
textBox.Size = new Size(125, 27);
textBox.TabIndex = 0;
textBox.TextChanged += TextBox_TextChanged;
//
// checkBox1
//
checkBox1.AutoSize = true;
checkBox1.Location = new Point(34, 73);
checkBox1.Name = "checkBox1";
checkBox1.Size = new Size(101, 24);
checkBox1.TabIndex = 1;
checkBox1.Text = "checkBox1";
checkBox1.UseVisualStyleBackColor = true;
checkBox1.CheckedChanged += CheckBox_CheckedChanged;
//
// TextBoxComponent
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(checkBox1);
Controls.Add(textBox);
Name = "TextBoxComponent";
Size = new Size(439, 252);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox;
private CheckBox checkBox1;
}
}

View File

@ -0,0 +1,129 @@
using DocumentFormat.OpenXml.Drawing.Diagrams;
using KOP_Labs.Exceptions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
namespace KOP_Labs
{
public partial class TextBoxComponent : UserControl
{
public TextBoxComponent()
{
InitializeComponent();
Error = string.Empty;
}
public string Error { get; private set; }
public float? Value
{
get
{
if (checkBox1.Checked)
{
return null;
}
if (CheckValue())
{
return float.Parse(textBox.Text);
}
return null;
}
set
{
if (value == null)
{
checkBox1.Checked = true;
}
textBox.Text = value.ToString();
}
}
private EventHandler checkChanged;
public event EventHandler CheckChanged
{
add
{
checkChanged += value;
}
remove
{
checkChanged -= value;
}
}
private void CheckBox_CheckedChanged(object sender, EventArgs e)
{
Error = string.Empty;
if (checkBox1.Checked)
{
textBox.Enabled = false;
textBox.Text = string.Empty;
}
else
{
textBox.Enabled = true;
}
checkChanged?.Invoke(sender, e);
}
private EventHandler valueChanged;
public event EventHandler ValueChanged
{
add
{
valueChanged += value;
}
remove
{
valueChanged -= value;
}
}
public bool CheckValue()
{
Error = string.Empty;
if (!checkBox1.Checked && (string.IsNullOrEmpty(textBox.Text)))
{
Error = "Пусто!";
return false;
}
if (!checkBox1.Checked && !float.TryParse(textBox.Text, out float floatValue))
{
Error = "Не тот тип!";
return false;
}
return true;
}
private void TextBox_TextChanged(object sender, EventArgs e)
{
valueChanged?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

7
Plugin/Class1.cs Normal file
View File

@ -0,0 +1,7 @@
namespace Plugin
{
public class Class1
{
}
}

View File

@ -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
{/*
/// <summary>
/// Название плагина
/// </summary>
string PluginName { get; }
/// <summary>
/// Получение контрола для вывода набора данных
/// </summary>
UserControl GetControl { get; }
/// <summary>
/// Получение элемента, выбранного в контроле
/// </summary>
PluginsConventionElement GetElement { get; }
/// <summary>
/// Получение формы для создания/редактирования объекта
/// </summary>
/// <param name="element"></param>
/// <returns></returns>
Form GetForm(PluginsConventionElement element);
/// <summary>
/// Получение формы для работы со справочником
/// </summary>
/// <returns></returns>
Form GetThesaurus();
/// <summary>
/// Удаление элемента
3
/// </summary>
/// <param name="element"></param>
/// <returns></returns>
bool DeleteElement(PluginsConventionElement element);
/// <summary>
/// Обновление набора данных в контроле
/// </summary>
void ReloadData();
/// <summary>
/// Создание простого документа
/// </summary>
/// <param name="saveDocument"></param>
/// <returns></returns>
bool CreateSimpleDocument(PluginsConventionSaveDocument
saveDocument);
/// <summary>
/// Создание простого документа
/// </summary>
/// <param name="saveDocument"></param>
/// <returns></returns>
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
/// <summary>
/// Создание документа с диаграммой
/// </summary>
/// <param name="saveDocument"></param>
/// <returns></returns>
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);*/
}
}

9
Plugin/Plugin.csproj Normal file
View File

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

View File

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

View File

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

View File

@ -1,2 +0,0 @@
# Zhelovanov_Dmitrii_COP

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

@ -0,0 +1,182 @@
namespace WinForm
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
booksForm1 = new KOP_Labs.BooksForm();
buttonFillValues = new Button();
buttonClear = new Button();
textBoxComponent1 = new KOP_Labs.TextBoxComponent();
labelCheckComponent = new Label();
buttonTextBox = new Button();
tableComponent = new KOP_Labs.TableComponent();
buttonTable = new Button();
buttonConfig = new Button();
buttonCleatTable = new Button();
buttonGetObj = new Button();
SuspendLayout();
//
// booksForm1
//
booksForm1.Location = new Point(12, 12);
booksForm1.Name = "booksForm1";
booksForm1.SelectedValue = null;
booksForm1.Size = new Size(563, 251);
booksForm1.TabIndex = 0;
//
// buttonFillValues
//
buttonFillValues.Location = new Point(51, 290);
buttonFillValues.Name = "buttonFillValues";
buttonFillValues.Size = new Size(94, 29);
buttonFillValues.TabIndex = 1;
buttonFillValues.Text = "Заполнить";
buttonFillValues.UseVisualStyleBackColor = true;
buttonFillValues.Click += buttonFillValues_Click;
//
// buttonClear
//
buttonClear.Location = new Point(180, 290);
buttonClear.Name = "buttonClear";
buttonClear.Size = new Size(94, 29);
buttonClear.TabIndex = 2;
buttonClear.Text = "Очистить";
buttonClear.UseVisualStyleBackColor = true;
buttonClear.Click += buttonClear_Click;
//
// textBoxComponent1
//
textBoxComponent1.Location = new Point(280, 212);
textBoxComponent1.Name = "textBoxComponent1";
textBoxComponent1.Size = new Size(549, 315);
textBoxComponent1.TabIndex = 3;
//
// labelCheckComponent
//
labelCheckComponent.AutoSize = true;
labelCheckComponent.Location = new Point(491, 358);
labelCheckComponent.Name = "labelCheckComponent";
labelCheckComponent.Size = new Size(129, 20);
labelCheckComponent.TabIndex = 4;
labelCheckComponent.Text = "Введенный текст:";
//
// buttonTextBox
//
buttonTextBox.Location = new Point(324, 349);
buttonTextBox.Name = "buttonTextBox";
buttonTextBox.Size = new Size(142, 29);
buttonTextBox.TabIndex = 5;
buttonTextBox.Text = "Ввести значение";
buttonTextBox.UseVisualStyleBackColor = true;
buttonTextBox.Click += buttonTextBox_Click;
//
// tableComponent
//
tableComponent.IndexRow = 0;
tableComponent.Location = new Point(649, 12);
tableComponent.Name = "tableComponent";
tableComponent.Size = new Size(678, 242);
tableComponent.TabIndex = 6;
//
// buttonTable
//
buttonTable.Location = new Point(790, 270);
buttonTable.Name = "buttonTable";
buttonTable.Size = new Size(94, 29);
buttonTable.TabIndex = 7;
buttonTable.Text = "Ввести";
buttonTable.UseVisualStyleBackColor = true;
buttonTable.Click += buttonTable_Click;
//
// buttonConfig
//
buttonConfig.Location = new Point(661, 270);
buttonConfig.Name = "buttonConfig";
buttonConfig.Size = new Size(123, 29);
buttonConfig.TabIndex = 8;
buttonConfig.Text = "Конфигурация";
buttonConfig.UseVisualStyleBackColor = true;
buttonConfig.Click += buttonConfig_Click;
//
// buttonCleatTable
//
buttonCleatTable.Location = new Point(890, 270);
buttonCleatTable.Name = "buttonCleatTable";
buttonCleatTable.Size = new Size(94, 29);
buttonCleatTable.TabIndex = 9;
buttonCleatTable.Text = "Очистить";
buttonCleatTable.UseVisualStyleBackColor = true;
buttonCleatTable.Click += buttonCleatTable_Click;
//
// buttonGetObj
//
buttonGetObj.Location = new Point(990, 270);
buttonGetObj.Name = "buttonGetObj";
buttonGetObj.Size = new Size(156, 29);
buttonGetObj.TabIndex = 10;
buttonGetObj.Text = "Получить значение";
buttonGetObj.UseVisualStyleBackColor = true;
buttonGetObj.Click += buttonGetObj_Click;
//
// Form1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1153, 450);
Controls.Add(buttonGetObj);
Controls.Add(buttonCleatTable);
Controls.Add(buttonConfig);
Controls.Add(buttonTable);
Controls.Add(tableComponent);
Controls.Add(buttonTextBox);
Controls.Add(labelCheckComponent);
Controls.Add(textBoxComponent1);
Controls.Add(buttonClear);
Controls.Add(buttonFillValues);
Controls.Add(booksForm1);
Name = "Form1";
Text = "Form1";
ResumeLayout(false);
PerformLayout();
}
#endregion
private KOP_Labs.BooksForm booksForm1;
private Button buttonFillValues;
private Button buttonClear;
private KOP_Labs.TextBoxComponent textBoxComponent1;
private Label labelCheckComponent;
private Button buttonTextBox;
private KOP_Labs.TableComponent tableComponent;
private Button buttonTable;
private Button buttonConfig;
private Button buttonCleatTable;
private Button buttonGetObj;
}
}

76
WinForm/Form1.cs Normal file
View File

@ -0,0 +1,76 @@
using KOP_Labs.Classes;
using KOP_Labs.Exceptions;
using System.Security.Principal;
using System.Text;
namespace WinForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void booksForm1_Load(object sender, EventArgs e)
{
}
private void buttonFillValues_Click(object sender, EventArgs e)
{
booksForm1.FillValues("fgdfgfdgd fdgdffdg adsdds");
}
private void buttonClear_Click(object sender, EventArgs e)
{
booksForm1.ClearList();
}
private void buttonTextBox_Click(object sender, EventArgs e)
{
labelCheckComponent.Text = "Ââåäåííûé òåêñò: ";
labelCheckComponent.Text += textBoxComponent1.Value;
if (textBoxComponent1.Error.Length > 0)
{
MessageBox.Show(textBoxComponent1.Error);
}
}
private void buttonTable_Click(object sender, EventArgs e)
{
tableComponent.AddRow(new Book("gfgdf", "book1", "lalala"));
tableComponent.AddRow(new Book("Pushkin","book2", "lalala2"));
tableComponent.AddRow(new Book("Pushkin", "book3", "lalala"));
}
private void buttonConfig_Click(object sender, EventArgs e)
{
List<TableParameters> tableParameters = new List<TableParameters>();
tableParameters.Add(new TableParameters("fds", 80, true, "Id"));
tableParameters.Add(new TableParameters("fds", 80, true, "Name"));
tableParameters.Add(new TableParameters("fds", 80, true, "Annotation"));
tableComponent.TableConfiguration(3, tableParameters);
}
private void buttonCleatTable_Click(object sender, EventArgs e)
{
tableComponent.ClearRows();
}
private void buttonGetObj_Click(object sender, EventArgs e)
{
string answer = tableComponent.GetSelectedObject<Book>().Name.ToString() + " " + tableComponent.GetSelectedObject<Book>().Annotation.ToString() + " ";
MessageBox.Show(answer);
}
}
}

60
WinForm/Form1.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

153
WinForm/FormCreateBook.Designer.cs generated Normal file
View File

@ -0,0 +1,153 @@
namespace WinForm
{
partial class FormCreateBook
{
/// <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()
{
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;
}
}

75
WinForm/FormCreateBook.cs Normal file
View File

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

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>

162
WinForm/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,162 @@
namespace WinForm
{
partial class FormMain
{
/// <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()
{
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;
}
}

432
WinForm/FormMain.cs Normal file
View File

@ -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<Book>().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<Book>().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<string[,]> totalList = new();
List<BookViewModel> 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<BookViewModel>? 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<BookViewModel>
{
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<string, List<int>>();
for (var i = 0; i < Names.Length; i++)
{
var curlist = new List<int>();
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;*/
}
}
}
}
}

75
WinForm/FormMain.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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="wordTableComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>152, 17</value>
</metadata>
<metadata name="componentDocumentWithTableHeaderColumnPdf1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>365, 17</value>
</metadata>
<metadata name="pdfTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>770, 17</value>
</metadata>
<metadata name="diagramComponent1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>891, 17</value>
</metadata>
</root>

64
WinForm/FormShapes.Designer.cs generated Normal file
View File

@ -0,0 +1,64 @@
namespace WinForm
{
partial class FormShapes
{
/// <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()
{
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;
}
}

148
WinForm/FormShapes.cs Normal file
View File

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

60
WinForm/FormShapes.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

92
WinForm/NonVisualForm.Designer.cs generated Normal file
View File

@ -0,0 +1,92 @@
namespace WinForm
{
partial class NonVisualForm
{
/// <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()
{
components = new System.ComponentModel.Container();
wordTableComponent1 = new KOP_Labs.NonVisualComponents.WordTableComponent(components);
buttonWordSave = new Button();
buttonSaveHist = new Button();
wordHistogramm1 = new KOP_Labs.NonVisualComponents.WordHistogramm(components);
wordTableHeaderComponent1 = new KOP_Labs.NonVisualComponents.WordTableHeaderComponent(components);
buttonHead = new Button();
SuspendLayout();
//
// buttonWordSave
//
buttonWordSave.Location = new Point(54, 262);
buttonWordSave.Name = "buttonWordSave";
buttonWordSave.Size = new Size(94, 29);
buttonWordSave.TabIndex = 0;
buttonWordSave.Text = "Сохранить";
buttonWordSave.UseVisualStyleBackColor = true;
buttonWordSave.Click += buttonWordSave_Click;
//
// buttonSaveHist
//
buttonSaveHist.Location = new Point(279, 262);
buttonSaveHist.Name = "buttonSaveHist";
buttonSaveHist.Size = new Size(94, 29);
buttonSaveHist.TabIndex = 1;
buttonSaveHist.Text = "xlsx";
buttonSaveHist.UseVisualStyleBackColor = true;
buttonSaveHist.Click += buttonSaveHist_Click;
//
// buttonHead
//
buttonHead.Location = new Point(499, 262);
buttonHead.Name = "buttonHead";
buttonHead.Size = new Size(169, 29);
buttonHead.TabIndex = 2;
buttonHead.Text = "Таблица с шапкой";
buttonHead.UseVisualStyleBackColor = true;
buttonHead.Click += buttonHead_Click;
//
// NonVisualForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonHead);
Controls.Add(buttonSaveHist);
Controls.Add(buttonWordSave);
Name = "NonVisualForm";
Text = "NonVisualForm";
ResumeLayout(false);
}
#endregion
private KOP_Labs.NonVisualComponents.WordTableComponent wordTableComponent1;
private Button buttonWordSave;
private Button buttonSaveHist;
private KOP_Labs.NonVisualComponents.WordHistogramm wordHistogramm1;
private KOP_Labs.NonVisualComponents.WordTableHeaderComponent wordTableHeaderComponent1;
private Button buttonHead;
}
}

143
WinForm/NonVisualForm.cs Normal file
View File

@ -0,0 +1,143 @@
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Spreadsheet;
using KOP_Labs.Classes;
using Microsoft.VisualBasic.ApplicationServices;
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 NonVisualForm : Form
{
public NonVisualForm()
{
InitializeComponent();
}
MyHistogramm histogram;
private void buttonWordSave_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
string title = "Заголовок";
string[,] row1 = {
{ "Стр1 Кол1", "Стр1 Кол2" }
};
string[,] row2 = {
{ "Стр2 Кол1", "Стр2 Кол2" }
};
string[,] row3 = {
{ "Стр3 Кол1", "Стр3 Кол3" }
};
MyTable table = new MyTable(dialog.FileName, title, new List<string[,]> { row1, row2, row3 });
wordTableComponent1.CreateDoc(table);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSaveHist_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
histogram = new(dialog.FileName, "Заголовок", "Гистограмма", EnumLegends.Right, new List<DataHistogramm> {
new DataHistogramm("Тихий дон", 170), new DataHistogramm("Мастер и Маргарита", 400),
new DataHistogramm("Сборник Пушкина", 240), new DataHistogramm("12 стульев", 200)
});
wordHistogramm1.CreateHistogramm(histogram);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
List<Book> books;
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<int, ColumnParameters> colData;
private void buttonHead_Click(object sender, EventArgs e)
{
books = new()
{
book1, book2, book3, book4, book5, book6
};
colData = new Dictionary<int, ColumnParameters>()
{
{ 0, new ColumnParameters("Автор", "Author") },
{ 1, new ColumnParameters("Id книги", "Id") },
{ 2, new ColumnParameters("Имя", "Name") },
{ 3, new ColumnParameters("Аннотация", "Annotation") }
};
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
MyTableWithHead<Book> myTable = new(dialog.FileName, "Заголовок", new List<double> { 50, 50 },
new List<double> { 2000, 2000, 1500, 1500 }, books.GroupBy(b => b.Author).SelectMany(a => a).ToList(), colData);
wordTableHeaderComponent1.CreateDoc(myTable);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

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

40
WinForm/Program.cs Normal file
View File

@ -0,0 +1,40 @@
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;
/// <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();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<IBookStorage, BookStorage>();
services.AddTransient<IShapeStorage, ShapeStorage>();
services.AddTransient<NonVisualForm>();
services.AddTransient<FormMain>();
services.AddTransient<FormCreateBook>();
services.AddTransient<FormShapes>();
}
}
}

30
WinForm/WinForm.csproj Normal file
View File

@ -0,0 +1,30 @@
<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="6.0.25">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1004" />
<PackageReference Include="SergComponent" Version="1.0.0" />
<PackageReference Include="ViewComponents" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\KOP_Labs\KOP_Labs.csproj" />
</ItemGroup>
</Project>