Skip to content

Commit

Permalink
fixed commands not stored
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaslischka committed Sep 12, 2017
1 parent e69362c commit 9bcdbc5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion StartLauncher.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void App_Startup(object sender, StartupEventArgs e)
{
new MainWindow
{
DataContext = new MainViewModel(_commandsDataAccessor.Commands, _commandsDataAccessor)
DataContext = new MainViewModel(_commandsDataAccessor.Commands, _commandsDataAccessor, _executablesAccessor)
}.Show();
}

Expand Down
5 changes: 4 additions & 1 deletion StartLauncher.App/ViewModels/EditViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ namespace StartLauncher.App.ViewModels
public class EditViewModel : CommandViewModel
{
private readonly ICommandsDataAccessor _commandsDataAccessor;
private readonly IExecutablesAccessor _executablesAccessor;

public EditViewModel(CommandDto commandDto, ICommandsDataAccessor commandsDataAccessor) : base(commandDto)
public EditViewModel(CommandDto commandDto, ICommandsDataAccessor commandsDataAccessor, IExecutablesAccessor executablesAccessor) : base(commandDto)
{
_commandsDataAccessor = commandsDataAccessor;
_executablesAccessor = executablesAccessor;
}

public ICommand SaveCommand => new DelegateCommand<Window>(window =>
{
_commandsDataAccessor.SaveCommand(ToModel());
_executablesAccessor.EnsureCommands();
window.Close();
}
);
Expand Down
8 changes: 5 additions & 3 deletions StartLauncher.App/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ namespace StartLauncher.App.ViewModels
public class MainViewModel : ObservableObject
{
private readonly ICommandsDataAccessor _commandsDataAccessor;
private readonly IExecutablesAccessor _executablesAccessor;

public MainViewModel(ObservableCollection<CommandDto> commands, ICommandsDataAccessor commandsDataAccessor)
public MainViewModel(ObservableCollection<CommandDto> commands, ICommandsDataAccessor commandsDataAccessor, IExecutablesAccessor executablesAccessor)
{
_commandsDataAccessor = commandsDataAccessor;
_executablesAccessor = executablesAccessor;
Commands = commands;
}

Expand All @@ -25,7 +27,7 @@ public MainViewModel(ObservableCollection<CommandDto> commands, ICommandsDataAcc
{
var editWindow = new EditWindow
{
DataContext = new EditViewModel(new CommandDto(), _commandsDataAccessor)
DataContext = new EditViewModel(new CommandDto(), _commandsDataAccessor, _executablesAccessor)
};
editWindow.ShowDialog();
}
Expand All @@ -38,7 +40,7 @@ public MainViewModel(ObservableCollection<CommandDto> commands, ICommandsDataAcc
var editWindow = new EditWindow
{
DataContext = new EditViewModel(SelectedCommand, _commandsDataAccessor)
DataContext = new EditViewModel(SelectedCommand, _commandsDataAccessor, _executablesAccessor)
};
editWindow.ShowDialog();
}
Expand Down

0 comments on commit 9bcdbc5

Please sign in to comment.