Esempio n. 1
0
        public PrintDialogViewModel(AggregateIdentifier identifier,
                                    IClientMedicalPracticeRepository medicalPracticeRepository,
                                    IClientReadModelRepository readModelRepository,
                                    Action <string> errorCallback)
        {
            Cancel = new Command(CloseWindow);
            Print  = new ParameterrizedCommand <FrameworkElement>(DoPrint);

            medicalPracticeRepository.RequestMedicalPractice(
                practice =>
            {
                readModelRepository.RequestAppointmentSetOfADay(
                    appointmentSet =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var initialGridSize = CurrentGridSize ?? new Size(new Width(850), new Height(600));

                        AppointmentGrid = new PrintAppointmentGridViewModel(identifier, practice, appointmentSet.Appointments, initialGridSize);
                    });
                },
                    identifier,
                    errorCallback
                    );
            },
                identifier.MedicalPracticeId,
                identifier.Date,
                errorCallback
                );
        }
Esempio n. 2
0
        public SearchPageViewModel(IPatientSelectorViewModel patientSelectorViewModel,
                                   ISharedStateReadOnly <Patient> selectedPatientVariable,
                                   ISharedState <Date> selectedDateVariable,
                                   IViewModelCommunication viewModelCommunication,
                                   ICommandService commandService,
                                   IClientReadModelRepository readModelRepository,
                                   IClientMedicalPracticeRepository medicalPracticeRepository,
                                   Action <string> errorCallBack)
        {
            this.selectedPatientVariable   = selectedPatientVariable;
            this.viewModelCommunication    = viewModelCommunication;
            this.commandService            = commandService;
            this.readModelRepository       = readModelRepository;
            this.medicalPracticeRepository = medicalPracticeRepository;
            this.errorCallBack             = errorCallBack;
            this.selectedDateVariable      = selectedDateVariable;

            NoAppointmentsAvailable = false;

            selectedPatientVariable.StateChanged += OnSelectedPatientVariableChanged;

            PatientSelectorViewModel = patientSelectorViewModel;

            DeleteAppointment = new ParameterrizedCommand <DisplayAppointmentData>(DoDeleteAppointment);
            ModifyAppointment = new ParameterrizedCommand <DisplayAppointmentData>(DoModifyAppointment);

            SelectedPatient = NoPatientSelected;

            DisplayedAppointments = new ObservableCollection <DisplayAppointmentData>();
        }
Esempio n. 3
0
        public CommandExampleViewModel()
        {
            SomeInput = string.Empty;

            DoSomeAction = new Command(() => MessageBox.Show("Action"),
                                       () => SomeInput == "ACTION",
                                       new PropertyChangedCommandUpdater(this, nameof(SomeInput)));

            DoSomeActionWithParameter = new ParameterrizedCommand <string>(param => MessageBox.Show($"How cool is {param}?!"));
            // Can-Execute-Func and updater is here possible too (like the command above)
        }
Esempio n. 4
0
        public LoginViewModel(ISession session,
                              ILocalSettingsRepository localSettingsRepository)
        {
            this.session = session;
            this.localSettingsRepository = localSettingsRepository;

            Login = new ParameterrizedCommand <PasswordBox>(DoLogin,
                                                            IsLoginPossible);

            Connect = new Command(DoConnect,
                                  IsConnectPossible);

            DebugConnect = new Command(DoDebugConnect,
                                       IsConnectPossible);

            Disconnect = new Command(DoDisconnect,
                                     IsDisconnectPossible);

            AutoConnectOnNextStart = localSettingsRepository.IsAutoConnectionEnabled;

            AvailableUsers = new ObservableCollection <ClientUserData>();

            ClientIpAddresses = IpAddressCatcher.GetAllAvailableLocalIpAddresses()
                                .Select(address => address.Identifier.ToString())
                                .ToObservableCollection();

            ClientAddress = ClientIpAddresses.First();

            session.ApplicationStateChanged += OnApplicationStateChanged;
            OnApplicationStateChanged(session.CurrentApplicationState);

            AreConnectionSettingsVisible = !AutoConnectOnNextStart;

            if (AutoConnectOnNextStart)
            {
                var clientIpAddress = localSettingsRepository.AutoConnectionClientAddress.ToString();

                if (ClientIpAddresses.Contains(clientIpAddress))
                {
                    ClientAddress = clientIpAddress;
                    ServerAddress = localSettingsRepository.AutoConnectionServerAddress.ToString();
                    Connect.Execute(null);
                }
            }
        }
Esempio n. 5
0
        public MainWindowViewModel(IOverviewPageViewModel overviewPageViewModel,
                                   IConnectionsPageViewModel connectionsPageViewModel,
                                   IUserPageViewModel userPageViewModel,
                                   ILicencePageViewModel licencePageViewModel,
                                   IInfrastructurePageViewModel infrastructurePageViewModel,
                                   IHoursOfOpeningPageViewModel hoursOfOpeningPageViewModel,
                                   ITherapyPlaceTypesPageViewModel therapyPlaceTypesPageViewModel,
                                   ILabelPageViewModel labelPageViewModel,
                                   IPatientsPageViewModel patientsPageViewModel,
                                   IBackupPageViewModel backupPageViewModel,
                                   IOptionsPageViewModel optionsPageViewModel,
                                   IAboutPageViewModel aboutPageViewModel,
                                   ISharedState <MainPage> selectedPageVariable)
        {
            this.selectedPageVariable = selectedPageVariable;
            LabelPageViewModel        = labelPageViewModel;
            BackupPageViewModel       = backupPageViewModel;

            selectedPageVariable.StateChanged += OnSelectedPageVariableChanged;

            PatientsPageViewModel          = patientsPageViewModel;
            OverviewPageViewModel          = overviewPageViewModel;
            ConnectionsPageViewModel       = connectionsPageViewModel;
            UserPageViewModel              = userPageViewModel;
            LicencePageViewModel           = licencePageViewModel;
            InfrastructurePageViewModel    = infrastructurePageViewModel;
            HoursOfOpeningPageViewModel    = hoursOfOpeningPageViewModel;
            OptionsPageViewModel           = optionsPageViewModel;
            AboutPageViewModel             = aboutPageViewModel;
            TherapyPlaceTypesPageViewModel = therapyPlaceTypesPageViewModel;

            SwitchToPage = new ParameterrizedCommand <MainPage>(page => SelectedPage = page);
            CloseWindow  = new Command(DoCloseApplication);

            CheckWindowClosing = true;

#if DEBUG
            Title = ">>> DEBUG <<<       OnkoTePla - Server       >>> Debug <<<";
#else
            Title = "OnkoTePla - Server";
#endif
        }
Esempio n. 6
0
        public AppointmentViewModel(Appointment appointment,
                                    ICommandService commandService,
                                    IViewModelCommunication viewModelCommunication,
                                    TherapyPlaceRowIdentifier initialLocalisation,
                                    ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                    ISharedState <Date> selectedDateVariable,
                                    IAppointmentModificationsBuilder appointmentModificationsBuilder,
                                    IWindowBuilder <EditDescription> editDescriptionWindowBuilder,
                                    AdornerControl adornerControl,
                                    Action <string> errorCallback)
        {
            this.appointment         = appointment;
            this.initialLocalisation = initialLocalisation;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.selectedDateVariable             = selectedDateVariable;
            ViewModelCommunication = viewModelCommunication;
            AdornerControl         = adornerControl;

            viewModelCommunication.RegisterViewModelAtCollection <IAppointmentViewModel, Guid>(
                Constants.ViewModelCollections.AppointmentViewModelCollection,
                this
                );

            SwitchToEditMode = new ParameterrizedCommand <bool>(
                isInitalAdjusting =>
            {
                if (appointmentModificationsVariable.Value == null)
                {
                    CurrentAppointmentModifications = appointmentModificationsBuilder.Build(appointment,
                                                                                            initialLocalisation.PlaceAndDate.MedicalPracticeId,
                                                                                            isInitalAdjusting,
                                                                                            errorCallback);

                    CurrentAppointmentModifications.PropertyChanged += OnAppointmentModificationsPropertyChanged;
                    appointmentModificationsVariable.Value           = CurrentAppointmentModifications;
                    OperatingMode = OperatingMode.Edit;
                    appointmentModificationsVariable.StateChanged += OnCurrentModifiedAppointmentChanged;
                }
            }
                );

            DeleteAppointment = new Command(
                async() =>
            {
                var dialog = new UserDialogBox("", "Wollen Sie den Termin wirklich löschen?",
                                               MessageBoxButton.OKCancel);
                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    if (appointmentModificationsVariable.Value.IsInitialAdjustment)
                    {
                        viewModelCommunication.SendTo(                                                                                  //
                            Constants.ViewModelCollections.AppointmentViewModelCollection,                                              // do nothing but
                            appointmentModificationsVariable.Value.OriginalAppointment.Id,                                              // deleting the temporarly
                            new Dispose()                                                                                               // created Appointment
                            );                                                                                                          //
                    }
                    else
                    {
                        commandService.TryDeleteAppointment(
                            operationSuccessful =>
                        {
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                if (!operationSuccessful)
                                {
                                    Process(new RestoreOriginalValues());
                                    viewModelCommunication.Send(new ShowNotification("löschen des Termins fehlgeschlagen; bearbeitung wurde zurückgesetzt", 5));
                                }
                            });
                        },
                            currentLocation.PlaceAndDate,
                            appointment.Patient.Id,
                            appointment.Id,
                            appointment.Description,
                            appointment.StartTime,
                            appointment.EndTime,
                            appointment.TherapyPlace.Id,
                            appointment.Label.Id,
                            ActionTag.RegularAction,
                            errorCallback
                            );
                    }

                    appointmentModificationsVariable.Value = null;
                }
            }
                );

            EditDescription = new Command(
                () =>
            {
                viewModelCommunication.Send(new ShowDisabledOverlay());

                var dialog = editDescriptionWindowBuilder.BuildWindow();
                dialog.ShowDialog();

                viewModelCommunication.Send(new HideDisabledOverlay());
            }
                );

            ConfirmChanges = new Command(() => viewModelCommunication.Send(new ConfirmChanges()));
            RejectChanges  = new Command(() => viewModelCommunication.Send(new RejectChanges()));

            BeginTime   = appointment.StartTime;
            EndTime     = appointment.EndTime;
            Description = appointment.Description;
            LabelColor  = appointment.Label.Color;

            ShowDisabledOverlay = false;

            SetNewLocation(initialLocalisation, true);
        }
Esempio n. 7
0
        public MainWindowViewModel(IBoardViewModel boardViewModel,
                                   IBoardPlacementViewModel boardPlacementViewModel,
                                   ILanguageSelectionViewModel languageSelectionViewModel,
                                   IGameService gameService,
                                   IApplicationSettingsRepository applicationSettingsRepository,
                                   IProgressFileVerifierFactory progressFileVerifierFactory,
                                   bool disableClosingDialog)
        {
            CultureManager.CultureChanged += RefreshCaptions;

            this.gameService = gameService;
            this.applicationSettingsRepository = applicationSettingsRepository;
            this.progressFileVerifierFactory   = progressFileVerifierFactory;
            this.disableClosingDialog          = disableClosingDialog;

            LanguageSelectionViewModel = languageSelectionViewModel;
            BoardPlacementViewModel    = boardPlacementViewModel;
            BoardViewModel             = boardViewModel;

            DebugMessages = new ObservableCollection <string>();
            GameProgress  = new ObservableCollection <string>();

            gameService.NewBoardStateAvailable += OnNewBoardStateAvailable;
            gameService.WinnerAvailable        += OnWinnerAvailable;
            gameService.NewDebugMsgAvailable   += OnNewDebugMsgAvailable;

            IsAutoScrollDebugMsgActive = true;
            IsAutoScrollProgressActive = true;

            PreventWindowClosingToAskUser = !disableClosingDialog;

            TopPlayerName = "- - - - -";
            MovesLeft     = "--";

            BrowseDll = new Command(DoBrowseDll,
                                    () => GameStatus != GameStatus.Active,
                                    new PropertyChangedCommandUpdater(this, nameof(GameStatus)));

            Start = new Command(async() => await DoStart(),
                                () => GameStatus != GameStatus.Active && !string.IsNullOrWhiteSpace(DllPathInput),
                                new PropertyChangedCommandUpdater(this, nameof(GameStatus), nameof(DllPathInput)));

            StartWithProgress = new ParameterrizedCommand <string>(async filePath => await DoStartWithProgress(filePath),
                                                                   _ => GameStatus != GameStatus.Active && !string.IsNullOrWhiteSpace(DllPathInput),
                                                                   new PropertyChangedCommandUpdater(this, nameof(GameStatus), nameof(DllPathInput)));
            Capitulate = new Command(DoCapitulate,
                                     IsMoveApplyable,
                                     new PropertyChangedCommandUpdater(this, nameof(GameStatus)));

            ShowAboutHelp      = new Command(DoShowAboutHelp);
            DumpDebugToFile    = new Command(DoDumpDebugToFile);
            DumpProgressToFile = new Command(DoDumpProgressToFile);
            CloseWindow        = new Command(DoCloseWindow);

            GameStatus = GameStatus.Unloaded;

            DllPathInput              = applicationSettingsRepository.LastUsedBotPath;
            IsDebugSectionExpanded    = applicationSettingsRepository.IsDebugSectionExpanded;
            IsProgressSectionExpanded = applicationSettingsRepository.IsProgressSecionExpanded;

            botCountDownTimer = new Timer(BotCountDownTimerOnTick, null, Timeout.Infinite, Timeout.Infinite);
            StopTimer();
        }