Compare commits
67 Commits
main
...
Lab_work_0
Author | SHA1 | Date | |
---|---|---|---|
|
9517896ece | ||
|
85be301862 | ||
|
105b576311 | ||
|
52f2fd6b15 | ||
|
8c80db4df3 | ||
|
e073e19639 | ||
|
e9733d991b | ||
|
695eca91b9 | ||
|
b9162ffb1a | ||
|
b97be5168a | ||
|
c71b6fe616 | ||
|
cbc1144b74 | ||
|
cac22b1578 | ||
|
d6fd160b27 | ||
|
3ec2154684 | ||
|
19d6cfae36 | ||
|
911fd9d6c6 | ||
|
af7eb58283 | ||
|
67698429f2 | ||
|
9675ad7004 | ||
|
f143475b3a | ||
|
9c2288c766 | ||
|
bb7e397adc | ||
|
cf6bc53d69 | ||
|
d77baa2273 | ||
|
352635edf0 | ||
|
85f3440431 | ||
|
4b6d44e659 | ||
|
3666046345 | ||
|
cfba8354fb | ||
|
a60f4cd6ce | ||
|
8750c3a305 | ||
|
e79648acd7 | ||
|
056880251c | ||
|
5b8fe3a26e | ||
|
d001a8e245 | ||
|
f1dbb5e420 | ||
|
74c7c849f2 | ||
|
61ecbdc532 | ||
|
5335b9bf40 | ||
|
487d5b784e | ||
|
5ff2f7cce8 | ||
|
7cb9784d4f | ||
|
0479020de6 | ||
|
b84f61e1cb | ||
|
8771c2c962 | ||
|
78810b76e6 | ||
|
32b483ff02 | ||
|
6e40e75b38 | ||
|
3733e7b099 | ||
|
df6dc6cc54 | ||
|
9ca65527e1 | ||
|
5ee58b256e | ||
|
1ff7c269ba | ||
|
edb62e34b6 | ||
|
479b08bcf0 | ||
|
1944070931 | ||
|
74aa787f1d | ||
|
bf736e563d | ||
|
8666b365b0 | ||
|
cbabf209bb | ||
|
1605f4c548 | ||
|
bb487bf6e1 | ||
|
51152f5d9b | ||
|
1be19b8943 | ||
|
fa7bb6f3c8 | ||
|
a70cfd1d18 |
@ -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
|
@ -1,10 +0,0 @@
|
||||
namespace VisualComponents
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
13
VisualComponentsForm/Contracts/Contracts.csproj
Normal file
13
VisualComponentsForm/Contracts/Contracts.csproj
Normal 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>
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
33
VisualComponentsForm/Contracts/ViewModel/LabWorkViewModel.cs
Normal file
33
VisualComponentsForm/Contracts/ViewModel/LabWorkViewModel.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
9
VisualComponentsForm/DataModels/DataModels.csproj
Normal file
9
VisualComponentsForm/DataModels/DataModels.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
13
VisualComponentsForm/DataModels/IId.cs
Normal file
13
VisualComponentsForm/DataModels/IId.cs
Normal 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; }
|
||||
}
|
||||
}
|
13
VisualComponentsForm/DataModels/Models/IDiscipline.cs
Normal file
13
VisualComponentsForm/DataModels/Models/IDiscipline.cs
Normal 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; }
|
||||
}
|
||||
}
|
21
VisualComponentsForm/DataModels/Models/ILabWork.cs
Normal file
21
VisualComponentsForm/DataModels/Models/ILabWork.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -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>
|
27
VisualComponentsForm/DatabaseImplement/ElegevContext.cs
Normal file
27
VisualComponentsForm/DatabaseImplement/ElegevContext.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
75
VisualComponentsForm/DatabaseImplement/Migrations/20231023124245_InitialCreate.Designer.cs
generated
Normal file
75
VisualComponentsForm/DatabaseImplement/Migrations/20231023124245_InitialCreate.Designer.cs
generated
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
52
VisualComponentsForm/DatabaseImplement/Models/Discipline.cs
Normal file
52
VisualComponentsForm/DatabaseImplement/Models/Discipline.cs
Normal 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
|
||||
};
|
||||
}
|
||||
}
|
71
VisualComponentsForm/DatabaseImplement/Models/LabWork.cs
Normal file
71
VisualComponentsForm/DatabaseImplement/Models/LabWork.cs
Normal 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
|
||||
};
|
||||
}
|
||||
}
|
15
VisualComponentsForm/PluginLib/PluginLib.csproj
Normal file
15
VisualComponentsForm/PluginLib/PluginLib.csproj
Normal 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>
|
2
VisualComponentsForm/Plugins/.gitignore
vendored
Normal file
2
VisualComponentsForm/Plugins/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
192
VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.Designer.cs
generated
Normal file
192
VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
286
VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.cs
Normal file
286
VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.cs
Normal 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();
|
||||
}
|
||||
}
|
120
VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.resx
Normal file
120
VisualComponentsForm/PluginsConventionLibraryNet60/FormMain.resx
Normal 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>
|
@ -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>
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
33
VisualComponentsForm/PluginsLib/IPluginsConvention.cs
Normal file
33
VisualComponentsForm/PluginsLib/IPluginsConvention.cs
Normal 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);
|
||||
}
|
||||
}
|
13
VisualComponentsForm/PluginsLib/PluginsConventionElement.cs
Normal file
13
VisualComponentsForm/PluginsLib/PluginsConventionElement.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
22
VisualComponentsForm/PluginsLib/PluginsLib.csproj
Normal file
22
VisualComponentsForm/PluginsLib/PluginsLib.csproj
Normal 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>
|
64
VisualComponentsForm/VisualComponentsForm.sln
Normal file
64
VisualComponentsForm/VisualComponentsForm.sln
Normal 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
|
63
VisualComponentsForm/VisualComponentsForm/FormCreateDiscipline.Designer.cs
generated
Normal file
63
VisualComponentsForm/VisualComponentsForm/FormCreateDiscipline.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
162
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.Designer.cs
generated
Normal file
162
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
108
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.cs
Normal file
108
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.resx
Normal file
120
VisualComponentsForm/VisualComponentsForm/FormCreateLabWork.resx
Normal 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>
|
94
VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs
generated
Normal file
94
VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
420
VisualComponentsForm/VisualComponentsForm/FormMain.cs
Normal file
420
VisualComponentsForm/VisualComponentsForm/FormMain.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
132
VisualComponentsForm/VisualComponentsForm/FormMain.resx
Normal file
132
VisualComponentsForm/VisualComponentsForm/FormMain.resx
Normal 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>
|
134
VisualComponentsForm/VisualComponentsForm/FormWord.Designer.cs
generated
Normal file
134
VisualComponentsForm/VisualComponentsForm/FormWord.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
146
VisualComponentsForm/VisualComponentsForm/FormWord.cs
Normal file
146
VisualComponentsForm/VisualComponentsForm/FormWord.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
129
VisualComponentsForm/VisualComponentsForm/FormWord.resx
Normal file
129
VisualComponentsForm/VisualComponentsForm/FormWord.resx
Normal 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>
|
29
VisualComponentsForm/VisualComponentsForm/Models/People.cs
Normal file
29
VisualComponentsForm/VisualComponentsForm/Models/People.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
334
VisualComponentsForm/VisualComponentsForm/PluginsConvention.cs
Normal file
334
VisualComponentsForm/VisualComponentsForm/PluginsConvention.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
39
VisualComponentsForm/VisualComponentsForm/Program.cs
Normal file
39
VisualComponentsForm/VisualComponentsForm/Program.cs
Normal 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>();
|
||||
}
|
||||
}
|
||||
}
|
@ -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 "$(TargetDir)*.dll" "$(SolutionDir)Plugins\*.dll"" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
@ -1,6 +1,6 @@
|
||||
namespace VisualComponents
|
||||
namespace WinFormPluginsApp
|
||||
{
|
||||
partial class Form1
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -28,10 +28,10 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
components = new System.ComponentModel.Container();
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
10
VisualComponentsForm/WinFormPluginsApp/FormMain.cs
Normal file
10
VisualComponentsForm/WinFormPluginsApp/FormMain.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace WinFormPluginsApp
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
VisualComponentsForm/WinFormPluginsApp/FormMain.resx
Normal file
120
VisualComponentsForm/WinFormPluginsApp/FormMain.resx
Normal 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>
|
@ -1,4 +1,4 @@
|
||||
namespace VisualComponents
|
||||
namespace WinFormPluginsApp
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
@ -11,7 +11,7 @@ namespace VisualComponents
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new FormMain());
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
36
VisualComponentsLib/Components/ComponentBigTable.Designer.cs
generated
Normal file
36
VisualComponentsLib/Components/ComponentBigTable.Designer.cs
generated
Normal 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
|
||||
}
|
||||
}
|
285
VisualComponentsLib/Components/ComponentBigTable.cs
Normal file
285
VisualComponentsLib/Components/ComponentBigTable.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
36
VisualComponentsLib/Components/ComponentWord.Designer.cs
generated
Normal file
36
VisualComponentsLib/Components/ComponentWord.Designer.cs
generated
Normal 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
|
||||
}
|
||||
}
|
188
VisualComponentsLib/Components/ComponentWord.cs
Normal file
188
VisualComponentsLib/Components/ComponentWord.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
36
VisualComponentsLib/Components/ComponentWordHistogram.Designer.cs
generated
Normal file
36
VisualComponentsLib/Components/ComponentWordHistogram.Designer.cs
generated
Normal 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
|
||||
}
|
||||
}
|
104
VisualComponentsLib/Components/ComponentWordHistogram.cs
Normal file
104
VisualComponentsLib/Components/ComponentWordHistogram.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
28
VisualComponentsLib/Components/SupportClasses/Car.cs
Normal file
28
VisualComponentsLib/Components/SupportClasses/Car.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
22
VisualComponentsLib/Components/SupportClasses/ColumnName.cs
Normal file
22
VisualComponentsLib/Components/SupportClasses/ColumnName.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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,
|
||||
}
|
||||
}
|
@ -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());
|
||||
//}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
24
VisualComponentsLib/Components/SupportClasses/SimpleTable.cs
Normal file
24
VisualComponentsLib/Components/SupportClasses/SimpleTable.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
19
VisualComponentsLib/CustomException/TextBoxException.cs
Normal file
19
VisualComponentsLib/CustomException/TextBoxException.cs
Normal 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)
|
||||
{ }
|
||||
}
|
||||
}
|
61
VisualComponentsLib/MyDataGridView.Designer.cs
generated
Normal file
61
VisualComponentsLib/MyDataGridView.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
114
VisualComponentsLib/MyDataGridView.cs
Normal file
114
VisualComponentsLib/MyDataGridView.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
120
VisualComponentsLib/MyDataGridView.resx
Normal file
120
VisualComponentsLib/MyDataGridView.resx
Normal 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>
|
61
VisualComponentsLib/MyListBox.Designer.cs
generated
Normal file
61
VisualComponentsLib/MyListBox.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
71
VisualComponentsLib/MyListBox.cs
Normal file
71
VisualComponentsLib/MyListBox.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
120
VisualComponentsLib/MyListBox.resx
Normal file
120
VisualComponentsLib/MyListBox.resx
Normal 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>
|
72
VisualComponentsLib/MyTextBox.Designer.cs
generated
Normal file
72
VisualComponentsLib/MyTextBox.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
100
VisualComponentsLib/MyTextBox.cs
Normal file
100
VisualComponentsLib/MyTextBox.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
120
VisualComponentsLib/MyTextBox.resx
Normal file
120
VisualComponentsLib/MyTextBox.resx
Normal 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>
|
27
VisualComponentsLib/SupportClass/DataGridViewInfoCol.cs
Normal file
27
VisualComponentsLib/SupportClass/DataGridViewInfoCol.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
17
VisualComponentsLib/VisualComponentsLib.csproj
Normal file
17
VisualComponentsLib/VisualComponentsLib.csproj
Normal 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>
|
58
WinFormsMyComponents/MyButton.Designer.cs
generated
Normal file
58
WinFormsMyComponents/MyButton.Designer.cs
generated
Normal 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;
|
||||
}
|
||||
}
|
15
WinFormsMyComponents/MyButton.cs
Normal file
15
WinFormsMyComponents/MyButton.cs
Normal 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("Пробный показ");
|
||||
}
|
||||
}
|
||||
}
|
120
WinFormsMyComponents/MyButton.resx
Normal file
120
WinFormsMyComponents/MyButton.resx
Normal 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>
|
@ -1,11 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user