Compare commits

...

67 Commits

Author SHA1 Message Date
ElEgEv
9517896ece Lab work 4. 2023-11-08 12:01:13 +04:00
ElEgEv
85be301862 All working! :) :) :) 2023-11-03 00:22:31 +04:00
ElEgEv
105b576311 Итоговые правки. 2023-11-03 00:07:27 +04:00
ElEgEv
52f2fd6b15 Промежуточный. 2023-11-02 23:54:11 +04:00
ElEgEv
8c80db4df3 Saves. 2023-11-02 23:12:21 +04:00
ElEgEv
e073e19639 Something was created. 2023-11-02 21:46:57 +04:00
ElEgEv
e9733d991b First common. 2023-11-02 21:27:47 +04:00
ElEgEv
695eca91b9 Small commit. 2023-11-02 17:27:46 +04:00
ElEgEv
b9162ffb1a Slowly adding the code. 2023-11-02 16:54:48 +04:00
ElEgEv
b97be5168a Start working. 2023-11-02 16:30:00 +04:00
ElEgEv
c71b6fe616 УРА СДАЛ 2023-10-25 13:40:26 +04:00
ElEgEv
cbc1144b74 Во, так лучше 2023-10-25 00:13:54 +04:00
ElEgEv
cac22b1578 Вроде Word работает по ТЗ. 2023-10-25 00:07:28 +04:00
ElEgEv
d6fd160b27 Работа с документами. 2023-10-24 21:40:42 +04:00
ElEgEv
3ec2154684 УРА 2023-10-24 19:45:26 +04:00
ElEgEv
19d6cfae36 Не работает контекстное меню. 2023-10-24 12:52:55 +04:00
ElEgEv
911fd9d6c6 Create Form for create LabWork. 2023-10-24 12:11:06 +04:00
ElEgEv
af7eb58283 Первая форма готова. 2023-10-24 00:00:25 +04:00
ElEgEv
67698429f2 / 2023-10-23 22:34:53 +04:00
ElEgEv
9675ad7004 Я СМОГ ДОБАВИТЬ ИХ КОМПОНЕНТЫ 2023-10-23 19:38:16 +04:00
ElEgEv
f143475b3a . 2023-10-23 18:05:29 +04:00
ElEgEv
9c2288c766 Congratulates! DB is created :) 2023-10-23 16:47:58 +04:00
ElEgEv
bb7e397adc Промежуточное сохранение. 2023-10-23 16:21:36 +04:00
ElEgEv
cf6bc53d69 . 2023-10-21 00:15:53 +04:00
ElEgEv
d77baa2273 Add new lib. 2023-10-20 23:13:02 +04:00
ElEgEv
352635edf0 Начало работ. 2023-10-20 22:56:51 +04:00
ElEgEv
85f3440431 Сданная лаба. 2023-10-11 12:14:23 +04:00
ElEgEv
4b6d44e659 Вроде робит 2023-10-11 11:15:44 +04:00
ElEgEv
3666046345 Вроде робит 2023-10-11 10:59:52 +04:00
ElEgEv
cfba8354fb Переход на Dictionary. 2023-10-11 00:09:17 +04:00
ElEgEv
a60f4cd6ce . 2023-10-10 22:29:07 +04:00
ElEgEv
8750c3a305 Промежуточное. 2023-10-10 00:38:20 +04:00
ElEgEv
e79648acd7 Таблица генерится. 2023-10-09 22:54:08 +04:00
ElEgEv
056880251c Промежуточное глобальное. Искренне надеюсь, что сработает (но нет) 2023-10-09 19:17:33 +04:00
ElEgEv
5b8fe3a26e Промежуточное. 2023-10-09 18:14:48 +04:00
ElEgEv
d001a8e245 Начало 3-го компонента. 2023-10-07 00:47:07 +04:00
ElEgEv
f1dbb5e420 Вроде третий компонент. 2023-10-06 21:29:34 +04:00
ElEgEv
74c7c849f2 . 2023-10-06 13:27:30 +04:00
ElEgEv
61ecbdc532 Вроде сделал. 2023-10-06 13:21:49 +04:00
ElEgEv
5335b9bf40 Продвигаюсь... 2023-10-06 00:47:23 +04:00
ElEgEv
487d5b784e Установка пакетов. 2023-10-05 21:35:43 +04:00
ElEgEv
5ff2f7cce8 Я СДАЛ 2023-09-27 13:52:25 +04:00
ElEgEv
7cb9784d4f . 2023-09-27 13:00:47 +04:00
ElEgEv
0479020de6 Всё пытаюсь сдать... 2023-09-27 12:59:45 +04:00
ElEgEv
b84f61e1cb Третий компонент?? 2023-09-27 12:09:32 +04:00
ElEgEv
8771c2c962 Промежуточное 2023-09-27 11:38:01 +04:00
ElEgEv
78810b76e6 Add objects. 2023-09-27 11:26:30 +04:00
ElEgEv
32b483ff02 Правки 2023-09-27 01:26:31 +04:00
ElEgEv
6e40e75b38 Промежуточное. 2023-09-27 00:51:33 +04:00
ElEgEv
3733e7b099 Начало работы над третим компонетом. 2023-09-27 00:31:17 +04:00
ElEgEv
df6dc6cc54 Второй компонент. 2023-09-26 21:38:38 +04:00
ElEgEv
9ca65527e1 Перед перелопачиванием 2023-09-26 20:44:05 +04:00
ElEgEv
5ee58b256e Мелкие правки 2023-09-26 09:42:55 +04:00
ElEgEv
1ff7c269ba ПЕРВЫЙ КОМПОНЕНТ ВРОДЕ КАК. 2023-09-21 14:27:34 +04:00
ElEgEv
edb62e34b6 dfsgdsfgs 2023-09-13 14:55:54 +04:00
ElEgEv
479b08bcf0 . 2023-09-13 14:50:19 +04:00
ElEgEv
1944070931 правка лабы. 2023-09-13 14:47:07 +04:00
ElEgEv
74aa787f1d . 2023-09-13 13:48:16 +04:00
ElEgEv
bf736e563d Промежуточное. 2023-09-13 12:53:53 +04:00
ElEgEv
8666b365b0 . 2023-09-13 11:57:01 +04:00
ElEgEv
cbabf209bb Другой подход 2023-09-13 11:54:50 +04:00
ElEgEv
1605f4c548 . 2023-09-13 10:30:37 +04:00
ElEgEv
bb487bf6e1 Правки 2023-09-13 09:58:42 +04:00
ElEgEv
51152f5d9b Test first component. 2023-09-12 12:27:56 +04:00
ElEgEv
1be19b8943 New Lib. 2023-09-12 11:25:18 +04:00
ElEgEv
fa7bb6f3c8 Add dependence. 2023-09-12 10:38:04 +04:00
ElEgEv
a70cfd1d18 Add new lib. 2023-09-12 10:37:31 +04:00
86 changed files with 5962 additions and 45 deletions

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponents", "VisualComponents\VisualComponents.csproj", "{E5333284-B1A3-4A29-AFFB-5DB3692C036B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E5333284-B1A3-4A29-AFFB-5DB3692C036B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5333284-B1A3-4A29-AFFB-5DB3692C036B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5333284-B1A3-4A29-AFFB-5DB3692C036B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5333284-B1A3-4A29-AFFB-5DB3692C036B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0C8F62C5-A49D-4EEF-8AA8-3F9E0682A2E3}
EndGlobalSection
EndGlobal

View File

@ -1,10 +0,0 @@
namespace VisualComponents
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,24 @@
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModel
{
public class DisciplineBindingModel : IDiscipline
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public DisciplineBindingModel() { }
public DisciplineBindingModel(IDiscipline discipline)
{
Id = discipline.Id;
Name = discipline.Name;
}
}
}

View File

@ -0,0 +1,33 @@
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.BindingModel
{
public class LabWorkBindingModel : ILabWork
{
public int Id {get; set; }
public string Theme { get; set; } = string.Empty;
public string FCs { get; set; }
public string Discipline { get; set; }
public string Questions { get; set; }
public LabWorkBindingModel() { }
public LabWorkBindingModel(ILabWork labWork)
{
Id = labWork.Id;
Theme = labWork.Theme;
FCs = labWork.FCs;
Discipline = labWork.Discipline;
Questions = labWork.Questions;
}
}
}

View File

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

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModel
{
public class DisciplineSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.SearchModel
{
public class LabWorkSearchModel
{
public int? Id { get; set; }
public string? Theme { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using Contracts.BindingModel;
using Contracts.SearchModel;
using Contracts.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface IDisciplineStorage
{
List<DisciplineViewModel> GetFullList();
DisciplineViewModel? GetElement(DisciplineSearchModel model);
DisciplineViewModel? Insert(DisciplineBindingModel model);
DisciplineViewModel? Update(DisciplineBindingModel model);
DisciplineViewModel? Delete(DisciplineBindingModel model);
}
}

View File

@ -0,0 +1,26 @@
using Contracts.BindingModel;
using Contracts.SearchModel;
using Contracts.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.StorageContracts
{
public interface ILabWorkStorage
{
List<LabWorkViewModel> GetFullList();
LabWorkViewModel? GetElement(LabWorkSearchModel model);
List<LabWorkViewModel> GetFilteredList(LabWorkSearchModel model);
LabWorkViewModel? Insert(LabWorkBindingModel model);
LabWorkViewModel? Update(LabWorkBindingModel model);
LabWorkViewModel? Delete(LabWorkBindingModel model);
}
}

View File

@ -0,0 +1,24 @@
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModel
{
public class DisciplineViewModel : IDiscipline
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public DisciplineViewModel() { }
public DisciplineViewModel(IDiscipline discipline)
{
Id = discipline.Id;
Name = discipline.Name;
}
}
}

View File

@ -0,0 +1,33 @@
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Contracts.ViewModel
{
public class LabWorkViewModel : ILabWork
{
public int Id { get; set; }
public string Theme { get; set; } = string.Empty;
public string FCs { get; set; }
public string Discipline { get; set; }
public string Questions { get; set; }
public LabWorkViewModel() { }
public LabWorkViewModel(ILabWork labWork)
{
Id = labWork.Id;
Theme = labWork.Theme;
FCs = labWork.FCs;
Discipline = labWork.Discipline;
Questions = labWork.Questions;
}
}
}

View File

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

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,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataModels.Models
{
public interface IDiscipline : IId
{
string Name { get; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataModels.Models
{
public interface ILabWork : IId
{
string Theme { get; }
//ФИО
string FCs { get; }
string Discipline { get; }
//Вопросы по лабораторной
string Questions { get; }
}
}

View File

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

View File

@ -0,0 +1,27 @@
using DatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement
{
public class ElegevContext : DbContext
{
public DbSet<LabWork> LabWorks { get; set; }
public DbSet<Discipline> Disciplines { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=MSI-B17;Initial Catalog=ElegevContext;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
}
}

View File

@ -0,0 +1,92 @@
using Contracts.BindingModel;
using Contracts.SearchModel;
using Contracts.StorageContracts;
using Contracts.ViewModel;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class DisciplineStorage : IDisciplineStorage
{
public List<DisciplineViewModel> GetFullList()
{
using var context = new ElegevContext();
return context.Disciplines
.Select(x => x.GetViewModel)
.ToList();
}
public DisciplineViewModel? GetElement(DisciplineSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new ElegevContext();
return context.Disciplines
.FirstOrDefault(x =>(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public DisciplineViewModel? Insert(DisciplineBindingModel model)
{
var newDiscipline = Discipline.Create(model);
if (newDiscipline == null)
{
return null;
}
using var context = new ElegevContext();
context.Disciplines.Add(newDiscipline);
context.SaveChanges();
return newDiscipline.GetViewModel;
}
public DisciplineViewModel? Update(DisciplineBindingModel model)
{
using var context = new ElegevContext();
var discipline = context.Disciplines
.FirstOrDefault(x => x.Id == model.Id);
if (discipline == null)
{
return null;
}
discipline.Update(model);
context.SaveChanges();
return discipline.GetViewModel;
}
public DisciplineViewModel? Delete(DisciplineBindingModel model)
{
using var context = new ElegevContext();
var element = context.Disciplines
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Disciplines.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,102 @@
using Contracts.BindingModel;
using Contracts.SearchModel;
using Contracts.StorageContracts;
using Contracts.ViewModel;
using DatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Implements
{
public class LabWorkStorage : ILabWorkStorage
{
public List<LabWorkViewModel> GetFullList()
{
using var context = new ElegevContext();
return context.LabWorks
.Select(x => x.GetViewModel)
.ToList();
}
public List<LabWorkViewModel> GetFilteredList(LabWorkSearchModel model)
{
using var context = new ElegevContext();
return context.LabWorks
.Where(x => x.Theme == model.Theme)
.Select(x => x.GetViewModel)
.ToList();
}
public LabWorkViewModel? GetElement(LabWorkSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new ElegevContext();
return context.LabWorks
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public LabWorkViewModel? Insert(LabWorkBindingModel model)
{
var newLabWork = LabWork.Create(model);
if (newLabWork == null)
{
return null;
}
using var context = new ElegevContext();
context.LabWorks.Add(newLabWork);
context.SaveChanges();
return newLabWork.GetViewModel;
}
public LabWorkViewModel? Update(LabWorkBindingModel model)
{
using var context = new ElegevContext();
var labWork = context.LabWorks
.FirstOrDefault(x => x.Id == model.Id);
if (labWork == null)
{
return null;
}
labWork.Update(model);
context.SaveChanges();
return labWork.GetViewModel;
}
public LabWorkViewModel? Delete(LabWorkBindingModel model)
{
using var context = new ElegevContext();
var element = context.LabWorks
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.LabWorks.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,75 @@
// <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(ElegevContext))]
[Migration("20231023124245_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Discipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Disciplines");
});
modelBuilder.Entity("DatabaseImplement.Models.LabWork", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discipline")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FCs")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Questions")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Theme")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("LabWorks");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,53 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Disciplines",
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_Disciplines", x => x.Id);
});
migrationBuilder.CreateTable(
name: "LabWorks",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Theme = table.Column<string>(type: "nvarchar(max)", nullable: false),
FCs = table.Column<string>(type: "nvarchar(max)", nullable: false),
Discipline = table.Column<string>(type: "nvarchar(max)", nullable: false),
Questions = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LabWorks", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Disciplines");
migrationBuilder.DropTable(
name: "LabWorks");
}
}
}

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(ElegevContext))]
partial class ElegevContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DatabaseImplement.Models.Discipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Disciplines");
});
modelBuilder.Entity("DatabaseImplement.Models.LabWork", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Discipline")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FCs")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Questions")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Theme")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("LabWorks");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,52 @@
using Contracts.BindingModel;
using Contracts.ViewModel;
using DataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class Discipline : IDiscipline
{
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
public static Discipline? Create(DisciplineBindingModel model)
{
if (model == null)
{
return null;
}
return new Discipline()
{
Id = model.Id,
Name = model.Name
};
}
public void Update(DisciplineBindingModel? model)
{
if (model == null)
{
return;
}
Id = model.Id;
Name = model.Name;
}
public DisciplineViewModel GetViewModel => new()
{
Id = Id,
Name = Name
};
}
}

View File

@ -0,0 +1,71 @@
using Contracts.BindingModel;
using Contracts.ViewModel;
using DataModels.Models;
using Microsoft.EntityFrameworkCore.Infrastructure;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DatabaseImplement.Models
{
public class LabWork : ILabWork
{
public int Id { get; set; }
[Required]
public string Theme { get; set; } = string.Empty;
[Required]
public string FCs { get; set; }
[Required]
public string Discipline { get; set; }
[Required]
public string Questions { get; set; }
public static LabWork? Create(LabWorkBindingModel model)
{
if (model == null)
{
return null;
}
return new LabWork()
{
Id = model.Id,
Theme = model.Theme,
FCs = model.FCs,
Discipline = model.Discipline,
Questions = model.Questions
};
}
public void Update(LabWorkBindingModel? model)
{
if (model == null)
{
return;
}
Id = model.Id;
Theme = model.Theme;
FCs = model.FCs;
Discipline = model.Discipline;
Questions = model.Questions;
}
public LabWorkViewModel GetViewModel => new()
{
Id = Id,
Theme = Theme,
FCs = FCs,
Discipline = Discipline,
Questions = Questions
};
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\VisualComponentsLib\VisualComponentsLib.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -0,0 +1,192 @@
namespace PluginsConventionLibraryNet60
{
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()
{
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.ControlsStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ActionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ThesaurusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AddElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.UpdElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DelElementToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.DocsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.SimpleDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TableDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ChartDocToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panelControl = new System.Windows.Forms.Panel();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ControlsStripMenuItem,
this.ActionsToolStripMenuItem,
this.DocsToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
this.menuStrip.Size = new System.Drawing.Size(914, 30);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "Меню";
//
// ControlsStripMenuItem
//
this.ControlsStripMenuItem.Name = "ControlsStripMenuItem";
this.ControlsStripMenuItem.Size = new System.Drawing.Size(113, 24);
this.ControlsStripMenuItem.Text = "Компоненты";
//
// ActionsToolStripMenuItem
//
this.ActionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ThesaurusToolStripMenuItem,
this.AddElementToolStripMenuItem,
this.UpdElementToolStripMenuItem,
this.DelElementToolStripMenuItem});
this.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem";
this.ActionsToolStripMenuItem.Size = new System.Drawing.Size(88, 24);
this.ActionsToolStripMenuItem.Text = "Действия";
//
// ThesaurusToolStripMenuItem
//
this.ThesaurusToolStripMenuItem.Name = "ThesaurusToolStripMenuItem";
this.ThesaurusToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I)));
this.ThesaurusToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
this.ThesaurusToolStripMenuItem.Text = "Справочник";
this.ThesaurusToolStripMenuItem.Click += new System.EventHandler(this.ThesaurusToolStripMenuItem_Click);
//
// AddElementToolStripMenuItem
//
this.AddElementToolStripMenuItem.Name = "AddElementToolStripMenuItem";
this.AddElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A)));
this.AddElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
this.AddElementToolStripMenuItem.Text = "Добавить";
this.AddElementToolStripMenuItem.Click += new System.EventHandler(this.AddElementToolStripMenuItem_Click);
//
// UpdElementToolStripMenuItem
//
this.UpdElementToolStripMenuItem.Name = "UpdElementToolStripMenuItem";
this.UpdElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U)));
this.UpdElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
this.UpdElementToolStripMenuItem.Text = "Изменить";
this.UpdElementToolStripMenuItem.Click += new System.EventHandler(this.UpdElementToolStripMenuItem_Click);
//
// DelElementToolStripMenuItem
//
this.DelElementToolStripMenuItem.Name = "DelElementToolStripMenuItem";
this.DelElementToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D)));
this.DelElementToolStripMenuItem.Size = new System.Drawing.Size(223, 26);
this.DelElementToolStripMenuItem.Text = "Удалить";
this.DelElementToolStripMenuItem.Click += new System.EventHandler(this.DelElementToolStripMenuItem_Click);
//
// DocsToolStripMenuItem
//
this.DocsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.SimpleDocToolStripMenuItem,
this.TableDocToolStripMenuItem,
this.ChartDocToolStripMenuItem});
this.DocsToolStripMenuItem.Name = "DocsToolStripMenuItem";
this.DocsToolStripMenuItem.Size = new System.Drawing.Size(101, 24);
this.DocsToolStripMenuItem.Text = "Документы";
//
// SimpleDocToolStripMenuItem
//
this.SimpleDocToolStripMenuItem.Name = "SimpleDocToolStripMenuItem";
this.SimpleDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.SimpleDocToolStripMenuItem.Size = new System.Drawing.Size(291, 26);
this.SimpleDocToolStripMenuItem.Text = "Простой документ";
this.SimpleDocToolStripMenuItem.Click += new System.EventHandler(this.SimpleDocToolStripMenuItem_Click);
//
// TableDocToolStripMenuItem
//
this.TableDocToolStripMenuItem.Name = "TableDocToolStripMenuItem";
this.TableDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
this.TableDocToolStripMenuItem.Size = new System.Drawing.Size(291, 26);
this.TableDocToolStripMenuItem.Text = "Документ с таблицой";
this.TableDocToolStripMenuItem.Click += new System.EventHandler(this.TableDocToolStripMenuItem_Click);
//
// ChartDocToolStripMenuItem
//
this.ChartDocToolStripMenuItem.Name = "ChartDocToolStripMenuItem";
this.ChartDocToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C)));
this.ChartDocToolStripMenuItem.Size = new System.Drawing.Size(291, 26);
this.ChartDocToolStripMenuItem.Text = "Диаграмма";
this.ChartDocToolStripMenuItem.Click += new System.EventHandler(this.ChartDocToolStripMenuItem_Click);
//
// panelControl
//
this.panelControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl.Location = new System.Drawing.Point(0, 30);
this.panelControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panelControl.Name = "panelControl";
this.panelControl.Size = new System.Drawing.Size(914, 570);
this.panelControl.TabIndex = 1;
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(914, 600);
this.Controls.Add(this.panelControl);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Главная форма";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormMain_KeyDown);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.ToolStripMenuItem ControlsStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem DocsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
SimpleDocToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
TableDocToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
ChartDocToolStripMenuItem;
private System.Windows.Forms.Panel panelControl;
private System.Windows.Forms.ToolStripMenuItem
ActionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
ThesaurusToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
AddElementToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
UpdElementToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem
DelElementToolStripMenuItem;
}
}

View File

@ -0,0 +1,286 @@
using PluginsLib;
using System.Reflection;
namespace PluginsConventionLibraryNet60
{
public partial class FormMain : Form
{
private readonly Dictionary<string, IPluginsConvention> _plugins;
private string _selectedPlugin;
public FormMain()
{
InitializeComponent();
_plugins = LoadPlugins();
_selectedPlugin = string.Empty;
}
private Dictionary<string, IPluginsConvention> LoadPlugins()
{
Dictionary<string, IPluginsConvention> plugins = new Dictionary<string, IPluginsConvention>();
List<IPluginsConvention> pluginsList = LoadPl();
foreach (var plugin in pluginsList)
{
plugins[plugin.PluginName] = plugin;
CreateMenuItem(plugin.PluginName);
}
return plugins;
}
private void CreateMenuItem(string pluginName)
{
ToolStripMenuItem menuItem = new(pluginName);
menuItem.Click += (object? sender, EventArgs e) =>
{
UserControl userControl = _plugins[pluginName].GetControl;
if (userControl != null)
{
panelControl.Controls.Clear();
userControl.Dock = DockStyle.Fill;
_plugins[pluginName].ReloadData();
_selectedPlugin = pluginName;
panelControl.Controls.Add(userControl);
}
};
ControlsStripMenuItem.DropDownItems.Add(menuItem);
}
public List<IPluginsConvention> LoadPl()
{
string currentDir = Environment.CurrentDirectory;
string pluginsDir = Directory.GetParent(currentDir).Parent.Parent.Parent.FullName + "\\Plugins";
string[] dllFiles = Directory.GetFiles(
pluginsDir,
"*.dll",
SearchOption.AllDirectories
);
List<IPluginsConvention> plugins = new();
foreach (string dllFile in dllFiles)
{
try
{
// Çàãðóæàåì ñáîðêó ñ çàäàííûì èìåíåì ôàéëà ñáîðêè
Assembly assembly = Assembly.LoadFrom(dllFile);
// Ìàññèâ, ñîäåðæàùèé âñå òèïû, êîòîðûå îïðåäåëåíû â ýòîé ñáîðêå
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
// "Åñëè áû ó ìåíÿ áûëà ïåðåìåííàÿ ýòîãî òèïà, ìîã áû ÿ ïðèñâîèòü åé çíà÷åíèå ýòîãî òèïà?"
// È ÷òî ýòî íå èòåðôåéñ, ÍÅ ÈÍÒÅÐÔÅÉÑ
if (typeof(IPluginsConvention).IsAssignableFrom(type) && !type.IsInterface)
{
// CreateInstance - Ñîçäàåò ýêçåìïëÿð óêàçàííîãî òèïà, èñïîëüçóÿ êîíñòðóêòîð,
// êîòîðûé íàèáîëåå ïîëíî ñîîòâåòñòâóåò óêàçàííûì ïàðàìåòðàì
// è ïðîâåðêà ñîâìåñòèìîñòè ðåçóëüòàòà âûðàæåíèÿ ñ óêàçàííûì òèïîì
// èëè æå: ñîçäà¸ì îáúåêò è ïðåîáðàçóåì åãî ê IPluginsConvention
if (Activator.CreateInstance(type) is IPluginsConvention plugin)
{
plugins.Add(plugin);
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Áåäà ñ .dll â ïàïêå Plugins - {dllFile}: {ex.Message}");
}
}
return plugins;
}
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if (string.IsNullOrEmpty(_selectedPlugin) ||
!_plugins.ContainsKey(_selectedPlugin))
{
return;
}
if (!e.Control)
{
return;
}
switch (e.KeyCode)
{
case Keys.I:
ShowThesaurus();
break;
case Keys.A:
AddNewElement();
break;
case Keys.U:
UpdateElement();
break;
case Keys.D:
DeleteElement();
break;
case Keys.S:
CreateSimpleDoc();
break;
case Keys.T:
CreateTableDoc();
break;
case Keys.C:
CreateChartDoc();
break;
}
}
private void ShowThesaurus()
{
_plugins[_selectedPlugin].GetThesaurus()?.Show();
}
private void AddNewElement()
{
var form = _plugins[_selectedPlugin].GetForm(null);
if (form != null)
{
form.ShowDialog();
_plugins[_selectedPlugin].ReloadData();
}
}
private void UpdateElement()
{
try
{
var element = _plugins[_selectedPlugin].GetElement;
var form = _plugins[_selectedPlugin].GetForm(element);
if (form != null)
{
form.ShowDialog();
_plugins[_selectedPlugin].ReloadData();
}
}
catch
{
MessageBox.Show("Íå âûäåëåíà çàïèñü äëÿ îáíîâëåíèÿ", "Îøèáêà îáíîâëåíèÿ", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
private void DeleteElement()
{
if (MessageBox.Show("Âû òî÷íî õîòèòå óäàëèòü âûáðàííóþ çàïèñü?", "Âíèìàíèå!",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
try
{
var element = _plugins[_selectedPlugin].GetElement;
if (_plugins[_selectedPlugin].DeleteElement(element))
{
_plugins[_selectedPlugin].ReloadData();
}
}
catch
{
MessageBox.Show("Íå âûäåëåíà çàïèñü äëÿ óäàëåíèÿ", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
private void CreateSimpleDoc()
{
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateSimpleDocument(new PluginsConventionSaveDocument()
{
FileName = dialog.FileName
}))
{
MessageBox.Show("Ôàéë óñïåøíî ñîçäàí!", "Îïîâåùåíèå", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Îøèáêà ñîõðàíåíèÿ äîêóìåíòà", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void CreateTableDoc()
{
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
if (dialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateTableDocument(new PluginsConventionSaveDocument()
{
FileName = dialog.FileName
}))
{
MessageBox.Show("Ôàéë óñïåøíî ñîçäàí!", "Îïîâåùåíèå", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Îøèáêà ñîõðàíåíèÿ äîêóìåíòà", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void CreateChartDoc()
{
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
if (_plugins[_selectedPlugin].CreateChartDocument(new PluginsConventionSaveDocument()
{
FileName = dialog.FileName
}))
{
MessageBox.Show("Ôàéë óñïåøíî ñîçäàí!", "Îïîâåùåíèå", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Îøèáêà ñîõðàíåíèÿ äîêóìåíòà", "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ThesaurusToolStripMenuItem_Click(object sender, EventArgs e) => ShowThesaurus();
private void AddElementToolStripMenuItem_Click(object sender, EventArgs e) => AddNewElement();
private void UpdElementToolStripMenuItem_Click(object sender, EventArgs e) => UpdateElement();
private void DelElementToolStripMenuItem_Click(object sender, EventArgs e) => DeleteElement();
private void SimpleDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateSimpleDoc();
private void TableDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateTableDoc();
private void ChartDocToolStripMenuItem_Click(object sender, EventArgs e) => CreateChartDoc();
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\PluginsLib\PluginsLib.csproj" />
</ItemGroup>
</Project>

View File

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

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PluginsLib
{
public interface IPluginsConvention
{
string PluginName { get; }
UserControl GetControl { get; }
PluginsConventionElement GetElement { get; }
Form GetForm(PluginsConventionElement element);
Form GetThesaurus();
bool DeleteElement(PluginsConventionElement element);
void ReloadData();
bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument);
bool CreateTableDocument(PluginsConventionSaveDocument saveDocument);
bool CreateChartDocument(PluginsConventionSaveDocument saveDocument);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginsLib
{
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 PluginsLib
{
public class PluginsConventionSaveDocument
{
public string FileName { get; set; }
}
}

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MarkNoVisualV2" Version="1.1.0" />
<PackageReference Include="MarkVisual" Version="1.4.0" />
<PackageReference Include="NVGeorgiy" Version="1.1.0" />
<PackageReference Include="VGeorgiy" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VisualComponentsLib\VisualComponentsLib.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,64 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsForm", "VisualComponentsForm\VisualComponentsForm.csproj", "{29E20B1C-11E3-4B0D-A614-097ACBB21263}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsLib", "..\VisualComponentsLib\VisualComponentsLib.csproj", "{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataModels", "DataModels\DataModels.csproj", "{D208DBE1-5E90-4611-BAFD-2B021BCE0ADA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{E78467E3-3100-4F40-B454-7C44CB49FAB4}"
ProjectSection(ProjectDependencies) = postProject
{D208DBE1-5E90-4611-BAFD-2B021BCE0ADA} = {D208DBE1-5E90-4611-BAFD-2B021BCE0ADA}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{2985D756-04FC-485F-BF53-95C02C43E1C2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsLib", "PluginsLib\PluginsLib.csproj", "{BB23AF9D-1359-4E2B-9FE4-BA971B3D6F83}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginsConventionLibraryNet60", "PluginsConventionLibraryNet60\PluginsConventionLibraryNet60.csproj", "{F6851562-4D46-4348-9FFF-8618390C91BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{29E20B1C-11E3-4B0D-A614-097ACBB21263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29E20B1C-11E3-4B0D-A614-097ACBB21263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29E20B1C-11E3-4B0D-A614-097ACBB21263}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29E20B1C-11E3-4B0D-A614-097ACBB21263}.Release|Any CPU.Build.0 = Release|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Release|Any CPU.Build.0 = Release|Any CPU
{D208DBE1-5E90-4611-BAFD-2B021BCE0ADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D208DBE1-5E90-4611-BAFD-2B021BCE0ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D208DBE1-5E90-4611-BAFD-2B021BCE0ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D208DBE1-5E90-4611-BAFD-2B021BCE0ADA}.Release|Any CPU.Build.0 = Release|Any CPU
{E78467E3-3100-4F40-B454-7C44CB49FAB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E78467E3-3100-4F40-B454-7C44CB49FAB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E78467E3-3100-4F40-B454-7C44CB49FAB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E78467E3-3100-4F40-B454-7C44CB49FAB4}.Release|Any CPU.Build.0 = Release|Any CPU
{2985D756-04FC-485F-BF53-95C02C43E1C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2985D756-04FC-485F-BF53-95C02C43E1C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2985D756-04FC-485F-BF53-95C02C43E1C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2985D756-04FC-485F-BF53-95C02C43E1C2}.Release|Any CPU.Build.0 = Release|Any CPU
{BB23AF9D-1359-4E2B-9FE4-BA971B3D6F83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB23AF9D-1359-4E2B-9FE4-BA971B3D6F83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB23AF9D-1359-4E2B-9FE4-BA971B3D6F83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB23AF9D-1359-4E2B-9FE4-BA971B3D6F83}.Release|Any CPU.Build.0 = Release|Any CPU
{F6851562-4D46-4348-9FFF-8618390C91BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6851562-4D46-4348-9FFF-8618390C91BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6851562-4D46-4348-9FFF-8618390C91BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6851562-4D46-4348-9FFF-8618390C91BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ADD13092-BD8B-4F13-97C5-0C56B2AB3309}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,63 @@
namespace VisualComponentsForm
{
partial class FormCreateDiscipline
{
/// <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()
{
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 12);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(240, 225);
dataGridView.TabIndex = 0;
dataGridView.CellValueChanged += DataGridView_CellValueChanged;
dataGridView.KeyDown += DataGridView_KeyDown;
//
// FormCreateDiscipline
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(264, 249);
Controls.Add(dataGridView);
Name = "FormCreateDiscipline";
Text = "Создание дисциплин";
Load += FormCreateDiscipline_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,143 @@
using Contracts.BindingModel;
using Contracts.SearchModel;
using Contracts.StorageContracts;
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 VisualComponentsForm
{
public partial class FormCreateDiscipline : Form
{
public readonly IDisciplineStorage _disciplineStorage;
public FormCreateDiscipline(IDisciplineStorage disciplineStorage)
{
InitializeComponent();
_disciplineStorage = disciplineStorage;
}
private void FormCreateDiscipline_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _disciplineStorage.GetFullList();
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
dataGridView.KeyDown += DataGridView_KeyDown;
dataGridView.CellValueChanged += DataGridView_CellValueChanged;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
//обработчик нажатия клавиш
private void DataGridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Insert)
{
// Добавление новой строки при нажатии на клавишу Insert
var list = _disciplineStorage.GetFullList();
list.Add(new());
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
e.Handled = true;
}
else if (e.KeyCode == Keys.Delete)
{
// Удаление выбранных строк при нажатии на клавишу Delete
if (dataGridView.SelectedRows.Count > 0)
{
DialogResult result = MessageBox.Show("Вы уверены, что хотите удалить выбранные записи?", "Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
foreach (DataGridViewRow row in dataGridView.SelectedRows)
{
if (!row.IsNewRow)
{
int id = Convert.ToInt32(row.Cells["Id"].Value);
var view = _disciplineStorage.GetElement(new DisciplineSearchModel
{
Id = id
});
_disciplineStorage.Delete(new(view!));
}
}
LoadData();
}
}
e.Handled = true;
}
}
private void DataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
// Сохранение изменений при завершении редактирования ячейки
if (e.RowIndex >= 0)
{
DataGridViewRow row = dataGridView.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 DisciplineBindingModel
{
Id = id,
Name = name
};
if (model.Id == 0)
{
_disciplineStorage.Insert(model);
}
else
{
_disciplineStorage.Update(model);
}
LoadData();
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,162 @@
namespace VisualComponentsForm
{
partial class FormCreateLabWork
{
/// <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()
{
dropDownList = new COP_lab.DropDownList();
inputInRange = new VisualComponents.InputInRange();
textBoxStudents = new TextBox();
label1 = new Label();
label2 = new Label();
label3 = new Label();
textBoxQuestions = new TextBox();
label4 = new Label();
buttonCreate = new Button();
SuspendLayout();
//
// dropDownList
//
dropDownList.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dropDownList.Location = new Point(12, 88);
dropDownList.Name = "dropDownList";
dropDownList.Selected = "";
dropDownList.Size = new Size(191, 72);
dropDownList.TabIndex = 0;
//
// inputInRange
//
inputInRange.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
inputInRange.Location = new Point(12, 34);
inputInRange.MaxValue = null;
inputInRange.MinValue = null;
inputInRange.Name = "inputInRange";
inputInRange.Size = new Size(191, 24);
inputInRange.TabIndex = 1;
inputInRange.Value = null;
//
// textBoxStudents
//
textBoxStudents.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
textBoxStudents.Location = new Point(12, 192);
textBoxStudents.Name = "textBoxStudents";
textBoxStudents.Size = new Size(191, 23);
textBoxStudents.TabIndex = 2;
//
// label1
//
label1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
label1.AutoSize = true;
label1.Location = new Point(12, 163);
label1.Name = "label1";
label1.Size = new Size(113, 15);
label1.TabIndex = 3;
label1.Text = "Сдавшие студенты:";
//
// label2
//
label2.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
label2.AutoSize = true;
label2.Location = new Point(12, 70);
label2.Name = "label2";
label2.Size = new Size(79, 15);
label2.TabIndex = 4;
label2.Text = "Дисциплина:";
//
// label3
//
label3.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
label3.AutoSize = true;
label3.Location = new Point(12, 9);
label3.Name = "label3";
label3.Size = new Size(120, 15);
label3.TabIndex = 5;
label3.Text = "Тема лабораторной:";
//
// textBoxQuestions
//
textBoxQuestions.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
textBoxQuestions.Location = new Point(12, 270);
textBoxQuestions.Name = "textBoxQuestions";
textBoxQuestions.Size = new Size(191, 23);
textBoxQuestions.TabIndex = 6;
//
// label4
//
label4.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
label4.AutoSize = true;
label4.Location = new Point(12, 238);
label4.Name = "label4";
label4.Size = new Size(152, 15);
label4.TabIndex = 7;
label4.Text = "Вопросы к лабораторной:";
//
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonCreate.Location = new Point(224, 34);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(75, 23);
buttonCreate.TabIndex = 8;
buttonCreate.Text = "Создать";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// FormCreateLabWork
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(314, 317);
Controls.Add(buttonCreate);
Controls.Add(label4);
Controls.Add(textBoxQuestions);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(textBoxStudents);
Controls.Add(inputInRange);
Controls.Add(dropDownList);
Name = "FormCreateLabWork";
Text = "Создание лабораторной работы";
Load += FormCreateLabWork_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private COP_lab.DropDownList dropDownList;
private VisualComponents.InputInRange inputInRange;
private TextBox textBoxStudents;
private Label label1;
private Label label2;
private Label label3;
private TextBox textBoxQuestions;
private Label label4;
private Button buttonCreate;
}
}

View File

@ -0,0 +1,108 @@
using Contracts.BindingModel;
using Contracts.SearchModel;
using Contracts.StorageContracts;
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Wordprocessing;
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 VisualComponentsLib;
namespace VisualComponentsForm
{
public partial class FormCreateLabWork : Form
{
public readonly ILabWorkStorage _labWorkStorage;
public readonly IDisciplineStorage _disciplineStorage;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateLabWork(ILabWorkStorage labWorkStorage, IDisciplineStorage disciplineStorage)
{
InitializeComponent();
_labWorkStorage = labWorkStorage;
_disciplineStorage = disciplineStorage;
//выставляем ограничения на длинну названия дисциплины
inputInRange.MinValue = 1;
inputInRange.MaxValue = 50;
}
private void FormCreateLabWork_Load(object sender, EventArgs e)
{
LoadData();
}
private void ButtonCreate_Click(object sender, EventArgs e)
{
var model = new LabWorkBindingModel
{
Id = _id ?? 0,
Theme = inputInRange.Value,
FCs = textBoxStudents.Text,
Discipline = dropDownList.Selected,
Questions = textBoxQuestions.Text,
};
if (!_id.HasValue)
{
_labWorkStorage.Insert(model);
}
else
{
_labWorkStorage.Update(model);
}
Close();
}
//загрузка данных для комбобокса
private void LoadData()
{
try
{
var list = _disciplineStorage.GetFullList();
if (list != null)
{
foreach (var item in list)
{
dropDownList.AddingToList(item.Name);
}
}
if (_id.HasValue)
{
buttonCreate.Text = "Сохранить";
var model = _labWorkStorage.GetElement(new LabWorkSearchModel
{
Id = _id.Value,
});
if (model != null)
{
inputInRange.SetStartText(model.Theme);
dropDownList.Selected = model.Discipline;
textBoxStudents.Text = model.FCs;
textBoxQuestions.Text = model.Questions;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,94 @@
namespace VisualComponentsForm
{
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();
lineChartExcel = new NonVisualComponents.LineChartExcel(components);
pdfTable = new NonVisualComponents.PdfTable(components);
componentWord = new VisualComponentsLib.Components.ComponentWord(components);
buttonCreateDiscipline = new Button();
contextMenuStrip = new ContextMenuStrip(components);
myListBox = new VisualComponentsLib.CustomListBox.MyListBox();
SuspendLayout();
//
// pdfTable
//
pdfTable.Error = null;
//
// buttonCreateDiscipline
//
buttonCreateDiscipline.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonCreateDiscipline.Location = new Point(369, 12);
buttonCreateDiscipline.Name = "buttonCreateDiscipline";
buttonCreateDiscipline.Size = new Size(158, 25);
buttonCreateDiscipline.TabIndex = 8;
buttonCreateDiscipline.Text = "Создать дисциплину";
buttonCreateDiscipline.UseVisualStyleBackColor = true;
buttonCreateDiscipline.Click += ButtonCreateDiscipline_Click;
//
// contextMenuStrip
//
contextMenuStrip.Name = "contextMenuStrip";
contextMenuStrip.Size = new Size(61, 4);
contextMenuStrip.Text = "Меню";
//
// myListBox
//
myListBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
myListBox.Location = new Point(12, 12);
myListBox.MinimumSize = new Size(84, 53);
myListBox.Name = "myListBox";
myListBox.SelectedString = null;
myListBox.Size = new Size(351, 300);
myListBox.TabIndex = 3;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(539, 316);
ContextMenuStrip = contextMenuStrip;
Controls.Add(myListBox);
Controls.Add(buttonCreateDiscipline);
KeyPreview = true;
Name = "FormMain";
Text = "Главная";
KeyDown += FormMain_KeyDown;
ResumeLayout(false);
}
#endregion
private NonVisualComponents.LineChartExcel lineChartExcel;
private NonVisualComponents.PdfTable pdfTable;
private VisualComponentsLib.Components.ComponentWord componentWord;
private Button buttonCreateDiscipline;
private ContextMenuStrip contextMenuStrip;
private VisualComponentsLib.CustomListBox.MyListBox myListBox;
}
}

View File

@ -0,0 +1,420 @@
using Contracts.BindingModel;
using Contracts.SearchModel;
using Contracts.StorageContracts;
using Contracts.ViewModel;
using DatabaseImplement.Implements;
using DocumentFormat.OpenXml.Bibliography;
using NPOI.POIFS.Properties;
using System;
using System.Windows.Forms;
using VisualComponentsForm.Models;
using VisualComponentsLib.Components.SupportClasses;
using VisualComponentsLib.SupportClass;
using System.Runtime.InteropServices;
using NonVisualComponents;
using NonVisualComponents.Classes;
using IronPdf;
using System.Text;
using NonVisualComponents.objects;
using NonVisualComponents.Enums;
namespace VisualComponentsForm
{
public partial class FormMain : Form
{
private readonly ILabWorkStorage _labWorkStorage;
private readonly IDisciplineStorage _disciplineStorage;
public FormMain(ILabWorkStorage labWorkStorage, IDisciplineStorage disciplineStorage)
{
InitializeComponent();
ToolStripMenuItem createLabWork = new("Создать лаб. раб.");
ToolStripMenuItem updateLabWork = new("Обновить лаб. раб.");
ToolStripMenuItem deleteLabWork = new("Удалить лаб. раб.");
ToolStripMenuItem createSimpleDocItem = new("Создать Word");
ToolStripMenuItem createTableDocEntityItem = new("Создать Excel");
ToolStripMenuItem createChartDocEntityItem = new("Создать Pdf");
contextMenuStrip.Items.AddRange(new[] { createLabWork, updateLabWork, deleteLabWork,
createSimpleDocItem, createTableDocEntityItem, createChartDocEntityItem});
myListBox.ContextMenuStrip = contextMenuStrip;
createLabWork.Click += CreateLabWork_Click;
updateLabWork.Click += UpdateLabWork_Click;
deleteLabWork.Click += DeleteLabWork_Click;
createSimpleDocItem.Click += CreateSimpleDocItem_Click;
createTableDocEntityItem.Click += CreateTableDocEntityItem_Click;
createChartDocEntityItem.Click += CreateChartDocEntityItem_Click;
_labWorkStorage = labWorkStorage;
_disciplineStorage = disciplineStorage;
LoadData();
}
public void CreateLabWork_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateLabWork));
if (service is FormCreateLabWork form)
{
form.ShowDialog();
LoadData();
}
}
public void UpdateLabWork_Click(object sender, EventArgs e)
{
try
{
int Id = GetSelectedId();
var service = Program.ServiceProvider?.GetService(typeof(FormCreateLabWork));
if (service is FormCreateLabWork form)
{
form.Id = Id;
form.ShowDialog();
LoadData();
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка операции", "Необходимо выбрать элемент списка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void DeleteLabWork_Click(object sender, EventArgs e)
{
try
{
int Id = GetSelectedId();
DialogResult result = MessageBox.Show("Вы уверены, что хотите удалить выбранную запись?", "Подтверждение удаления", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
_labWorkStorage.Delete(new LabWorkBindingModel
{
Id = Id
});
LoadData();
}
}
catch (Exception ex)
{
MessageBox.Show("Ошибка операции", "Необходимо выбрать элемент списка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
//Word файл
public void CreateSimpleDocItem_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
//сразу группируем списки по дисциплинам
var list = _labWorkStorage.GetFullList().OrderBy(l => l.Discipline).ToList();
var disciplines = _disciplineStorage.GetFullList().OrderBy(d => d.Name).ToList();
List<string[,]> totalList = new();
List<LabWorkViewModel> supportList = new();
foreach (var discipline in disciplines)
{
foreach (var elem in list)
{
if (elem.Discipline == discipline.Name)
{
supportList.Add(elem);
}
}
supportList = supportList.OrderBy(sl => sl.Theme).ToList();
totalList.Add(new string[,] { { "Дисциплина", discipline.Name } });
foreach (var elem in supportList)
{
var listFCs = elem.FCs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
string[,] newArray = { { elem.Theme, listFCs[listFCs.Count - 1] } };
totalList.Add(newArray);
}
supportList.Clear();
}
SimpleTable table = new(dialog.FileName, "Первое задание", totalList);
componentWord.CreateDoc(table);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
public void CreateTableDocEntityItem_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "pdf|*.pdf"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
//сразу группируем списки по дисциплинам
var list = _labWorkStorage.GetFullList().OrderBy(l => l.Discipline).ToList();
var disciplines = _disciplineStorage.GetFullList().OrderBy(d => d.Name).ToList();
List<string[,]> totalList = new();
List<LabWorkViewModel> supportList = new();
string[] headers = new[]
{
"Id", "Theme", "FCs",
"Discipline", "Questions"
};
Dictionary<int, (String, int)> merge = new() { [3] = ("Описание", 2) };
PdfTable pdfTable = new();
CreatePDF(new TableData<LabWorkViewModel>
{
FilePath = dialog.FileName,
Title = "Второе задание",
Merge = merge,
Headers = headers,
Data = list.ToArray(),
RowHeight = new double[] { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 }
});
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
public void CreateChartDocEntityItem_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "xlsx|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
//сразу группируем списки по дисциплинам
var list = _labWorkStorage.GetFullList();
List<string[,]> totalList = new();
List<int> supportList = new(4) { 0, 0, 0, 0 };
LineChartExcel chart = new();
foreach(var elem in list)
{
if(elem.Questions.Length >= 50 && elem.Questions.Length < 100)
{
supportList[0]++;
}
if (elem.Questions.Length >= 100 && elem.Questions.Length < 150)
{
supportList[1]++;
}
if (elem.Questions.Length >= 150 && elem.Questions.Length < 200)
{
supportList[2]++;
}
if (elem.Questions.Length >= 200 && elem.Questions.Length < 250)
{
supportList[3]++;
}
}
var data = new List<DataItem>()
{
new DataItem() { Name = "50-100", Value = supportList[0] },
new DataItem() { Name = "100-150", Value = supportList[1] },
new DataItem() { Name = "150-200", Value = supportList[2] },
new DataItem() { Name = "200-250", Value = supportList[3] }
};
ExcelChartInfo info = new(dialog.FileName, "Третье задание", "Диаграмма", EnumAreaLegend.Left, data);
try
{
chart.GenerateChartExcel(info);
MessageBox.Show("Сохарнено успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control)
{
if (e.KeyCode == Keys.A)
{
CreateLabWork_Click(sender, e);
}
if (e.KeyCode == Keys.U)
{
UpdateLabWork_Click(sender, e);
}
if (e.KeyCode == Keys.D)
{
DeleteLabWork_Click(sender, e);
}
if (e.KeyCode == Keys.S)
{
//Word
CreateSimpleDocItem_Click(sender, e);
}
if (e.KeyCode == Keys.T)
{
//Pdf
CreateTableDocEntityItem_Click(sender, e);
}
if (e.KeyCode == Keys.C)
{
//Excel
CreateChartDocEntityItem_Click(sender, e);
}
}
}
private void ButtonCreateDiscipline_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateDiscipline));
if (service is FormCreateDiscipline form)
{
form.ShowDialog();
LoadData();
}
}
public void CreatePDF<T>(TableData<T> data)
{
ChromePdfRenderer renderer = new ChromePdfRenderer();
StringBuilder htmlContainer = new StringBuilder();
htmlContainer.AppendLine("<link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\">");
htmlContainer.AppendLine($"<h1>{data.Title}</h1>");
htmlContainer.AppendLine("<table class=\"table\">");
int counter = 0;
for (int i = 0; i < data.Headers.Length; i++)
{
htmlContainer.Append($"<tr style=\"height: {data.RowHeight[i]}px\">\r\n");
if (data.Merge.Keys.Contains(i))
{
htmlContainer.Append($"<th rowspan=\"{data.Merge[i].Item2}\">{data.Merge[i].Item1}</th>\r\n");
htmlContainer.Append($"<th>{data.Headers[i]}</th>\r\n");
counter = data.Merge[i].Item2 - 1;
}
else if (counter != 0)
{
htmlContainer.Append($"<th>{data.Headers[i]}</th>\r\n");
counter--;
}
else
{
htmlContainer.Append($"<th colspan=\"2\">{data.Headers[i]}</th>\r\n");
}
foreach (var elem in data.Data)
{
Type type = typeof(T);
string value = type
.GetProperty(data.Headers[i])!
.GetValue(elem, null)!.ToString()!;
htmlContainer.Append($"<td>{value}</th>\r\n");
}
htmlContainer.Append("</tr>\r\n");
}
htmlContainer.AppendLine("</table>");
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContainer.ToString());
Console.WriteLine(htmlContainer.ToString());
pdf.SaveAs(data.FilePath);
}
//загрузка данных из бд
public void LoadData()
{
var labWorks = _labWorkStorage.GetFullList();
myListBox.ClearAll();
foreach (var labWork in labWorks)
{
myListBox.AddItem(labWork.Discipline + " | " + labWork.Id.ToString() + " | "
+ labWork.Theme + " | " + labWork.Questions);
}
}
public int GetSelectedId()
{
char dilimiterSimbol = '|';
var _id = myListBox.SelectedString.SkipWhile(z => z != dilimiterSimbol).Skip(1).ToList()[1];
return int.Parse(_id.ToString());
}
}
}

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd: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="lineChartExcel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="pdfTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>146, 17</value>
</metadata>
<metadata name="componentWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>245, 17</value>
</metadata>
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>390, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,134 @@
namespace VisualComponentsForm
{
partial class FormWord
{
/// <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();
componentWord = new VisualComponentsLib.Components.ComponentWord(components);
buttonFirstTask = new Button();
groupBox1 = new GroupBox();
groupBox2 = new GroupBox();
buttonThirdTask = new Button();
componentWordHistogram = new VisualComponentsLib.Components.ComponentWordHistogram(components);
componentBigTable = new VisualComponentsLib.Components.ComponentBigTable(components);
groupBox3 = new GroupBox();
buttonStartSecond = new Button();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
groupBox3.SuspendLayout();
SuspendLayout();
//
// buttonFirstTask
//
buttonFirstTask.Location = new Point(22, 32);
buttonFirstTask.Name = "buttonFirstTask";
buttonFirstTask.Size = new Size(75, 23);
buttonFirstTask.TabIndex = 0;
buttonFirstTask.Text = "Создать";
buttonFirstTask.UseVisualStyleBackColor = true;
buttonFirstTask.Click += ButtonFirstTask_Click;
//
// groupBox1
//
groupBox1.Controls.Add(buttonFirstTask);
groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(120, 79);
groupBox1.TabIndex = 1;
groupBox1.TabStop = false;
groupBox1.Text = "Простая таблица";
//
// groupBox2
//
groupBox2.Controls.Add(buttonThirdTask);
groupBox2.Location = new Point(270, 12);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(129, 79);
groupBox2.TabIndex = 2;
groupBox2.TabStop = false;
groupBox2.Text = "Третье задание";
//
// buttonThirdTask
//
buttonThirdTask.Location = new Point(27, 32);
buttonThirdTask.Name = "buttonThirdTask";
buttonThirdTask.Size = new Size(75, 23);
buttonThirdTask.TabIndex = 0;
buttonThirdTask.Text = "Создать";
buttonThirdTask.UseVisualStyleBackColor = true;
buttonThirdTask.Click += ButtonThirdTask_Click;
//
// groupBox3
//
groupBox3.Controls.Add(buttonStartSecond);
groupBox3.Location = new Point(138, 12);
groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(126, 79);
groupBox3.TabIndex = 3;
groupBox3.TabStop = false;
groupBox3.Text = "Второе задание";
//
// buttonStartSecond
//
buttonStartSecond.Location = new Point(24, 32);
buttonStartSecond.Name = "buttonStartSecond";
buttonStartSecond.Size = new Size(75, 23);
buttonStartSecond.TabIndex = 0;
buttonStartSecond.Text = "Создать";
buttonStartSecond.UseVisualStyleBackColor = true;
buttonStartSecond.Click += ButtonStartSecond_Click;
//
// FormWord
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(411, 103);
Controls.Add(groupBox3);
Controls.Add(groupBox2);
Controls.Add(groupBox1);
Name = "FormWord";
Text = "Невизуальные компоненты";
groupBox1.ResumeLayout(false);
groupBox2.ResumeLayout(false);
groupBox3.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private VisualComponentsLib.Components.ComponentWord componentWord;
private Button buttonFirstTask;
private GroupBox groupBox1;
private GroupBox groupBox2;
private Button buttonThirdTask;
private VisualComponentsLib.Components.ComponentWordHistogram componentWordHistogram;
private VisualComponentsLib.Components.ComponentBigTable componentBigTable;
private GroupBox groupBox3;
private Button buttonStartSecond;
}
}

View File

@ -0,0 +1,146 @@
using DocumentFormat.OpenXml.Spreadsheet;
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 VisualComponentsLib.Components.SupportClasses;
using VisualComponentsLib.Components.SupportClasses.Enums;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace VisualComponentsForm
{
public partial class FormWord : Form
{
SimpleTable table;
SimpleHistogram histogram;
SetDataTable<Car> setDataTable;
string[,] first = {
{ "Первый", "Второй" }
};
string[,] second = {
{ "Третий", "Четвёртый" }
};
string[,] third = {
{ "Пятый", "Шестой" }
};
List<Car> listCars;
Car seventhCar = new("Audi", "TT", 3500000, 2005);
Car firstCar = new ("Lada", "XRay", 1566000, 2016);
Car secondCar = new("Opel", "Astra", 1320000, 2017);
Car thirdCar = new("Lada", "Granta", 430000, 2009);
Car fourthCar = new("Lada", "Vesta", 1220000, 2022);
Car fifthCar = new("Opel", "Vectra", 2100000, 2018);
Car sixthCar = new("Mercedes", "E-class", 3200500, 2019);
Dictionary<int, ColumnName> colData;
public FormWord()
{
InitializeComponent();
listCars = new()
{
seventhCar, firstCar, secondCar, thirdCar, fourthCar, fifthCar, sixthCar
};
colData = new Dictionary<int, ColumnName>()
{
{ 0, new ColumnName("Марка автомобиля", "Brand") },
{ 1, new ColumnName("Модель", "Model") },
{ 2, new ColumnName("Год выпуска", "YearProduction") },
{ 3, new ColumnName("Цена", "Price") },
};
}
private void ButtonFirstTask_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
table = new(dialog.FileName, "Первое задание", new List<string[,]> { first, second, third });
componentWord.CreateDoc(table);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonStartSecond_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
setDataTable = new(dialog.FileName, "Второе задание", new List<double> { 48, 24 },
new List<double> { 2000, 2000, 1500, 1500 }, listCars.GroupBy(x => x.Brand).SelectMany(r => r).ToList(), colData);
componentBigTable.CreateDoc(setDataTable);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonThirdTask_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
histogram = new(dialog.FileName, "Третье задание", "Гистограмма", EnumAreaLegend.Right, new List<DataHistogram> {
new DataHistogram("Доход", "Январь", 300), new DataHistogram("Доход", "Апрель", 600),
new DataHistogram("Доход", "Июль", 400), new DataHistogram("Доход", "Октябрь", 200)
});
componentWordHistogram.AddHistogram(histogram);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd: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="componentWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="componentWordHistogram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>162, 17</value>
</metadata>
<metadata name="componentBigTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>363, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsForm.Models
{
public class People
{
public int? Id { get; set; }
public string? Name { get; set; }
public string? Surname { get; set; }
public int? Age { get; set; }
public People() { }
public People(int Id, string Name, string Surname, int Age)
{
this.Id = Id;
this.Name = Name;
this.Surname = Surname;
this.Age = Age;
}
}
}

View File

@ -0,0 +1,334 @@
using Contracts.BindingModel;
using Contracts.StorageContracts;
using Contracts.ViewModel;
using DatabaseImplement.Implements;
using DataModels.Models;
using DocumentFormat.OpenXml.EMMA;
using IronPdf;
using NonVisualComponents;
using NonVisualComponents.Classes;
using NonVisualComponents.Enums;
using NonVisualComponents.objects;
using PluginsLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisualComponentsLib.Components;
using VisualComponentsLib.Components.SupportClasses;
using VisualComponentsLib.CustomListBox;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
namespace VisualComponentsForm
{
public class PluginsConvention : IPluginsConvention
{
private readonly LabWorkStorage _labWorkStorage;
private readonly IDisciplineStorage _discipline;
private readonly MyListBox listBox;
private ComponentWord wordTable;
private PdfTable pdfTable;
private ExcelChartInfo excelTable;
public string PluginName { get; set; } = "Список объектов";
public PluginsConvention()
{
_labWorkStorage = new LabWorkStorage();
_discipline = new DisciplineStorage();
wordTable = new ComponentWord();
pdfTable = new PdfTable();
//excelTable = new ExcelChartInfo();
listBox = new MyListBox();
}
public UserControl GetControl
{
get { return listBox; }
}
public PluginsConventionElement GetElement
{
get
{
int Id = GetSelectedId();
byte[] bytes = new byte[16];
BitConverter.GetBytes(Id).CopyTo(bytes, 0);
Guid curId = new Guid(bytes);
return new PluginsConventionElement() { Id = curId };
}
}
//запуск формы с лабораторными из предыдущей лабы
public Form GetForm(PluginsConventionElement element)
{
if (element == null)
{
return new FormCreateLabWork(_labWorkStorage, _discipline);
}
else
{
FormCreateLabWork form = new FormCreateLabWork(_labWorkStorage, _discipline);
form.Id = BitConverter.ToInt32(element.Id.ToByteArray(), 0);
return form;
}
}
//получаем список дисциплин (мои перечисления по заданию)
public Form GetThesaurus()
{
return new FormCreateDiscipline(_discipline);
}
//создание word табилцы
public bool CreateSimpleDocument(PluginsConventionSaveDocument saveDocument)
{
try
{
//сразу группируем списки по дисциплинам
var list = _labWorkStorage.GetFullList().OrderBy(l => l.Discipline).ToList();
var disciplines = _discipline.GetFullList().OrderBy(d => d.Name).ToList();
List<string[,]> totalList = new();
List<LabWorkViewModel> supportList = new();
foreach (var discipline in disciplines)
{
foreach (var elem in list)
{
if (elem.Discipline == discipline.Name)
{
supportList.Add(elem);
}
}
supportList = supportList.OrderBy(sl => sl.Theme).ToList();
totalList.Add(new string[,] { { "Дисциплина", discipline.Name } });
foreach (var elem in supportList)
{
var listFCs = elem.FCs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
string[,] newArray = { { elem.Theme, listFCs[listFCs.Count - 1] } };
totalList.Add(newArray);
}
supportList.Clear();
}
SimpleTable table = new(saveDocument.FileName, "Первое задание", totalList);
wordTable.CreateDoc(table);
return true;
}
catch (Exception ex)
{
return false;
}
}
//создание pdf таблицы
public bool CreateTableDocument(PluginsConventionSaveDocument saveDocument)
{
try
{
//сразу группируем списки по дисциплинам
var list = _labWorkStorage.GetFullList().OrderBy(l => l.Discipline).ToList();
var disciplines = _discipline.GetFullList().OrderBy(d => d.Name).ToList();
List<string[,]> totalList = new();
List<LabWorkViewModel> supportList = new();
string[] headers = new[]
{
"Id", "Theme", "FCs",
"Discipline", "Questions"
};
Dictionary<int, (String, int)> merge = new() { [3] = ("Описание", 2) };
PdfTable pdfTable = new();
CreatePDF(new TableData<LabWorkViewModel>
{
FilePath = saveDocument.FileName,
Title = "Второе задание",
Merge = merge,
Headers = headers,
Data = list.ToArray(),
RowHeight = new double[] { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 }
});
return true;
}
catch (Exception ex)
{
return false;
}
}
//создание диаграммы
public bool CreateChartDocument(PluginsConventionSaveDocument saveDocument)
{
try
{
//сразу группируем списки по дисциплинам
var list = _labWorkStorage.GetFullList();
List<string[,]> totalList = new();
List<int> supportList = new(4) { 0, 0, 0, 0 };
LineChartExcel chart = new();
foreach (var elem in list)
{
if (elem.Questions.Length >= 50 && elem.Questions.Length < 100)
{
supportList[0]++;
}
if (elem.Questions.Length >= 100 && elem.Questions.Length < 150)
{
supportList[1]++;
}
if (elem.Questions.Length >= 150 && elem.Questions.Length < 200)
{
supportList[2]++;
}
if (elem.Questions.Length >= 200 && elem.Questions.Length < 250)
{
supportList[3]++;
}
}
var data = new List<DataItem>()
{
new DataItem() { Name = "50-100", Value = supportList[0] },
new DataItem() { Name = "100-150", Value = supportList[1] },
new DataItem() { Name = "150-200", Value = supportList[2] },
new DataItem() { Name = "200-250", Value = supportList[3] }
};
excelTable = new(
saveDocument.FileName,
"Третье задание",
"Диаграмма",
EnumAreaLegend.Left,
data
);
chart.GenerateChartExcel(excelTable);
return true;
}
catch (Exception ex)
{
return false;
}
}
public bool DeleteElement(PluginsConventionElement element)
{
_labWorkStorage.Delete(new LabWorkBindingModel
{
Id = element.Id.GetHashCode()
});
return true;
}
public void ReloadData()
{
var labWorks = _labWorkStorage.GetFullList();
listBox.ClearAll();
foreach (var labWork in labWorks)
{
listBox.AddItem(labWork.Discipline + " | " + labWork.Id.ToString() + " | "
+ labWork.Theme + " | " + labWork.Questions);
}
}
//иначе для pdf-ки никак :(((
public void CreatePDF<T>(TableData<T> data)
{
ChromePdfRenderer renderer = new ChromePdfRenderer();
StringBuilder htmlContainer = new StringBuilder();
htmlContainer.AppendLine("<link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\">");
htmlContainer.AppendLine($"<h1>{data.Title}</h1>");
htmlContainer.AppendLine("<table class=\"table\">");
int counter = 0;
for (int i = 0; i < data.Headers.Length; i++)
{
htmlContainer.Append($"<tr style=\"height: {data.RowHeight[i]}px\">\r\n");
if (data.Merge.Keys.Contains(i))
{
htmlContainer.Append($"<th rowspan=\"{data.Merge[i].Item2}\">{data.Merge[i].Item1}</th>\r\n");
htmlContainer.Append($"<th>{data.Headers[i]}</th>\r\n");
counter = data.Merge[i].Item2 - 1;
}
else if (counter != 0)
{
htmlContainer.Append($"<th>{data.Headers[i]}</th>\r\n");
counter--;
}
else
{
htmlContainer.Append($"<th colspan=\"2\">{data.Headers[i]}</th>\r\n");
}
foreach (var elem in data.Data)
{
Type type = typeof(T);
string value = type
.GetProperty(data.Headers[i])!
.GetValue(elem, null)!.ToString()!;
htmlContainer.Append($"<td>{value}</th>\r\n");
}
htmlContainer.Append("</tr>\r\n");
}
htmlContainer.AppendLine("</table>");
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContainer.ToString());
Console.WriteLine(htmlContainer.ToString());
pdf.SaveAs(data.FilePath);
}
//получение Id объекта в выделенной строке
public int GetSelectedId()
{
char dilimiterSimbol = '|';
var _id = listBox.SelectedString.SkipWhile(z => z != dilimiterSimbol).Skip(1).ToList()[1];
return int.Parse(_id.ToString());
}
}
}

View File

@ -0,0 +1,39 @@
using Contracts.StorageContracts;
using DatabaseImplement.Implements;
using Microsoft.Extensions.DependencyInjection;
namespace VisualComponentsForm
{
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<ILabWorkStorage, LabWorkStorage>();
services.AddTransient<IDisciplineStorage, DisciplineStorage>();
services.AddTransient<FormMain>();
services.AddTransient<FormCreateDiscipline>();
services.AddTransient<FormCreateLabWork>();
}
}
}

View File

@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspose.Words" Version="23.10.0" />
<PackageReference Include="MarkNoVisualV2" Version="1.1.0" />
<PackageReference Include="MarkVisual" Version="1.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NVGeorgiy" Version="1.1.0" />
<PackageReference Include="VGeorgiy" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VisualComponentsLib\VisualComponentsLib.csproj" />
<ProjectReference Include="..\Contracts\Contracts.csproj" />
<ProjectReference Include="..\DatabaseImplement\DatabaseImplement.csproj" />
<ProjectReference Include="..\DataModels\DataModels.csproj" />
<ProjectReference Include="..\PluginsLib\PluginsLib.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)Plugins\*.dll&quot;" />
</Target>
</Project>

View File

@ -1,6 +1,6 @@
namespace VisualComponents namespace WinFormPluginsApp
{ {
partial class Form1 partial class FormMain
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -28,10 +28,10 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450); ClientSize = new Size(800, 450);
this.Text = "Form1"; Text = "Form1";
} }
#endregion #endregion

View File

@ -0,0 +1,10 @@
namespace WinFormPluginsApp
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,4 +1,4 @@
namespace VisualComponents namespace WinFormPluginsApp
{ {
internal static class Program internal static class Program
{ {
@ -11,7 +11,7 @@ namespace VisualComponents
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1()); Application.Run(new FormMain());
} }
} }
} }

View File

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

View File

@ -0,0 +1,36 @@
namespace VisualComponentsLib.Components
{
partial class ComponentBigTable
{
/// <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,285 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualComponentsLib.Components.SupportClasses;
using Spire.Doc.Formatting;
using System.CodeDom;
using DocumentFormat.OpenXml.Vml;
namespace VisualComponentsLib.Components
{
public partial class ComponentBigTable : Component
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
public ComponentBigTable()
{
InitializeComponent();
}
public ComponentBigTable(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDoc<T> (SetDataTable<T> setDataTable)
{
//создаём документ word
_wordDocument = WordprocessingDocument.Create(setDataTable.FilePath, WordprocessingDocumentType.Document);
//вытаскиваем главную часть из вордовского документа
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
//генерируем тело основной части документа
_docBody = mainPart.Document.AppendChild(new Body());
_wordDocument.Close();
AddTable<T> (setDataTable);
}
//создание таблицы
private void AddTable<T> (SetDataTable<T> setDataTable)
{
if (!CheckData(setDataTable.DataList))
{
throw new Exception("Не все ячейки заполнены");
}
using (var document = WordprocessingDocument.Open(setDataTable.FilePath, true))
{
var doc = document.MainDocumentPart.Document;
#region Создание заголовка
ParagraphProperties paragraphProperties = new();
paragraphProperties.AppendChild(new Justification
{
Val = JustificationValues.Center
});
paragraphProperties.AppendChild(new Indentation());
Paragraph header = new();
header.AppendChild(paragraphProperties);
var docRun = new Run();
var properties = new RunProperties();
properties.AppendChild(new FontSize
{
Val = "48"
});
properties.Append(new Bold());
docRun.AppendChild(properties);
docRun.AppendChild(new Text(setDataTable.FileHeader));
header.AppendChild(docRun);
#endregion
#region Создание таблицы
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 setDataTable.ColumnsSettings)
{
_tr.Append(new TableRowProperties(new TableRowHeight
{
Val = Convert.ToUInt32(setDataTable.HeightRow[indexHeaderHeigh])
}));
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = setDataTable.WidthCol[indexHeaderWidth].ToString(),
}
));
if (string.IsNullOrEmpty(setDataTable.ColumnsSettings[indexHeaderWidth].NameField) ||
string.IsNullOrEmpty(setDataTable.ColumnsSettings[indexHeaderWidth].NameColumn))
{
throw new Exception("Некорректное заполнение информации для шапки таблицы");
}
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);
//увеличиваем счётчик на 1, т. к. в списке только два значения
indexHeaderHeigh++;
indexHeaderWidth = 0;
int numberColunm = 0;
//генерация тела таблицы
for (var i = 1; i < setDataTable.DataList.Count; i++)
{
var tr = new TableRow();
//пробегаемся по словарю, чтобы сразу добавлять значения в нужном порядке
foreach (var item in setDataTable.ColumnsSettings)
{
tr.Append(new TableRowProperties(new TableRowHeight
{
Val = Convert.ToUInt32(setDataTable.HeightRow[indexHeaderHeigh])
}));
var tc = new TableCell();
tc.Append(new TableCellProperties(new TableCellWidth
{
Type = TableWidthUnitValues.Dxa,
Width = setDataTable.WidthCol[indexHeaderWidth].ToString(),
}
));
//вытаскиваем нужное значение
foreach(var val in setDataTable.DataList[i].GetType().GetProperties())
{
if(val.Name == item.Value.NameField)
{
var newParagraph = new Paragraph();
var newRun = new Run();
var runProperties = new RunProperties();
if(indexHeaderWidth == 0)
{
runProperties.Append(new Bold());
}
newRun.AppendChild(runProperties);
newRun.AppendChild(new Text(val.GetValue(setDataTable.DataList[i]).ToString()));
newParagraph.AppendChild(newRun);
tc.Append(newParagraph);
break;
}
}
tr.Append(tc);
indexHeaderWidth++;
}
indexHeaderWidth = 0;
table.Append(tr);
}
#endregion
doc.Body.Append(header);
doc.Body.Append(table);
doc.Save();
}
}
//проверка заполненности входных значений
bool CheckData<T>(List<T> dataList)
{
foreach(var data in dataList)
{
foreach (var value in data.GetType().GetProperties())
{
//для простоты проверки приводим значение каждого поля к типу string
if(string.IsNullOrEmpty(value.GetValue(data).ToString()))
{
return false;
}
}
}
return true;
}
}
}

View File

@ -0,0 +1,36 @@
namespace VisualComponentsLib.Components
{
partial class ComponentWord
{
/// <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,188 @@
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualComponentsLib.Components.SupportClasses;
using DocumentFormat.OpenXml.EMMA;
using DocumentFormat.OpenXml.Drawing.Diagrams;
using FontFamily = DocumentFormat.OpenXml.Wordprocessing.FontFamily;
using System.Reflection.PortableExecutable;
namespace VisualComponentsLib.Components
{
public partial class ComponentWord : Component
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
public ComponentWord()
{
InitializeComponent();
}
public ComponentWord(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public void CreateDoc(SimpleTable simpleTable)
{
//создаём документ word
_wordDocument = WordprocessingDocument.Create(simpleTable.FilePath, WordprocessingDocumentType.Document);
//вытаскиваем главную часть из вордовского документа
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
mainPart.Document = new Document();
//генерируем тело основной части документа
_docBody = mainPart.Document.AppendChild(new Body());
_wordDocument.Close();
AddTable(simpleTable);
}
//создание таблицы
private void AddTable(SimpleTable simpleTable)
{
if (!CheckData(simpleTable.DataList))
{
throw new Exception("Не все ячейки заполнены");
}
using (var document = WordprocessingDocument.Open(simpleTable.FilePath, true))
{
var doc = document.MainDocumentPart.Document;
#region Создание заголовка
ParagraphProperties paragraphProperties = new ();
paragraphProperties.AppendChild(new Justification
{
Val = JustificationValues.Center
});
paragraphProperties.AppendChild(new Indentation());
Paragraph header = new();
header.AppendChild(paragraphProperties);
var docRun = new Run();
var properties = new RunProperties();
properties.AppendChild(new FontSize
{
Val = "48"
});
properties.AppendChild(new Bold());
docRun.AppendChild(properties);
docRun.AppendChild(new Text(simpleTable.TableHeader));
header.AppendChild(docRun);
#endregion
#region Создание таблицы
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 < simpleTable.DataList.Count; i++)
{
var tr = new TableRow();
for (var j = 0; j < simpleTable.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(simpleTable.DataList[i][0, j]))));
tr.Append(tc);
}
table.Append(tr);
}
#endregion
doc.Body.Append(header);
doc.Body.Append(table);
doc.Save();
}
}
//проверка заполненности входных значений
bool CheckData(List<string[,]> data)
{
for (int i = 0; i < data.Count; i++)
{
for (int j = 0; j < data[i].Length; j++)
{
if (string.IsNullOrEmpty(data[i][0, j])) return false;
}
}
return true;
}
}
}

View File

@ -0,0 +1,36 @@
namespace VisualComponentsLib.Components
{
partial class ComponentWordHistogram
{
/// <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,104 @@
using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Drawing.Charts;
using System.ComponentModel;
using VisualComponentsLib.Components.SupportClasses;
namespace VisualComponentsLib.Components
{
public partial class ComponentWordHistogram : Component
{
public ComponentWordHistogram()
{
InitializeComponent();
}
public ComponentWordHistogram(IContainer container)
{
container.Add(this);
InitializeComponent();
}
//создание таблицы
public void AddHistogram(SimpleHistogram simpleHistogram)
{
if (!CheckData(simpleHistogram.DataList))
{
throw new Exception("Не данные заполнены");
}
// Initialize document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Specify font formatting
Aspose.Words.Font font = builder.Font;
font.Size = 24;
font.Bold = true;
font.Color = System.Drawing.Color.Black;
font.Name = "Times New Roman";
// Specify paragraph formatting
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
paragraphFormat.FirstLineIndent = 8;
paragraphFormat.SpaceAfter = 24;
paragraphFormat.Alignment = ParagraphAlignment.Center;
paragraphFormat.KeepTogether = true;
builder.Writeln(simpleHistogram.FileHeader);
// Добавьте диаграмму с данными по умолчанию. Вы можете указать различные типы и размеры диаграмм.
Shape shape = builder.InsertChart(ChartType.Column, 500, 270);
// Свойство диаграммы формы содержит все параметры, связанные с диаграммой.
Chart chart = shape.Chart;
chart.Title.Text = simpleHistogram.HistogramName;
// Получите коллекцию серий диаграмм.
ChartSeriesCollection seriesColl = chart.Series;
// Проверьте количество серий.
Console.WriteLine(seriesColl.Count);
// Удалить серию, сгенерированную по умолчанию.
seriesColl.Clear();
// Создайте массив имен категорий
string[] categories = new string[] { simpleHistogram.DataList[0].NameSeries };
// Добавление новых серий. Обратите внимание, что массивы данных не должны быть пустыми, а массивы должны быть одного размера.
foreach (var data in simpleHistogram.DataList)
{
seriesColl.Add(data.NameData, categories, new double[] { data.Data });
}
// Move the chart's legend to the top right corner.
ChartLegend legend = chart.Legend;
legend.Position = (LegendPosition)simpleHistogram.AreaLegend;
// Give other chart elements, such as the graph, more room by allowing them to overlap the legend.
legend.Overlay = true;
// Сохраните документ
doc.Save(simpleHistogram.FilePath);
}
//проверка заполненности входных значений
static bool CheckData(List<DataHistogram> data)
{
foreach (var _data in data)
{
if(string.IsNullOrEmpty(_data.NameSeries) || string.IsNullOrEmpty(_data.Data.ToString()))
{
return false;
}
}
return true;
}
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses
{
public class Car
{
public string Brand { get; set; } = string.Empty;
public string Model { get; set; } = string.Empty;
public int Price { get; set; }
public int YearProduction { get; set; }
public Car(string brand, string model, int price, int yearProduction)
{
Brand = brand;
Model = model;
Price = price;
YearProduction = yearProduction;
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses
{
//для настройки соответствия столбцов полям
public class ColumnName
{
public string NameColumn { get; set; } = string.Empty;
public string NameField { get; set; } = string.Empty;
public ColumnName(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 VisualComponentsLib.Components.SupportClasses
{
public class DataHistogram
{
public string NameSeries { get; set; } = string.Empty;
public string NameData { get; set; } = string.Empty;
public double Data { get; set; }
public DataHistogram(string nameSeries, string nameData, double data)
{
NameSeries = nameSeries;
NameData = nameData;
Data = data;
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses.Enums
{
public enum EnumAreaLegend
{
None,
Left,
Top,
Right,
Bottom,
TopRight,
}
}

View File

@ -0,0 +1,47 @@
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualComponentsLib.Components.SupportClasses.Enums;
namespace VisualComponentsLib.Components.SupportClasses
{
public class SetDataTable<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, ColumnName> ColumnsSettings;
public SetDataTable(string filePath, string fileHeader, List<double> heightRow,
List<double> widthCol, List<T> dataList, Dictionary<int, ColumnName> columnsSettings)
{
FilePath = filePath;
FileHeader = fileHeader;
HeightRow = heightRow;
WidthCol = widthCol;
DataList = dataList;
ColumnsSettings = columnsSettings;
}
////группировка элементов списка по первому полю
//private static List<T> GroupValue<T>(List<T> data)
//{
// var mainField = data[0].GetType().GetProperties().First().Name;
// return data.GroupBy(field => field.GetType().GetProperties().First().Name).Select(field => field.ToList());
//}
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualComponentsLib.Components.SupportClasses.Enums;
namespace VisualComponentsLib.Components.SupportClasses
{
public class SimpleHistogram
{
public string FilePath = string.Empty;
public string FileHeader = string.Empty;
public string HistogramName = string.Empty;
public EnumAreaLegend AreaLegend;
public List<DataHistogram> DataList = new();
public SimpleHistogram(string filePath, string fileHeader, string histogramName, EnumAreaLegend areaLegend, List<DataHistogram> dataList)
{
FilePath = filePath;
FileHeader = fileHeader;
HistogramName = histogramName;
AreaLegend = areaLegend;
DataList = dataList;
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.Components.SupportClasses
{
public class SimpleTable
{
public string FilePath = string.Empty;
public string TableHeader = string.Empty;
public List<string[,]> DataList = new();
public SimpleTable(string filePath, string tableHeader, List<string[,]> dataList)
{
FilePath = filePath;
TableHeader = tableHeader;
DataList = dataList;
}
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Runtime.Serialization;
namespace VisualComponentsLib.CustomException
{
[Serializable]
public class TextBoxException : Exception
{
// Constructors
public TextBoxException(string message)
: base(message)
{ }
// Ensure Exception is Serializable
protected TextBoxException(SerializationInfo info, StreamingContext ctxt)
: base(info, ctxt)
{ }
}
}

View File

@ -0,0 +1,61 @@
namespace VisualComponentsLib
{
partial class MyDataGridView
{
/// <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(3, 3);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(290, 177);
dataGridView.TabIndex = 0;
//
// MyDataGridView
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(dataGridView);
Name = "MyDataGridView";
Size = new Size(296, 183);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisualComponentsLib.SupportClass;
namespace VisualComponentsLib
{
public partial class MyDataGridView : UserControl
{
//метод для получения индекса выбранной строки
public int IndexRow
{
get
{
if (dataGridView.CurrentCell == null)
{
return -1;
}
return dataGridView.CurrentCell.RowIndex;
}
set
{
if (dataGridView.CurrentCell != null)
{
dataGridView.CurrentCell = dataGridView.Rows[value].Cells[0];
}
}
}
public MyDataGridView()
{
InitializeComponent();
}
//публичный метод создания заголовков таблицы
public void AddHeader(List<DataGridViewInfoCol> elements)
{
foreach (var elem in elements)
{
DataGridViewColumn textColumn = new DataGridViewColumn();
textColumn.Name = elem.HeaderName;
textColumn.HeaderText = elem.Name;
textColumn.Width = elem.Width;
textColumn.Visible = elem.IsVisible;
textColumn.CellTemplate = new DataGridViewTextBoxCell();
dataGridView.Columns.Add(textColumn);
}
}
//публичный параметризованный метод для добавления нового объекта в список
public void AddObject<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;
}
//полная очистка
public void ClearTable()
{
dataGridView.Rows.Clear();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,61 @@
namespace VisualComponentsLib.CustomListBox
{
partial class MyListBox
{
/// <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()
{
listBox = new ListBox();
SuspendLayout();
//
// listBox
//
listBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
listBox.FormattingEnabled = true;
listBox.ItemHeight = 15;
listBox.Location = new Point(3, 3);
listBox.Name = "listBox";
listBox.Size = new Size(234, 229);
listBox.TabIndex = 0;
listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;
//
// MyListBox
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBox);
Location = new Point(3, 5);
MinimumSize = new Size(84, 53);
Name = "MyListBox";
Size = new Size(242, 240);
ResumeLayout(false);
}
#endregion
private ListBox listBox;
}
}

View File

@ -0,0 +1,71 @@
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 VisualComponentsLib.CustomListBox
{
[DefaultEvent(nameof(TextChanged))]
public partial class MyListBox : UserControl
{
[Browsable(true)]
public string SelectedString
{
get
{
if (listBox.SelectedItems.Count == 0)
{
return null;
}
else
{
return listBox.SelectedItem.ToString();
}
}
set
{
if (!string.IsNullOrEmpty(value) && listBox.Items.IndexOf(value) != -1)
{
listBox.SelectedItem = value;
}
}
}
public MyListBox()
{
InitializeComponent();
}
public void AddItem(string item)
{
if (!string.IsNullOrEmpty(item))
{
listBox.Items.Add(item);
}
}
public void ClearAll()
{
listBox.Items.Clear();
}
private EventHandler _textChanged;
public event EventHandler? TextChanged
{
add => _textChanged += value;
remove => _textChanged -= value;
}
private void ListBox_SelectedIndexChanged(object sender, EventArgs e)
{
_textChanged?.Invoke(sender, e);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,72 @@
namespace VisualComponentsLib
{
partial class MyTextBox
{
/// <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()
{
checkBox = new CheckBox();
textBox = new TextBox();
SuspendLayout();
//
// checkBox
//
checkBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
checkBox.AutoSize = true;
checkBox.Location = new Point(14, 52);
checkBox.Name = "checkBox";
checkBox.Size = new Size(104, 19);
checkBox.TabIndex = 0;
checkBox.Text = "Включить null";
checkBox.UseVisualStyleBackColor = true;
checkBox.CheckedChanged += CheckBox_CheckedChanged_1;
//
// textBox
//
textBox.Location = new Point(14, 12);
textBox.Name = "textBox";
textBox.Size = new Size(182, 23);
textBox.TabIndex = 2;
textBox.TextChanged += TextBox_TextChanged;
//
// MyTextBox
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBox);
Controls.Add(checkBox);
Name = "MyTextBox";
Size = new Size(210, 80);
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckBox checkBox;
private TextBox textBox;
}
}

View File

@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using VisualComponentsLib.CustomException;
namespace VisualComponentsLib
{
public partial class MyTextBox : UserControl
{
public double? TextBoxValue
{
get
{
if (checkBox.Checked)
{
return null;
}
if (!CheckValue())
{
return null;
}
return Convert.ToDouble(textBox.Text);
}
set
{
checkBox.Checked = !value.HasValue;
textBox.Text = value?.ToString();
}
}
private string? ErrorMessage
{
get;
set;
}
public MyTextBox()
{
InitializeComponent();
}
private EventHandler _textChanged;
public new event EventHandler? TextChanged
{
add => _textChanged += value;
remove => _textChanged -= value;
}
private void CheckBox_CheckedChanged_1(object sender, EventArgs e)
{
if (textBox.ReadOnly == true)
{
textBox.ReadOnly = false;
}
else
{
textBox.ReadOnly = true;
}
}
private void TextBox_TextChanged(object sender, EventArgs e)
{
_textChanged?.Invoke(sender, e);
}
private bool CheckValue()
{
if (textBox.Text == null && !checkBox.Checked)
{
ErrorMessage = "Недопустимое значение null";
return false;
}
if (!textBox.Text.Contains('.') ||
textBox.Text.IndexOf('.') == textBox.Text.Length - 1 ||
textBox.Text.Length <= 2)
{
ErrorMessage = "Некорректное double значение";
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.SupportClass
{
public class DataGridViewInfoCol
{
public string Name { get; set; }
public string HeaderName { get; set; }
public int Width { get; set; }
public bool IsVisible { get; set; }
public DataGridViewInfoCol(string name, string headerName, int width, bool isVisible)
{
Name = name;
HeaderName = headerName;
Width = width;
IsVisible = isVisible;
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspose.Words" Version="23.10.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
<PackageReference Include="FreeSpire.Doc" Version="11.6.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,58 @@
namespace WinFormsMyComponents
{
partial class MyButton
{
/// <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 Component 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()
{
button1 = new Button();
SuspendLayout();
//
// button1
//
button1.Location = new Point(20, 17);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 0;
button1.Text = "Показ";
button1.UseVisualStyleBackColor = true;
button1.Click += Button1_Click;
//
// UserControl1
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(button1);
Name = "UserControl1";
Size = new Size(115, 59);
ResumeLayout(false);
}
#endregion
private Button button1;
}
}

View File

@ -0,0 +1,15 @@
namespace WinFormsMyComponents
{
public partial class MyButton : UserControl
{
public MyButton()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Пробный показ");
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

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