private void AssociatedObjectOnMouseLeave(object sender, MouseEventArgs mouseEventArgs) { if (mouseIsDown) { EndDrag(); ViewModelCommunication.SendTo( Constants.ViewModelCollections.AppointmentViewModelCollection, AppointmentModifications.OriginalAppointment.Id, new ShowDisabledOverlay() ); AdornerControl.CreateAdorner(AppointmentModifications.OriginalAppointment.Patient.Name, AppointmentModifications.CurrentAppointmentPixelWidth); DragDrop.DoDragDrop((DependencyObject)sender, AppointmentModifications.OriginalAppointment, DragDropEffects.Link); AdornerControl.DisposeAdorner(); ViewModelCommunication.SendTo( Constants.ViewModelCollections.AppointmentViewModelCollection, AppointmentModifications.OriginalAppointment.Id, new HideDisabledOverlay() ); } }
protected override void CleanUp() { ViewModelCommunication.DeregisterViewModelAtCollection <AppointmentViewModel, Guid>( Constants.ViewModelCollections.AppointmentViewModelCollection, this ); ViewModelCommunication.SendTo( Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection, currentLocation, new RemoveAppointmentFromTherapyPlaceRow(this) ); }
private void SetNewLocation(TherapyPlaceRowIdentifier therapyPlaceRowIdentifier, bool isInitialLocation) { if (!isInitialLocation) { ViewModelCommunication.SendTo( Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection, currentLocation, new RemoveAppointmentFromTherapyPlaceRow(this) ); } currentLocation = therapyPlaceRowIdentifier; ViewModelCommunication.SendTo( Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection, therapyPlaceRowIdentifier, new AddAppointmentToTherapyPlaceRow(this) ); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); AssureAppDataDirectoriesExist(); /////////////////////////////////////////////////////////////////////////////////////////////// //////// ////////// //////// Composition Root and Setup ////////// //////// ////////// /////////////////////////////////////////////////////////////////////////////////////////////// var connectionService = new ConnectionService(); var eventBus = new ClientEventBus(connectionService); var commandHandlerCollection = new SingleHandlerCollection <DomainCommand>(); var commandMessageBus = new LocalMessageBus <DomainCommand>(commandHandlerCollection); var commandBus = new CommandBus(commandMessageBus); var persistenceService = new LocalSettingsXMLPersistenceService(GlobalConstants.LocalSettingsPersistenceFile); var localSettingsRepository = new LocalSettingsRepository(persistenceService); localSettingsRepository.LoadRepository(); var clientMedicalPracticeRepository = new ClientMedicalPracticeRepository(connectionService); var clientPatientRepository = new ClientPatientRepository(connectionService); var clienttherapyPlaceTypeRepository = new ClientTherapyPlaceTypeRepository(connectionService); var clientLabelRepository = new ClientLabelRepository(connectionService); var clientReadmodelRepository = new ClientReadModelRepository(eventBus, clientPatientRepository, clientMedicalPracticeRepository, clientLabelRepository, connectionService); var workFlow = new ClientWorkflow(); var session = new Session(connectionService, workFlow); var fatalErrorHandler = new FatalErrorHandler(session); var commandService = new CommandService(session, clientReadmodelRepository, commandBus); var userActionBuilder = new UserActionBuilder(commandService); // CommandHandler var addAppointmentCommandHandler = new AddAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); var deleteAppointmentCommandHandler = new DeleteAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); var replaceAppointmentCommandHandler = new ReplaceAppointmentCommandHandler(connectionService, session, clientPatientRepository, clientMedicalPracticeRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); commandBus.RegisterCommandHandler(addAppointmentCommandHandler); commandBus.RegisterCommandHandler(deleteAppointmentCommandHandler); commandBus.RegisterCommandHandler(replaceAppointmentCommandHandler); // initiate ViewModelCommunication var handlerCollection = new MultiHandlerCollection <ViewModelMessage>(); IMessageBus <ViewModelMessage> viewModelMessageBus = new LocalMessageBus <ViewModelMessage>(handlerCollection); IViewModelCollectionList viewModelCollections = new ViewModelCollectionList(); IViewModelCommunication viewModelCommunication = new ViewModelCommunication(viewModelMessageBus, viewModelCollections); var mainWindowBuilder = new MainWindowBuilder(localSettingsRepository, clientPatientRepository, clientMedicalPracticeRepository, clientReadmodelRepository, clienttherapyPlaceTypeRepository, clientLabelRepository, commandService, viewModelCommunication, session, "0.1.0.0", // TODO: get real versionNumber fatalErrorHandler.HandleFatalError); var mainWindow = mainWindowBuilder.BuildWindow(); mainWindow.ShowDialog(); /////////////////////////////////////////////////////////////////////////////////////////////// //////// ////////// //////// Clean Up and store data after main Window was closed ////////// //////// ////////// /////////////////////////////////////////////////////////////////////////////////////////////// localSettingsRepository.PersistRepository(); connectionService.Dispose(); }
public void BuildAndStart(StartupEventArgs startupEventArgs) { #if DEBUG var listener = new OnkoTePlaDebugListener(); Debug.Listeners.Add(listener); #endif AssureAppDataDirectoriesExist(); connectionService = new ConnectionService(); var eventBus = new ClientEventBus(connectionService); var commandHandlerCollection = new SingleHandlerCollection <DomainCommand>(); var commandMessageBus = new LocalMessageBus <DomainCommand>(commandHandlerCollection); var commandBus = new CommandBus(commandMessageBus); var persistenceService = new LocalSettingsXMLPersistenceService(GlobalConstants.LocalSettingsPersistenceFile); localSettingsRepository = new LocalSettingsRepository(persistenceService); localSettingsRepository.LoadRepository(); var clientMedicalPracticeRepository = new ClientMedicalPracticeRepository(connectionService); var clientPatientRepository = new ClientPatientRepository(connectionService); var clienttherapyPlaceTypeRepository = new ClientTherapyPlaceTypeRepository(connectionService); var clientLabelRepository = new ClientLabelRepository(connectionService); var clientReadmodelRepository = new ClientReadModelRepository(eventBus, clientPatientRepository, clientMedicalPracticeRepository, clientLabelRepository, connectionService); var workFlow = new ClientWorkflow(); var session = new Session(connectionService, workFlow); var fatalErrorHandler = new FatalErrorHandler(session); var commandService = new CommandService(session, clientReadmodelRepository, commandBus); var userActionBuilder = new UserActionBuilder(commandService); // CommandHandler var addAppointmentCommandHandler = new AddAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); var deleteAppointmentCommandHandler = new DeleteAppointmentCommandHandler(connectionService, session, clientPatientRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); var replaceAppointmentCommandHandler = new ReplaceAppointmentCommandHandler(connectionService, session, clientPatientRepository, clientMedicalPracticeRepository, userActionBuilder, fatalErrorHandler.HandleFatalError); commandBus.RegisterCommandHandler(addAppointmentCommandHandler); commandBus.RegisterCommandHandler(deleteAppointmentCommandHandler); commandBus.RegisterCommandHandler(replaceAppointmentCommandHandler); // initiate ViewModelCommunication var handlerCollection = new MultiHandlerCollection <ViewModelMessage>(); IMessageBus <ViewModelMessage> viewModelMessageBus = new LocalMessageBus <ViewModelMessage>(handlerCollection); IViewModelCollectionList viewModelCollections = new ViewModelCollectionList(); IViewModelCommunication viewModelCommunication = new ViewModelCommunication(viewModelMessageBus, viewModelCollections); var mainWindowBuilder = new MainWindowBuilder(localSettingsRepository, clientPatientRepository, clientMedicalPracticeRepository, clientReadmodelRepository, clienttherapyPlaceTypeRepository, clientLabelRepository, commandService, viewModelCommunication, session, fatalErrorHandler.HandleFatalError); var mainWindow = mainWindowBuilder.BuildWindow(); mainWindow.Show(); #if DEBUG var debugOutputWindowViewModel = new DebugOutputWindowViewModel(listener); var debugWindow = new DebugOutputWindow { Owner = mainWindow, DataContext = debugOutputWindowViewModel }; debugWindow.Show(); #endif }