/// <summary> /// Receive edited service from the EditViewModel /// </summary> private void getServiceEdit() { Messenger.Default.Register <ServiceItem>( this, service => { if (SelectedServicesCollection.Any(x => x.OriginalDisplayName == service.OriginalDisplayName)) { SelectedServicesCollection[SelectedServicesCollection.IndexOf(service)].DisplayName = service.DisplayName; SelectedServicesCollection[SelectedServicesCollection.IndexOf(service)].Description = service.Description; } }); }
/// <summary> /// Save services in SelectedServicesCollection when programm closes /// </summary> private void saveServices() { try { ServiceManager.SetSavedServiceItems(SelectedServicesCollection.ToList()); } catch (Exception ex) { string caption = "Save error"; string exception = ex.Message; string exceptionMessage = String.Format("{0} {1}", exception, "\n" + ex.InnerException ?? ex.InnerException.Message); base.ShowErrorMessage(exceptionMessage, caption); } }
/// <summary> /// Get selected services from the collection of services on the AddWindow /// </summary> private void displaySelectedServices() { Messenger.Default.Register <ObservableCollection <ServiceItem> >( this, services => { foreach (ServiceItem service in services) { if (!SelectedServicesCollection.Any(x => x.DisplayName == service.DisplayName)) { SelectedServicesCollection.Add(service); } } }); }
/// <summary> /// Refresh all services in datagrid selected or not, check if still exists and display info message if was removed /// </summary> private void refreshAllServicesStatus() { if (SelectedServicesCollection.Count != 0) { foreach (ServiceItem service in SelectedServicesCollection.ToList()) { if (ServiceManager.IsServiceExists(service.ServiceName)) { service.Status = ServiceManager.RefreshStatus(service).Status; service.StartMode = ServiceManager.RefreshStatus(service).StartMode; } else { SelectedServicesCollection.Remove(service); base.ShowInfoMessage(service.DisplayName + " " + "(" + service.ServiceName + ")" + " " + "was removed", "Load Info"); } } } }