using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Matematika_gyakorlo
{
    public partial class Form7 : Form
    {
        string ut = Path.GetDirectoryName(Application.ExecutablePath);

        public Form7()
        {
            InitializeComponent();
        }

        private void Form7_Load(object sender, EventArgs e)
        {
            //radioButton1_CheckedChanged(sender, e);
           

        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            listView1.Items.Clear();
           
            string s;
          string ut = Path.GetDirectoryName(Application.ExecutablePath);
           try{StreamReader sr=new StreamReader(ut+"\\II.txt");

               try
               {
                   int i, n = 5;
                   ListViewItem x;
                   for (i = 1; i <= n; i++)
                   {
                       s = sr.ReadLine();
                       x = listView1.Items.Add(s);
                   }
               }
               catch (Exception)
               { MessageBox.Show("Nem jó az állomány szerkezete"); }
               sr.Close();
           }
            catch(Exception)
           {
               MessageBox.Show("Nem létezik az állomány!");
           }
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            
            string s;
            string ut = Path.GetDirectoryName(Application.ExecutablePath);
           try{StreamReader sr=new StreamReader(ut+"\\III.txt");
               
               try
               {
                   int i, n = 5;
                   ListViewItem x;
                   for (i = 1; i <= n; i++)
                   {
                       s = sr.ReadLine();
                       x = listView1.Items.Add(s);
                   }
               }
               catch (Exception)
               { MessageBox.Show("Nem jó az állomány szerkezete"); }
               sr.Close();
           }
            catch(Exception)
           {
               MessageBox.Show("Nem létezik az állomány!");
           }
        }

        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            listView1.Items.Clear();
           
            string ut = Path.GetDirectoryName(Application.ExecutablePath);
           try{StreamReader sr=new StreamReader(ut+"\\IV.txt");
               string s;
               try
               {
                   int i, n = 5;
                   ListViewItem x;
                   for (i = 1; i <= n; i++)
                   {
                       s = sr.ReadLine();
                       x = listView1.Items.Add(s);
                   }
               }
               catch (Exception)
               { MessageBox.Show("Nem jó az állomány szerkezete"); }
               sr.Close();
           }
            catch(Exception)
           {
               MessageBox.Show("Nem létezik az állomány!");
           }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            listView1.Items.Clear();
           
            string s;
            try
            {
                StreamReader sr = new StreamReader(ut + "\\I.txt");

                try
                {
                    int i, n = 5;
                    ListViewItem x;
                    for (i = 1; i <= n; i++)
                    {
                        s = sr.ReadLine();
                        x = listView1.Items.Add(s);
                    }
                }
                catch (Exception)
                { MessageBox.Show("Nem jó az állomány szerkezete"); }
                sr.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Nem létezik az állomány!");
            }
        }

        private void Form7_Shown(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
                radioButton1_CheckedChanged(sender, e);

            if (radioButton3.Checked == true)
                radioButton3_CheckedChanged(sender, e);
            if (radioButton2.Checked == true)
                radioButton2_CheckedChanged(sender, e);
            if (radioButton4.Checked == true)
                radioButton4_CheckedChanged(sender, e);
        }
               


        }
    }
