protected override void Execute(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { var ofd = new OpenFileDialog { AddExtension = true, CheckFileExists = true, CheckPathExists = true, DereferenceLinks = true, Filter = "SysEx Files (*.syx)|*.syx|All Files (*.*)|*.*", FilterIndex = 0, Multiselect = false, RestoreDirectory = false, Title = "Select the SysEx file to open.", ValidateNames = true }; if (ofd.ShowDialog() == true) { using (var fileStream = File.OpenRead(ofd.FileName)) { var serializer = new SysExSerializer(); var buffers = serializer.Deserialize(fileStream); _appData.SysExBuffers.Clear(); foreach (var buffer in buffers) { _appData.SysExBuffers.Add(buffer); } } } base.Execute(sender, e); }
protected override void Execute(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { var sfd = new SaveFileDialog(); sfd.AddExtension = true; sfd.CheckFileExists = false; sfd.CheckPathExists = true; sfd.DereferenceLinks = true; sfd.Filter = "SysEx Files (*.syx)|*.syx|All Files (*.*)|*.*"; sfd.FilterIndex = 0; sfd.RestoreDirectory = false; sfd.Title = "Select the target SysEx file."; sfd.ValidateNames = true; sfd.OverwritePrompt = true; if (sfd.ShowDialog() == true) { using (var fileStream = File.OpenWrite(sfd.FileName)) { var serializer = new SysExSerializer(); serializer.Serialize(fileStream, this.appData.SelectedContentItems); } } base.Execute(sender, e); }