102 lines
3.1 KiB
C#

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");
}
}
}