From 19440709315a396dbebdbc24b0ca7bb40d5fcb09 Mon Sep 17 00:00:00 2001 From: ElEgEv <12032003> Date: Wed, 13 Sep 2023 14:47:07 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VisualComponentsForm/FormMain.Designer.cs | 86 ++++++++++++- .../VisualComponentsForm/FormMain.cs | 5 + .../VisualComponentsForm/FormMain.resx | 62 +-------- .../VisualComponentsForm.csproj | 1 + VisualComponentsLib/Form1.Designer.cs | 39 ------ VisualComponentsLib/Form1.cs | 20 --- VisualComponentsLib/Form1.resx | 120 ------------------ VisualComponentsLib/MyListBox.Designer.cs | 75 +++-------- VisualComponentsLib/MyListBox.cs | 21 +-- VisualComponentsLib/MyListBox.resx | 62 +-------- VisualComponentsLib/Program.cs | 23 ---- .../VisualComponentsLib.csproj | 2 +- 12 files changed, 124 insertions(+), 392 deletions(-) delete mode 100644 VisualComponentsLib/Form1.Designer.cs delete mode 100644 VisualComponentsLib/Form1.cs delete mode 100644 VisualComponentsLib/Form1.resx delete mode 100644 VisualComponentsLib/Program.cs diff --git a/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs b/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs index 98a0549..6f4f5df 100644 --- a/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs +++ b/VisualComponentsForm/VisualComponentsForm/FormMain.Designer.cs @@ -28,12 +28,90 @@ /// private void InitializeComponent() { - components = new System.ComponentModel.Container(); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Text = "Form1"; + 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 + // + 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"; + // + // 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); + // + // myListBox1 + // + 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; + // + // textBox1 + // + 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; + // + // button1 + // + 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; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(346, 120); + 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; + // + // 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(); + } #endregion + private Label labelCheck; + private Button buttonCheck; + private VisualComponentsLib.CustomListBox.MyListBox myListBox1; + private TextBox textBox1; + private Button button1; + private Button button2; } } \ No newline at end of file diff --git a/VisualComponentsForm/VisualComponentsForm/FormMain.cs b/VisualComponentsForm/VisualComponentsForm/FormMain.cs index c5ccc56..ae0c68d 100644 --- a/VisualComponentsForm/VisualComponentsForm/FormMain.cs +++ b/VisualComponentsForm/VisualComponentsForm/FormMain.cs @@ -6,5 +6,10 @@ namespace VisualComponentsForm { InitializeComponent(); } + + private void ButtonCheck_Click(object sender, EventArgs e) + { + + } } } \ No newline at end of file diff --git a/VisualComponentsForm/VisualComponentsForm/FormMain.resx b/VisualComponentsForm/VisualComponentsForm/FormMain.resx index a395bff..f298a7b 100644 --- a/VisualComponentsForm/VisualComponentsForm/FormMain.resx +++ b/VisualComponentsForm/VisualComponentsForm/FormMain.resx @@ -1,64 +1,4 @@ - - - + diff --git a/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj b/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj index a40f00b..eb55cd9 100644 --- a/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj +++ b/VisualComponentsForm/VisualComponentsForm/VisualComponentsForm.csproj @@ -9,6 +9,7 @@ + diff --git a/VisualComponentsLib/Form1.Designer.cs b/VisualComponentsLib/Form1.Designer.cs deleted file mode 100644 index aaf08ec..0000000 --- a/VisualComponentsLib/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace VisualComponentsLib -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - 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"; - } - - #endregion - } -} \ No newline at end of file diff --git a/VisualComponentsLib/Form1.cs b/VisualComponentsLib/Form1.cs deleted file mode 100644 index dc46618..0000000 --- a/VisualComponentsLib/Form1.cs +++ /dev/null @@ -1,20 +0,0 @@ -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 VisualComponentsLib -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/VisualComponentsLib/Form1.resx b/VisualComponentsLib/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/VisualComponentsLib/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VisualComponentsLib/MyListBox.Designer.cs b/VisualComponentsLib/MyListBox.Designer.cs index 61bdbd5..fec6703 100644 --- a/VisualComponentsLib/MyListBox.Designer.cs +++ b/VisualComponentsLib/MyListBox.Designer.cs @@ -28,70 +28,35 @@ /// private void InitializeComponent() { - listBox = new ListBox(); - buttonAdd = new Button(); - textBox = new TextBox(); - buttonRemove = new Button(); - SuspendLayout(); + this.listBox = new System.Windows.Forms.ListBox(); + this.SuspendLayout(); // // listBox // - 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; + 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; // - // buttonAdd + // MyListBox // - buttonAdd.Location = new Point(261, 52); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(114, 23); - buttonAdd.TabIndex = 1; - buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += ButtonAdd_Click; - // - // textBox - // - textBox.Location = new Point(252, 12); - textBox.Name = "textBox"; - textBox.Size = new Size(133, 23); - textBox.TabIndex = 2; - // - // buttonRemove - // - buttonRemove.Location = new Point(261, 96); - buttonRemove.Name = "buttonRemove"; - buttonRemove.Size = new Size(114, 23); - buttonRemove.TabIndex = 3; - buttonRemove.Text = "Очистить список"; - buttonRemove.UseVisualStyleBackColor = true; - buttonRemove.Click += ButtonRemove_Click; - // - // UserListBox - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - Controls.Add(buttonRemove); - Controls.Add(textBox); - Controls.Add(buttonAdd); - Controls.Add(listBox); - Location = new Point(3, 5); - MinimumSize = new Size(84, 53); - Name = "UserListBox"; - Size = new Size(398, 240); - ResumeLayout(false); - PerformLayout(); + 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); + } #endregion private ListBox listBox; - private Button buttonAdd; - private TextBox textBox; - private Button buttonRemove; } } diff --git a/VisualComponentsLib/MyListBox.cs b/VisualComponentsLib/MyListBox.cs index 05d216f..4deedae 100644 --- a/VisualComponentsLib/MyListBox.cs +++ b/VisualComponentsLib/MyListBox.cs @@ -17,7 +17,14 @@ namespace VisualComponentsLib.CustomListBox public string selectedString { get => listBox.SelectedItem.ToString(); - set => listBox.SelectedItem = value; + + set + { + if (!string.IsNullOrEmpty(value) && listBox.Items.IndexOf(value) != -1) + { + listBox.SelectedItem = value; + } + } } public MyListBox() @@ -26,23 +33,21 @@ namespace VisualComponentsLib.CustomListBox } [Browsable(true)] - public new event EventHandler? TextChanged + public event EventHandler? TextChanged { add => listBox.Items.Add(value); remove => listBox.Items.Clear(); } - private void ButtonAdd_Click(object sender, EventArgs e) + private void addItem(string item) { - if (!string.IsNullOrEmpty(textBox.Text)) + if (!string.IsNullOrEmpty(item)) { - listBox.Items.Add(textBox.Text); - - textBox.Text = string.Empty; + listBox.Items.Add(item); } } - private void ButtonRemove_Click(object sender, EventArgs e) + private void clearAll() { listBox.Items.Clear(); } diff --git a/VisualComponentsLib/MyListBox.resx b/VisualComponentsLib/MyListBox.resx index a395bff..f298a7b 100644 --- a/VisualComponentsLib/MyListBox.resx +++ b/VisualComponentsLib/MyListBox.resx @@ -1,64 +1,4 @@ - - - + diff --git a/VisualComponentsLib/Program.cs b/VisualComponentsLib/Program.cs deleted file mode 100644 index cd75e1a..0000000 --- a/VisualComponentsLib/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VisualComponentsLib -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [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()); - } - } -} diff --git a/VisualComponentsLib/VisualComponentsLib.csproj b/VisualComponentsLib/VisualComponentsLib.csproj index fd51cd6..db6be70 100644 --- a/VisualComponentsLib/VisualComponentsLib.csproj +++ b/VisualComponentsLib/VisualComponentsLib.csproj @@ -5,7 +5,7 @@ enable true enable - WinExe + Library