- handle no driver selected

master
Simon G 5 years ago
parent 623690aaec
commit 017d5fa409
  1. 13
      Mystify/ViewModels/MainWindowViewModel.cs

@ -9,6 +9,7 @@ using System.Linq;
using System.Windows.Input; using System.Windows.Input;
using Avalonia.Controls; using Avalonia.Controls;
using Lib.Driver; using Lib.Driver;
using Lib.Logging;
using Lib.Tools; using Lib.Tools;
using Mystify.Views; using Mystify.Views;
using ReactiveUI; using ReactiveUI;
@ -53,9 +54,17 @@ namespace Mystify.ViewModels
Filters = new List<FileDialogFilter> {new() {Extensions = new List<string> {DriverLoader.DRIVER_FILE_EXTENSION}, Name = "Mystify Driver"}} Filters = new List<FileDialogFilter> {new() {Extensions = new List<string> {DriverLoader.DRIVER_FILE_EXTENSION}, Name = "Mystify Driver"}}
}; };
string driverPath = (await openFileDialog.ShowAsync(_mainWindow))[0]; string[] selectedPaths = await openFileDialog.ShowAsync(_mainWindow);
if (selectedPaths.Length == 0)
{
await Log.Write<MainWindowViewModel>("No Driver selected.");
return;
}
string driverPath = selectedPaths[0];
_mainModel?.LoadDriverAndDevice(driverPath); if (!string.IsNullOrEmpty(driverPath))
_mainModel?.LoadDriverAndDevice(driverPath);
RaisePropertyChanged(() => SelectedDeviceText); RaisePropertyChanged(() => SelectedDeviceText);
RaisePropertyChanged(() => Channels); RaisePropertyChanged(() => Channels);

Loading…
Cancel
Save