Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 System.IO;
- namespace testApp
- {
- public partial class Form1 : Form
- {
- public List<int> A = new List<int>();
- public List<int> B = new List<int>();
- public List<int> C = new List<int>();
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- int x1 = Convert.ToInt32(textBox1.Text);
- int x2 = Convert.ToInt32(textBox2.Text);
- if (radioButton1.Checked)
- {
- for (int i = x1; i <= x2; i++)
- {
- A.Add(i);
- }
- }
- else if (radioButton2.Checked)
- {
- for (int i = x1; i <= x2; i++)
- {
- B.Add(i);
- }
- }
- else if (radioButton3.Checked)
- {
- for (int i = x1; i <= x2; i++)
- {
- C.Add(i);
- }
- }
- else
- {
- MessageBox.Show("Bez pośpiechu, " +
- "musisz wybrać do której grupy chcesz dodać liczby :)");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("Ups wystąpił jakiś błąd: " + ex.ToString());
- //throw;
- }
- }
- private void otwórzToolStripMenuItem_Click(object sender, EventArgs e)
- {
- string[] lines = { };
- try
- {
- lines = System.IO.File.ReadAllLines("dokumentTekstowy.txt");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- //throw;
- }
- int space = 0;
- foreach (string line in lines)
- {
- if (space == 0)
- {
- if (line != "") A.Add(Convert.ToInt32(line));
- else space++;
- }
- else if (space == 1)
- {
- if (line != "") B.Add(Convert.ToInt32(line));
- else space++;
- }
- else if (space == 2)
- {
- if (line != "") C.Add(Convert.ToInt32(line));
- else space++;
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- try
- {
- int x = Convert.ToInt32(textBox3.Text);
- foreach (int Item in A)
- {
- if (Item == x)
- {
- listView1.Items.Add(Item.ToString() + "Br1");
- }
- }
- foreach (int Item in B)
- {
- if (Item == x)
- {
- listView1.Items.Add(Item.ToString() + "Br2");
- }
- }
- foreach (int Item in C)
- {
- if (Item == x)
- {
- listView1.Items.Add(Item.ToString() + "Br3");
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- //throw
- }
- }
- private void zapiszToolStripMenuItem_Click_1(object sender, EventArgs e)
- {
- TextWriter tw = new StreamWriter("myFile.txt");
- foreach (int item in A)
- {
- tw.WriteLine(item.ToString());
- }
- tw.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement