示例#1
0
        public NotificationsService(IDispatcherService dispatcherService,
                                    IJsBridgeService jsBridgeService,
                                    IWindowService windowService,
                                    IViewModelFactory viewModelFactory)
        {
            Ensure.Argument.IsNotNull(dispatcherService, "dispatcherService");
            Ensure.Argument.IsNotNull(jsBridgeService, "jsBridgeService");
            Ensure.Argument.IsNotNull(windowService, "windowService");
            Ensure.Argument.IsNotNull(viewModelFactory, "viewModelFactory");

            this.dispatcherService = dispatcherService;
            this.jsBridgeService   = jsBridgeService;
            this.windowService     = windowService;
            this.viewModelFactory  = viewModelFactory;
        }
示例#2
0
        protected BrowserViewModelBase(IJsBridgeService jsBridgeService)
        {
            Ensure.Argument.IsNotNull(jsBridgeService, "jsBridgeService");
            this.isOpen = true;

            // Create our browser.
            this.Browser = new ChromiumWebBrowser(string.Empty)
            {
                KeyboardHandler = this,
                MenuHandler     = this
            };

            // Register events on the browser.
            this.Browser.IsBrowserInitializedChanged += this.Browser_Initialized;

            // Create the binding.
            this.JsBinding = jsBridgeService.RegisterBrowser <T>(this.Browser);

            // Commands.
            this.WindowActivatedCommand = new RelayCommand(() =>
            {
                // Focus browser on UI thread.
                DispatcherHelper.RunAsync(() => this.Browser.SetFocus(true));
            });
            this.WindowLostFocusCommand = new RelayCommand(() =>
            {
                // Unfocus browser on UI thread.
                DispatcherHelper.RunAsync(() => this.Browser.SetFocus(false));
            });
            this.ClosedCommand = new RelayCommand <Window>(window =>
            {
                // Dispose the browser when the window gets closed.
                if (this.Browser.IsDisposed || this.Browser.Disposing)
                {
                    return;
                }
                this.Browser.Dispose();
            });
        }
示例#3
0
        public MainViewModel(IJsBridgeService jsBridgeService,
                             ITaskBarOverlayService taskBarOverlayService,
                             IExternalProcessService externalProcessService,
                             IInjectScriptService injectScriptService,
                             IMessenger messenger,
                             IAppConstants appConstants)
            : base(jsBridgeService)
        {
            Ensure.Argument.IsNotNull(taskBarOverlayService, nameof(taskBarOverlayService));
            Ensure.Argument.IsNotNull(externalProcessService, nameof(externalProcessService));
            Ensure.Argument.IsNotNull(messenger, nameof(messenger));
            Ensure.Argument.IsNotNull(appConstants, nameof(appConstants));

            this.TaskBar = taskBarOverlayService;
            this.externalProcessService = externalProcessService;
            this.injectScriptService    = injectScriptService;
            this.appConstants           = appConstants;

            // Initialize variables.
            this.isLoading = true;

            // Create the browser for the main page.
            this.Browser.LifeSpanHandler = this;
            this.Browser.KeyboardHandler = this;
            this.Browser.RequestHandler  = this;
            this.BaseUrl = this.appConstants.AppUrl + this.appConstants.SignInPath;

            // Register events on the browser.
            this.Browser.FrameLoadEnd += this.Browser_FrameLoadEnd;

            // Set the default title.
            this.SetSubtitle();

            // Initialize the inject script service.
            this.injectScriptService.InitializeAsync();
        }