Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int min = VremePogodok / 60;
            int sec = VremePogodok % 60;
            string vreme = string.Format("{0:00}:{1:00}", min, sec);

            string imeIgrac = textBox1.Text.Trim();
            Igrac i = new Igrac(imeIgrac, vreme);
            siteIgraci.Add(i);

            if (matricaOdbrana != MATRICA6X6)
            {
                string path = Application.StartupPath.ToString();
                string[] parts1 = path.Split('\\');
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < parts1.Length - 2; j++)
                {
                    sb.Append(parts1[j]);
                    sb.Append("\\");
                }

                System.IO.StreamWriter file = new System.IO.StreamWriter(sb.ToString() + @"\Properties\MemoryData\rezultati.txt");
                for (int j = 0; j < siteIgraci.Count; j++)
                {
                    Igrac igrac = (Igrac)siteIgraci[j];
                    sb = new StringBuilder();
                    sb.Append(igrac.ImeIgrac);
                    sb.Append(" ");
                    sb.Append(igrac.Vreme);
                    file.WriteLine(sb.ToString());
                }
                file.Close();
            }

            if (matricaOdbrana == MATRICA6X6)
            {
                string path = Application.StartupPath.ToString();
                string[] parts1 = path.Split('\\');
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < parts1.Length - 2; j++)
                {
                    sb.Append(parts1[j]);
                    sb.Append("\\");
                }

                System.IO.StreamWriter file = new System.IO.StreamWriter(sb.ToString() + @"\Properties\MemoryData\rezultati6.txt");
                for (int j = 0; j < siteIgraci.Count; j++)
                {
                    Igrac igrac = (Igrac)siteIgraci[j];
                    sb = new StringBuilder();
                    sb.Append(igrac.ImeIgrac);
                    sb.Append(" ");
                    sb.Append(igrac.Vreme);
                    file.WriteLine(sb.ToString());
                }
                file.Close();
            }

                if (NewGame && VneseniPodatoci)
                {
                    this.Close();
                }
                if(VneseniPodatoci)
                {
                    this.Close();
                }
        }
Exemple #2
0
        public Form2(int pom, bool newGame, bool closeA, int mat)
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            VremePogodok = pom;
            NewGame = newGame;
            CloseApp = closeA;
            VneseniPodatoci = false;
            textBox1.Select();
            matricaOdbrana = mat;
            if (matricaOdbrana != MATRICA6X6)
            {
                string path = Application.StartupPath.ToString();
                string[] parts1 = path.Split('\\');
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < parts1.Length - 2; i++)
                {
                    sb.Append(parts1[i]);
                    sb.Append("\\");
                }

                System.IO.StreamReader file = new System.IO.StreamReader(sb.ToString() + @"\Properties\MemoryData\rezultati.txt");
                string line = file.ReadLine();
                siteIgraci = new List<Igrac>();
                while (line != null)
                {
                    string[] parts = line.Split(' ');
                    Igrac i = new Igrac(parts[0], parts[1]);
                    siteIgraci.Add(i);
                    line = file.ReadLine();
                }
                siteIgraci.Sort(new MyComparator());
                lb1.Items.Clear();
                int brojac = 0;
                int j = 0;
                while (j < siteIgraci.Count)
                {
                    Igrac igr = (Igrac)siteIgraci[j];
                    Pecati pecati = new Pecati(igr.ImeIgrac, igr.Vreme, j + 1);
                    lb1.Items.Add(pecati);
                    j++;
                    brojac++;
                    if (brojac == 10)
                    {
                        break;
                    }
                }
                file.Close();
                int min = VremePogodok / 60;
                int sec = VremePogodok % 60;

                textBox2.Text = string.Format("{0:00}:{1:00}", min, sec);
            }

            if (matricaOdbrana == MATRICA6X6)
            {
                string path = Application.StartupPath.ToString();
                string[] parts1 = path.Split('\\');
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < parts1.Length - 2; i++)
                {
                    sb.Append(parts1[i]);
                    sb.Append("\\");
                }

                System.IO.StreamReader file = new System.IO.StreamReader(sb.ToString() + @"\Properties\MemoryData\rezultati6.txt");
                string line = file.ReadLine();
                siteIgraci = new List<Igrac>();
                while (line != null)
                {
                    string[] parts = line.Split(' ');
                    Igrac i = new Igrac(parts[0], parts[1]);
                    siteIgraci.Add(i);
                    line = file.ReadLine();
                }
                siteIgraci.Sort(new MyComparator());
                lb1.Items.Clear();
                int brojac = 0;
                int j = 0;
                while (j < siteIgraci.Count)
                {
                    Igrac igr = (Igrac)siteIgraci[j];
                    Pecati pecati = new Pecati(igr.ImeIgrac, igr.Vreme, j + 1);
                    lb1.Items.Add(pecati);
                    j++;
                    brojac++;
                    if (brojac == 10)
                    {
                        break;
                    }
                }
                file.Close();
                int min = VremePogodok / 60;
                int sec = VremePogodok % 60;

                textBox2.Text = string.Format("{0:00}:{1:00}", min, sec);
            }
        }
Exemple #3
0
        public Form5()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            string path = Application.StartupPath.ToString();
            string[] parts1 = path.Split('\\');
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < parts1.Length - 2; i++)
            {
                sb.Append(parts1[i]);
                sb.Append("\\");
            }

            System.IO.StreamReader file = new System.IO.StreamReader(sb.ToString() + @"\Properties\MemoryData\rezultati.txt");
            string line = file.ReadLine();
            siteIgraci = new List<Igrac>();
            while (line != null)
            {
                string[] parts = line.Split(' ');
                if (!(parts.Count() < 2))
                {
                    Igrac i = new Igrac(parts[0], parts[1]);
                    siteIgraci.Add(i);
                }
                line = file.ReadLine();
            }
            siteIgraci.Sort(new MyComparator());
            lb1.Items.Clear();
            int brojac = 0;
            int j = 0;
            while (j < siteIgraci.Count)
            {
                Igrac igr = (Igrac)siteIgraci[j];
                Pecati pecati = new Pecati(igr.ImeIgrac, igr.Vreme, j + 1);
                lb1.Items.Add(pecati);
                j++;
                brojac++;
                if (brojac == 10)
                {
                    break;
                }
            }
            file.Close();

            path = Application.StartupPath.ToString();
            parts1 = path.Split('\\');
            sb = new StringBuilder();
            for (int i = 0; i < parts1.Length - 2; i++)
            {
                sb.Append(parts1[i]);
                sb.Append("\\");
            }

            file = new System.IO.StreamReader(sb.ToString() + @"\Properties\MemoryData\rezultati6.txt");
            line = file.ReadLine();
            siteIgraci = new List<Igrac>();
            while (line != null)
            {
                string[] parts = line.Split(' ');
                if(!(parts.Count() < 2)){
                Igrac i = new Igrac(parts[0], parts[1]);
                siteIgraci.Add(i);
                }
                line = file.ReadLine();
            }
            siteIgraci.Sort(new MyComparator());
            lb2.Items.Clear();
            brojac = 0;
            j = 0;
            while (j < siteIgraci.Count)
            {
                Igrac igr = (Igrac)siteIgraci[j];
                Pecati pecati = new Pecati(igr.ImeIgrac, igr.Vreme, j + 1);
                lb2.Items.Add(pecati);
                j++;
                brojac++;
                if (brojac == 10)
                {
                    break;
                }
            }
            file.Close();
        }