diff --git a/COP/COP.csproj b/COP/COP.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/COP/COP.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/COP/COP.sln b/COP/COP.sln new file mode 100644 index 0000000..d5d4a5f --- /dev/null +++ b/COP/COP.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "COP", "COP.csproj", "{E146CFBA-8D76-44BC-8010-59FE2109E1F6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E146CFBA-8D76-44BC-8010-59FE2109E1F6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {156893E4-8829-479A-A3C9-A042674F4ACD} + EndGlobalSection +EndGlobal diff --git a/COP/Class1.cs b/COP/Class1.cs new file mode 100644 index 0000000..85ba4b6 --- /dev/null +++ b/COP/Class1.cs @@ -0,0 +1,7 @@ +namespace COP +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/COPWinForms/COPWinForms.csproj b/COPWinForms/COPWinForms.csproj new file mode 100644 index 0000000..b57c89e --- /dev/null +++ b/COPWinForms/COPWinForms.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + \ No newline at end of file diff --git a/COPWinForms/ComponentCBox.Designer.cs b/COPWinForms/ComponentCBox.Designer.cs new file mode 100644 index 0000000..84a8053 --- /dev/null +++ b/COPWinForms/ComponentCBox.Designer.cs @@ -0,0 +1,57 @@ +namespace COPWinForms +{ + partial class ComponentCBox + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.comboBox = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // comboBox + // + this.comboBox.FormattingEnabled = true; + this.comboBox.Location = new System.Drawing.Point(0, 0); + this.comboBox.Name = "comboBox"; + this.comboBox.Size = new System.Drawing.Size(151, 28); + this.comboBox.TabIndex = 0; + this.comboBox.SelectedValueChanged += new System.EventHandler(this.comboBox_SelectedValueChanged); + // + // ComponentCBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.comboBox); + this.Name = "ComponentCBox"; + this.ResumeLayout(false); + + } + + #endregion + + private ComboBox comboBox; + } +} diff --git a/COPWinForms/ComponentCBox.cs b/COPWinForms/ComponentCBox.cs new file mode 100644 index 0000000..b4d367f --- /dev/null +++ b/COPWinForms/ComponentCBox.cs @@ -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 COPWinForms +{ + public partial class ComponentCBox : UserControl + { + public ComponentCBox() + { + InitializeComponent(); + } + //метод, у которого в передаваемых параметрах идет список строк и через этот список идет заполнение ComboBox; + public void AddingToList(List Values) + { + if (Values.Count == 0) + { + return; + } + comboBox.Items.AddRange(Values.ToArray()); + } + + //Отдельный публичный метод отчистки списка. + public void Clear() + { + comboBox.Items.Clear(); + } + + //публичное свойство(set, get) для установки и получения выбранного значения (возвращает пустую строку, если нет выбранного значения) + public string Selected + { + get + { + if (comboBox.Items.Count == 0) + { + return ""; + } + if (comboBox.SelectedItem == null) + { + return ""; + } + return comboBox.SelectedItem.ToString()!; + } + set + { + if (comboBox.Items.Contains(value)) + { + comboBox.SelectedItem = value; + } + + } + } + private EventHandler _explicitEvent; + public event EventHandler ExplicitEvent + { + add + { + _explicitEvent += value; + } + remove + { + _explicitEvent -= value; + } + } + //событие, вызываемое при смене значения в ComboBox. + private void comboBox_SelectedValueChanged(object sender, EventArgs e) + { + _explicitEvent?.Invoke(sender, e); + } + } +} diff --git a/COPWinForms/ComponentCBox.resx b/COPWinForms/ComponentCBox.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/COPWinForms/ComponentCBox.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/COPWinForms/ComponentLBox.Designer.cs b/COPWinForms/ComponentLBox.Designer.cs new file mode 100644 index 0000000..a56e1a3 --- /dev/null +++ b/COPWinForms/ComponentLBox.Designer.cs @@ -0,0 +1,59 @@ +namespace COPWinForms +{ + partial class ComponentLBox + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.listBox = new System.Windows.Forms.ListBox(); + this.SuspendLayout(); + // + // listBox + // + this.listBox.FormattingEnabled = true; + this.listBox.HorizontalScrollbar = true; + this.listBox.ItemHeight = 20; + this.listBox.Location = new System.Drawing.Point(0, 0); + this.listBox.Name = "listBox"; + this.listBox.Size = new System.Drawing.Size(278, 144); + this.listBox.TabIndex = 0; + // + // ComponentLBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.listBox); + this.Name = "ComponentLBox"; + this.Size = new System.Drawing.Size(281, 150); + this.ResumeLayout(false); + + } + + #endregion + + private ListBox listBox; + } +} diff --git a/COPWinForms/ComponentLBox.cs b/COPWinForms/ComponentLBox.cs new file mode 100644 index 0000000..3aad4cf --- /dev/null +++ b/COPWinForms/ComponentLBox.cs @@ -0,0 +1,113 @@ +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 COPWinForms +{ + public partial class ComponentLBox : UserControl + { + //Макетная строка + private string layoutString; + //стартовый символ для обнаружения св-в/полей + private string startSymbol; + //конечный символ для обнаружения св-в/полей + private string endSymbol; + + private event Action? _errorOccured; + public string Error { get; private set; } + public ComponentLBox() + { + InitializeComponent(); + Error = string.Empty; + } + + //Метод для установки информации о макетной строке и символах (стартового и конечного) + public void SetLayoutInfo(string layout, string startS, string endS) + { + if (layout == null || startS == null || endS == null) + { + return; + } + layoutString = layout; + startSymbol = startS; + endSymbol = endS; + } + + //св-во для получения и заполнения индекса выбранного элемента + public int SelectedIndex + { + get + { + if (listBox.SelectedIndex == -1) + { + return -1; + } + return listBox.SelectedIndex; + } + set + { + if (listBox.SelectedItems.Count != 0) + { + listBox.SelectedIndex = value; + } + } + } + + //Публичный параметризованный метод для получения объекта из выбранной строки(создать объект и через рефлексию заполнить свойства его). + public T GetObjectFromStr() where T : class, new() + { + string selStr = ""; + if (listBox.SelectedIndex != -1) + { + selStr = listBox.SelectedItem.ToString()!; + } + T curObject = new T(); + foreach (var property in typeof(T).GetProperties()) + { + if (!property.CanWrite) + { + continue; + } + int borderOne = selStr.IndexOf(startSymbol); + StringBuilder sb = new StringBuilder(selStr); + sb[borderOne] = 'a'; + selStr = sb.ToString(); + int borderTwo = selStr.IndexOf(endSymbol); + if (borderOne == -1 || borderTwo == -1) break; + string propertyValue = selStr.Substring(borderOne + 1, borderTwo - borderOne - 1); + selStr = selStr.Substring(borderTwo + 1); + property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType)); + } + return curObject; + } + //параметризованный метод, у которого в передаваемых параметрах идет список объектов какого-то класса и через этот список идет заполнение ListBox; + public void AddInListBox(List objects) + { + if (layoutString == null || startSymbol == null || endSymbol == null) + { + return; + } + if (!layoutString.Contains(startSymbol) || !layoutString.Contains(endSymbol)) + { + return; + } + foreach (var item in objects) + { + string str = layoutString; + foreach (var prop in item.GetType().GetProperties()) + { + string str1 = $"{startSymbol}" + $"{prop.Name}" + $"{endSymbol}"; + str = str.Replace(str1, $"{startSymbol}" + prop.GetValue(item).ToString() + $"{endSymbol}"); + } + listBox.Items.Add(str); + } + + } + } +} diff --git a/COPWinForms/ComponentLBox.resx b/COPWinForms/ComponentLBox.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/COPWinForms/ComponentLBox.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/COPWinForms/ComponentTBox.Designer.cs b/COPWinForms/ComponentTBox.Designer.cs new file mode 100644 index 0000000..66f0599 --- /dev/null +++ b/COPWinForms/ComponentTBox.Designer.cs @@ -0,0 +1,62 @@ +namespace COPWinForms +{ + partial class ComponentTBox + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.textBox = new System.Windows.Forms.TextBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.SuspendLayout(); + // + // textBox + // + this.textBox.Location = new System.Drawing.Point(0, 0); + this.textBox.Name = "textBox"; + this.textBox.Size = new System.Drawing.Size(150, 27); + this.textBox.TabIndex = 0; + this.textBox.TextChanged += new System.EventHandler(this.textBox_TextChanged); + this.textBox.Enter += new System.EventHandler(this.textBox_Enter); + // + // ComponentTBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.textBox); + this.Name = "ComponentTBox"; + this.Size = new System.Drawing.Size(150, 51); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBox; + private ToolTip toolTip1; + } +} diff --git a/COPWinForms/ComponentTBox.cs b/COPWinForms/ComponentTBox.cs new file mode 100644 index 0000000..2c781dc --- /dev/null +++ b/COPWinForms/ComponentTBox.cs @@ -0,0 +1,156 @@ +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.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace COPWinForms +{ + public partial class ComponentTBox : UserControl + { + //Шаблон для textbox + private string? pattern; + //Пример ввода + private string example = "example@gmail.com"; + private event Action? _errorOccured; + + + public string Error { get; private set; } + + public ComponentTBox() + { + InitializeComponent(); + Error = string.Empty; + + } + //Публичное свойство для получения и заполнения шаблона + public string? Pattern + { + get { return pattern; } + set { pattern = value; } + } + //Публичное свойство для получения и заполнения значения + public string? TextBoxValue + { + get + { + + if (pattern != null) { + Regex regex = new Regex(Pattern); + bool isValid = regex.IsMatch(textBox.Text); + if (isValid) + { + return textBox.Text; + } + else + { + Error = "Is not email"; + _errorOccured?.Invoke(); + return null; + } + } + else { + Error = "No pattern"; + _errorOccured?.Invoke(); + return null; + } + } + set + { + if (pattern != null) + { + Regex regex = new Regex(Pattern); + bool isValid = regex.IsMatch(value); + if (isValid) + { + textBox.Text = value; + } + else + { + Error = "Is not email"; + _errorOccured?.Invoke(); + return; + } + + } + else + { + Error = "No pattern"; + _errorOccured?.Invoke(); + return; + } + } + } + + //Метод для заполнения примера + public void setExample(string str) + { + if (pattern != null) + { + Regex regex = new Regex(Pattern); + bool isValid = regex.IsMatch(str); + if (isValid) + { + example = str; + } + } + else + { + Error = "No pattern"; + _errorOccured?.Invoke(); + return; + } + + + } + + //ToolTip для вывода примера + private void textBox_Enter(object sender, EventArgs e) + { + int VisibleTime = 3000; //in milliseconds + + ToolTip tt = new ToolTip(); + tt.Show(example, textBox, 0, 20, VisibleTime); + } + + private EventHandler _explicitEvent; + public event EventHandler ExplicitEvent + { + add + { + _explicitEvent += value; + } + remove + { + _explicitEvent -= value; + } + } + public event Action AnErrorOccurred + { + add { _errorOccured += value; } + remove { _errorOccured -= value; } + } + + //событие при смене значения + private void textBox_TextChanged(object sender, EventArgs e) + { + try + { + _explicitEvent?.Invoke(sender, e); + } + catch (Exception ex) + { + Error = ex.Message; + _errorOccured?.Invoke(); + } + + } + + } +} diff --git a/COPWinForms/ComponentTBox.resx b/COPWinForms/ComponentTBox.resx new file mode 100644 index 0000000..ec38833 --- /dev/null +++ b/COPWinForms/ComponentTBox.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 22, 26 + + \ No newline at end of file diff --git a/COPWinForms/Program.cs b/COPWinForms/Program.cs new file mode 100644 index 0000000..d933728 --- /dev/null +++ b/COPWinForms/Program.cs @@ -0,0 +1,17 @@ +namespace COPWinForms +{ + 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(); + } + } +} \ No newline at end of file diff --git a/COPWinForms/Student.cs b/COPWinForms/Student.cs new file mode 100644 index 0000000..7a36b18 --- /dev/null +++ b/COPWinForms/Student.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace COPWinForms +{ + public class Student + { + public string FIO { get; set; } + public string Group { get; set; } + public string Email { get; set; } + + public Student(string fIO, string group, string email) + { + FIO = fIO; + Group = group; + Email = email; + } + + public Student() { } + } +} diff --git a/COP_1/COP_1.csproj b/COP_1/COP_1.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/COP_1/COP_1.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/COP_1/COP_1.sln b/COP_1/COP_1.sln new file mode 100644 index 0000000..63986ab --- /dev/null +++ b/COP_1/COP_1.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COP_1", "COP_1.csproj", "{3A354E62-6788-412B-8F8F-5A3484373BDA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "COPWinForms", "..\COPWinForms\COPWinForms.csproj", "{C88D51BC-B17E-40DD-BC69-480DD08ED488}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsTest", "..\WinFormsTest\WinFormsTest.csproj", "{75E77B58-7C69-4C52-8283-03EBC03D2C85}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3A354E62-6788-412B-8F8F-5A3484373BDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A354E62-6788-412B-8F8F-5A3484373BDA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A354E62-6788-412B-8F8F-5A3484373BDA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A354E62-6788-412B-8F8F-5A3484373BDA}.Release|Any CPU.Build.0 = Release|Any CPU + {C88D51BC-B17E-40DD-BC69-480DD08ED488}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C88D51BC-B17E-40DD-BC69-480DD08ED488}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C88D51BC-B17E-40DD-BC69-480DD08ED488}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C88D51BC-B17E-40DD-BC69-480DD08ED488}.Release|Any CPU.Build.0 = Release|Any CPU + {75E77B58-7C69-4C52-8283-03EBC03D2C85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75E77B58-7C69-4C52-8283-03EBC03D2C85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75E77B58-7C69-4C52-8283-03EBC03D2C85}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7DE53E23-1C86-4BF5-A79B-AEC5B8C88A43} + EndGlobalSection +EndGlobal diff --git a/COP_1/Class1.cs b/COP_1/Class1.cs new file mode 100644 index 0000000..3204174 --- /dev/null +++ b/COP_1/Class1.cs @@ -0,0 +1,7 @@ +namespace COP_1 +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/WinFormsTest/FormTestApp.Designer.cs b/WinFormsTest/FormTestApp.Designer.cs new file mode 100644 index 0000000..74c7af7 --- /dev/null +++ b/WinFormsTest/FormTestApp.Designer.cs @@ -0,0 +1,199 @@ +namespace WinFormsTest +{ + partial class FormTestApp + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.buttonShow = new System.Windows.Forms.Button(); + this.textBoxShow = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.buttonShowTB = new System.Windows.Forms.Button(); + this.textBoxShowTB = new System.Windows.Forms.TextBox(); + this.buttonShowItem = new System.Windows.Forms.Button(); + this.componenttBox1 = new COPWinForms.ComponentTBox(); + this.componentlBox1 = new COPWinForms.ComponentLBox(); + this.textBoxShowItem = new System.Windows.Forms.TextBox(); + this.componentcBox1 = new COPWinForms.ComponentCBox(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(36, 12); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(83, 20); + this.label1.TabIndex = 3; + this.label1.Text = "ComboBox"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(369, 12); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(61, 20); + this.label2.TabIndex = 4; + this.label2.Text = "TextBox"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(736, 12); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(56, 20); + this.label3.TabIndex = 5; + this.label3.Text = "ListBox"; + // + // buttonShow + // + this.buttonShow.Location = new System.Drawing.Point(32, 126); + this.buttonShow.Name = "buttonShow"; + this.buttonShow.Size = new System.Drawing.Size(149, 29); + this.buttonShow.TabIndex = 6; + this.buttonShow.Text = "Показать"; + this.buttonShow.UseVisualStyleBackColor = true; + this.buttonShow.Click += new System.EventHandler(this.buttonShow_Click); + // + // textBoxShow + // + this.textBoxShow.Location = new System.Drawing.Point(32, 161); + this.textBoxShow.Name = "textBoxShow"; + this.textBoxShow.Size = new System.Drawing.Size(149, 27); + this.textBoxShow.TabIndex = 7; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(32, 194); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(149, 29); + this.button1.TabIndex = 8; + this.button1.Text = "Очистить"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.buttonClear_Click); + // + // buttonShowTB + // + this.buttonShowTB.Location = new System.Drawing.Point(369, 126); + this.buttonShowTB.Name = "buttonShowTB"; + this.buttonShowTB.Size = new System.Drawing.Size(163, 29); + this.buttonShowTB.TabIndex = 9; + this.buttonShowTB.Text = "Проверить"; + this.buttonShowTB.UseVisualStyleBackColor = true; + this.buttonShowTB.Click += new System.EventHandler(this.buttonShowTB_Click); + // + // textBoxShowTB + // + this.textBoxShowTB.Location = new System.Drawing.Point(369, 161); + this.textBoxShowTB.Name = "textBoxShowTB"; + this.textBoxShowTB.Size = new System.Drawing.Size(163, 27); + this.textBoxShowTB.TabIndex = 10; + // + // buttonShowItem + // + this.buttonShowItem.Location = new System.Drawing.Point(711, 207); + this.buttonShowItem.Name = "buttonShowItem"; + this.buttonShowItem.Size = new System.Drawing.Size(279, 29); + this.buttonShowItem.TabIndex = 15; + this.buttonShowItem.Text = "Получить значение"; + this.buttonShowItem.UseVisualStyleBackColor = true; + this.buttonShowItem.Click += new System.EventHandler(this.buttonShowItem_Click); + // + // componenttBox1 + // + this.componenttBox1.Location = new System.Drawing.Point(369, 53); + this.componenttBox1.Name = "componenttBox1"; + this.componenttBox1.Pattern = null; + this.componenttBox1.Size = new System.Drawing.Size(188, 46); + this.componenttBox1.TabIndex = 16; + // + // componentlBox1 + // + this.componentlBox1.Location = new System.Drawing.Point(711, 53); + this.componentlBox1.Name = "componentlBox1"; + this.componentlBox1.SelectedIndex = -1; + this.componentlBox1.Size = new System.Drawing.Size(351, 148); + this.componentlBox1.TabIndex = 17; + // + // textBoxShowItem + // + this.textBoxShowItem.Location = new System.Drawing.Point(711, 249); + this.textBoxShowItem.Name = "textBoxShowItem"; + this.textBoxShowItem.Size = new System.Drawing.Size(279, 27); + this.textBoxShowItem.TabIndex = 18; + // + // componentcBox1 + // + this.componentcBox1.Location = new System.Drawing.Point(32, 49); + this.componentcBox1.Name = "componentcBox1"; + this.componentcBox1.Selected = ""; + this.componentcBox1.Size = new System.Drawing.Size(188, 50); + this.componentcBox1.TabIndex = 19; + this.componentcBox1.CursorChanged += new System.EventHandler(this.componentcBox1_ExplicitEvent); + // + // FormTestApp + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1027, 288); + this.Controls.Add(this.componentcBox1); + this.Controls.Add(this.textBoxShowItem); + this.Controls.Add(this.componentlBox1); + this.Controls.Add(this.componenttBox1); + this.Controls.Add(this.buttonShowItem); + this.Controls.Add(this.textBoxShowTB); + this.Controls.Add(this.buttonShowTB); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBoxShow); + this.Controls.Add(this.buttonShow); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "FormTestApp"; + this.Text = "Тест"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + private Label label1; + private Label label2; + private Label label3; + private Button buttonShow; + private TextBox textBoxShow; + private Button button1; + private Button buttonShowTB; + private TextBox textBoxShowTB; + private Button buttonShowItem; + private COPWinForms.ComponentTBox componenttBox1; + private COPWinForms.ComponentLBox componentlBox1; + private TextBox textBoxShowItem; + private COPWinForms.ComponentCBox componentcBox1; + } + + #endregion +} diff --git a/WinFormsTest/FormTestApp.cs b/WinFormsTest/FormTestApp.cs new file mode 100644 index 0000000..175fdc4 --- /dev/null +++ b/WinFormsTest/FormTestApp.cs @@ -0,0 +1,98 @@ +using COPWinForms; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace WinFormsTest +{ + public partial class FormTestApp : Form + { + List list = new List(); + List students = new List(); + public FormTestApp() + { + list = new List(); + list.AddRange(new string[] { " 1", " 2", " 3", " 4", " 5" }); + + Student student1 = new Student(" ..", "-32", "rogashovae@mail.ru"); + Student student2 = new Student(" ..", "-11", "petrov@gmail.com"); + Student student3 = new Student(" ..", "-41", "noskovaaa@gmail.com"); + Student student4 = new Student(" ..", "C-41", "noskovaa@gmail.com"); + + students.Add(student1); + students.Add(student2); + students.Add(student3); + students.Add(student4); + InitializeComponent(); + + componenttBox1.Pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"; + componentlBox1.SetLayoutInfo(": *FIO* : *Group* Email: *Email*", "*", "*"); + componentlBox1.AddInListBox(students); + componentcBox1.AddingToList(new List() { "", "", "" }); + componentcBox1.ExplicitEvent += Event_Handler; + componenttBox1.ExplicitEvent += Event_Handler; + componenttBox1.setExample("eeee@mail.ru"); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + componentcBox1.AddingToList(list); + } + + private void Event_Handler(object sender, EventArgs e) + { + MessageBox.Show(""); + } + + private void buttonShow_Click(object sender, EventArgs e) + { + textBoxShow.Text = componentcBox1.Selected; + } + + private void buttonClear_Click(object sender, EventArgs e) + { + componentcBox1.Clear(); + } + + + //private void buttonSetExample_Click(object sender, EventArgs e) + //{ + // if (textBoxExample.Text == String.Empty) + // { + // return; + // } + // componenttBox1.setExample(textBoxExample.Text); + //} + + private void buttonShowTB_Click(object sender, EventArgs e) + { + try + { + if (componenttBox1.TextBoxValue != null) + { + textBoxShowTB.Text = "true"; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + + + } + + private void button1_Click(object sender, EventArgs e) + { + componentlBox1.AddInListBox(students); + } + + private void buttonShowItem_Click(object sender, EventArgs e) + { + string str = componentlBox1.GetObjectFromStr().FIO + " " + componentlBox1.GetObjectFromStr().Group + " " + componentlBox1.GetObjectFromStr().Email; + textBoxShowItem.Text = str; + } + private void componentcBox1_ExplicitEvent(object sender, EventArgs e) + { + MessageBox.Show("Change avatar"); + } + } +} \ No newline at end of file diff --git a/WinFormsTest/FormTestApp.resx b/WinFormsTest/FormTestApp.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/WinFormsTest/FormTestApp.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/WinFormsTest/Program.cs b/WinFormsTest/Program.cs new file mode 100644 index 0000000..6b1b5be --- /dev/null +++ b/WinFormsTest/Program.cs @@ -0,0 +1,17 @@ +namespace WinFormsTest +{ + 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 FormTestApp()); + } + } +} \ No newline at end of file diff --git a/WinFormsTest/WinFormsTest.csproj b/WinFormsTest/WinFormsTest.csproj new file mode 100644 index 0000000..e5d67dc --- /dev/null +++ b/WinFormsTest/WinFormsTest.csproj @@ -0,0 +1,15 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + \ No newline at end of file