/// <summary> /// SetSongFromNetwork. /// </summary> /// <param name="args">MidiFileReceivedEventArguments.</param> private async void SetSongFromNetwork(MidiFileReceivedEventArguments args) => await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, async() => { this.ShowOrHideSongSelection(false); this.lblReceivedSongName.Text = Path.GetFileNameWithoutExtension(args.FilePath); this.lblReceivedSongName.Visibility = Visibility.Visible; this.lblReceivedSongNameText.Visibility = Visibility.Visible; UserData.Song = args.FilePath; await SongPagesHelper.AddMidiAsync().ConfigureAwait(true); this.sendTheSongToOtherPlayers = false; this.btnStartMultiplayerGame.Visibility = Visibility.Visible; });
private static async Task <StorageFile> ReadMidiFileAsync(DataReader reader) { var fileName = await ReadStringFromStreamAsync(reader).ConfigureAwait(true); var midiFileBytes = await ReadByteArrayAsync(reader).ConfigureAwait(true); var storageFolder = ApplicationData.Current.LocalFolder; var sampleFile = await storageFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); await FileIO.WriteBytesAsync(sampleFile, midiFileBytes); var eventArgs = new MidiFileReceivedEventArguments(sampleFile.Path); // Tracking number is available, raise the event. OnMidiFileReceived?.Invoke(eventArgs); return(sampleFile); }