public void opensoundfile() { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.DefaultExt = ".mp3"; dialog.Filter = "Sound Files(*.mp3;*.wav)|*.mp3;*.wav"; Nullable <bool> result = dialog.ShowDialog(); if (result == true) { SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName); if (System.IO.Path.GetExtension(dialog.FileName) == ".wav") { File.Copy(dialog.FileName, AppData + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName), true); file.extension = "wav"; } else if (System.IO.Path.GetExtension(dialog.FileName) == ".mp3") { ConvertMp3 converter = new ConvertMp3(dialog.FileName, AppData + "\\Sounds\\" + file.soundname + ".wav"); converter.ShowDialog(); file.extension = "mp3"; } file.filepath = AppData + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName); sounds.Add(file); System.Windows.Controls.ComboBoxItem SoundMenuItem = new System.Windows.Controls.ComboBoxItem(); this.soundselection.Items.Add(SoundMenuItem); } }
void loadsounds() { string path = Directory.GetCurrentDirectory(); string[] filenameswav = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Sounds", "*.wav"); string[] filenamesmp3 = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Sounds", "*.mp3"); for (int o = 0; o < filenamesmp3.Length; o++) { string Sname = filenamesmp3[o]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); ConvertMp3 converter = new ConvertMp3(Sname, Directory.GetCurrentDirectory() + @"\Sounds\" + file.soundname + ".wav", Sname); converter.ShowDialog(); file.filepath = Directory.GetCurrentDirectory() + @"\Sounds\" + file.soundname + ".wav"; file.extension = "wav"; sounds.Add(file); } for (int d = 0; d < filenameswav.Length; d++) { string Sname = filenameswav[d]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); file.filepath = Sname; file.extension = "wav"; sounds.Add(file); } for (int s = 0; s < sounds.Count; s++) { SoundFile sound = sounds[s]; System.Windows.Controls.ComboBoxItem SoundMenuItem = new System.Windows.Controls.ComboBoxItem(); SoundMenuItem.Content = sound.soundname; Mainwindow.soundselection.Items.Add(SoundMenuItem); } CurrentSelectedSound = sounds[0]; // Bleep.mp3 will be the default sound, unless the user picked a different one previously Mainwindow.soundselection.SelectedIndex = 0; }
void loadsounds() { if (!Directory.Exists(System.IO.Path.Combine(AppData, "Sounds"))) { Directory.CreateDirectory(System.IO.Path.Combine(AppData, "Sounds")); } string path = Directory.GetCurrentDirectory(); string[] filenameswav = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Sounds", "*.wav"); string[] filenamesmp3 = Directory.GetFiles(Directory.GetCurrentDirectory() + "\\Sounds", "*.mp3"); string[] AppDatafilenameswav = Directory.GetFiles(AppData + "\\Sounds", "*.wav"); string[] AppDatafilenamesmp3 = Directory.GetFiles(AppData + "\\Sounds", "*.mp3"); for (int o = 0; o < filenamesmp3.Length; o++) { string Sname = filenamesmp3[o]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); ConvertMp3 converter = new ConvertMp3(Sname, AppData + @"\Sounds\" + file.soundname + ".wav", Sname); converter.ShowDialog(); file.filepath = Directory.GetCurrentDirectory() + @"\Sounds\" + file.soundname + ".wav"; file.extension = "wav"; sounds.Add(file); } for (int d = 0; d < filenameswav.Length; d++) { string Sname = filenameswav[d]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); file.filepath = Sname; file.extension = "wav"; sounds.Add(file); } for (int e = 0; e < AppDatafilenamesmp3.Length; e++) { string Sname = filenamesmp3[e]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); ConvertMp3 converter = new ConvertMp3(Sname, AppData + @"\Sounds\" + file.soundname + ".wav", Sname); converter.ShowDialog(); file.filepath = AppData + @"\Sounds\" + file.soundname + ".wav"; file.extension = "wav"; sounds.Add(file); } for (int n = 0; n < AppDatafilenameswav.Length; n++) { string Sname = filenameswav[n]; SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(Sname); file.filepath = Sname; file.extension = "wav"; sounds.Add(file); } for (int s = 0; s < sounds.Count; s++) { SoundFile sound = sounds[s]; System.Windows.Controls.ComboBoxItem SoundMenuItem = new System.Windows.Controls.ComboBoxItem(); SoundMenuItem.Content = sound.soundname; this.soundselection.Items.Add(SoundMenuItem); } CurrentSelectedSound = sounds[0]; // Bleep.mp3 will be the default sound, unless the user picked a different one previously this.soundselection.SelectedIndex = 0; }
public void opensoundfile() { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); dialog.DefaultExt = ".mp3"; dialog.Filter = "Sound Files(*.mp3;*.wav)|*.mp3;*.wav"; Nullable<bool> result = dialog.ShowDialog(); if (result == true) { SoundFile file = new SoundFile(); file.soundname = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName); if (System.IO.Path.GetExtension(dialog.FileName) == ".wav") { File.Copy(dialog.FileName, Directory.GetCurrentDirectory() + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName), true); file.extension = "wav"; } else if (System.IO.Path.GetExtension(dialog.FileName) == ".mp3") { ConvertMp3 converter = new ConvertMp3(dialog.FileName, Directory.GetCurrentDirectory() + "\\Sounds\\" + file.soundname + ".wav"); converter.ShowDialog(); file.extension = "mp3"; } file.filepath = Directory.GetCurrentDirectory() + "\\Sounds\\" + System.IO.Path.GetFileName(dialog.FileName); sounds.Add(file); System.Windows.Controls.ComboBoxItem SoundMenuItem = new System.Windows.Controls.ComboBoxItem(); Mainwindow.soundselection.Items.Add(SoundMenuItem); } }