Esempio n. 1
0
        private void FilenameGrid_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            // transfer the filenames to a string array
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            // loop through the string array, adding each filename to the ListBox
            foreach (string filename in files)
            {
                // Make sure the file is a WAV audio file before adding it.
                if (WAVFile.IsWaveFile(filename))
                {
                    AddAudioFilename(filename);
                }
            }
        }
        /// <summary>
        /// Add a filename to our list of files for processing
        /// </summary>
        /// <param name="filename">The completely pathed filename of the file to read</param>
        private void AddAudioFilename(String filename)
        {
            WAVFormat format = WAVFile.GetAudioFormat(filename);

            if (format.NumChannels > 1)
            {
                //TODO: Pop up something here
                return;
            }

            if (format.BitsPerSample != 8 && format.BitsPerSample != 16)
            {
                Console.Out.WriteLine(format.BitsPerSample);
                return;
            }

            if (!WAVFile.IsWaveFile(filename))
            {
                //TODO: Pop up a window to alert the user that an invalid file was specified
                return;
            }

            Downsampler.WavetableRef wavref = new WavetableRef();
            wavref.filename = Path.GetFileName(filename);
            wavref.filedir  = Path.GetDirectoryName(filename);
            wavref.filepath = filename;
            mSoundFiles.Add(wavref);

            fileGridView.Rows.Add(1);

            int rowNum = fileGridView.Rows.Count - 1;

            fileGridView.Columns[0].AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            fileGridView.Rows[rowNum].Cells[0].Value = wavref.filename;
            fileGridView.Rows[rowNum].Cells[1].Value = "Copy (As Array)";
            fileGridView.Rows[rowNum].Cells[2].Value = "Remove";
        }