private void PopulateMenuItems() { this.MenuItems = new ObservableCollection <MenuItemViewModelBase>(); this.MenuItems.Add(new MenuItemViewModel() { Header = "Start", Icon = App.GetImageResource("Run.ico"), Command = new DelegateCommand(t => this.Start(), t => this.CanStart()), }); this.MenuItems.Add(new MenuItemViewModel() { Header = "Stop", Icon = App.GetImageResource("Stop.ico"), Command = new DelegateCommand(t => this.Stop(false), t => this.CanStop()), }); this.MenuItems.Add(new MenuItemViewModel() { Header = "Stop and cancel run", Icon = App.GetImageResource("Stop.ico"), Command = new DelegateCommand(t => this.Stop(true), t => this.CanStop() && this.CanCancelRun()), }); this.MenuItems.Add(new MenuItemViewModel() { Header = "Cancel run", Icon = App.GetImageResource("Cancel.ico"), Command = new DelegateCommand(t => this.CancelRun(), t => this.CanCancelRun()), }); try { MenuItemViewModel addrp = new MenuItemViewModel() { Header = "Add run profile to execution queue", Command = new DelegateCommand(t => { }, t => this.CanAddToExecutionQueue()) }; ConfigClient c = App.GetDefaultConfigClient(); c.InvokeThenClose(u => { foreach (string rp in c.GetManagementAgentRunProfileNames(this.ManagementAgentID, true).OrderBy(t => t)) { addrp.MenuItems.Add(new MenuItemViewModel() { Header = rp, Command = new DelegateCommand(t => this.AddToExecutionQueue(rp)), }); } }); if (addrp.MenuItems.Count > 0) { this.MenuItems.Add(new SeparatorViewModel()); this.MenuItems.Add(addrp); } } catch (Exception ex) { Trace.WriteLine("Error getting the run profile list"); Trace.WriteLine(ex.ToString()); } }