コード例 #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;
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: MatejS86/Praktikum
 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;
         }
     }
 }