mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
- Added check for dependencies, which can be installed from the builder. - Replaced CosmosTask with CosmosBuildDefinition, which is much simpler. - The builder can be opened without any command line arguments. - If the VS path is not specified as a command line argument, it can be selected in a dialog.
53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
using Cosmos.Build.Builder.Models;
|
|
using Cosmos.Build.Builder.Services;
|
|
|
|
namespace Cosmos.Build.Builder.ViewModels
|
|
{
|
|
internal class VisualStudioInstanceDialogViewModel : ViewModelBase
|
|
{
|
|
public IEnumerable<VisualStudioInstance> VisualStudioInstances { get; }
|
|
|
|
public VisualStudioInstance SelectedVisualStudioInstance
|
|
{
|
|
get => _selectedVisualStudioInstance;
|
|
set => SetAndRaiseIfChanged(ref _selectedVisualStudioInstance, value);
|
|
}
|
|
|
|
public ICommand OkCommand { get; }
|
|
public ICommand CancelCommand { get; }
|
|
|
|
private IVisualStudioService _visualStudioService;
|
|
|
|
private VisualStudioInstance _selectedVisualStudioInstance;
|
|
|
|
public VisualStudioInstanceDialogViewModel(IVisualStudioService visualStudioService)
|
|
{
|
|
_visualStudioService = visualStudioService;
|
|
|
|
VisualStudioInstances = _visualStudioService.GetInstances().Select(i => new VisualStudioInstance(i)).ToList();
|
|
SelectedVisualStudioInstance = VisualStudioInstances.FirstOrDefault();
|
|
|
|
OkCommand = new RelayCommand(p => Close(p as Window, true));
|
|
CancelCommand = new RelayCommand(p => Close(p as Window, false));
|
|
}
|
|
|
|
private void Close(Window window, bool? dialogResult)
|
|
{
|
|
#if DEBUG
|
|
if (window == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(window));
|
|
}
|
|
#endif
|
|
|
|
window.DialogResult = dialogResult;
|
|
window.Close();
|
|
}
|
|
}
|
|
}
|