Ejemplo n.º 1
0
        public MainViewModel()
        {
            if (DesignTimeHelper.IsInDesignMode)
            {
                _personDataStore        = new FakePersonDataStore();
                _shooterDataStore       = new FakeShooterDataStore();
                _participationDataStore = new FakeParticipationDataStore();
                _groupMemberDetailsView = new FakeGroupMemberDetailsView();
                _groupDetailsView       = new FakeGroupDetailsView();
            }
            else
            {
                IConfiguration config = ConfigurationSource.Configuration;
                _personDataStore                         = config.GetPersonDataStore();
                _shooterDataStore                        = config.GetShooterDataStore();
                _participationDataStore                  = config.GetParticipationDataStore();
                _shooterParticipationDataStore           = config.GetShooterParticipationDataStore();
                _groupMemberDetailsView                  = config.GetGroupMemberDetailsView();
                _shooterParticipationView                = config.GetShooterParticipationView();
                _groupDetailsView                        = config.GetGroupDetailsView();
                _sessionDetailsView                      = config.GetSessionDetailsView();
                _shooterDataWriterService                = config.GetSsvShooterDataWriterService();
                _collectionShooterDataStore              = config.GetCollectionShooterDataStore();
                _shooterCollectionDataStore              = config.GetShooterCollectionDataStore();
                _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore();
                _shooterNumberService                    = config.GetShooterNumberService();
                _windowService         = config.GetWindowService();
                _barcodePrintService   = config.GetBarcodePrintService();
                _barcodeBuilderService = config.GetBarcodeBuilderService();
                _events   = config.GetEvents();
                _uiEvents = config.GetUIEvents();
                _uiEvents.RequireSelectedPerson   += () => _uiEvents.PersonSelected(SelectedUiPerson);
                _uiEvents.SelectPersonById        += (id) => { SelectedUiPerson = UiPeople.FirstOrDefault(_ => _.PersonId == id); };
                _uiEvents.RequireSelectedShooter  += () => _uiEvents.ShooterSelected(SelectedUiShooter);
                _uiEvents.FetchSelectedShooter    += () => SelectedUiShooter;
                _uiEvents.PersonDataStoreChanged  += LoadPersonList;
                _uiEvents.ShooterDataStoreChanged += LoadShooterList;
                _shooterNumberService.Configure(_shooterDataStore);

                LoadPersonList();
                LoadShooterList();
                LoadParticipationList();
            }

            CreatePersonCommand = new RelayCommand <object>(ExecuteCreatePersonCommand);
            EditPersonCommand   = new RelayCommand <UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand);
            DeletePersonCommand = new RelayCommand <UiPerson>(ExecuteDeletePersonCommand, CanExecuteDeletePersonCommand);

            CreateShooterCommand = new RelayCommand <UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand);
            EditShooterCommand   = new RelayCommand <UiShooter>(ExecuteEditShooterCommand, CanExecuteEditShooterCommand);
            DeleteShooterCommand = new RelayCommand <UiShooter>(ExecuteDeleteShooterCommand, CanExecuteDeleteShooterCommand);

            CreateParticipationCommand = new RelayCommand <object>(ExecuteCreateParticipationCommand);
            //EditParticipationCommand = new RelayCommand<UiParticipation>
            //DeleteParticipationCommand = new RelayCommand<UiParticipation>

            PrintBarcodeCommand = new RelayCommand <UiShooter>(ExecutePrintBarcodeCommand, CanExecutePrintBarcodeCommand);
            EditPassCommand     = new RelayCommand <SessionDetails>(ExecuteEditPassCommand);
        }
Ejemplo n.º 2
0
    public MainViewModel()
    {
      if (DesignTimeHelper.IsInDesignMode)
      {
        _personDataStore = new FakePersonDataStore();
        _shooterDataStore = new FakeShooterDataStore();
        _participationDataStore = new FakeParticipationDataStore();
        _groupMemberDetailsView = new FakeGroupMemberDetailsView();
        _groupDetailsView = new FakeGroupDetailsView();
      }
      else
      {
        IConfiguration config = ConfigurationSource.Configuration;
        _personDataStore = config.GetPersonDataStore();
        _shooterDataStore = config.GetShooterDataStore();
        _participationDataStore = config.GetParticipationDataStore();
        _shooterParticipationDataStore = config.GetShooterParticipationDataStore();
        _groupMemberDetailsView = config.GetGroupMemberDetailsView();
        _shooterParticipationView = config.GetShooterParticipationView();
        _groupDetailsView = config.GetGroupDetailsView();
        _sessionDetailsView = config.GetSessionDetailsView();
        _shooterDataWriterService = config.GetSsvShooterDataWriterService();
        _collectionShooterDataStore = config.GetCollectionShooterDataStore();
        _shooterCollectionDataStore = config.GetShooterCollectionDataStore();
        _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore();
        _shooterNumberService = config.GetShooterNumberService();
        _windowService = config.GetWindowService();
        _barcodePrintService = config.GetBarcodePrintService();
        _barcodeBuilderService = config.GetBarcodeBuilderService();
        _events = config.GetEvents();
        _uiEvents = config.GetUIEvents();
        _uiEvents.RequireSelectedPerson += () => _uiEvents.PersonSelected(SelectedUiPerson);
        _uiEvents.SelectPersonById += (id) => { SelectedUiPerson = UiPeople.FirstOrDefault(_ => _.PersonId == id); };
        _uiEvents.RequireSelectedShooter += () => _uiEvents.ShooterSelected(SelectedUiShooter);
        _uiEvents.FetchSelectedShooter += () => SelectedUiShooter;
        _uiEvents.PersonDataStoreChanged += LoadPersonList;
        _uiEvents.ShooterDataStoreChanged += LoadShooterList;
        _shooterNumberService.Configure(_shooterDataStore);

        LoadPersonList();
        LoadShooterList();
        LoadParticipationList();
      }

      CreatePersonCommand = new RelayCommand<object>(ExecuteCreatePersonCommand);
      EditPersonCommand = new RelayCommand<UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand);
      DeletePersonCommand = new RelayCommand<UiPerson>(ExecuteDeletePersonCommand, CanExecuteDeletePersonCommand);
      
      CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand);
      EditShooterCommand = new RelayCommand<UiShooter>(ExecuteEditShooterCommand, CanExecuteEditShooterCommand);
      DeleteShooterCommand = new RelayCommand<UiShooter>(ExecuteDeleteShooterCommand, CanExecuteDeleteShooterCommand);

      CreateParticipationCommand = new RelayCommand<object>(ExecuteCreateParticipationCommand);
      //EditParticipationCommand = new RelayCommand<UiParticipation>
      //DeleteParticipationCommand = new RelayCommand<UiParticipation>

      PrintBarcodeCommand = new RelayCommand<UiShooter>(ExecutePrintBarcodeCommand, CanExecutePrintBarcodeCommand);
      EditPassCommand = new RelayCommand<SessionDetails>(ExecuteEditPassCommand);
    }