Компонент 1 готов.
This commit is contained in:
parent
b2505135e5
commit
e73a259ccb
@ -1,6 +0,0 @@
|
||||
namespace Component_1
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
86
Component_1/List_with_choice.Designer.cs
generated
Normal file
86
Component_1/List_with_choice.Designer.cs
generated
Normal file
@ -0,0 +1,86 @@
|
||||
namespace Component_1
|
||||
{
|
||||
partial class List_with_choice
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
checkedListBox1 = new CheckedListBox();
|
||||
button_Load = new Button();
|
||||
button_Clean = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkedListBox1
|
||||
//
|
||||
checkedListBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
checkedListBox1.FormattingEnabled = true;
|
||||
checkedListBox1.Location = new Point(85, 23);
|
||||
checkedListBox1.Name = "checkedListBox1";
|
||||
checkedListBox1.Size = new Size(201, 92);
|
||||
checkedListBox1.TabIndex = 0;
|
||||
checkedListBox1.SelectedIndexChanged += checkedListBox1_SelectedIndexChanged;
|
||||
//
|
||||
// button_Load
|
||||
//
|
||||
button_Load.Anchor = AnchorStyles.Bottom;
|
||||
button_Load.Location = new Point(6, 146);
|
||||
button_Load.Name = "button_Load";
|
||||
button_Load.Size = new Size(161, 29);
|
||||
button_Load.TabIndex = 1;
|
||||
button_Load.Text = "Заполнить список";
|
||||
button_Load.UseVisualStyleBackColor = true;
|
||||
button_Load.Click += button_Load_Click;
|
||||
//
|
||||
// button_Clean
|
||||
//
|
||||
button_Clean.Anchor = AnchorStyles.Bottom;
|
||||
button_Clean.Location = new Point(203, 146);
|
||||
button_Clean.Name = "button_Clean";
|
||||
button_Clean.Size = new Size(153, 29);
|
||||
button_Clean.TabIndex = 2;
|
||||
button_Clean.Text = "Очистить список";
|
||||
button_Clean.UseVisualStyleBackColor = true;
|
||||
button_Clean.Click += button_Clean_Click;
|
||||
//
|
||||
// List_with_choice
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(button_Clean);
|
||||
Controls.Add(button_Load);
|
||||
Controls.Add(checkedListBox1);
|
||||
Name = "List_with_choice";
|
||||
Size = new Size(371, 198);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckedListBox checkedListBox1;
|
||||
private Button button_Load;
|
||||
private Button button_Clean;
|
||||
}
|
||||
}
|
125
Component_1/List_with_choice.cs
Normal file
125
Component_1/List_with_choice.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Component_1
|
||||
{
|
||||
public partial class List_with_choice : UserControl
|
||||
{
|
||||
private event EventHandler? _checkedlistChanged;
|
||||
private event Action? _errorOccured;
|
||||
public string Error { get; private set; }
|
||||
|
||||
public String Element
|
||||
{
|
||||
get
|
||||
{
|
||||
if (checkedListBox1.SelectedItem != null) return checkedListBox1.SelectedItem.ToString();
|
||||
else return string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
checkedListBox1.SelectedItem = value;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler Checkedlist
|
||||
{
|
||||
add { _checkedlistChanged += value; }
|
||||
remove { _checkedlistChanged -= value; }
|
||||
}
|
||||
public event Action AnErrorOccurred
|
||||
{
|
||||
add { _errorOccured += value; }
|
||||
remove { _errorOccured -= value; }
|
||||
}
|
||||
|
||||
public List_with_choice()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
|
||||
public void Fill_List(string str) //метод заполнения списка
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
MessageBox.Show("Вы не ввели строку");
|
||||
return;
|
||||
}
|
||||
|
||||
string[] list = str.Split(' ');
|
||||
foreach (string s in list)
|
||||
{
|
||||
checkedListBox1.Items.Add(s);
|
||||
}
|
||||
}
|
||||
public void Clean_List() //метод очистки списка
|
||||
{
|
||||
checkedListBox1.Items.Clear();
|
||||
}
|
||||
private void button_Load_Click(object sender, EventArgs e)
|
||||
{
|
||||
string value = "";
|
||||
if (InputBox("Заполнение списка", "Пожалуйста введите строку", ref value) == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
Fill_List(value);
|
||||
_checkedlistChanged?.Invoke(this, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error = ex.Message;
|
||||
_errorOccured?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
public static DialogResult InputBox(string title, string promptText, ref string value)//диалоговое окно
|
||||
{
|
||||
Form form = new Form();
|
||||
Label label = new Label();
|
||||
TextBox textBox = new TextBox();
|
||||
Button buttonOk = new Button();
|
||||
Button buttonCancel = new Button();
|
||||
form.Text = title;
|
||||
label.Text = promptText;
|
||||
buttonOk.Text = "OK";
|
||||
buttonCancel.Text = "Cancel";
|
||||
buttonOk.DialogResult = DialogResult.OK;
|
||||
buttonCancel.DialogResult = DialogResult.Cancel;
|
||||
label.SetBounds(36, 36, 372, 13);
|
||||
textBox.SetBounds(36, 86, 700, 20);
|
||||
buttonOk.SetBounds(228, 160, 160, 60);
|
||||
buttonCancel.SetBounds(400, 160, 160, 60);
|
||||
label.AutoSize = true;
|
||||
form.ClientSize = new Size(796, 307);
|
||||
form.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
form.StartPosition = FormStartPosition.CenterScreen;
|
||||
form.MinimizeBox = false;
|
||||
form.MaximizeBox = false;
|
||||
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
|
||||
form.AcceptButton = buttonOk;
|
||||
form.CancelButton = buttonCancel;
|
||||
DialogResult dialogResult = form.ShowDialog();
|
||||
value = textBox.Text;
|
||||
return dialogResult;
|
||||
}
|
||||
private void button_Clean_Click(object sender, EventArgs e)
|
||||
{
|
||||
Clean_List();
|
||||
}
|
||||
}
|
||||
}
|
60
Component_1/List_with_choice.resx
Normal file
60
Component_1/List_with_choice.resx
Normal 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>
|
@ -8,4 +8,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Component_1\Component_1.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -5,6 +5,8 @@ VisualStudioVersion = 17.5.33627.172
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Components", "Components.csproj", "{637B2B5F-8015-4DE8-B264-74F24B115812}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Component_1", "..\Component_1\Component_1.csproj", "{9E53BE81-4309-40C4-B6F8-0C80756EE09E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +17,10 @@ Global
|
||||
{637B2B5F-8015-4DE8-B264-74F24B115812}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{637B2B5F-8015-4DE8-B264-74F24B115812}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{637B2B5F-8015-4DE8-B264-74F24B115812}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9E53BE81-4309-40C4-B6F8-0C80756EE09E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
26
Components/Form1.Designer.cs
generated
26
Components/Form1.Designer.cs
generated
@ -28,12 +28,30 @@
|
||||
/// </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";
|
||||
list_with_choice1 = new Component_1.List_with_choice();
|
||||
SuspendLayout();
|
||||
//
|
||||
// list_with_choice1
|
||||
//
|
||||
list_with_choice1.Element = "";
|
||||
list_with_choice1.Location = new Point(131, 60);
|
||||
list_with_choice1.Name = "list_with_choice1";
|
||||
list_with_choice1.Size = new Size(464, 248);
|
||||
list_with_choice1.TabIndex = 0;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(list_with_choice1);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Component_1.List_with_choice list_with_choice1;
|
||||
}
|
||||
}
|
@ -1,64 +1,4 @@
|
||||
<?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.
|
||||
-->
|
||||
<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">
|
||||
|
Loading…
Reference in New Issue
Block a user