This commit is contained in:
alexul3 2024-07-29 20:10:28 +04:00
commit ec97a1419c
19 changed files with 1521 additions and 0 deletions

400
.gitignore vendored Normal file
View File

@ -0,0 +1,400 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33502.453
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestForms", "TestForms\TestForms.csproj", "{8F7F9843-EC02-4318-B507-0D114253D021}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomComponents", "CustomComponents\CustomComponents.csproj", "{84341626-2887-45C2-9D91-FB8B5A14EBFB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8F7F9843-EC02-4318-B507-0D114253D021}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F7F9843-EC02-4318-B507-0D114253D021}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F7F9843-EC02-4318-B507-0D114253D021}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F7F9843-EC02-4318-B507-0D114253D021}.Release|Any CPU.Build.0 = Release|Any CPU
{84341626-2887-45C2-9D91-FB8B5A14EBFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84341626-2887-45C2-9D91-FB8B5A14EBFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84341626-2887-45C2-9D91-FB8B5A14EBFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84341626-2887-45C2-9D91-FB8B5A14EBFB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {308288F3-F285-4816-9F45-4BE8A1BF6F8A}
EndGlobalSection
EndGlobal

View File

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

View File

@ -0,0 +1,59 @@
namespace CustomComponents
{
partial class DateTextBox
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
textBox = new TextBox();
SuspendLayout();
//
// textBox
//
textBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
textBox.Location = new Point(0, 0);
textBox.Name = "textBox";
textBox.Size = new Size(150, 27);
textBox.TabIndex = 0;
textBox.TextChanged += textBox_TextChanged;
textBox.Enter += textBox_Enter;
//
// DateTextBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(textBox);
Name = "DateTextBox";
Size = new Size(150, 28);
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox;
}
}

View File

@ -0,0 +1,94 @@
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;
namespace CustomComponents
{
public partial class DateTextBox : UserControl
{
private string? pattern;
private string example = "Формат ввода: DD.MM.YYYY";
public DateTextBox()
{
InitializeComponent();
}
public string? Pattern
{
get { return pattern; }
set { pattern = value; }
}
public string TextBoxValue
{
get
{
Regex regex = new Regex(Pattern);
bool isValid = regex.IsMatch(textBox.Text);//2 zadanie
if (isValid)
{
return textBox.Text;
}
else
{
Error = "Неправильный ввод";
return null;
}
}
set
{
Regex regex = new Regex(Pattern);
bool isValid = regex.IsMatch(value);
if (isValid)
{
textBox.Text = value;
}
else
{
Error = "Неправильно";
}
}
}
public string Error
{
get; private set;
}
public void SetExample(string exampleStr)
{
Regex regex = new Regex(Pattern);
bool isValid = regex.IsMatch(exampleStr);
if (isValid)
{
example = exampleStr;
}
}
private void textBox_Enter(object sender, EventArgs e)
{
ToolTip tt = new ToolTip();
tt.Show(example, textBox, 30, -20, 1000);
}
private void textBox_TextChanged(object sender, EventArgs e)
{
_changeEvent?.Invoke(sender, e);
}
private EventHandler _changeEvent;
public event EventHandler ChangeEvent
{
add
{
_changeEvent += value;
}
remove
{
_changeEvent -= value;
}
}
}
}

View File

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

View File

@ -0,0 +1,58 @@
namespace CustomComponents
{
partial class DropDownList
{
/// <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()
{
ComboBox = new ComboBox();
SuspendLayout();
//
// ComboBox
//
ComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
ComboBox.FormattingEnabled = true;
ComboBox.Location = new Point(0, 0);
ComboBox.Name = "ComboBox";
ComboBox.Size = new Size(151, 28);
ComboBox.TabIndex = 0;
ComboBox.SelectedIndexChanged += ComboBox_SelectedIndexChanged;
//
// DropDownList
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(ComboBox);
Name = "DropDownList";
Size = new Size(154, 29);
ResumeLayout(false);
}
#endregion
private ComboBox ComboBox;
}
}

View File

@ -0,0 +1,70 @@
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 CustomComponents
{
public partial class DropDownList : UserControl
{
public DropDownList()
{
InitializeComponent();
}
public void AddToList(string value)// 1 zadanie
{
if (value == null)
{
return;
}
ComboBox.Items.Add(value);
}
public void ClearList()
{
ComboBox.Items.Clear();
}
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
_changeEvent?.Invoke(sender, e);
}
public string? Selected
{
get
{
if (ComboBox.Items.Count == 0 || ComboBox.SelectedItem == null)
{
return "";
}
return ComboBox.SelectedItem.ToString()!;
}
set
{
if (ComboBox.Items.Contains(value))
{
ComboBox.SelectedItem = value;
}
}
}
private EventHandler _changeEvent;
public event EventHandler ChangeEvent
{
add
{
_changeEvent += value;
}
remove
{
_changeEvent -= value;
}
}
}
}

View File

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

View File

@ -0,0 +1,57 @@
namespace CustomComponents
{
partial class ListBoxObjects
{
/// <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.FormattingEnabled = true;
listBox.ItemHeight = 20;
listBox.Location = new Point(0, 0);
listBox.Name = "listBox";
listBox.Size = new Size(458, 144);
listBox.TabIndex = 0;
//
// ListBoxObjects
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBox);
Name = "ListBoxObjects";
Size = new Size(458, 143);
ResumeLayout(false);
}
#endregion
private ListBox listBox;
}
}

View File

@ -0,0 +1,95 @@
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 CustomComponents
{
public partial class ListBoxObjects : UserControl
{
private string LayoutString;
private string StartS;
private string EndS;
private int SelectedStr;
public ListBoxObjects()
{
InitializeComponent();
}
public int SelectedIndex {
get {
if (listBox.SelectedIndex == -1)
{
return -1;
}
return listBox.SelectedIndex;
}
set
{
if(listBox.Items.Count != 0)
{
listBox.SelectedIndex = value;
}
}
}
public void SetLayout(string layoutString, string startS, string endS)
{
if (layoutString == null || startS == null || endS == null) return;
LayoutString = layoutString;
StartS = startS;
EndS = endS;
}
public void AddItemInList<T>(T Object)//3 zadanie
{
if (Object == null)
{
throw new ArgumentNullException();
}
if (!LayoutString.Contains(StartS) && !LayoutString.Contains(EndS))
{
return;
}
string str = LayoutString;
foreach (var prop in Object.GetType().GetProperties())
{
string str1 = $"{StartS}" + prop.Name + $"{EndS}";
str = str.Replace(str1, $"{StartS}" + prop.GetValue(Object).ToString() + $"{EndS}");
}
listBox.Items.Add(str);
}
public T GetItemFromList<T>() where T : class, new()
{
string SelectedStr = "";
if (listBox.SelectedIndex != -1)
{
SelectedStr = listBox.SelectedItem.ToString();
}
T currentObject = new T();
foreach (var prop in typeof(T).GetProperties())
{
if (!prop.CanWrite)
{
continue;
}
int startS = SelectedStr.IndexOf(StartS);
int endS = SelectedStr.IndexOf(EndS);
if (startS == -1 || endS == -1)
{
break;
}
string propValue = SelectedStr.Substring(startS + 1, endS - startS - 1);
SelectedStr = SelectedStr.Substring(endS + 1);
prop.SetValue(currentObject, Convert.ChangeType(propValue, prop.PropertyType));
}
return currentObject;
}
}
}

View File

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

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomComponents.Objects
{
public class DaysOfWeek
{
public DateTime Date { get; set; }
public string Day { get; set; }
public int Temperature { get; set; }
public DaysOfWeek(DateTime date, string day, int temperature)
{
Date = date;
Day = day;
Temperature = temperature;
}
public DaysOfWeek() { }
}
}

View File

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

267
COP_LabWork/TestForms/TestForm.Designer.cs generated Normal file
View File

@ -0,0 +1,267 @@
namespace TestForms
{
partial class TestForm
{
/// <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()
{
TextBoxList = new TextBox();
ButtonAdd = new Button();
ButtonClear = new Button();
ButtonCheckDrop = new Button();
dropDownList = new CustomComponents.DropDownList();
groupBoxDrop = new GroupBox();
labelShowDrop = new Label();
groupBoxDate = new GroupBox();
ButtonCheckText = new Button();
labelShowText = new Label();
dateTextBox = new CustomComponents.DateTextBox();
listBoxObjects = new CustomComponents.ListBoxObjects();
dateTimePicker = new DateTimePicker();
numericUpDown = new NumericUpDown();
buttonInList = new Button();
buttonGet = new Button();
ButtonExample = new Button();
textBoxExample = new TextBox();
groupBoxDrop.SuspendLayout();
groupBoxDate.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown).BeginInit();
SuspendLayout();
//
// TextBoxList
//
TextBoxList.Location = new Point(16, 59);
TextBoxList.Name = "TextBoxList";
TextBoxList.Size = new Size(152, 27);
TextBoxList.TabIndex = 2;
//
// ButtonAdd
//
ButtonAdd.Location = new Point(16, 92);
ButtonAdd.Name = "ButtonAdd";
ButtonAdd.Size = new Size(70, 29);
ButtonAdd.TabIndex = 3;
ButtonAdd.Text = "Add";
ButtonAdd.UseVisualStyleBackColor = true;
ButtonAdd.Click += ButtonAdd_Click;
//
// ButtonClear
//
ButtonClear.Location = new Point(103, 92);
ButtonClear.Name = "ButtonClear";
ButtonClear.Size = new Size(65, 29);
ButtonClear.TabIndex = 4;
ButtonClear.Text = "Clear";
ButtonClear.UseVisualStyleBackColor = true;
ButtonClear.Click += ButtonClear_Click;
//
// ButtonCheckDrop
//
ButtonCheckDrop.Location = new Point(16, 148);
ButtonCheckDrop.Name = "ButtonCheckDrop";
ButtonCheckDrop.Size = new Size(152, 29);
ButtonCheckDrop.TabIndex = 5;
ButtonCheckDrop.Text = "CheckDrop";
ButtonCheckDrop.UseVisualStyleBackColor = true;
ButtonCheckDrop.Click += ButtonCheckDrop_Click;
//
// dropDownList
//
dropDownList.Location = new Point(16, 26);
dropDownList.Name = "dropDownList";
dropDownList.Selected = "";
dropDownList.Size = new Size(152, 27);
dropDownList.TabIndex = 6;
//
// groupBoxDrop
//
groupBoxDrop.Controls.Add(labelShowDrop);
groupBoxDrop.Controls.Add(TextBoxList);
groupBoxDrop.Controls.Add(dropDownList);
groupBoxDrop.Controls.Add(ButtonCheckDrop);
groupBoxDrop.Controls.Add(ButtonAdd);
groupBoxDrop.Controls.Add(ButtonClear);
groupBoxDrop.Location = new Point(12, 12);
groupBoxDrop.Name = "groupBoxDrop";
groupBoxDrop.Size = new Size(186, 182);
groupBoxDrop.TabIndex = 7;
groupBoxDrop.TabStop = false;
groupBoxDrop.Text = "Дроп";
//
// labelShowDrop
//
labelShowDrop.AutoSize = true;
labelShowDrop.Location = new Point(16, 122);
labelShowDrop.Name = "labelShowDrop";
labelShowDrop.Size = new Size(46, 20);
labelShowDrop.TabIndex = 7;
labelShowDrop.Text = "check";
//
// groupBoxDate
//
groupBoxDate.Controls.Add(textBoxExample);
groupBoxDate.Controls.Add(ButtonExample);
groupBoxDate.Controls.Add(ButtonCheckText);
groupBoxDate.Controls.Add(labelShowText);
groupBoxDate.Controls.Add(dateTextBox);
groupBoxDate.Location = new Point(204, 12);
groupBoxDate.Name = "groupBoxDate";
groupBoxDate.Size = new Size(203, 182);
groupBoxDate.TabIndex = 8;
groupBoxDate.TabStop = false;
groupBoxDate.Text = "Дата";
//
// ButtonCheckText
//
ButtonCheckText.Location = new Point(6, 85);
ButtonCheckText.Name = "ButtonCheckText";
ButtonCheckText.Size = new Size(191, 29);
ButtonCheckText.TabIndex = 8;
ButtonCheckText.Text = "CheckData";
ButtonCheckText.UseVisualStyleBackColor = true;
ButtonCheckText.Click += ButtonCheckText_Click;
//
// labelShowText
//
labelShowText.AutoSize = true;
labelShowText.Location = new Point(6, 62);
labelShowText.Name = "labelShowText";
labelShowText.Size = new Size(46, 20);
labelShowText.TabIndex = 8;
labelShowText.Text = "check";
//
// dateTextBox
//
dateTextBox.Location = new Point(6, 26);
dateTextBox.Name = "dateTextBox";
dateTextBox.Pattern = "^\\s*(3[01]|[12][0-9]|0?[1-9])\\.(1[012]|0?[1-9])\\.((?:0|1|2)\\d{3})\\s*$";
dateTextBox.Size = new Size(188, 27);
dateTextBox.TabIndex = 6;
//
// listBoxObjects
//
listBoxObjects.Location = new Point(424, 28);
listBoxObjects.Name = "listBoxObjects";
listBoxObjects.SelectedIndex = -1;
listBoxObjects.Size = new Size(485, 147);
listBoxObjects.TabIndex = 9;
//
// dateTimePicker
//
dateTimePicker.Format = DateTimePickerFormat.Short;
dateTimePicker.Location = new Point(915, 28);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(148, 27);
dateTimePicker.TabIndex = 10;
//
// numericUpDown
//
numericUpDown.Location = new Point(915, 97);
numericUpDown.Name = "numericUpDown";
numericUpDown.Size = new Size(150, 27);
numericUpDown.TabIndex = 12;
//
// buttonInList
//
buttonInList.Location = new Point(915, 130);
buttonInList.Name = "buttonInList";
buttonInList.Size = new Size(150, 29);
buttonInList.TabIndex = 13;
buttonInList.Text = "Add";
buttonInList.UseVisualStyleBackColor = true;
buttonInList.Click += buttonInList_Click;
//
// buttonGet
//
buttonGet.Location = new Point(915, 165);
buttonGet.Name = "buttonGet";
buttonGet.Size = new Size(148, 29);
buttonGet.TabIndex = 14;
buttonGet.Text = "Get";
buttonGet.UseVisualStyleBackColor = true;
buttonGet.Click += buttonGet_Click;
//
// ButtonExample
//
ButtonExample.Location = new Point(6, 148);
ButtonExample.Name = "ButtonExample";
ButtonExample.Size = new Size(188, 29);
ButtonExample.TabIndex = 9;
ButtonExample.Text = "Change example";
ButtonExample.UseVisualStyleBackColor = true;
ButtonExample.Click += ButtonExample_Click;
//
// textBoxExample
//
textBoxExample.Location = new Point(6, 119);
textBoxExample.Name = "textBoxExample";
textBoxExample.Size = new Size(188, 27);
textBoxExample.TabIndex = 10;
//
// TestForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1068, 201);
Controls.Add(buttonGet);
Controls.Add(buttonInList);
Controls.Add(numericUpDown);
Controls.Add(dateTimePicker);
Controls.Add(listBoxObjects);
Controls.Add(groupBoxDate);
Controls.Add(groupBoxDrop);
Name = "TestForm";
Text = "TestForm";
groupBoxDrop.ResumeLayout(false);
groupBoxDrop.PerformLayout();
groupBoxDate.ResumeLayout(false);
groupBoxDate.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox TextBoxList;
private Button ButtonAdd;
private Button ButtonClear;
private Button ButtonCheckDrop;
private CustomComponents.DropDownList dropDownList;
private GroupBox groupBoxDrop;
private GroupBox groupBoxDate;
private CustomComponents.DateTextBox dateTextBox;
private CustomComponents.ListBoxObjects listBoxObjects;
private DateTimePicker dateTimePicker;
private NumericUpDown numericUpDown;
private Button buttonInList;
private Button buttonGet;
private Label labelShowDrop;
private Label labelShowText;
private Button ButtonCheckText;
private TextBox textBoxExample;
private Button ButtonExample;
}
}

View File

@ -0,0 +1,84 @@
using CustomComponents.Objects;
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 TestForms
{
public partial class TestForm : Form
{
public TestForm()
{
InitializeComponent();
dropDownList.AddToList("фыв");
dateTextBox.Pattern = "^\\s*(3[01]|[12][0-9]|0?[1-9])\\.(1[012]|0?[1-9])\\.((?:0|1|2)\\d{3})\\s*$";
listBoxObjects.SetLayout("Число: {Date}, День {Day}, Температура {Temperature}", "{", "}");
listBoxObjects.AddItemInList<DaysOfWeek>(new DaysOfWeek(DateTime.Today.AddDays(-3), "Среда", 15));
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(TextBoxList.Text))
{
dropDownList.AddToList(TextBoxList.Text);
}
else
{
ToolTip tt = new ToolTip();
tt.Show("Заполните поле", TextBoxList, 3000);
}
}
private void ButtonClear_Click(object sender, EventArgs e)
{
dropDownList.ClearList();
}
private void buttonInList_Click(object sender, EventArgs e)
{
if (dateTimePicker.Text == null)
{
return;
}
listBoxObjects.AddItemInList<DaysOfWeek>(new(dateTimePicker.Value, dateTimePicker.Value.ToString("dddd"), Convert.ToInt32(numericUpDown.Value)));
}
private void buttonGet_Click(object sender, EventArgs e)
{
DaysOfWeek dow = listBoxObjects.GetItemFromList<DaysOfWeek>();
if (dow == null || dow.Date == default(DateTime))
{
return;
}
dateTimePicker.Value = dow.Date;
numericUpDown.Value = dow.Temperature;
}
private void ButtonCheckDrop_Click(object sender, EventArgs e)
{
labelShowDrop.Text = dropDownList.Selected;
}
private void ButtonCheckText_Click(object sender, EventArgs e)
{
labelShowText.Text = dateTextBox.TextBoxValue;
}
private void ButtonExample_Click(object sender, EventArgs e)
{
if(textBoxExample.Text == String.Empty)
{
return;
}
dateTextBox.SetExample(textBoxExample.Text);
}
}
}

View File

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

View File

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

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# Pidb-32_Lazarev_A_A_COP_13