private void _add(object obj) { var newEngine = new Model.Engine() { Servers = Model.Servers, ArchiveDirectories = Model.ArchiveDirectories, VolumeReferenceLoudness = -23.0 }; Model.EngineList.Add(newEngine); var newPlayoutServerViewmodel = new EngineViewmodel(newEngine); _engines.Add(newPlayoutServerViewmodel); SelectedEngine = newPlayoutServerViewmodel; }
public EnginesViewmodel(string connectionString, string connectionStringSecondary) : base(new Model.Engines(connectionString, connectionStringSecondary), typeof(EnginesView), "Engines") { Engines = new ObservableCollection <EngineViewmodel>(Model.EngineList.Select(e => { var newVm = new EngineViewmodel(e); newVm.Load(); return(newVm); })); Engines.CollectionChanged += _engines_CollectionChanged; CommandAdd = new UICommand { ExecuteDelegate = _add }; CommandDelete = new UICommand { ExecuteDelegate = o => Engines.Remove(_selectedEngine), CanExecuteDelegate = o => _selectedEngine != null }; }