366 lines
11 KiB
C#
366 lines
11 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
using System.Text.RegularExpressions;
|
|||
|
|
|||
|
namespace WindowsFormsApp4
|
|||
|
{
|
|||
|
public partial class Form1 : Form
|
|||
|
{
|
|||
|
public Form1()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
OpenFileDialog OpenDlg = new OpenFileDialog();
|
|||
|
|
|||
|
if (OpenDlg.ShowDialog() == DialogResult.OK)
|
|||
|
{
|
|||
|
StreamReader Reader = new StreamReader(OpenDlg.FileName, Encoding.UTF8);
|
|||
|
richTextBox1.Text = Reader.ReadToEnd();
|
|||
|
Reader.Close();
|
|||
|
}
|
|||
|
OpenDlg.Dispose();
|
|||
|
}
|
|||
|
|
|||
|
private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
SaveFileDialog SaveDlg = new SaveFileDialog();
|
|||
|
|
|||
|
SaveDlg.Filter = "Text Files (*.txt)|*.txt|All files (*.*)|*.*";
|
|||
|
SaveDlg.DefaultExt = "txt";
|
|||
|
SaveDlg.FileName = "Новый файл";
|
|||
|
|
|||
|
if (SaveDlg.ShowDialog() == DialogResult.OK)
|
|||
|
{
|
|||
|
StreamWriter Writer = new StreamWriter(SaveDlg.FileName);
|
|||
|
for (int i = 0; i < listBox2.Items.Count; i++)
|
|||
|
{
|
|||
|
Writer.WriteLine((string)listBox2.Items[i]);
|
|||
|
}
|
|||
|
Writer.Close();
|
|||
|
}
|
|||
|
SaveDlg.Dispose();
|
|||
|
}
|
|||
|
|
|||
|
private void выйтиToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Application.Exit();
|
|||
|
}
|
|||
|
|
|||
|
private void toolStripMenuItem1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
MessageBox.Show("Желонкин Денис Сергеевич ИС-23-1");
|
|||
|
}
|
|||
|
|
|||
|
private void button14_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox1.Items.Clear();
|
|||
|
listBox2.Items.Clear();
|
|||
|
listBox1.BeginUpdate();
|
|||
|
string[] Strings = richTextBox1.Text.Split(new char[] { '\n', '\t', ' ' },
|
|||
|
StringSplitOptions.RemoveEmptyEntries);
|
|||
|
foreach (string s in Strings)
|
|||
|
{
|
|||
|
string Str = s.Trim();
|
|||
|
if (Str == String.Empty) continue;
|
|||
|
if (radioButton1.Checked) listBox1.Items.Add(Str);
|
|||
|
if (radioButton2.Checked)
|
|||
|
{
|
|||
|
if (Regex.IsMatch(Str, @"\d")) listBox1.Items.Add(Str);
|
|||
|
}
|
|||
|
if (radioButton3.Checked)
|
|||
|
{
|
|||
|
if (Regex.IsMatch(Str, @"\w+@\w+\.\w+")) listBox1.Items.Add(Str);
|
|||
|
}
|
|||
|
}
|
|||
|
listBox1.EndUpdate();
|
|||
|
}
|
|||
|
|
|||
|
private void button13_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Application.Exit();
|
|||
|
}
|
|||
|
|
|||
|
private void button12_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox1.Items.Clear();
|
|||
|
listBox2.Items.Clear();
|
|||
|
listBox3.Items.Clear();
|
|||
|
richTextBox1.Clear();
|
|||
|
textBox1.Clear();
|
|||
|
checkBox1.Checked = false;
|
|||
|
checkBox2.Checked = false;
|
|||
|
radioButton1.Checked = false;
|
|||
|
radioButton2.Checked = false;
|
|||
|
radioButton3.Checked = false;
|
|||
|
comboBox1.Text = "Сортировка по...";
|
|||
|
comboBox2.Text = "Сортировка по...";
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void button11_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox3.Items.Clear();
|
|||
|
string Find = textBox1.Text;
|
|||
|
if (checkBox1.Checked)
|
|||
|
{
|
|||
|
foreach (string String in listBox1.Items)
|
|||
|
{
|
|||
|
if (String.Contains(Find)) listBox3.Items.Add(String);
|
|||
|
}
|
|||
|
}
|
|||
|
if (checkBox2.Checked)
|
|||
|
{
|
|||
|
foreach (string String in listBox2.Items)
|
|||
|
{
|
|||
|
if (String.Contains(Find)) listBox3.Items.Add(String);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void button7_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Form2 AddRec = new Form2();
|
|||
|
AddRec.Owner = this;
|
|||
|
AddRec.ShowDialog();
|
|||
|
}
|
|||
|
|
|||
|
private void button8_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
for (int i = listBox1.Items.Count - 1; i >= 0; i--)
|
|||
|
{
|
|||
|
if (listBox1.GetSelected(i)) listBox1.Items.RemoveAt(i);
|
|||
|
}
|
|||
|
for (int i = listBox2.Items.Count - 1; i >= 0; i--)
|
|||
|
{
|
|||
|
if (listBox2.GetSelected(i)) listBox2.Items.RemoveAt(i);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void button3_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox2.Items.AddRange(listBox1.Items);
|
|||
|
listBox1.Items.Clear();
|
|||
|
}
|
|||
|
|
|||
|
private void button4_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox1.Items.AddRange(listBox2.Items);
|
|||
|
listBox2.Items.Clear();
|
|||
|
}
|
|||
|
|
|||
|
private void button1_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox2.BeginUpdate();
|
|||
|
foreach (object Item in listBox1.SelectedItems)
|
|||
|
{
|
|||
|
listBox2.Items.Add(Item);
|
|||
|
}
|
|||
|
listBox2.EndUpdate();
|
|||
|
listBox1.Items.Remove(listBox1.SelectedItem);
|
|||
|
}
|
|||
|
|
|||
|
private void button2_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox1.BeginUpdate();
|
|||
|
foreach (object Item in listBox2.SelectedItems)
|
|||
|
{
|
|||
|
listBox1.Items.Add(Item);
|
|||
|
}
|
|||
|
listBox1.EndUpdate();
|
|||
|
listBox2.Items.Remove(listBox2.SelectedItem);
|
|||
|
}
|
|||
|
|
|||
|
private void button6_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox1.Items.Clear();
|
|||
|
}
|
|||
|
|
|||
|
private void button10_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
listBox2.Items.Clear();
|
|||
|
}
|
|||
|
|
|||
|
private void button5_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (comboBox1.Text == "По алфавиту ⬇")
|
|||
|
{
|
|||
|
listBox1.Sorted = true;
|
|||
|
}
|
|||
|
else if (comboBox1.Text == "По алфавиту ⬆")
|
|||
|
{
|
|||
|
listBox1.Sorted = false;
|
|||
|
List<string> items = new List<string>();
|
|||
|
|
|||
|
foreach (string item in listBox1.Items)
|
|||
|
{
|
|||
|
items.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
items.Sort();
|
|||
|
items.Reverse();
|
|||
|
|
|||
|
listBox1.Items.Clear();
|
|||
|
foreach (string item in items)
|
|||
|
{
|
|||
|
listBox1.Items.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
else if (comboBox1.Text == "По длине ⬇")
|
|||
|
{
|
|||
|
listBox1.Sorted = false;
|
|||
|
List<string> items = new List<string>();
|
|||
|
|
|||
|
foreach (string item in listBox1.Items)
|
|||
|
{
|
|||
|
items.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < items.Count - 1; i++)
|
|||
|
{
|
|||
|
for (int j = i + 1; j < items.Count; j++)
|
|||
|
{
|
|||
|
if (items[i].Length > items[j].Length)
|
|||
|
{
|
|||
|
string temp = items[i];
|
|||
|
items[i] = items[j];
|
|||
|
items[j] = temp;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
listBox1.Items.Clear();
|
|||
|
foreach (string item in items)
|
|||
|
{
|
|||
|
listBox1.Items.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
else if (comboBox1.Text == "По длине ⬆")
|
|||
|
{
|
|||
|
listBox1.Sorted = false;
|
|||
|
List<string> items = new List<string>();
|
|||
|
|
|||
|
foreach (string item in listBox1.Items)
|
|||
|
{
|
|||
|
items.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < items.Count - 1; i++)
|
|||
|
{
|
|||
|
for (int j = i + 1; j < items.Count; j++)
|
|||
|
{
|
|||
|
if (items[i].Length < items[j].Length)
|
|||
|
{
|
|||
|
string temp = items[i];
|
|||
|
items[i] = items[j];
|
|||
|
items[j] = temp;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
listBox1.Items.Clear();
|
|||
|
foreach (string item in items)
|
|||
|
{
|
|||
|
listBox1.Items.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void button9_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (comboBox2.Text == "По алфавиту ⬇")
|
|||
|
{
|
|||
|
listBox2.Sorted = true;
|
|||
|
}
|
|||
|
else if (comboBox2.Text == "По алфавиту ⬆")
|
|||
|
{
|
|||
|
listBox2.Sorted = false;
|
|||
|
List<string> items = new List<string>();
|
|||
|
|
|||
|
foreach (string item in listBox2.Items)
|
|||
|
{
|
|||
|
items.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
items.Sort();
|
|||
|
items.Reverse();
|
|||
|
|
|||
|
listBox2.Items.Clear();
|
|||
|
foreach (string item in items)
|
|||
|
{
|
|||
|
listBox2.Items.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
else if (comboBox2.Text == "По длине ⬇")
|
|||
|
{
|
|||
|
listBox2.Sorted = false;
|
|||
|
List<string> items = new List<string>();
|
|||
|
|
|||
|
foreach (string item in listBox2.Items)
|
|||
|
{
|
|||
|
items.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < items.Count - 1; i++)
|
|||
|
{
|
|||
|
for (int j = i + 1; j < items.Count; j++)
|
|||
|
{
|
|||
|
if (items[i].Length > items[j].Length)
|
|||
|
{
|
|||
|
string temp = items[i];
|
|||
|
items[i] = items[j];
|
|||
|
items[j] = temp;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
listBox2.Items.Clear();
|
|||
|
foreach (string item in items)
|
|||
|
{
|
|||
|
listBox2.Items.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
else if (comboBox2.Text == "По длине ⬆")
|
|||
|
{
|
|||
|
listBox2.Sorted = false;
|
|||
|
List<string> items = new List<string>();
|
|||
|
|
|||
|
foreach (string item in listBox2.Items)
|
|||
|
{
|
|||
|
items.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < items.Count - 1; i++)
|
|||
|
{
|
|||
|
for (int j = i + 1; j < items.Count; j++)
|
|||
|
{
|
|||
|
if (items[i].Length < items[j].Length)
|
|||
|
{
|
|||
|
string temp = items[i];
|
|||
|
items[i] = items[j];
|
|||
|
items[j] = temp;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
listBox2.Items.Clear();
|
|||
|
foreach (string item in items)
|
|||
|
{
|
|||
|
listBox2.Items.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|