-
-
Save anonymous/82420aad4fd453ebabd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Windows.Forms; | |
namespace testapp | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
//удалить повторы | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
string[] myArray = textBox1.Text.Split(new Char[] { ',' }); | |
List<String> names = myArray.OfType<String>().ToList(); | |
List<String> noDupes = names.Distinct().ToList(); | |
textBox1.Text = displayMembers(noDupes); | |
} | |
//Отобразить | |
public string displayMembers(List<String> noDupes) | |
{ | |
return string.Join("\n ", noDupes.ToArray()); | |
} | |
//spravka | |
private void button2_Click(object sender, EventArgs e) | |
{ | |
MessageBox.Show(" Пример \n \n Имя Фамилия 10а, \n Имя Фамилия 11б, \n Имя Фамилия 11a, \n Имя Фамилия 11а, "); | |
} | |
//form laod | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
textBox1.Multiline = true; | |
textBox1.ShortcutsEnabled = true; | |
textBox1.ScrollBars = ScrollBars.Vertical; | |
textBox1.AcceptsReturn = true; | |
textBox1.AcceptsTab = true; | |
textBox1.WordWrap = true; | |
// Set the default text of the control. | |
textBox1.Text = "Имя Фамилия,"; | |
} | |
//ctrls | |
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) | |
{ | |
const int WM_KEYDOWN = 0x100; | |
var keyCode = (Keys)(msg.WParam.ToInt32() & | |
Convert.ToInt32(Keys.KeyCode)); | |
if ((msg.Msg == WM_KEYDOWN && keyCode == Keys.A) | |
&& (ModifierKeys == Keys.Control) | |
&& textBox1.Focused) | |
{ | |
textBox1.SelectAll(); | |
return true; | |
} | |
return base.ProcessCmdKey(ref msg, keyData); | |
} | |
//ToolStripMenuItem | |
private void открытьToolStripMenuItem_Click_1(object sender, EventArgs e) | |
{ | |
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) | |
{ | |
openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*"; | |
openFileDialog1.FilterIndex = 1; | |
System.IO.StreamReader sr = new | |
System.IO.StreamReader(openFileDialog1.FileName, System.Text.Encoding.GetEncoding(1251), true); | |
textBox1.Text = sr.ReadToEnd(); | |
sr.Close(); | |
} | |
} | |
//save as | |
private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e) | |
{ | |
using (var sfd = new SaveFileDialog()) | |
{ | |
sfd.Filter = "txt files (*.txt)|*.txt"; | |
sfd.FilterIndex = 2; | |
if (sfd.ShowDialog() == DialogResult.OK) | |
{ | |
File.WriteAllText(sfd.FileName, textBox1.Text); | |
} | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment