コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     //to dictionary ws classs einai [Serializable] opote sto dictionary playlistTracks tha apothikeuw
     //ta tracks me key to onoma tou track kai value ena tracks objects
     //otan teleiwnw me to playlist to arxeio pou tha dimiourgeitai tha brisketai mesa ston folder Playlists
     string[] filenames, filepaths;
     openFileDialog1.Filter = "All Supported Audio | *.mp3; *.wma | MP3s | *.mp3 | WMAs | *.wma";
     if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         filepaths = openFileDialog1.FileNames;
         filenames = openFileDialog1.SafeFileNames;
         for (int i = 0; i < filenames.Length; i++)
         {
             if (!playlistTracks.ContainsKey(filenames[i]))
             {
                 listBox1.Items.Add(filenames[i]);
                 Tracks track = new Tracks();
                 track.songName = filenames[i];
                 track.path     = filepaths[i];
                 track.readMetaData(filepaths[i]);
                 playlistTracks.Add(filenames[i], track);
             }
         }
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: DimPap99/University-Projects
        private void button1_Click(object sender, EventArgs e)
        {
            string[] filenames, filepaths;
            openFileDialog1.Filter = "All Media Files|*.wav;*.aac;*.wma;*.wmv;*.avi;*.mpg;*.mpeg;*.m1v;*.mp2;*.mp3;*.mpa;*.mpe;*.m3u;*.mp4;*.mov;*.3g2;*.3gp2;*.3gp;*.3gpp;*.m4a;*.cda;*.aif;*.aifc;*.aiff;*.mid;*.midi;*.rmi;*.mkv;*.WAV;*.AAC;*.WMA;*.WMV;*.AVI;*.MPG;*.MPEG;*.M1V;*.MP2;*.MP3;*.MPA;*.MPE;*.M3U;*.MP4;*.MOV;*.3G2;*.3GP2;*.3GP;*.3GPP;*.M4A;*.CDA;*.AIF;*.AIFC;*.AIFF;*.MID;*.MIDI;*.RMI;*.MKV";
            //set default path for OFD

            if (Directory.Exists("Songs"))
            {
                openFileDialog1.InitialDirectory = "Songs";
            }

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                filenames = openFileDialog1.SafeFileNames;
                filepaths = openFileDialog1.FileNames;
                for (int i = 0; i < filenames.Length; i++)
                {
                    //elegxos wste na min uparxoun idia image files sto checkedlistbox
                    if (!SongsNPaths.ContainsKey(filenames[i]))
                    {//pairname ta names sto listbox kai names&paths sto dictionary songsnpaths
                        listBox1.Items.Add(filenames[i]);
                        SongsNPaths.Add(filenames[i], filepaths[i]);
                        //gia kathe audio file dimiourgw ena tracks obj diabazw ta metadata tou kai to apothikeuw se ena dictionary me key to onoma tou audio file
                        Tracks track = new Tracks();
                        track.path     = filepaths[i];
                        track.songName = filenames[i];
                        track.readMetaData(filepaths[i]);
                        TracksDict.Add(filenames[i], track);
                        track.playingFrequency++;

                        //gia to frequency pou akouei o xrhsths ena tragoudi
                        //to obj ginetai serialize mono tin prwti fora
                        //tis alles fores aplws auxanetai to frequency
                        if (!File.Exists(@"Tracks\" + track.songName + ".txt"))
                        {
                            Tracks.serializeTrack(track);
                        }
                        else
                        {
                            Tracks tr = Tracks.DeserializeTrack(track.songName);

                            tr.playingFrequency++;
                            Tracks.serializeTrack(tr);
                        }
                    }
                }
            }
        }