Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldivis committed Jun 28, 2022
1 parent fa9d35e commit 4d6511f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/DarkMidiRemapperDesktop/DarkMidiRemapperDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0-preview4" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />
<PackageReference Include="Syncfusion.SfGrid.WPF" Version="20.1.0.61" />
<PackageReference Include="Syncfusion.SfTextInputLayout.WPF" Version="20.1.0.61" />
<PackageReference Include="Syncfusion.Shared.WPF" Version="20.1.0.61" />
<PackageReference Include="Syncfusion.Themes.FluentDark.WPF" Version="20.1.0.61" />
<PackageReference Include="Syncfusion.Tools.WPF" Version="20.1.0.61" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 15 additions & 2 deletions src/DarkMidiRemapperDesktop/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using DarkMidiRemapperCore;
using Microsoft.Win32;
using NAudio.Midi;
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows;

namespace DarkMidiRemapperDesktop;

Expand Down Expand Up @@ -38,9 +40,18 @@ private void Load()
{
return;
}


try
{
_midiFile = new MidiFile(dlg.FileName, false);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Failed to load MIDI file");
return;
}

MidiFilePath = dlg.FileName;
_midiFile = new MidiFile(MidiFilePath, false);
IsMidiFileLoaded = true;
SaveCommand.NotifyCanExecuteChanged();
ClearCommand.NotifyCanExecuteChanged();
Expand Down Expand Up @@ -83,6 +94,8 @@ private void Save()
_remapper.AlterMapping(_midiFile, Mappings);

MidiFile.Export(targetMidiFilePath, _midiFile.Events);

MessageBox.Show($"Done! Re-mapped MIDI file was saved to {targetMidiFilePath}", "Success");
}

[RelayCommand(CanExecute = nameof(IsMidiFileLoaded))]
Expand Down

0 comments on commit 4d6511f

Please sign in to comment.