示例#1
0
        public Form1()
        {
            InitializeComponent();
            ArrayList folderyMuzyczne, folderyNiemuzyczne, utworyGrane;

            folderyMuzyczne = new ArrayList();
            folderyNiemuzyczne = new ArrayList();
            utworyGrane = new ArrayList();

            StreamReader czytnik = new StreamReader("test.txt");
            string linia = czytnik.ReadLine();
            string[] dane = linia.Split(';');

            Song piosenka = new Song(dane[0], dane[1], dane[2]);

            int numer = utworyGrane.BinarySearch(piosenka);
            if (numer < 0)
            {
                utworyGrane.Add(piosenka);
            }
            else
            {
                piosenka = (Song)utworyGrane[numer];
                piosenka.nadania++;
                utworyGrane[numer] = piosenka;
            }
        }
示例#2
0
        private void btn_start_Click(object sender, EventArgs e)
        {
            bool muzyczny;
            while (files.Count > 0)
            {
                StreamReader czytnik = new StreamReader((string)files[0], Encoding.GetEncoding(1250));
                while (czytnik.EndOfStream == false)
                {
                    string linia = czytnik.ReadLine();
                    string[] dane = linia.Split(';');
                    if (dane.Length > 3)
                    {
                        if (dane[0].Length > 8)
                        {
                            dane = try_to_fix_time(linia);
                        }
                    }
                    if (dane != null)
                    {
                        if (dane.Length > 3)
                        {
                            find_time(dane[0]);
                            if (find_if_exists(folderyMuzyczne, find_directory_from_path(dane[1])) == (-1))
                            {
                                if (find_if_exists(folderyNiemuzyczne, find_directory_from_path(dane[1])) == (-1))
                                {
                                    if (find_if_contains(dontask, dane[1]) == (-1))
                                    {
                                        if (find_if_contains(dontaskmuz, dane[1]) == (-1))
                                        {
                                            czy_folder test = new czy_folder(find_directory_from_path(dane[1]));
                                            test.ShowDialog();
                                            if (test.muzyczny)
                                            { folderyMuzyczne.Add(find_directory_from_path(dane[1])); lst_muzyczne.Items.Add(find_directory_from_path(dane[1])); muzyczny = true; }
                                            else { folderyNiemuzyczne.Add(find_directory_from_path(dane[1])); lst_nmuzyczne.Items.Add(find_directory_from_path(dane[1])); muzyczny = false; }
                                        }
                                        else { muzyczny = true; }

                                     }
                                    else { muzyczny = false; }
                                }
                                else { muzyczny = false; }
                            }
                            else { muzyczny = true; }

                            if (muzyczny)
                            {
                                if (dane[5].Length < 2)
                                {
                                    dane = find_data_from_filename(dane);
                                    if (dane.Length < 2)
                                    { muzyczny = false; }
                                }
                            }

                            if (muzyczny)
                            {

                                Song piosenka = new Song(dane[1], dane[5].Trim(), dane[3].Trim(), dane[0].Trim());

                                if (piosenka.utwor == "Keep Holding On")
                                {
                                    bool test = true;
                                }

                                piosenka.czas = find_taglib_path(piosenka.file, piosenka.czas);

                                int numer = find_if_exists(utworyGrane, piosenka);
                                if (numer < 0)
                                {
                                    utworyGrane.Add(piosenka);
                                    last_index = utworyGrane.Count - 1;
                                }
                                else
                                {
                                    piosenka = (Song)utworyGrane[numer];
                                    piosenka.nadania++;
                                    utworyGrane[numer] = piosenka;
                                    last_index = numer;
                                }
                            }
                        }
                        else
                        {
                            if (dane.Length < 4 & dane.Length > 0)
                            {
                                find_time(dane[0]);
                                last_index = -1;
                            }
                        }
                    }
                    }
                    files.RemoveAt(0);
                    lst_files.Items.RemoveAt(0);
                }
                if (last_index != -1)
                {
                    find_time("00:00:01");
                }
        }
示例#3
0
        int find_if_exists(ArrayList arej, Song piosnka)
        {
            int a = 0;
            while (a < arej.Count)
            {
                Song song1=(Song)arej[a];
                if (song1.utwor.ToLower() == piosnka.utwor.ToLower() & song1.wykonawca.ToLower() == piosnka.wykonawca.ToLower() & song1.file == piosnka.file)      //check also path v2
                {
                    return a;
                }
                a++;
            }

            return (-1);
        }