Example #1
0
        public MainWindowViewModel(ISearchViewModel searchViewModel, ILoggerViewModel loggerViewModel, ISearchService searchService, IDispatcher dispatcher)
        {
            if (searchViewModel == null)
            {
                throw new ArgumentNullException(nameof(searchViewModel));
            }

            if (loggerViewModel == null)
            {
                throw new ArgumentNullException(nameof(loggerViewModel));
            }

            if (searchService == null)
            {
                throw new ArgumentNullException(nameof(searchService));
            }

            if (dispatcher == null)
            {
                throw new ArgumentNullException(nameof(dispatcher));
            }

            SearchViewModel = searchViewModel;
            LoggerViewModel = loggerViewModel;

            _searchService = searchService;
            _dispatcher    = dispatcher;
            _searchQueue.CollectionChanged += OnQueueChanged;
        }
Example #2
0
 protected override void Establish_context()
 {
     base.Establish_context();
     _searchViewModel          = new SearchViewModel();
     _searchViewModel.Criteria = "foo";
     _searchViewModel.Results  = new List <ItemType>();
 }
        /// <summary>
        /// Get search results by search view model
        /// </summary>
        /// <param name="searchViewModel"></param>
        /// <returns></returns>
        protected async Task <ActionResult> SearchByViewModel(ISearchViewModel searchViewModel)
        {
            IEnumerable <ISearchResultModel> list;
            int        totalNum;
            string     viewName;
            ISqlAction sqlAction = SqlManager.GetSqlAction(this);

            // Get result list and total result mumber
            if (searchViewModel.IsLatest)
            {
                list     = sqlAction.GetResultIsLatestByFilter(searchViewModel);
                totalNum = sqlAction.GetTotalNumberByFilter(searchViewModel);
                viewName = "_SearchResultIsLatestPartial";
            }
            else
            {
                list     = sqlAction.GetResultByFilter(searchViewModel);
                totalNum = sqlAction.GetTotalNumberByFilter(searchViewModel);
                viewName = "_SearchResultPartial";
            }

            // If requested download
            if (searchViewModel.IsDownload)
            {
                return(ExportToExcel(list.ToList()));
            }

            // Otherwise return view
            ViewBag.Pager = new Pager(totalNum, searchViewModel.Page, ConstantHelper.PaginationPageSize);
            ViewBag.SearchResultViewModel = searchViewModel;
            return(PartialView(viewName, list));
        }
Example #4
0
        internal SearchStateMachine(ISearchViewModel searchViewModel, ISearchService searchService)
        {
            _searchViewModel = searchViewModel;
            _searchService   = searchService;

            CreateStateMachine();
        }
Example #5
0
        public QuestionsViewModel(IApplicationViewModel application = null, ISearchViewModel search = null, INetworkApi networkApi = null)
            : base(application)
        {
            NetworkApi    = networkApi ?? Api <INetworkApi>();
            Search        = Service(search);
            LoadQuestions = ReactiveCommand.CreateFromTask(LoadQuestionsImpl);
            Clear         = ReactiveCommand.Create(() =>
            {
                Questions.Clear();
            });
            Refresh = ReactiveCommand.CreateFromTask(async() =>
            {
                await Clear.Execute();
                await LoadQuestions.Execute();
            }, canExecute: Clear.CanExecute.CombineLatest(LoadQuestions.CanExecute, (canClearExecute, canLoadExecute) => canClearExecute && canLoadExecute));
            DisplayQuestion = ReactiveCommand.CreateFromTask(async(QuestionItemViewModel question) =>
            {
                await Application.Navigate.Handle(new NavigationParams(typeof(QuestionPage), question.Question));
            });

            this.WhenActivated(d =>
            {
                SelectedQuestion = null;

                d(Search.WhenAnyValue(s => s.SelectedSite)
                  .Skip(1)
                  .Select(svm => Unit.Default)
                  .InvokeCommand(this, vm => vm.Refresh));

                d(this.WhenAnyValue(s => s.SelectedQuestion)
                  .Skip(1)
                  .Where(question => question != null)
                  .InvokeCommand(this, vm => vm.DisplayQuestion));
            });
        }
Example #6
0
        public StockTickerViewModel(ISearchViewModel searchViewModel, IBusyIndicationViewModel busyIndication)
        {
            this.Search         = searchViewModel;
            this.BusyIndication = busyIndication;

            this.DisplayName = General.StockTickerTitle;
        }
 private IEnumerable <ResultsViewModel> GetResults(ISearchViewModel model)
 {
     foreach (var item in criminalRepositoryService.Get(model))
     {
         yield return(new ResultsViewModel(item));
     }
 }
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel(IModel model, ISearchViewModel searchViewModel,
                      IStatisticsViewModel statisticsViewModel)
 {
     _model               = model;
     _searchViewModel     = searchViewModel;
     _statisticsViewModel = statisticsViewModel;
     CurrentView          = _searchViewModel as ViewModelBase;
 }
Example #9
0
        public void SearchViewModel_should_reflect_search()
        {
            ISearchViewModel vmdl = ueb.GetSearchViewModel();

            AssertEmptyOrNull(vmdl.SearchText);
            vmdl.SearchText = "Hallo";
            AssertEquals("Hallo", vmdl.SearchText);
        }
Example #10
0
        public void SearchViewModel_should_reflect_active_search()
        {
            ISearchViewModel vmdl = ueb.GetSearchViewModel();

            AssertTrue("IsActive == false", vmdl.IsActive == false);
            vmdl.SearchText = "Hallo";
            AssertTrue("IsActive == true", vmdl.IsActive == true);
        }
Example #11
0
 private void BootStrapper_BackRequested(object sender, HandledEventArgs e)
 {
     if (_interceptedBackButtonDestination != null)
     {
         e.Handled     = true;
         SelectedPivot = _interceptedBackButtonDestination;
         _interceptedBackButtonDestination = null;
     }
 }
 public OutlookBarItemViewModel(IEventAggregator eventAggregator,
                                ISearchViewModel searchViewModel,
                                IGroupTreeViewModelFactory modelFactory)
 {
     _eventAggregator = eventAggregator;
     _searchViewModel = searchViewModel;
     _modelFactory    = modelFactory;
     Initialize();
 }
Example #13
0
 public ShellViewModel(INavigationViewModel navigation, ISearchViewModel search, IArtViewModel art, IStatusViewModel status, IActionTabsViewModel action_tabs)
 {
     Navigation = navigation;
     Search     = search;
     Art        = art;
     Status     = status;
     ActionTabs = action_tabs;
     Navigation.Events.Subscribe(ActionTabs);
 }
        /// <summary>
        /// Launch the view-model's search command
        /// </summary>
        /// <param name="keyword">Search keyword</param>
        private void Search(string keyword)
        {
            ISearchViewModel viewModel = (ISearchViewModel)DataContext;

            if (viewModel.SearchCommand.CanExecute(keyword))
            {
                viewModel.SearchCommand.Execute(keyword);
            }
        }
Example #15
0
        private void SearchForLine(MessageTypes.LineSearchRequested args)
        {
            if (args.Source == typeof(StopSearchContentViewModel))
            {
                _interceptedBackButtonDestination = SelectedPivot;
            }

            SelectedPivot = _linesSearchViewModel;
            _linesSearchViewModel.GetLinesByIdAsync(args.Line.GtfsId).DoNotAwait();
        }
        public IEnumerable <ISearchResultModel> GetResultIsLatestByFilter(ISearchViewModel searchViewModel)
        {
            // Generate sql
            var sqlString = GenerateSqlStringByFilter(searchViewModel, false);

            // get data from database
            var list = GetResultIsLatestBySqlQuery(sqlString);

            return(list);
        }
Example #17
0
        private void UpdateSelectedPivot(ISearchViewModel newPivotSelection)
        {
            MapCircles = newPivotSelection.MapCircles;
            MapPlaces  = newPivotSelection.MapPlaces;
            MapLines   = newPivotSelection.MapLines;

            if (newPivotSelection.OwnedBy == SearchSection.Nearby)
            {
                (SelectedPivot as StopSearchContentViewModel)?.CenterMapOnNearbyCircle();
            }
            return;
        }
        protected override object PaginationRouteValues(ISearchViewModel viewModel)
        {
            var searchViewModel = (Search)viewModel;

            return(new
            {
                searchViewModel.IsLatest,
                searchViewModel.CCName,
                searchViewModel.CategoryID,
                searchViewModel.FromDate,
                searchViewModel.ToDate,
                searchViewModel.UploadRecordID
            });
        }
Example #19
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var entityName = NavigationContext.QueryString["entity"];

            var abstractType = typeof(SearchViewModel<>);
            var entityType = ReflectionHelper.GetAssemblyType(entityName);
            var helper = SearchHelper.Build(entityType);

            helper.BuildColumns(ucSearch.dataGridEntities);
            SearchViewModel = helper.GetViewModel();

            SearchViewModel.Refresh();

            DataContext = SearchViewModel;
        }
Example #20
0
        public SearchModel(IEventAggregator eventPublisher, ISearchViewModel vm, IView view, IShellViewModel shellViewModel)
            : base(eventPublisher)
        {
            _shellViewModel            = shellViewModel;
            ViewModel                  = vm;
            View                       = view;
            ViewModel.PropertyChanged += (sender, args) =>
            {
                ViewModelUtils.RaiseCanExecuteChanged(_shellViewModel.SaveCommand);

                if (args.PropertyName == "DisplayName")
                {
                    NotifyOfPropertyChange(() => DisplayName);
                }
            };
        }
        public int GetTotalNumberByFilter(ISearchViewModel searchViewModel)
        {
            var sqlString = GenerateSqlStringByFilter(searchViewModel, true);

            // get total number
            try
            {
                var totalNum = DbManager.SqlQuery <int>(sqlString, ParameterValues.ToArray()).First();
                return(totalNum);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(0);
            }
        }
Example #22
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            _messenger.Register <MessageTypes.LineSearchRequested>(this, SearchForLine);
            BootStrapper.BackRequested += BootStrapper_BackRequested;

            var searchArgs = parameter as MessageTypes.LineSearchRequested;

            if (searchArgs != null)
            {
                // todo: HACK--we're getting a crash on navigation, and I think it's because we change pivots before
                // the page has finished loading
                // Possible fix: Wait until the underlying page his finished loading? But then we break MVVM. hmmm
                await Task.Delay(100);

                // HACK

                SelectedPivot = _linesSearchViewModel;
                if (searchArgs.SearchType == MessageTypes.LineSearchType.ById)
                {
                    await _linesSearchViewModel.GetLinesByIdAsync(searchArgs.SearchTerm);
                }
                else if (searchArgs.SearchType == MessageTypes.LineSearchType.ByTransitLine)
                {
                    await _linesSearchViewModel.GetLinesByIdAsync(searchArgs.Line.GtfsId);
                }
                else if (searchArgs.SearchType == MessageTypes.LineSearchType.ByString)
                {
                    _linesSearchViewModel.GetLinesAsync(searchArgs.SearchTerm);
                }
            }
            else
            {
                if (SelectedPivot == null)
                {
                    SelectedPivot = _nearbyStopsViewModel;
                }

                if (SelectedPivot.OwnedBy == SearchSection.Nearby)
                {
                    MoveNearbyCircleToUser();
                }
            }

            MapCircles = SelectedPivot.MapCircles;
            MapPlaces  = SelectedPivot.MapPlaces;
            MapLines   = SelectedPivot.MapLines;
        }
        public OutlookBarViewModel(
            IWorkspaceService workspaceService,
            IEventAggregator eventAggregator,
            ICachingService cachingService,
            IStatusBarMessageQueue statusBarMessageQueue,
            IOutlookBarItemViewModelFactory modelFactory,
            ISearchViewModel searchViewModel)
        {
            _workspaceService      = workspaceService;
            _eventAggregator       = eventAggregator;
            _cachingService        = cachingService;
            _statusBarMessageQueue = statusBarMessageQueue;
            _modelFactory          = modelFactory;
            _searchViewModel       = searchViewModel;

            Initialize();
        }
        public GeneralSearchExecutor(ISearchViewModel searchViewModel) : base(searchViewModel)
        {
            if (searchViewModel == null)
            {
                throw new ArgumentNullException(nameof(searchViewModel));
            }

            Settings.Input      = new[] { Copy(searchViewModel.InputViewModel.InputFile.Path) };
            Settings.Parameters = searchViewModel.SearchModeViewModel.Parameters;

            var extension = searchViewModel.InputViewModel.SelectedExtension.Value;

            if (extension != null)
            {
                AddExtension(extension);
            }
        }
        public SearchFactory(ISearchViewModel searchViewModel)
        {
            if (searchViewModel == null)
            {
                throw new ArgumentNullException(nameof(searchViewModel));
            }

            if (searchViewModel.IsAcceptGeneralSearch)
            {
                GeneralSearch = new GeneralSearchExecutor(searchViewModel);
            }

            if (searchViewModel.IsAcceptReferenceSearch)
            {
                ReferenceSearch = new ReferenceSearchExecutor(searchViewModel);
            }
        }
Example #26
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            this.ViewModel   = e.Parameter as ISearchViewModel;
            this.DataContext = this.ViewModel;

            this.albumResultViewModel = new ContentUserControlViewModel <IAlbumViewModel>(this.ViewModel,
                                                                                          nameof(ISearchViewModel.Albums),
                                                                                          nameof(ISearchViewModel.AlbumResultFetchState),
                                                                                          () => this.ViewModel.Albums,
                                                                                          () => this.ViewModel.AlbumResultFetchState,
                                                                                          OnAlbumSelected,
                                                                                          ServiceRegistry.PlatformServices);

            this.trackResultViewModel = new ContentUserControlViewModel <ITrackViewModel>(this.ViewModel,
                                                                                          nameof(ISearchViewModel.Tracks),
                                                                                          nameof(ISearchViewModel.TrackResultFetchState),
                                                                                          () => this.ViewModel.Tracks,
                                                                                          () => this.ViewModel.TrackResultFetchState,
                                                                                          _ => { },
                                                                                          ServiceRegistry.PlatformServices);

            this.artistResultViewModel = new ContentUserControlViewModel <IArtistViewModel>(this.ViewModel,
                                                                                            nameof(ISearchViewModel.Artists),
                                                                                            nameof(ISearchViewModel.ArtistResultFetchState),
                                                                                            () => this.ViewModel.Artists,
                                                                                            () => this.ViewModel.ArtistResultFetchState,
                                                                                            OnArtistSelected,
                                                                                            ServiceRegistry.PlatformServices);

            this.playlistResultViewModel = new ContentUserControlViewModel <IPlaylistViewModel>(this.ViewModel,
                                                                                                nameof(ISearchViewModel.Playlists),
                                                                                                nameof(ISearchViewModel.PlaylistResultFetchState),
                                                                                                () => this.ViewModel.Playlists,
                                                                                                () => this.ViewModel.PlaylistResultFetchState,
                                                                                                OnPlaylistSelected,
                                                                                                ServiceRegistry.PlatformServices);


            this.AlbumGrid.DataContext    = this.albumResultViewModel;
            this.TrackList.DataContext    = this.trackResultViewModel;
            this.ArtistGrid.DataContext   = this.artistResultViewModel;
            this.PlaylistGrid.DataContext = this.playlistResultViewModel;
        }
        public MainPage()
        {
            this.InitializeComponent();

            ServiceRegistry.Initialise(new UWPPlatformServices(this.Dispatcher),
                                       new Secrets());
            ServiceRegistry.Register <Frame>(this.ContentView);

            this.searchViewModel = ServiceRegistry.ViewModelFactory.CreateSearchViewModel();

            this.ContentView.Navigated += OnNavigationOccurs;
            this.MainNav.BackRequested += OnBackRequested;

            this.SearchBox.TextChanged    += OnSearchTextChanged;
            this.SearchBox.QuerySubmitted += OnSearchQuerySubmitted;

            this.MainNav.SelectedItem = this.MainNav.MenuItems[0];
        }
Example #28
0
        public SearchModel(IEventAggregator eventPublisher, ISearchViewModel vm, IView view)
            : base(eventPublisher)
        {
            ViewModel = vm;
            View      = view;
            ViewModel.PropertyChanged += (sender, args) =>
            {
                var mainViewModel = CustomContainer.Get <IShellViewModel>();
                if (mainViewModel != null)
                {
                    ViewModelUtils.RaiseCanExecuteChanged(mainViewModel.SaveCommand);
                }

                if (args.PropertyName == "DisplayName")
                {
                    NotifyOfPropertyChange(() => DisplayName);
                }
            };
        }
Example #29
0
        public override Task OnNavigatedFromAsync(IDictionary <string, object> pageState, bool suspending)
        {
            _messenger.Unregister <MessageTypes.LineSearchRequested>(this, SearchForLine);
            BootStrapper.BackRequested       -= BootStrapper_BackRequested;
            _interceptedBackButtonDestination = null;

            MapCircles = null;
            MapPlaces  = null;
            MapLines   = null;

            //TODO: HACK! For some reason, if we leave while SelectedPivot is anything by
            // the first pivot in the collection, when we come back to the page, we hard crash with
            // no stack trace and no (useful) error message.
            // Theoryheory: Probably some race condition deep in the binding system.
            // It RARELY happens if navigating to the page and quickly switching pivots at a very specific instant.
            SelectedPivot = _nearbyStopsViewModel;
            //-----end hack

            return(Task.CompletedTask);
        }
Example #30
0
        public MainViewModel(
            IMediator mediator,
            IFilmListViewModel filmListViewModel,
            IPersonListViewModel personListViewModel,
            ISearchViewModel searchViewModel,
            IFactory <IFilmDetailViewModel> filmDetailViewModelFactory,
            IFactory <IPersonDetailViewModel> personDetailViewModelFactory)
        {
            _mediator = mediator;

            FilmListViewModel   = filmListViewModel;
            PersonListViewModel = personListViewModel;
            SearchViewModel     = searchViewModel;

            _filmDetailViewModelFactory   = filmDetailViewModelFactory;
            _personDetailViewModelFactory = personDetailViewModelFactory;

            FilmDetailViewModel   = _filmDetailViewModelFactory.Create();
            PersonDetailViewModel = _personDetailViewModelFactory.Create();

            CloseFilmDetailTabCommand              = new RelayCommand(OnCloseFilmDetailTabExecute);
            ClosePersonDetailTabCommand            = new RelayCommand(OnClosePersonDetailTabExecute);
            FilmDetailTabSelectionChangedCommand   = new RelayCommand <FilmDetailViewModel>(FilmDetailTabChanged);
            PersonDetailTabSelectionChangedCommand = new RelayCommand <PersonDetailViewModel>(PersonDetailTabChanged);

            mediator.Register <NewMessage <FilmWrapper> >(OnFilmNewMessage);
            mediator.Register <NewMessage <PersonWrapper> >(OnPersonNewMessage);

            mediator.Register <SelectedMessage <FilmWrapper> >(OnFilmSelected);
            mediator.Register <SelectedMessage <PersonWrapper> >(OnPersonSelected);

            mediator.Register <UpdateMessage <FilmWrapper> >(OnFilmUpdated);
            mediator.Register <UpdateMessage <PersonWrapper> >(OnPersonUpdated);

            mediator.Register <DeleteMessage <FilmWrapper> >(OnFilmDeleted);
            mediator.Register <DeleteMessage <PersonWrapper> >(OnPersonDeleted);
        }
Example #31
0
        // Views are loaded here via RelayCommand along with their view models and data services
        public MainViewModel(ICustomerListViewModel _customerListViewModel,
                             ICustomerRepository _customerDataService,
                             Func <ICustomerDetailViewModel> _customerDetailViewModel,
                             IEmployeeRepository _employeeDataService,
                             IEmployeeListViewModel _employeeListViewModel,
                             Func <IEmployeeDetailViewModel> _employeeDetailViewModel,
                             IEventAggregator _eventAggregator,
                             IPatrolScheduleDataViewModel _patrolScheduleDataViewModel,
                             IPatrolRepository _patrolRepository,
                             Func <IPatrolScheduleDetailViewModel> _patrolScheduleDetailViewModel,
                             IEmpScheduleReport empScheduleReport,
                             ICustomersLookupReport customerLookupReport,
                             ISearchViewModel _searchViewModel)
        {
            _custView             = new CustomerView(_customerListViewModel, _customerDataService, _customerDetailViewModel, _eventAggregator);
            _employeeView         = new EmployeeView(_employeeListViewModel, _employeeDataService, _employeeDetailViewModel, _eventAggregator);
            _scheduleView         = new PatrolScheduleView(_patrolScheduleDataViewModel, _patrolRepository, _patrolScheduleDetailViewModel, _eventAggregator);
            _searchView           = new SearchView(_searchViewModel);
            _empScheduleReport    = empScheduleReport;
            _customerLookupReport = customerLookupReport;

            SelectCustomerView = new RelayCommand(() => SelectedView = _custView);
            SelectEmployeeView = new RelayCommand(() => SelectedView = _employeeView);
            SelectScheduleView = new RelayCommand(() => SelectedView = _scheduleView);
            SelectSearchView   = new RelayCommand(() => SelectedView = _searchView);

            GenerateEmployeeSchedules = new RelayCommand(async() => await RunEmpScheduleReport());
            GenerateCustomerReport    = new RelayCommand(async() => await RunCustomerReport());


            EmpSchedules = new ObservableCollection <EmpScheduleModel>();
            Customers    = new ObservableCollection <CustomerReportModel>();


            ExitCommand = new RelayCommand(() => Shutdown());
        }