public ShooterEditViewModel() { AddToAssingedParticipationCommand = new RelayCommand <ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand <ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand <object>(ExecuteCloseCommand); AssignShooterCollectionCommand = new RelayCommand <UiShooterCollection>(ExecuteAssignShooterCommand, CanExecuteAssignShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _personDataStore = config.GetPersonDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.ShooterSelected += shooter => { UiShooter = shooter; }; _uiEvents.RequireSelectedShooter(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); LoadData(); UiShooterCollections = new ObservableCollection <UiShooterCollection>(_shooterCollectionDataStore.GetAll().Select(UiBusinessObjectMapper.ToUiShooterCollection).OrderBy(_ => _.CollectionName)); } }
public ShooterEditViewModel() { AddToAssingedParticipationCommand = new RelayCommand<ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand<ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand<object>(ExecuteCloseCommand); AssignShooterCollectionCommand = new RelayCommand<UiShooterCollection>(ExecuteAssignShooterCommand, CanExecuteAssignShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _collectionShooterDataStore = config.GetCollectionShooterDataStore(); _personDataStore = config.GetPersonDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.ShooterSelected += shooter => { UiShooter = shooter; }; _uiEvents.RequireSelectedShooter(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _shooterCollectionDataStore = config.GetShooterCollectionDataStore(); _shooterCollectionParticipationDataStore = config.GetShooterCollectionParticipationDataStore(); LoadData(); UiShooterCollections = new ObservableCollection<UiShooterCollection>(_shooterCollectionDataStore.GetAll().Select(UiBusinessObjectMapper.ToUiShooterCollection).OrderBy(_ => _.CollectionName)); } }
public ShooterCreateViewModel() { AddToAssingedParticipationCommand = new RelayCommand <ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand <ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand <object>(ExecuteCloseCommand); CreateShooterCommand = new RelayCommand <UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.PersonSelected += person => { UiPerson = person; }; _uiEvents.RequireSelectedPerson(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _ssvShooterDataWriterService = config.GetSsvShooterDataWriterService(); LoadAvailableParticipationList(); LoadAssignedParticipationList(); } }
public ShooterCreateViewModel() { AddToAssingedParticipationCommand = new RelayCommand<ParticipationListItem>(ExecuteAddToAssignedParticipationCommand, CanExecuteAddtoAssignedParticipationCommand); RemoveFromAssingedParticipationCommand = new RelayCommand<ShooterParticipationListItem>(ExecuteRemoveFromAssignedParticipationCommand, CanExecuteRemoveFromAssignedParticipationCommand); CancelCommand = new RelayCommand<object>(ExecuteCloseCommand); CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _participationDataStore = config.GetParticipationDataStore(); _windowService = config.GetWindowService(); _shooterParticipationDataStore = config.GetShooterParticipationDataStore(); _uiEvents = config.GetUIEvents(); _uiEvents.PersonSelected += person => { UiPerson = person; }; _uiEvents.RequireSelectedPerson(); _shooterNumberService = config.GetShooterNumberService(); _shooterDataStore = config.GetShooterDataStore(); _shooterParticipationView = config.GetShooterParticipationView(); _ssvShooterDataWriterService = config.GetSsvShooterDataWriterService(); LoadAvailableParticipationList(); LoadAssignedParticipationList(); } }
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); }
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); }
public void Initialize() { _personDataStore = ServiceLocator.Current.GetInstance <IPersonDataStore>(); _shooterDataStore = ServiceLocator.Current.GetInstance <IShooterDataStore>(); _shooterNumberService = ServiceLocator.Current.GetInstance <IShooterNumberService>(); _shooterDataWriter = ServiceLocator.Current.GetInstance <ISsvShooterDataWriterService>(); _collectionShooterDataStore = ServiceLocator.Current.GetInstance <ICollectionShooterDataStore>(); _shooterCollectionDataStore = ServiceLocator.Current.GetInstance <IShooterCollectionDataStore>(); _serviceDeskConfiguration = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>(); MessengerInstance.Register <PersonSelectedMessage>(this, x => { UpdateCommandCanExecuteOnSelectedPersonChanged(); LoadShooters(x.PersonId); }); MessengerInstance.Register <SetSelectedPersonMessage>(this, x => { SelectedPerson = FilteredPersons.FirstOrDefault(person => person.PersonId == x.PersonId); }); MessengerInstance.Register <SetSelectedShooterMessage>(this, x => { SelectedShooter = Shooters.FirstOrDefault(s => s.Shooter.ShooterId == x.ShooterId); if (SelectedShooter == null) { SelectedShooter = Shooters.FirstOrDefault(); } }); MessengerInstance.Register <RefreshDataFromRepositoriesMessage>(this, x => { UiPerson selectedPerson = SelectedPerson; ShooterViewModel selectedShooter = SelectedShooter; LoadPersons(); if (selectedPerson != null) { MessengerInstance.Send(new SetSelectedPersonMessage(selectedPerson.PersonId)); } if (selectedShooter != null) { MessengerInstance.Send(new SetSelectedShooterMessage(selectedShooter.Shooter.ShooterId)); } }); }
public PersonEditViewModel() { EditPersonCommand = new RelayCommand <UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand); CancelCommand = new RelayCommand <object>(ExecuteCloseCommand); //CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _personDataStore = config.GetPersonDataStore(); _shooterDataStore = config.GetShooterDataStore(); _uiEvents = config.GetUIEvents(); _windowService = config.GetWindowService(); _shooterNumberService = config.GetShooterNumberService(); _uiEvents.PersonSelected += person => { UiPerson = person ?? new UiPerson(); }; _uiEvents.RequireSelectedPerson(); } }
public PersonEditViewModel() { EditPersonCommand = new RelayCommand<UiPerson>(ExecuteEditPersonCommand, CanExecuteEditPersonCommand); CancelCommand = new RelayCommand<object>(ExecuteCloseCommand); //CreateShooterCommand = new RelayCommand<UiPerson>(ExecuteCreateShooterCommand, CanExecuteCreateShooterCommand); if (!DesignTimeHelper.IsInDesignMode) { IConfiguration config = ConfigurationSource.Configuration; _personDataStore = config.GetPersonDataStore(); _shooterDataStore = config.GetShooterDataStore(); _uiEvents = config.GetUIEvents(); _windowService = config.GetWindowService(); _shooterNumberService = config.GetShooterNumberService(); _uiEvents.PersonSelected += person => { UiPerson = person ?? new UiPerson(); }; _uiEvents.RequireSelectedPerson(); } }
public void Initialize() { _personDataStore = ServiceLocator.Current.GetInstance<IPersonDataStore>(); _shooterDataStore = ServiceLocator.Current.GetInstance<IShooterDataStore>(); _shooterNumberService = ServiceLocator.Current.GetInstance<IShooterNumberService>(); _shooterDataWriter = ServiceLocator.Current.GetInstance<ISsvShooterDataWriterService>(); _collectionShooterDataStore = ServiceLocator.Current.GetInstance<ICollectionShooterDataStore>(); _shooterCollectionDataStore = ServiceLocator.Current.GetInstance<IShooterCollectionDataStore>(); _serviceDeskConfiguration = ServiceLocator.Current.GetInstance<ServiceDeskConfiguration>(); MessengerInstance.Register<PersonSelectedMessage>(this, x => { UpdateCommandCanExecuteOnSelectedPersonChanged(); LoadShooters(x.PersonId); }); MessengerInstance.Register<SetSelectedPersonMessage>(this, x => { SelectedPerson = FilteredPersons.FirstOrDefault(person => person.PersonId == x.PersonId); }); MessengerInstance.Register<SetSelectedShooterMessage>(this, x => { SelectedShooter = Shooters.FirstOrDefault(s => s.Shooter.ShooterId == x.ShooterId); if (SelectedShooter == null) SelectedShooter = Shooters.FirstOrDefault(); }); MessengerInstance.Register<RefreshDataFromRepositoriesMessage>(this, x => { UiPerson selectedPerson = SelectedPerson; ShooterViewModel selectedShooter = SelectedShooter; LoadPersons(); if (selectedPerson != null) MessengerInstance.Send(new SetSelectedPersonMessage(selectedPerson.PersonId)); if (selectedShooter != null) MessengerInstance.Send(new SetSelectedShooterMessage(selectedShooter.Shooter.ShooterId)); }); }