Esempio n. 1
0
 /// <summary>
 /// True if the search input applies to the model
 /// </summary>
 public bool SearchInputApplies(RaceSearchInput searchInput, RaceModel raceModel)
 {
     return(HasSearchText(raceModel, searchInput.SearchText) &&
            IsSize(raceModel, searchInput.Size.Key) &&
            HasAbility(raceModel, searchInput.Ability.Key) &&
            HasLanguage(raceModel, searchInput.Language.Key));
 }
Esempio n. 2
0
        /// <summary>
        /// Creates an instance of <see cref="RacesViewModel"/>
        /// </summary>
        public RacesViewModel(Compendium compendium, RaceSearchService raceSearchService, RaceSearchInput raceSearchInput,
                              StringService stringService, DialogService dialogService, XMLImporter xmlImporter, XMLExporter xmlExporter)
        {
            _compendium        = compendium;
            _raceSearchService = raceSearchService;
            _raceSearchInput   = raceSearchInput;
            _stringService     = stringService;
            _dialogService     = dialogService;
            _xmlImporter       = xmlImporter;
            _xmlExporter       = xmlExporter;

            _selectRaceCommand     = new RelayCommand(obj => true, obj => SelectRace(obj as RaceListItemViewModel));
            _editRaceCommand       = new RelayCommand(obj => true, obj => EditRace(obj as RaceViewModel));
            _exportRaceCommand     = new RelayCommand(obj => true, obj => ExportRace(obj as RaceViewModel));
            _cancelEditRaceCommand = new RelayCommand(obj => true, obj => CancelEditRace());
            _saveEditRaceCommand   = new RelayCommand(obj => HasUnsavedChanges, obj => SaveEditRace());
            _resetFiltersCommand   = new RelayCommand(obj => true, obj => InitializeSearch());
            _addCommand            = new RelayCommand(obj => true, obj => Add());
            _copyCommand           = new RelayCommand(obj => _selectedRace != null, obj => Copy());
            _deleteCommand         = new RelayCommand(obj => _selectedRace != null, obj => Delete());
            _importCommand         = new RelayCommand(obj => true, obj => Import());
            _selectNextCommand     = new RelayCommand(obj => true, obj => SelectNext());
            _selectPreviousCommand = new RelayCommand(obj => true, obj => SelectPrevious());

            Search();
        }
Esempio n. 3
0
 /// <summary>
 /// Searches the compendium for races matching the search input
 /// </summary>
 public List <RaceModel> Search(RaceSearchInput searchInput)
 {
     return(Sort(_compendium.Races.Where(x => SearchInputApplies(searchInput, x)), searchInput.SortOption.Key));
 }