Esempio n. 1
0
 public UnhandledErrorViewModel(
     IViewModelManager viewModelManager, 
     IViewModelFactory viewModelFactory,
     IReactiveCommandFactory reactiveCommandFactory)
     : base(viewModelManager, viewModelFactory, reactiveCommandFactory)
 {
 }
 public ViewManager(IViewModelManager viewModelManager
                    , IServiceLocator serviceLocator)
 {
     _serviceLocator = serviceLocator;
     viewModelManager.ViewModelShown  += ShowViewForViewModel;
     viewModelManager.ViewModelClosed += CloseViewForViewModel;
 }
Esempio n. 3
0
 public WrappingViewModel(
     IViewModelManager viewModelManager, 
     IViewModelFactory viewModelFactory,
     IReactiveCommandFactory reactiveCommandFactory)
     : base(viewModelManager, viewModelFactory, reactiveCommandFactory)
 {
 }
Esempio n. 4
0
    public RequeryAllTheThings(IViewModelManager viewModelManager)
    {
        Argument.IsNotNull(() => viewModelManager);

        _viewModelManager = viewModelManager;

        System.Windows.Input.CommandManager.RequerySuggested += OnCommandManagerRequerySuggested;
    }
    public App()
        : base()
    {
        var dependencyResolver = this.GetDependencyResolver();

        _ViewModelManager = dependencyResolver.Resolve <IViewModelManager>();
        System.Windows.Input.CommandManager.RequerySuggested += RequerySuggested;
    }
 protected virtual void ConfigureContainer(IContainer container)
 {
     container.RegisterInstance <IApplicationBase>(this);
     container.RegisterInstance <IApplicationSettings>(ApplicationSettings);
     container.RegisterType <IViewModelManager, ViewModelManager>(true);
     container.RegisterType <IWindowManager, CustomWindowManager>(true);
     ViewModelManager = container.Resolve <IViewModelManager>();
 }
Esempio n. 7
0
 public ViewModelBase(INavigationService navigationService, IPageDialogService pageDialogService,
                      IDeviceService deviceService, IViewModelManager viewModelManager)
 {
     _pageDialogService = pageDialogService;
     _deviceService     = deviceService;
     _navigationService = navigationService;
     _viewModelManager  = viewModelManager;
 }
Esempio n. 8
0
        /// <summary>
        /// Gets the first or default instance of the specified view type.
        /// </summary>
        /// <typeparam name="TView">The type of the view.</typeparam>
        /// <param name="viewManager">The view manager.</param>
        /// <returns>The view or <c>null</c> if the view is not registered.</returns>
        public static TView GetFirstOrDefaultInstance <TView>(this IViewModelManager viewManager)
            where TView : IView
        {
            Argument.IsNotNull("viewManager", viewManager);

            var viewType = typeof(TView);

            return((TView)viewManager.GetFirstOrDefaultInstance(viewType));
        }
 public static void RegisterViewModelManager <TViewModel>(this IUFrameContainer container,
                                                          IViewModelManager <TViewModel> manager)
 {
     container.RegisterInstance <IViewModelManager>(manager, typeof(TViewModel).Name.Replace("ViewModel", ""));
     container.RegisterInstance <IViewModelManager>(manager, typeof(TViewModel).Name);
     container.RegisterInstance <IViewModelManager <TViewModel> >(manager,
                                                                  typeof(TViewModel).Name.Replace("ViewModel", ""));
     container.RegisterInstance <IViewModelManager <TViewModel> >(manager);
 }
Esempio n. 10
0
        public override void Init(IDiContainer container,
                               IViewModelManager vmManager,
                               IMessagingManager messagingManager,
                               IPresenter presenter,
                               ILogger logger)
        {
            mContainer = container;
              mLogger = logger;

              MainPage = new ContentPage();
        }
Esempio n. 11
0
        public ViewManager(IViewModelManager manager, IViewFactory viewFactory, IViewModelFactory viewModelFactory,
            IViewMappingContainer viewMappingContainer)
        {
            _viewFactory = viewFactory;
            _viewModelFactory = viewModelFactory;
            _viewMappingContainer = viewMappingContainer;

            IViewModelManager viewModelManager = manager;
            viewModelManager.ViewModelShowing += ViewModelManagerOnViewModelShowing;
            viewModelManager.ViewModelClosing += ViewModelManagerOnViewModelClosing;
        }
Esempio n. 12
0
 public CoreServicesImpl(IUserDialogs dialogs,
                         IAppState state,
                         IViewModelManager vmManager,
                         //IAppSettings appSettings,
                         IAdapter adapter)
 {
     this.Dialogs   = dialogs;
     this.AppState  = state;
     this.VmManager = vmManager;
     //this.AppSettings = appSettings;
     this.BleAdapter = adapter;
 }
Esempio n. 13
0
        public AddGeofenceViewModel(IGeofenceManager geofences,
                                    IUserDialogs dialogs,
                                    IViewModelManager viewModelMgr,
                                    IGeolocator geolocator)
        {
            this.Add = ReactiveCommand.CreateAsyncTask(
                this.WhenAny(
                    x => x.RadiusMeters,
                    x => x.Latitude,
                    x => x.Longitude,
                    x => x.Identifer,
                    (radius, lat, lng, id) =>
                    {
                        if (radius.Value < 100)
                            return false;

                        if (lat.Value < -90 || lat.Value > 90)
                            return false;

                        if (lng.Value < -180 || lng.Value > 180)
                            return false;

                        if (id.Value.IsEmpty())
                            return false;

                        return true;
                    }
                ),
                async x =>
                {
                    geofences.StartMonitoring(new GeofenceRegion
                    {
                        Identifier = this.Identifer,
                        Center = new Position(this.Latitude, this.Longitude),
                        Radius = Distance.FromMeters(this.RadiusMeters)
                    });
                    await viewModelMgr.PopNav();
                }
            );
            this.UseCurrentLocation = ReactiveCommand.CreateAsyncTask(async x =>
            {
                try
                {
                    var current = await geolocator.GetPositionAsync(5000);
                    this.Latitude = current.Latitude;
                    this.Longitude = current.Longitude;
                }
                catch
                {
                }
            });
        }
 public CreateUserAccountPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService,
                                       IDeviceService deviceService, IViewModelManager viewModelManager)
     : base(navigationService, pageDialogService, deviceService, viewModelManager)
 {
     try
     {
         Title = AppResources.UserAccount_PageTitle;
     }
     catch (Exception ex)
     {
         LogError(ex);
     }
 }
 public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService,
                          IDeviceService deviceService, IViewModelManager viewModelManager)
     : base(navigationService, pageDialogService, deviceService, viewModelManager)
 {
     try
     {
         Title   = "Hi From Prism";
         AppUser = _viewModelManager.UpdateOrCreatetUser(null);
     }
     catch (Exception ex)
     {
         // TODO: Logger.LogError(ex);
     }
 }
Esempio n. 16
0
        /// <summary>
        /// Closes all view models that are currently being managed by the <see cref="ViewModelManager" /> which
        /// match the predicate.
        /// </summary>
        /// <param name="viewModelManager">The view model manager.</param>
        /// <param name="predicate">The predicate.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelManager" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelManager" /> is <c>null</c>.</exception>
        public static async Task CancelAndCloseViewModelsAsync(this IViewModelManager viewModelManager, Func <IViewModel, bool> predicate)
        {
            Argument.IsNotNull("viewModelManager", viewModelManager);
            Argument.IsNotNull("predicate", predicate);

            var activeViewModels = viewModelManager.ActiveViewModels;

            foreach (var viewModel in activeViewModels)
            {
                if (predicate(viewModel))
                {
                    await viewModel.CancelAndCloseViewModelAsync();
                }
            }
        }
        /// <summary>
        /// Closes all view models that are currently being managed by the <see cref="ViewModelManager" /> which
        /// match the predicate.
        /// </summary>
        /// <param name="viewModelManager">The view model manager.</param>
        /// <param name="predicate">The predicate.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelManager" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="viewModelManager" /> is <c>null</c>.</exception>
        public static void CancelAndCloseViewModels(this IViewModelManager viewModelManager, Func <IViewModel, bool> predicate)
        {
            Argument.IsNotNull(() => viewModelManager);
            Argument.IsNotNull(() => predicate);

            var activeViewModels = viewModelManager.ActiveViewModels.ToList();

            foreach (var viewModel in activeViewModels)
            {
                if (predicate(viewModel))
                {
                    viewModel.CancelAndCloseViewModel();
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UICompositionService" /> class.
        /// </summary>
        /// <param name="regionManager">The region manager</param>
        /// <param name="viewManager">The view manager</param>
        /// <param name="viewLocator">The view locator</param>
        /// <param name="dispatcherService">The dispatcher service</param>
        /// <param name="viewModelManager">The view model manager.</param>
        /// <param name="viewModelFactory">The view model factory.</param>
        /// <exception cref="System.ArgumentNullException">The <paramref name="regionManager" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewManager" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewLocator" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="dispatcherService" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewModelManager" /> is <c>null</c>.</exception>
        /// <exception cref="System.ArgumentNullException">The <paramref name="viewModelFactory" /> is <c>null</c>.</exception>
        public UICompositionService(IRegionManager regionManager, IViewManager viewManager, IViewLocator viewLocator,
                                    IDispatcherService dispatcherService, IViewModelManager viewModelManager, IViewModelFactory viewModelFactory)
        {
            Argument.IsNotNull(() => regionManager);
            Argument.IsNotNull(() => viewManager);
            Argument.IsNotNull(() => viewLocator);
            Argument.IsNotNull(() => dispatcherService);
            Argument.IsNotNull(() => viewModelManager);
            Argument.IsNotNull(() => viewModelFactory);

            _regionManager     = regionManager;
            _viewManager       = viewManager;
            _viewLocator       = viewLocator;
            _dispatcherService = dispatcherService;
            _viewModelManager  = viewModelManager;
            _viewModelFactory  = viewModelFactory;
        }
Esempio n. 19
0
        static Start()
        {
            String baseDirectory = Path.GetDirectoryName(typeof(Start).Assembly.Location);

            ViewModelManager = new ViewModelManager();
            ViewManager      = new ViewManager(new ViewManagerConfig()
            {
                ThemeFolder            = Path.Combine(baseDirectory, "Theme"),
                ThemePathInAssembly    = "Theme",
                ViewFileExtension      = ".xaml",
                LanguageFolder         = Path.Combine(baseDirectory, "Language"),
                LanguagePathInAssembly = "Language",
                LanguageFileExtension  = ".txt"
            })
            {
                ViewModelManager = ViewModelManager
            };
        }
Esempio n. 20
0
        public MainViewModel(IViewModelManager viewModelManager,
            IViewModelFactory viewModelFactory, 
            INotificationManager notificationManager,
            IReminderService reminderService,
            IReactiveCommandFactory reactiveCommandFactory)
            : base(viewModelManager, viewModelFactory, reactiveCommandFactory)
        {
            _notificationManager = notificationManager;
            _reminderService = reminderService;
            TrayNotificationEnabled = true;
            TaskFactory factory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
            CreateReminderCommand = reactiveCommandFactory.CreateAsyncTask(async (o, token) =>
            {
                await factory.StartNew(() =>
                {
                    var vm = viewModelFactory.Resolve<ReminderEditViewModel>();
                    vm.Show();
                });
            });

            ShowReminderGridCommand = reactiveCommandFactory.CreateAsyncTask(async (o, token) =>
            {
                await factory.StartNew(() =>
                {
                    var vm = viewModelFactory.Resolve<ReminderGridViewModel>();
                    vm.Show();
                });
            });

            ExitApplicationCommand = reactiveCommandFactory.CreateAsyncTask(async (o, token) =>
            {
                await factory.StartNew(() =>
                {
                    ApplicationInstanceProvider.Instance.ApplicationExit();
                });
            });
        }
        public AdapterListViewModel(IAdapterScanner scanner,
                                    IUserDialogs dialogs,
                                    IViewModelManager vmManager)
        {
            this.scanner = scanner;
            this.Select  = ReactiveCommand.CreateFromTask <IAdapter>(async adapter =>
            {
                CrossBleAdapter.Current = adapter;
                await vmManager.Push <MainViewModel>();
            });
            this.Scan = ReactiveCommand.Create(() =>
            {
                this.IsBusy = true;
                this.scanner
                .FindAdapters()
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(
                    this.Adapters.Add,
                    async() =>
                {
                    this.IsBusy = false;
                    switch (this.Adapters.Count)
                    {
                    case 0:
                        dialogs.Alert("No BluetoothLE Adapters Found");
                        break;

                    case 1:
                        CrossBleAdapter.Current = this.Adapters.First();
                        await vmManager.Push <MainViewModel>();
                        break;
                    }
                }
                    );
            },
                                               this.WhenAny(x => x.IsBusy, x => !x.Value));
        }
Esempio n. 22
0
 public PresenterDelegationTask(IDiContainer container, IViewModelManager viewModelManager)
 {
     mContainer = container;
       mViewModelManager = viewModelManager;
 }
Esempio n. 23
0
 public ViewManager(IViewModelManager <IChildViewModel> vmManager, IServiceLocator serviceLocator) : base(vmManager, serviceLocator)
 {
 }
Esempio n. 24
0
 public MainViewModel(IViewModelManager viewModelManager)
 {
     _viewModelManager = viewModelManager;
     DisplayName       = "Main";
 }
 public BaseUtilsPresenterDelegationTask(IDiContainer container,
                                     IViewModelManager viewModelManager)
     : base(container, viewModelManager)
 {
     Container = container;
 }
Esempio n. 26
0
 public NotificationViewModel(IViewModelManager viewModelManager, IViewModelFactory viewModelFactory, IReactiveCommandFactory reactiveCommandFactory)
     : base(viewModelManager, viewModelFactory, reactiveCommandFactory)
 {
     Title = Resources.NotificationViewModel_Title_Notification;
 }
Esempio n. 27
0
        public IActionResult Index([FromServices] IViewModelManager adminVmManager)
        {
            var model = adminVmManager?.GetHomeViewModel() ?? new HomeViewModel();

            return(View(model));
        }
 public ChildViewManager(IViewModelManager<IChildViewModel> vmManager, IServiceLocator serviceLocator)
     : base(vmManager, serviceLocator)
 {
 }
Esempio n. 29
0
 public PageResolutionTask(IDiContainer container, IViewModelManager viewModelManager)
 {
     mContainer = container;
       mViewModelmanager = viewModelManager;
 }
 public UserViewModel(IViewModelManager viewModelManager,
                      IServiceLocator serviceLocator)
     : base(viewModelManager)
 {
     _serviceLocator = serviceLocator;
 }
Esempio n. 31
0
 protected ViewManagerBase(IViewModelManager <TVm> vmManager, IServiceLocator serviceLocator)
 {
     ServiceLocator             = serviceLocator;
     vmManager.ViewModelShown  += OnViewModelShown;
     vmManager.ViewModelClosed += OnViewModelClosed;
 }
Esempio n. 32
0
 public static IViewModel GetOrAddViewModel <TViewModel>(this IViewModelManager viewModelManager)
 => viewModelManager.GetOrAddViewModel(typeof(TViewModel));
 protected ViewModelBase(IViewModelManager viewModelManager)
 {
     _viewModelManager = viewModelManager;
     viewModelManager.ShowViewModel(this);
 }
Esempio n. 34
0
 public static IViewModel FindViewModel <TViewModel>(this IViewModelManager viewModelManager)
 => viewModelManager.FindViewModel(typeof(TViewModel));
Esempio n. 35
0
        public SettingsViewModel(IPermissions permissions,
                                 IGeofenceManager geofences,
                                 IUserDialogs dialogs,
                                 IViewModelManager viewModelMgr)
        {
            this.permissions = permissions;
            this.geofences = geofences;
            this.dialogs = dialogs;

            this.Menu = new Command(() => dialogs.ActionSheet(new ActionSheetConfig()
                .SetCancel()
                .Add("Add Geofence", async () => 
                    await viewModelMgr.PushNav<AddGeofenceViewModel>()
                )
                .Add("Use Default Geofences", async () => 
                {
                    var result = await dialogs.ConfirmAsync(new ConfirmConfig()
                        .UseYesNo()
                        .SetMessage("This will stop monitoring all existing geofences and set the defaults.  Are you sure you want to do this?"));

                    if (result)
                    {
                        geofences.StopAllMonitoring();
                        await Task.Delay(500);
                        geofences.StartMonitoring(new GeofenceRegion
                        {
                            Identifier = "FC HQ",
                            Center = new Position(43.6411314, -79.3808415),   // 88 Queen's Quay - Home
                            Radius = Distance.FromKilometers(1)
                        });
                        geofences.StartMonitoring(new GeofenceRegion
                        {
                            Identifier = "Close to HQ",
                            Center = new Position(43.6411314, -79.3808415),   // 88 Queen's Quay
                            Radius = Distance.FromKilometers(3)
                        });
                        geofences.StartMonitoring(new GeofenceRegion 
                        {
                            Identifier = "Ajax GO Station",
                            Center = new Position(43.8477697, -79.0435461),
                            Radius = Distance.FromMeters(500)
                        });
                        await Task.Delay(500); // ios needs a second to breathe when registering like this
                        this.RaisePropertyChanged("CurrentRegions");
                    }                
                })
                .Add("Stop All Geofences", async () => 
                {
                    var result = await dialogs.ConfirmAsync(new ConfirmConfig()
                        .UseYesNo()
                        .SetMessage("Are you sure wish to stop monitoring all geofences?"));

                    if (result)
                    {
                        this.geofences.StopAllMonitoring();
                        this.RaisePropertyChanged("CurrentRegions");
                    }
                })
            ));
            
            this.Remove = new Command<GeofenceRegion>(x =>
            {
                this.geofences.StopMonitoring(x);
                this.RaisePropertyChanged("CurrentRegions");
            });
        }
Esempio n. 36
0
 public EditUserViewModel(IViewModelManager viewModelManager)
     : base(viewModelManager)
 {
 }
 public ConfigurationModelManager(IViewModelManager manager)
 {
     this.Manager = manager;
     this.Manager.Register(this);
     base.PropertyChanged += DependencyObject_PropertyChanged;
 }
 public NavigationPagePresenterDelegationTask(IDiContainer container, IViewModelManager viewModelManager)
     : base(container, viewModelManager)
 {
 }
Esempio n. 39
0
 /// <summary>
 /// Initializes static members of the <see cref="ViewModelBase" /> class.
 /// </summary>
 static ViewModelBase()
 {
     var serviceLocator = IoC.ServiceLocator.Default;
     serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelManager, ViewModelManager>();
     ViewModelManager = serviceLocator.ResolveType<IViewModelManager>();
 }
Esempio n. 40
0
 public abstract void Init(IDiContainer container,
                        IViewModelManager vmManager,
                        IMessagingManager messagingManager,
                        IPresenter presenter,
                        ILogger logger);
Esempio n. 41
0
 public DelegateNavigator(IViewModelManager viewModelManager)
 {
     this.viewModelManager = viewModelManager;
 }
Esempio n. 42
0
 protected EntityServiceBase(IServiceContext serviceContext, IViewModelManager viewModelManager, IRepositoryManager repositoryManager) : base(serviceContext)
 {
     this.ViewModelManager  = viewModelManager;
     this.RepositoryManager = repositoryManager;
 }