Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
77764ab6fa | |||
016779550c | |||
6862daad73 | |||
c8777e4549 | |||
c23bc5c7c1 | |||
c73d358184 |
10
Components/Components.csproj
Normal file
10
Components/Components.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
70
Components/CustomComboBox.Designer.cs
generated
Normal file
70
Components/CustomComboBox.Designer.cs
generated
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class CustomComboBox
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
comboBox = new ComboBox();
|
||||||
|
textBox1 = new TextBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBox
|
||||||
|
//
|
||||||
|
comboBox.FormattingEnabled = true;
|
||||||
|
comboBox.Location = new Point(10, 36);
|
||||||
|
comboBox.Name = "comboBox";
|
||||||
|
comboBox.Size = new Size(230, 28);
|
||||||
|
comboBox.TabIndex = 0;
|
||||||
|
comboBox.SelectedIndexChanged += CustomComboBox_SelectedValueChanged;
|
||||||
|
//
|
||||||
|
// textBox1
|
||||||
|
//
|
||||||
|
textBox1.Location = new Point(10, 3);
|
||||||
|
textBox1.Name = "textBox1";
|
||||||
|
textBox1.Size = new Size(230, 27);
|
||||||
|
textBox1.TabIndex = 1;
|
||||||
|
textBox1.Text = "Выпадающий список";
|
||||||
|
//
|
||||||
|
// CustomComboBox
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
Controls.Add(textBox1);
|
||||||
|
Controls.Add(comboBox);
|
||||||
|
Name = "CustomComboBox";
|
||||||
|
Size = new Size(248, 73);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBox;
|
||||||
|
private TextBox textBox1;
|
||||||
|
}
|
||||||
|
}
|
60
Components/CustomComboBox.cs
Normal file
60
Components/CustomComboBox.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
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 Components
|
||||||
|
{
|
||||||
|
public partial class CustomComboBox : UserControl
|
||||||
|
{
|
||||||
|
public CustomComboBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearComboBox()
|
||||||
|
{
|
||||||
|
comboBox.Items.Clear();
|
||||||
|
comboBox.SelectedItem = null;
|
||||||
|
comboBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SelectedItem
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return comboBox.SelectedItem?.ToString() ?? string.Empty; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBox.SelectedItem = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComboBox.ObjectCollection ComboBoxItems
|
||||||
|
{
|
||||||
|
get { return comboBox.Items; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventHandler _onValueChangedEvent;
|
||||||
|
public event EventHandler ValueChangedEvent
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
_onValueChangedEvent += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
_onValueChangedEvent -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CustomComboBox_SelectedValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_onValueChangedEvent?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Components/CustomComboBox.resx
Normal file
120
Components/CustomComboBox.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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">
|
||||||
|
<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>
|
57
Components/CustomListBox.Designer.cs
generated
Normal file
57
Components/CustomListBox.Designer.cs
generated
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class CustomListBox
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
listBox = new ListBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// listBox
|
||||||
|
//
|
||||||
|
listBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
listBox.FormattingEnabled = true;
|
||||||
|
listBox.Location = new Point(9, 5);
|
||||||
|
listBox.Name = "listBox";
|
||||||
|
listBox.Size = new Size(814, 384);
|
||||||
|
listBox.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// CustomListBox
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(listBox);
|
||||||
|
Name = "CustomListBox";
|
||||||
|
Size = new Size(828, 410);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ListBox listBox;
|
||||||
|
}
|
||||||
|
}
|
147
Components/CustomListBox.cs
Normal file
147
Components/CustomListBox.cs
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
public partial class CustomListBox : UserControl
|
||||||
|
{
|
||||||
|
public CustomListBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string template;
|
||||||
|
private string start;
|
||||||
|
private string end;
|
||||||
|
|
||||||
|
public void setTemplate(string _template, string _start, string _end)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_template) || string.IsNullOrEmpty(_start) || string.IsNullOrEmpty(_end))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Wrong template");
|
||||||
|
}
|
||||||
|
template = _template;
|
||||||
|
start = _start;
|
||||||
|
end = _end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SelectedRow
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return listBox.SelectedIndex;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 0) return;
|
||||||
|
listBox.SelectedIndex = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetObjectFromStr<T>() where T : class, new()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (listBox.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
string row = listBox.SelectedItem.ToString();
|
||||||
|
T curObject = new T();
|
||||||
|
StringBuilder sb = new StringBuilder(row);
|
||||||
|
|
||||||
|
//MessageBox.Show(sb.ToString());
|
||||||
|
|
||||||
|
string[] words = template.Split(new[] { char.Parse(start), char.Parse(end) });
|
||||||
|
|
||||||
|
// Дорогой дневник, мне не подобрать слов чтобы описать всю {Mood}, что я испытал сегодня; {Date}
|
||||||
|
// Дорогой дневник, мне не подобрать слов чтобы описать всю радость, что я испытал сегодня; 01.01.01
|
||||||
|
|
||||||
|
StringBuilder myrow = new StringBuilder(row);
|
||||||
|
List<string> flexPartsTemplate = new();
|
||||||
|
foreach (string word in words)
|
||||||
|
{
|
||||||
|
if (row.Contains(word) && !string.IsNullOrEmpty(word))
|
||||||
|
{
|
||||||
|
myrow.Replace(word, end);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flexPartsTemplate.Add(word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string[] flexParts = myrow.ToString().Split(end);
|
||||||
|
int i = 1;
|
||||||
|
StringBuilder result = new StringBuilder(template);
|
||||||
|
foreach (string word in flexPartsTemplate)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(word))
|
||||||
|
{
|
||||||
|
result.Replace(word, flexParts[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sb = result;
|
||||||
|
|
||||||
|
foreach (var property in typeof(T).GetProperties())
|
||||||
|
{
|
||||||
|
if (!property.CanWrite)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//MessageBox.Show(property.Name);
|
||||||
|
|
||||||
|
int startBorder = sb.ToString().IndexOf(start);
|
||||||
|
if (startBorder == -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int endBorder = sb.ToString().IndexOf(end, startBorder + 1);
|
||||||
|
if (endBorder == -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string propertyValue = sb.ToString(startBorder + 1, endBorder - startBorder - 1);
|
||||||
|
sb.Remove(0, endBorder + 1);
|
||||||
|
property.SetValue(curObject, Convert.ChangeType(propertyValue, property.PropertyType));
|
||||||
|
}
|
||||||
|
return curObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FillProperty<T>(T dataObject, int rowIndex, string propertyName)
|
||||||
|
{
|
||||||
|
while (listBox.Items.Count <= rowIndex)
|
||||||
|
{
|
||||||
|
listBox.Items.Add(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
string row = listBox.Items[rowIndex].ToString();
|
||||||
|
PropertyInfo propertyInfo = dataObject.GetType().GetProperty(propertyName);
|
||||||
|
|
||||||
|
if (propertyInfo != null)
|
||||||
|
{
|
||||||
|
var propertyValue = propertyInfo.GetValue(dataObject);
|
||||||
|
row = row.Replace($"{start}{propertyName}{end}", propertyValue.ToString());
|
||||||
|
listBox.Items[rowIndex] = row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CountRows()
|
||||||
|
{
|
||||||
|
return listBox.Items.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Components/CustomListBox.resx
Normal file
120
Components/CustomListBox.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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">
|
||||||
|
<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>
|
70
Components/CustomTextBox.Designer.cs
generated
Normal file
70
Components/CustomTextBox.Designer.cs
generated
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
partial class CustomTextBox
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
textBox = new TextBox();
|
||||||
|
textBox1 = new TextBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBox
|
||||||
|
//
|
||||||
|
textBox.Location = new Point(3, 40);
|
||||||
|
textBox.Name = "textBox";
|
||||||
|
textBox.Size = new Size(249, 27);
|
||||||
|
textBox.TabIndex = 0;
|
||||||
|
textBox.Click += showToolTip;
|
||||||
|
textBox.Leave += CustomTextBox_TextChanged;
|
||||||
|
//
|
||||||
|
// textBox1
|
||||||
|
//
|
||||||
|
textBox1.Location = new Point(3, 7);
|
||||||
|
textBox1.Name = "textBox1";
|
||||||
|
textBox1.Size = new Size(249, 27);
|
||||||
|
textBox1.TabIndex = 2;
|
||||||
|
textBox1.Text = "Поле для ввода номера телефона";
|
||||||
|
//
|
||||||
|
// CustomTextBox
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
Controls.Add(textBox1);
|
||||||
|
Controls.Add(textBox);
|
||||||
|
Name = "CustomTextBox";
|
||||||
|
Size = new Size(259, 68);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBox;
|
||||||
|
private TextBox textBox1;
|
||||||
|
}
|
||||||
|
}
|
95
Components/CustomTextBox.cs
Normal file
95
Components/CustomTextBox.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using Components.Exceptions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
public partial class CustomTextBox : UserControl
|
||||||
|
{
|
||||||
|
public CustomTextBox()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _numberPattern;
|
||||||
|
public string numberPattern
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _numberPattern;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_numberPattern = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string textBoxNumber
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_numberPattern == null)
|
||||||
|
{
|
||||||
|
throw new CustomException("there is no pattern");
|
||||||
|
}
|
||||||
|
Regex regex = new(_numberPattern);
|
||||||
|
if (regex.IsMatch(textBox.Text))
|
||||||
|
{
|
||||||
|
return textBox.Text;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new CustomException("there is wrong pattern");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_numberPattern))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Regex regex = new(_numberPattern);
|
||||||
|
if (regex.IsMatch(value))
|
||||||
|
{
|
||||||
|
textBox.Text = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textBox.Text = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showToolTip(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ToolTip tt = new ToolTip();
|
||||||
|
tt.Show("+X XXX XXX XX XX" , textBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EventHandler _onValueChangedEvent;
|
||||||
|
|
||||||
|
public event EventHandler ValueChangedEvent
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
_onValueChangedEvent += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
_onValueChangedEvent -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CustomTextBox_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_onValueChangedEvent?.Invoke(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Components/CustomTextBox.resx
Normal file
120
Components/CustomTextBox.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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">
|
||||||
|
<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>
|
14
Components/Exceptions/CustomException.cs
Normal file
14
Components/Exceptions/CustomException.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Components.Exceptions
|
||||||
|
{
|
||||||
|
public class CustomException: Exception
|
||||||
|
{
|
||||||
|
public CustomException() { }
|
||||||
|
public CustomException(string message) : base(message) { }
|
||||||
|
}
|
||||||
|
}
|
31
CustomComboBox/CustomComboBox.sln
Normal file
31
CustomComboBox/CustomComboBox.sln
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.11.35222.181
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Components", "..\Components\Components.csproj", "{52A015B2-0077-47D3-9BC8-F378C3BCF965}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{BF4A0F84-CD73-443C-A480-B54A9A0B7867}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{52A015B2-0077-47D3-9BC8-F378C3BCF965}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{52A015B2-0077-47D3-9BC8-F378C3BCF965}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{52A015B2-0077-47D3-9BC8-F378C3BCF965}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{52A015B2-0077-47D3-9BC8-F378C3BCF965}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BF4A0F84-CD73-443C-A480-B54A9A0B7867}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {F37036A6-D640-4CD0-8488-B7A0518B4EB8}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
6
CustomComboBox/CustomComboBox/Class1.cs
Normal file
6
CustomComboBox/CustomComboBox/Class1.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace CustomComboBox
|
||||||
|
{
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
10
CustomComboBox/CustomComboBox/CustomComboBox.csproj
Normal file
10
CustomComboBox/CustomComboBox/CustomComboBox.csproj
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
14
CustomComboBox/TestApp/Day.cs
Normal file
14
CustomComboBox/TestApp/Day.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public class Day
|
||||||
|
{
|
||||||
|
public string Mood { get; set; }
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
}
|
||||||
|
}
|
172
CustomComboBox/TestApp/Form1.Designer.cs
generated
Normal file
172
CustomComboBox/TestApp/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
customComboBox = new Components.CustomComboBox();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
buttonClear = new Button();
|
||||||
|
buttonGet = new Button();
|
||||||
|
customTextBox = new Components.CustomTextBox();
|
||||||
|
customListBox = new Components.CustomListBox();
|
||||||
|
buttonDay = new Button();
|
||||||
|
buttonAddDay = new Button();
|
||||||
|
textBoxMood = new TextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// customComboBox
|
||||||
|
//
|
||||||
|
customComboBox.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
customComboBox.Location = new Point(12, 0);
|
||||||
|
customComboBox.Name = "customComboBox";
|
||||||
|
customComboBox.SelectedItem = "";
|
||||||
|
customComboBox.Size = new Size(252, 91);
|
||||||
|
customComboBox.TabIndex = 0;
|
||||||
|
customComboBox.ValueChangedEvent += customComboBox_ValueChanged;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(5, 97);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(94, 29);
|
||||||
|
buttonAdd.TabIndex = 1;
|
||||||
|
buttonAdd.Text = "Add";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
|
//
|
||||||
|
// buttonClear
|
||||||
|
//
|
||||||
|
buttonClear.Location = new Point(105, 97);
|
||||||
|
buttonClear.Name = "buttonClear";
|
||||||
|
buttonClear.Size = new Size(94, 29);
|
||||||
|
buttonClear.TabIndex = 2;
|
||||||
|
buttonClear.Text = "Clear";
|
||||||
|
buttonClear.UseVisualStyleBackColor = true;
|
||||||
|
buttonClear.Click += buttonClear_Click;
|
||||||
|
//
|
||||||
|
// buttonGet
|
||||||
|
//
|
||||||
|
buttonGet.Location = new Point(205, 97);
|
||||||
|
buttonGet.Name = "buttonGet";
|
||||||
|
buttonGet.Size = new Size(94, 29);
|
||||||
|
buttonGet.TabIndex = 3;
|
||||||
|
buttonGet.Text = "Get";
|
||||||
|
buttonGet.UseVisualStyleBackColor = true;
|
||||||
|
buttonGet.Click += buttonGet_Click;
|
||||||
|
//
|
||||||
|
// customTextBox
|
||||||
|
//
|
||||||
|
customTextBox.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
customTextBox.Location = new Point(12, 144);
|
||||||
|
customTextBox.Name = "customTextBox";
|
||||||
|
customTextBox.numberPattern = null;
|
||||||
|
customTextBox.Size = new Size(258, 88);
|
||||||
|
customTextBox.TabIndex = 4;
|
||||||
|
customTextBox.ValueChangedEvent += customTextBox_ValueChanged;
|
||||||
|
//
|
||||||
|
// customListBox
|
||||||
|
//
|
||||||
|
customListBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
customListBox.Location = new Point(296, 0);
|
||||||
|
customListBox.Name = "customListBox";
|
||||||
|
customListBox.SelectedRow = -1;
|
||||||
|
customListBox.Size = new Size(848, 400);
|
||||||
|
customListBox.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonDay
|
||||||
|
//
|
||||||
|
buttonDay.Location = new Point(205, 342);
|
||||||
|
buttonDay.Name = "buttonDay";
|
||||||
|
buttonDay.Size = new Size(94, 29);
|
||||||
|
buttonDay.TabIndex = 6;
|
||||||
|
buttonDay.Text = "Get day";
|
||||||
|
buttonDay.UseVisualStyleBackColor = true;
|
||||||
|
buttonDay.Click += buttonDay_Click;
|
||||||
|
//
|
||||||
|
// buttonAddDay
|
||||||
|
//
|
||||||
|
buttonAddDay.Location = new Point(205, 371);
|
||||||
|
buttonAddDay.Name = "buttonAddDay";
|
||||||
|
buttonAddDay.Size = new Size(94, 29);
|
||||||
|
buttonAddDay.TabIndex = 7;
|
||||||
|
buttonAddDay.Text = "Write";
|
||||||
|
buttonAddDay.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddDay.Click += buttonAddDay_Click;
|
||||||
|
//
|
||||||
|
// textBoxMood
|
||||||
|
//
|
||||||
|
textBoxMood.Location = new Point(74, 371);
|
||||||
|
textBoxMood.Name = "textBoxMood";
|
||||||
|
textBoxMood.Size = new Size(125, 27);
|
||||||
|
textBoxMood.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(12, 378);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(52, 20);
|
||||||
|
label1.TabIndex = 9;
|
||||||
|
label1.Text = "Mood:";
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1156, 416);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(textBoxMood);
|
||||||
|
Controls.Add(buttonAddDay);
|
||||||
|
Controls.Add(buttonDay);
|
||||||
|
Controls.Add(customListBox);
|
||||||
|
Controls.Add(customTextBox);
|
||||||
|
Controls.Add(buttonGet);
|
||||||
|
Controls.Add(buttonClear);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(customComboBox);
|
||||||
|
Name = "Form1";
|
||||||
|
Text = "Form1";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Components.CustomComboBox customComboBox;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonClear;
|
||||||
|
private Button buttonGet;
|
||||||
|
private Components.CustomTextBox customTextBox;
|
||||||
|
private Components.CustomListBox customListBox;
|
||||||
|
private Button buttonDay;
|
||||||
|
private Button buttonAddDay;
|
||||||
|
private TextBox textBoxMood;
|
||||||
|
private Label label1;
|
||||||
|
}
|
||||||
|
}
|
101
CustomComboBox/TestApp/Form1.cs
Normal file
101
CustomComboBox/TestApp/Form1.cs
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
using Components;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
private int counter = 4;
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
FillCustomComboBox();
|
||||||
|
FillCustomTextBox();
|
||||||
|
FillCustomListBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FillCustomComboBox()
|
||||||
|
{
|
||||||
|
customComboBox.ComboBoxItems.Add("some text 1");
|
||||||
|
customComboBox.ComboBoxItems.Add("some text 2");
|
||||||
|
customComboBox.ComboBoxItems.Add("some text 3");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
customComboBox.ComboBoxItems.Add($"some text {counter}");
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonClear_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
customComboBox.ClearComboBox();
|
||||||
|
counter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void customComboBox_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MessageBox.Show(customComboBox.SelectedItem.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonGet_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Âûáðàííûé ýëåìåíò :" + customComboBox.SelectedItem.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void FillCustomTextBox()
|
||||||
|
{
|
||||||
|
customTextBox.numberPattern = @"\+\d\s\d{3}\s\d{3}\s\d{2}\s\d{2}$";
|
||||||
|
customTextBox.textBoxNumber = "+7 953 982 67 85";
|
||||||
|
}
|
||||||
|
private void customTextBox_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
customTextBox.textBoxNumber = customTextBox.textBoxNumber;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
customTextBox.textBoxNumber = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void FillCustomListBox()
|
||||||
|
{
|
||||||
|
Day day1 = new Day() { Mood = "áîëü", Date = DateTime.Now };
|
||||||
|
Day day2 = new Day() { Mood = "ðàäîñòü", Date = DateTime.Now.AddDays(1.0) };
|
||||||
|
|
||||||
|
customListBox.setTemplate("Äîðîãîé äíåâíèê, ìíå íå ïîäîáðàòü ñëîâ ÷òîáû îïèñàòü âñþ {Mood}, ÷òî ÿ èñïûòàë ñåãîäíÿ; {Date}", "{", "}");
|
||||||
|
|
||||||
|
customListBox.FillProperty(day1, 0, "Mood");
|
||||||
|
customListBox.FillProperty(day1, 0, "Date");
|
||||||
|
|
||||||
|
customListBox.FillProperty(day2, 1, "Mood");
|
||||||
|
customListBox.FillProperty(day2, 1, "Date");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonDay_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Day selectedDay = customListBox.GetObjectFromStr<Day>();
|
||||||
|
MessageBox.Show($"there was a lot {selectedDay.Mood} in {selectedDay.Date}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddDay_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Day day = new();
|
||||||
|
day.Date = DateTime.Now;
|
||||||
|
if (string.IsNullOrEmpty(textBoxMood.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Write something!!!", "Error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
day.Mood = textBoxMood.Text;
|
||||||
|
int index = customListBox.CountRows();
|
||||||
|
customListBox.FillProperty(day, index, "Mood");
|
||||||
|
customListBox.FillProperty(day, index, "Date");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
CustomComboBox/TestApp/Form1.resx
Normal file
120
CustomComboBox/TestApp/Form1.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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">
|
||||||
|
<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>
|
17
CustomComboBox/TestApp/Program.cs
Normal file
17
CustomComboBox/TestApp/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
CustomComboBox/TestApp/TestApp.csproj
Normal file
15
CustomComboBox/TestApp/TestApp.csproj
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Components\Components.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user