Beispiel #1
0
        //add comment
        void edit_comment()
        {
            paths sort = new paths();

            string[]        files             = sort.get_files();
            FileStream      s                 = new FileStream("mp3.txt", FileMode.Open);
            BinaryFormatter b                 = new BinaryFormatter();
            List <MP3Tag_and_nameOf_MP3> List = new List <MP3Tag_and_nameOf_MP3>();

            while (s.Position < s.Length)
            {
                MP3Tag_and_nameOf_MP3 m = (MP3Tag_and_nameOf_MP3)b.Deserialize(s);
                List.Add(m);
            }
            s.Close();
            for (int i = 0; i < List.Count(); i++)
            {
                for (int j = 0; j < files.Count(); j++)
                {
                    if (Path.GetFileName(files[j]) == List[i].Mp3_Name)
                    {
                        s = new FileStream(files[j], FileMode.Open);
                        byte[] tag = new byte[128];
                        s.Seek(s.Length - 128, SeekOrigin.Begin);
                        s.Read(tag, 0, 128);
                        Array.Clear(tag, 97, 30);
                        tag[97] = byte.Parse((List[i].Comment));
                        s.Write(tag, 0, 128);
                        s.Close();
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FBD2 = new FolderBrowserDialog();

            MessageBox.Show("choose the detination of stored items ");
            if (FBD2.ShowDialog() == DialogResult.OK)
            {
                List <MP3Tag_and_nameOf_MP3> list = new List <MP3Tag_and_nameOf_MP3>();
                FileStream      fs = new FileStream("mp3.txt", FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                while (fs.Position != fs.Length)
                {
                    MP3Tag_and_nameOf_MP3 Tag = new MP3Tag_and_nameOf_MP3();
                    Tag = (MP3Tag_and_nameOf_MP3)bf.Deserialize(fs);
                    list.Add(Tag);
                }
                paths         s         = new paths();
                string        from_file = s.get_from_path();
                string        to_file   = FBD2.SelectedPath.ToString();
                DirectoryInfo dir       = new DirectoryInfo(from_file);
                if (!dir.Exists)
                {
                    throw new Exception("source directory doesnot exist " + from_file);
                }

                if (!Directory.Exists(to_file))
                {
                    Directory.CreateDirectory(to_file);
                }

                FileInfo[] fil = dir.GetFiles();
                for (int i = 0; i < list.Count; i++)
                {
                    for (int j = 0; j < s.get_files().Count(); j++)
                    {
                        if (list[i].Mp3_Name == Path.GetFileName(s.get_files()[j]))
                        {
                            string temp = Path.Combine(to_file, fil[j].Name);
                            fil[j].CopyTo(temp);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FBD = new FolderBrowserDialog();

            if (FBD.ShowDialog() == DialogResult.OK)
            {
                checkedListBox1.Items.Clear();

                files = Directory.GetFiles(FBD.SelectedPath, "*.mp3");

                foreach (string file in files)
                {
                    checkedListBox1.Items.Add(Path.GetFileName(file));
                }
                paths s = new paths();
                s.set_files(files);
            }
            paths sb = new paths();

            sb.set_from_path(FBD.SelectedPath.ToString());
            panel1.Show();
        }
Beispiel #4
0
        private void bunifuTileButton11_Click(object sender, EventArgs e)
        {
            paths s = new paths();
            List <MP3Tag_and_nameOf_MP3> list = new List <MP3Tag_and_nameOf_MP3>();

            FileStream      fm = new FileStream("mp3.txt", FileMode.Open);
            BinaryFormatter BF = new BinaryFormatter();
            List <MP3Tag_and_nameOf_MP3> lis = new List <MP3Tag_and_nameOf_MP3>();

            while (fm.Position != fm.Length)
            {
                MP3Tag_and_nameOf_MP3 tag = (MP3Tag_and_nameOf_MP3)BF.Deserialize(fm);
                lis.Add(tag);
            }
            fm.Close();

            FileStream fs2 = new FileStream("mp3.txt", FileMode.Truncate);

            fs2.Close();
            int i = 0;

            for (int m = 0; m < lis.Count; m++)
            {
                for (int n = 0; n < s.get_files().Length; n++)
                {
                    if (lis[m].Mp3_Name == Path.GetFileName(s.get_files()[n]))
                    {
                        MP3Reader             MR     = new MP3Reader(s.get_files()[n]);
                        MP3Tag_and_nameOf_MP3 tag    = MR.getTag();
                        Mp3FileReader         reader = new Mp3FileReader(s.get_files()[n]);
                        TimeSpan duration            = reader.TotalTime;
                        list.Add(tag);
                        list[i].Duration = duration;
                        reader.Close();
                    }
                }
                i++;
            }

            sort_by_Durat D = new sort_by_Durat();

            list.Sort(D);



            for (int k = 0; k < list.Count; k++)
            {
                list[k].Comment = (k + 1) + "";
            }
            for (int m = 0; m < list.Count; m++)
            {
                for (int n = m + 1; n < list.Count; n++)
                {
                    if (list[m].Duration == list[n].Duration)
                    {
                        list[n].Comment = list[m].Comment;
                    }
                }
            }
            int count = 0;
            int index = 0;

            for (int a = 0; a < list.Count; a++)
            {
                for (int b = 0; b < list.Count; b++)
                {
                    if (list[b].Comment == a + 1 + "")
                    {
                        count++;
                        index = b;
                    }
                }
                if (count != 0)
                {
                    for (int c = index + 1; c < list.Count; c++)
                    {
                        list[c].Comment = int.Parse(list[c].Comment) - count + 1 + "";
                    }
                }
                count = 0;
            }
            FileStream      fs3 = new FileStream("mp3.txt", FileMode.Open);
            BinaryFormatter bf  = new BinaryFormatter();

            for (int j = 0; j < list.Count; j++)
            {
                bf.Serialize(fs3, list[j]);
            }
            dataGridView2.DataSource = list;
            fs3.Close();
            //edit comment
            edit_comment();
        }