void filename_Completed(object sender, PopUpEventArgs<string, PopUpResult> e) { string basePath="/customAudio/"; if (e.PopUpResult == PopUpResult.Ok) { // create a soundData object SoundData soundData = new SoundData(); soundData.FilePath = string.Format(basePath+"{0}.wav", DateTime.Now.ToFileTime()); soundData.Title = e.Result; // save wav file into directory /customAudio/ using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) { if (!isoStore.DirectoryExists(basePath)) { isoStore.CreateDirectory(basePath); } isoStore.MoveFile(_tempFileName, soundData.FilePath); } // add the soundData to App.ViewModel.CustomSounds App.ViewModel.CustomSounds.Items.Add(soundData); // save the list of CustomSounds to IsolatedStorage.ApplicationSettings var data = JsonConvert.SerializeObject(App.ViewModel.CustomSounds); IsolatedStorageSettings.ApplicationSettings[SoundModel.CUSTOM_SOUND_KEY] = data; IsolatedStorageSettings.ApplicationSettings.Save(); // We'll need to modify our SoundModel to retrieve CustomSounds from IsolatedStorage.ApplicationSettings NavigationService.Navigate(new Uri("/MainPage.xaml",UriKind.Relative)); } }
private void FileNameComplete(object sender, PopUpEventArgs<string, PopUpResult> e) { if (e.PopUpResult == PopUpResult.Ok) { // Create a SoundData object SoundData soundData = new SoundData(); soundData.FilePath = string.Format("/customAudio/{0}.wav", DateTime.Now.ToFileTime()); soundData.Title = e.Result; // Save wav file into directory /customAudio/ using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()){ if (!isoStore.DirectoryExists("/customAudio/")) { isoStore.CreateDirectory("/customAudio/"); } isoStore.MoveFile(_tempFileName, soundData.FilePath); } // Add the SoundData to App.ViewModel.CustomSounds App.ViewModel.CustomSounds.Items.Add(soundData); // Save the list of CustomSounds to IsolatedStorage.ApplicationSettings var data = JsonConvert.SerializeObject(App.ViewModel.CustomSounds); IsolatedStorageSettings.ApplicationSettings[SoundModel.CustomSoundKey] = data; IsolatedStorageSettings.ApplicationSettings.Save(); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute)); } }