ПЕРВЫЙ КОМПОНЕНТ ВРОДЕ КАК.

This commit is contained in:
ElEgEv 2023-09-21 14:27:34 +04:00
parent edb62e34b6
commit 1ff7c269ba
8 changed files with 262 additions and 107 deletions

View File

@ -4,14 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
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}"
ProjectSection(ProjectDependencies) = postProject
{317EA9D6-B5A5-44FE-B524-D646B518CB3E} = {317EA9D6-B5A5-44FE-B524-D646B518CB3E}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsLib", "..\VisualComponentsLib\VisualComponentsLib.csproj", "{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsMyComponents", "..\WinFormsMyComponents\WinFormsMyComponents.csproj", "{317EA9D6-B5A5-44FE-B524-D646B518CB3E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -26,10 +21,6 @@ Global
{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
{317EA9D6-B5A5-44FE-B524-D646B518CB3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{317EA9D6-B5A5-44FE-B524-D646B518CB3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{317EA9D6-B5A5-44FE-B524-D646B518CB3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{317EA9D6-B5A5-44FE-B524-D646B518CB3E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -28,90 +28,107 @@
/// </summary>
private void InitializeComponent()
{
this.labelCheck = new System.Windows.Forms.Label();
this.buttonCheck = new System.Windows.Forms.Button();
this.myListBox1 = new VisualComponentsLib.CustomListBox.MyListBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
labelCheck = new Label();
buttonCheck = new Button();
myListBox = new VisualComponentsLib.CustomListBox.MyListBox();
textBoxInput = new TextBox();
buttonAddList = new Button();
buttonClear = new Button();
groupBox = new GroupBox();
groupBox.SuspendLayout();
SuspendLayout();
//
// labelCheck
//
this.labelCheck.AutoSize = true;
this.labelCheck.Location = new System.Drawing.Point(522, 23);
this.labelCheck.Name = "labelCheck";
this.labelCheck.Size = new System.Drawing.Size(38, 15);
this.labelCheck.TabIndex = 1;
this.labelCheck.Text = "label1";
labelCheck.AutoSize = true;
labelCheck.BorderStyle = BorderStyle.FixedSingle;
labelCheck.Location = new Point(296, 139);
labelCheck.Name = "labelCheck";
labelCheck.Size = new Size(40, 17);
labelCheck.TabIndex = 1;
labelCheck.Text = "label1";
//
// buttonCheck
//
this.buttonCheck.Location = new System.Drawing.Point(532, 71);
this.buttonCheck.Name = "buttonCheck";
this.buttonCheck.Size = new System.Drawing.Size(75, 23);
this.buttonCheck.TabIndex = 2;
this.buttonCheck.Text = "Проверка";
this.buttonCheck.UseVisualStyleBackColor = true;
this.buttonCheck.Click += new System.EventHandler(this.ButtonCheck_Click);
buttonCheck.Location = new Point(279, 166);
buttonCheck.Name = "buttonCheck";
buttonCheck.Size = new Size(75, 23);
buttonCheck.TabIndex = 2;
buttonCheck.Text = "Проверка";
buttonCheck.UseVisualStyleBackColor = true;
buttonCheck.Click += ButtonCheck_Click;
//
// myListBox1
// myListBox
//
this.myListBox1.Location = new System.Drawing.Point(12, 12);
this.myListBox1.MinimumSize = new System.Drawing.Size(84, 53);
this.myListBox1.Name = "myListBox1";
this.myListBox1.Size = new System.Drawing.Size(242, 240);
this.myListBox1.TabIndex = 3;
myListBox.Location = new Point(6, 22);
myListBox.MinimumSize = new Size(84, 53);
myListBox.Name = "myListBox";
myListBox.SelectedString = null;
myListBox.Size = new Size(242, 240);
myListBox.TabIndex = 3;
//
// textBox1
// textBoxInput
//
this.textBox1.Location = new System.Drawing.Point(323, 26);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 23);
this.textBox1.TabIndex = 4;
textBoxInput.Location = new Point(254, 25);
textBoxInput.Name = "textBoxInput";
textBoxInput.Size = new Size(100, 23);
textBoxInput.TabIndex = 4;
//
// button1
// buttonAddList
//
this.button1.Location = new System.Drawing.Point(341, 69);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 5;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
buttonAddList.Location = new Point(279, 54);
buttonAddList.Name = "buttonAddList";
buttonAddList.Size = new Size(75, 23);
buttonAddList.TabIndex = 5;
buttonAddList.Text = "Добавить";
buttonAddList.UseVisualStyleBackColor = true;
buttonAddList.Click += ButtonAddList_Click;
//
// button2
// buttonClear
//
this.button2.Location = new System.Drawing.Point(299, 114);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 6;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
buttonClear.Location = new Point(279, 83);
buttonClear.Name = "buttonClear";
buttonClear.Size = new Size(75, 23);
buttonClear.TabIndex = 6;
buttonClear.Text = "Очистить";
buttonClear.UseVisualStyleBackColor = true;
buttonClear.Click += ButtonClear_Click;
//
// groupBox
//
groupBox.Controls.Add(myListBox);
groupBox.Controls.Add(buttonClear);
groupBox.Controls.Add(labelCheck);
groupBox.Controls.Add(buttonAddList);
groupBox.Controls.Add(buttonCheck);
groupBox.Controls.Add(textBoxInput);
groupBox.Location = new Point(12, 12);
groupBox.Name = "groupBox";
groupBox.Size = new Size(368, 271);
groupBox.TabIndex = 7;
groupBox.TabStop = false;
groupBox.Text = "Первый компонент";
//
// FormMain
//
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.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.myListBox1);
this.Controls.Add(this.buttonCheck);
this.Controls.Add(this.labelCheck);
this.Name = "FormMain";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(400, 297);
Controls.Add(groupBox);
Name = "FormMain";
Text = "Form1";
groupBox.ResumeLayout(false);
groupBox.PerformLayout();
ResumeLayout(false);
}
#endregion
private Label labelCheck;
private Button buttonCheck;
private VisualComponentsLib.CustomListBox.MyListBox myListBox1;
private TextBox textBox1;
private Button button1;
private Button button2;
private VisualComponentsLib.CustomListBox.MyListBox myListBox;
private TextBox textBoxInput;
private Button buttonAddList;
private Button buttonClear;
private GroupBox groupBox;
}
}

View File

@ -9,7 +9,19 @@ namespace VisualComponentsForm
private void ButtonCheck_Click(object sender, EventArgs e)
{
labelCheck.Text = myListBox.SelectedString;
}
private void ButtonAddList_Click(object sender, EventArgs e)
{
myListBox.AddItem(textBoxInput.Text);
textBoxInput.Text = string.Empty;
}
private void ButtonClear_Click(object sender, EventArgs e)
{
myListBox.ClearAll();
}
}
}

View File

@ -1,4 +1,64 @@
<root>
<?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">

View File

@ -10,7 +10,6 @@
<ItemGroup>
<ProjectReference Include="..\..\VisualComponentsLib\VisualComponentsLib.csproj" />
<ProjectReference Include="..\..\WinFormsMyComponents\WinFormsMyComponents.csproj" />
</ItemGroup>
</Project>

View File

@ -28,31 +28,30 @@
/// </summary>
private void InitializeComponent()
{
this.listBox = new System.Windows.Forms.ListBox();
this.SuspendLayout();
listBox = new ListBox();
SuspendLayout();
//
// listBox
//
this.listBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.listBox.FormattingEnabled = true;
this.listBox.ItemHeight = 15;
this.listBox.Location = new System.Drawing.Point(3, 3);
this.listBox.Name = "listBox";
this.listBox.Size = new System.Drawing.Size(234, 229);
this.listBox.TabIndex = 0;
listBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.listBox);
this.Location = new System.Drawing.Point(3, 5);
this.MinimumSize = new System.Drawing.Size(84, 53);
this.Name = "MyListBox";
this.Size = new System.Drawing.Size(242, 240);
this.ResumeLayout(false);
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

View File

@ -14,17 +14,27 @@ namespace VisualComponentsLib.CustomListBox
public partial class MyListBox : UserControl
{
[Browsable(true)]
public string selectedString
public string SelectedString
{
get => listBox.SelectedItem.ToString();
get
{
if (listBox.SelectedItems.Count == 0)
{
return null;
}
else
{
return listBox.SelectedItem.ToString();
}
}
set
set
{
if (!string.IsNullOrEmpty(value) && listBox.Items.IndexOf(value) != -1)
{
listBox.SelectedItem = value;
}
}
}
}
public MyListBox()
@ -32,13 +42,7 @@ namespace VisualComponentsLib.CustomListBox
InitializeComponent();
}
public event EventHandler? TextChanged
{
add => listBox.TextChanged += value;
remove => listBox.TextChanged -= value;
}
public void addItem(string item)
public void AddItem(string item)
{
if (!string.IsNullOrEmpty(item))
{
@ -46,9 +50,22 @@ namespace VisualComponentsLib.CustomListBox
}
}
public void clearAll()
public void ClearAll()
{
listBox.Items.Clear();
}
private EventHandler _textChanged;
public event EventHandler? TextChanged
{
add => _textChanged += value;
remove => _textChanged -= value;
}
private void ListBox_SelectedIndexChanged(object sender, EventArgs e)
{
_textChanged?.Invoke(sender, e);
}
}
}

View File

@ -1,4 +1,64 @@
<root>
<?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">