예제 #1
0
파일: MainForm.cs 프로젝트: svetakorn/DtWPF
        private void tsbNew_Click(object sender, EventArgs e)
        {
            if (sfdAudio.ShowDialog() == DialogResult.OK)
            {
                string           fileName = sfdAudio.FileName;
                Stream           stream   = null;
                IAudioReadWriter arw      = null;
                FormatDialog     fd       = null;
                switch (Path.GetExtension(fileName.ToLower()))
                {
                case ".wav":
                    fd = new FormatDialog(false);
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        stream = File.Create(fileName);
                        arw    = new WaveReadWriter(stream, AudioCompressionManager.FormatBytes(fd.Format));
                        rp.Open(arw);
                    }
                    break;

                case ".mp3":
                    fd = new FormatDialog(true);
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        stream = File.Create(fileName);
                        arw    = new Mp3ReadWriter(stream, fd.Format);
                        rp.Open(arw);
                    }
                    break;

                default:
                    fd = new FormatDialog(false);
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        stream = File.Create(fileName);
                        arw    = new RawReadWriter(stream, fd.Format);
                        rp.Open(arw);
                    }
                    return;
                }
            }
        }