public EntitySearchView(EntitySearchViewModel viewModel)
 {
     DataContext = viewModel;
     ViewModel   = viewModel;
     viewModel.SelectedEntityTypeChanged += viewModel_SelectedAccountTypeChanged;
     InitializeComponent();
 }
예제 #2
0
        public EntitySwitcherViewModel(IRegionManager regionManager,
                                       IApplicationState applicationState, IApplicationStateSetter applicationStateSetter, ICacheService cacheService,
                                       EntitySelectorView entitySelectorView, EntitySelectorViewModel entitySelectorViewModel,
                                       EntitySearchView entitySearchView, EntitySearchViewModel entitySearchViewModel,
                                       EntityDashboardView entityDashboardView, EntityDashboardViewModel entityDashboardViewModel, IUserService userService)
        {
            _regionManager            = regionManager;
            _applicationState         = applicationState;
            _applicationStateSetter   = applicationStateSetter;
            _cacheService             = cacheService;
            _entitySelectorView       = entitySelectorView;
            _entitySelectorViewModel  = entitySelectorViewModel;
            _entitySearchView         = entitySearchView;
            _entitySearchViewModel    = entitySearchViewModel;
            _entityDashboardView      = entityDashboardView;
            _entityDashboardViewModel = entityDashboardViewModel;
            _userService = userService;

            SelectEntityCategoryCommand = new DelegateCommand <EntityScreen>(OnSelectEntityCategoryExecuted);

            EventServiceFactory.EventService.GetEvent <GenericEvent <EventAggregator> >().Subscribe(
                x =>
            {
                if (x.Topic == EventTopicNames.ResetCache)
                {
                    _entityScreens         = null;
                    _entitySwitcherButtons = null;
                    RaisePropertyChanged(() => EntitySwitcherButtons);
                }
            });

            EventServiceFactory.EventService.GetEvent <GenericEvent <OperationRequest <Entity> > >().Subscribe(x =>
            {
                if (x.Topic == EventTopicNames.SelectEntity)
                {
                    var ss = UpdateEntityScreens(x.Value);
                    _currentOperationRequest = x.Value;
                    ActivateEntityScreen(ss);
                    if (ss != null && ss.DisplayMode == 1)
                    {
                        _entitySearchViewModel.SearchString = x.Value.Data;
                    }
                }
            });

            this.CancelSelectionCommand = new CaptionCommand <string>("Cancel", new Action <string>(this.OnCancelSelection));
            this.RemoveSelectionCommand = new CaptionCommand <string>("Remove", new Action <string>(this.OnRemoveSelection), new Func <string, bool>(this.CanRemoveSelection));
        }