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

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 VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsForm", "VisualComponentsForm\VisualComponentsForm.csproj", "{29E20B1C-11E3-4B0D-A614-097ACBB21263}" 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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsLib", "..\VisualComponentsLib\VisualComponentsLib.csproj", "{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VisualComponentsLib", "..\VisualComponentsLib\VisualComponentsLib.csproj", "{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsMyComponents", "..\WinFormsMyComponents\WinFormsMyComponents.csproj", "{317EA9D6-B5A5-44FE-B524-D646B518CB3E}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

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

View File

@ -9,7 +9,19 @@ namespace VisualComponentsForm
private void ButtonCheck_Click(object sender, EventArgs e) 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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

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

View File

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

View File

@ -14,9 +14,19 @@ namespace VisualComponentsLib.CustomListBox
public partial class MyListBox : UserControl public partial class MyListBox : UserControl
{ {
[Browsable(true)] [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
{ {
@ -32,13 +42,7 @@ namespace VisualComponentsLib.CustomListBox
InitializeComponent(); InitializeComponent();
} }
public event EventHandler? TextChanged public void AddItem(string item)
{
add => listBox.TextChanged += value;
remove => listBox.TextChanged -= value;
}
public void addItem(string item)
{ {
if (!string.IsNullOrEmpty(item)) if (!string.IsNullOrEmpty(item))
{ {
@ -46,9 +50,22 @@ namespace VisualComponentsLib.CustomListBox
} }
} }
public void clearAll() public void ClearAll()
{ {
listBox.Items.Clear(); 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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">