Первое вроде сделал.

This commit is contained in:
Артём Алейкин 2023-09-20 23:36:19 +04:00
parent 447f298c49
commit 636c56d311
14 changed files with 598 additions and 0 deletions

View File

@ -0,0 +1,6 @@
namespace WinFormsLibrary
{
public class Class1
{
}
}

View File

@ -0,0 +1,58 @@
namespace WinFormsLibrary
{
partial class CustomCheckedListBox
{
/// <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()
{
this.checkedListBox = new System.Windows.Forms.CheckedListBox();
this.SuspendLayout();
//
// checkedListBox
//
this.checkedListBox.FormattingEnabled = true;
this.checkedListBox.Location = new System.Drawing.Point(31, 16);
this.checkedListBox.Name = "checkedListBox";
this.checkedListBox.Size = new System.Drawing.Size(262, 94);
this.checkedListBox.TabIndex = 0;
this.checkedListBox.SelectedValueChanged += new System.EventHandler(this.checkedListBox_SelectedValueChanged);
//
// CustomCheckedListBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.checkedListBox);
this.Name = "CustomCheckedListBox";
this.Size = new System.Drawing.Size(333, 141);
this.ResumeLayout(false);
}
#endregion
private CheckedListBox checkedListBox;
}
}

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace WinFormsLibrary
{
public partial class CustomCheckedListBox : UserControl
{
public CustomCheckedListBox()
{
InitializeComponent();
}
//метод для очистки
public void Clear()
{
checkedListBox.Items.Clear();
}
//метод для заполнения
public void FillCheckedListBox(List<string> items)
{
checkedListBox.Items.Clear();
checkedListBox.Items.AddRange(items.ToArray());
}
//публичное свойство
public string Selected
{
get
{
if (checkedListBox.SelectedItems.Count == 0)
{
return "";
}
string result = "";
foreach (object itemChecked in checkedListBox.CheckedItems)
{
result += itemChecked.ToString() + Environment.NewLine;
}
return result;
}
set
{
if (checkedListBox.Items.Contains(value))
{
checkedListBox.SelectedItem = value;
}
}
}
private EventHandler onValueChanged;
public event EventHandler ValueChanged
{
add
{
onValueChanged += value;
}
remove
{
onValueChanged -= value;
}
}
private void checkedListBox_SelectedValueChanged(object sender, EventArgs e)
{
onValueChanged?.Invoke(sender, e);
}
}
}

View File

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

View File

@ -0,0 +1,45 @@
namespace WinFormsLibrary
{
partial class NumberTextBox
{
/// <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()
{
this.SuspendLayout();
//
// NumberTextBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "NumberTextBox";
this.Size = new System.Drawing.Size(364, 264);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@ -0,0 +1,20 @@
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 WinFormsLibrary
{
public partial class NumberTextBox : UserControl
{
public NumberTextBox()
{
InitializeComponent();
}
}
}

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,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,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsProject", "WinFormsProject\WinFormsProject.csproj", "{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsLibrary", "WinFormsLibrary\WinFormsLibrary.csproj", "{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FC6ABE3-DF27-453A-B2EE-FA17C71C9CF0}.Release|Any CPU.Build.0 = Release|Any CPU
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF6B5601-DC60-48A2-8BDC-1CE32E3F6F15}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2774D1CA-C461-4F94-89BF-C2FD28AC4024}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,97 @@
namespace WinFormsProject
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.customCheckedListBox1 = new WinFormsLibrary.CustomCheckedListBox();
this.Button_Fill = new System.Windows.Forms.Button();
this.Button_Clear = new System.Windows.Forms.Button();
this.Button_GetChosenValues = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// customCheckedListBox1
//
this.customCheckedListBox1.Location = new System.Drawing.Point(21, 21);
this.customCheckedListBox1.Name = "customCheckedListBox1";
this.customCheckedListBox1.Selected = "";
this.customCheckedListBox1.Size = new System.Drawing.Size(333, 141);
this.customCheckedListBox1.TabIndex = 0;
//
// Button_Fill
//
this.Button_Fill.Location = new System.Drawing.Point(130, 141);
this.Button_Fill.Name = "Button_Fill";
this.Button_Fill.Size = new System.Drawing.Size(106, 45);
this.Button_Fill.TabIndex = 1;
this.Button_Fill.Text = "Заполнить";
this.Button_Fill.UseVisualStyleBackColor = true;
this.Button_Fill.Click += new System.EventHandler(this.Button_Fill_Click);
//
// Button_Clear
//
this.Button_Clear.Location = new System.Drawing.Point(130, 206);
this.Button_Clear.Name = "Button_Clear";
this.Button_Clear.Size = new System.Drawing.Size(106, 53);
this.Button_Clear.TabIndex = 2;
this.Button_Clear.Text = "Очистить";
this.Button_Clear.UseVisualStyleBackColor = true;
this.Button_Clear.Click += new System.EventHandler(this.Button_Clear_Click);
//
// Button_GetChosenValues
//
this.Button_GetChosenValues.Location = new System.Drawing.Point(130, 277);
this.Button_GetChosenValues.Name = "Button_GetChosenValues";
this.Button_GetChosenValues.Size = new System.Drawing.Size(106, 52);
this.Button_GetChosenValues.TabIndex = 3;
this.Button_GetChosenValues.Text = "Выбранные значения";
this.Button_GetChosenValues.UseVisualStyleBackColor = true;
this.Button_GetChosenValues.Click += new System.EventHandler(this.Button_GetChosenValues_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.Button_GetChosenValues);
this.Controls.Add(this.Button_Clear);
this.Controls.Add(this.Button_Fill);
this.Controls.Add(this.customCheckedListBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private WinFormsLibrary.CustomCheckedListBox customCheckedListBox1;
private Button Button_Fill;
private Button Button_Clear;
private Button Button_GetChosenValues;
}
}

View File

@ -0,0 +1,41 @@
namespace WinFormsProject
{
public partial class Form1 : Form
{
List<string> list = new List<string> { "Ìàðàò", "Áóðàê", "Ðîâøàê" };
public Form1()
{
InitializeComponent();
customCheckedListBox1.FillCheckedListBox(list);
customCheckedListBox1.ValueChanged += CustomEventHandler;
}
private void CustomEventHandler(object sender, EventArgs e)
{
MessageBox.Show("Çíà÷åíèå áûëî èçìåíåíî.");
}
private void Button_Clear_Click(object sender, EventArgs e)
{
customCheckedListBox1.Clear();
}
private void Button_Fill_Click(object sender, EventArgs e)
{
customCheckedListBox1.FillCheckedListBox(list);
}
private void Button_GetChosenValues_Click(object sender, EventArgs e)
{
if (customCheckedListBox1.Selected == null || customCheckedListBox1.Selected == "")
{
MessageBox.Show("Íåòó âûáðàííûõ ýëåìåíòîâ.");
}
else
{
MessageBox.Show(customCheckedListBox1.Selected);
}
}
}
}

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,17 @@
namespace WinFormsProject
{
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 Form1());
}
}
}

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="..\WinFormsLibrary\WinFormsLibrary.csproj" />
</ItemGroup>
</Project>