Beispiel #1
0
 public BackgroundPageMapper(int numBackgroundPages, BackgroundPage backgroundPageSettings, int numCoverPages, int numAttachmentPages)
 {
     _numBackgroundPages     = numBackgroundPages;
     _backgroundPageSettings = backgroundPageSettings;
     _numCoverPages          = numCoverPages;
     _numAttachmentPages     = numAttachmentPages;
 }
 public void Setup()
 {
     _backgroundSettings = new BackgroundPage
     {
         Repetition   = BackgroundRepetition.NoRepetition,
         OnCover      = false,
         OnAttachment = false
     };
 }
        internal override void OnMessage(string method, JsonElement?serverParams)
        {
            switch (method)
            {
            case "close":
                Close?.Invoke(this, EventArgs.Empty);
                break;

            case "bindingCall":
                BindingCall?.Invoke(
                    this,
                    new() { BindingCall = serverParams?.GetProperty("binding").ToObject <BindingCallChannel>(Connection.DefaultJsonSerializerOptions).Object });
                break;

            case "route":
                var route   = serverParams?.GetProperty("route").ToObject <RouteChannel>(Connection.DefaultJsonSerializerOptions).Object;
                var request = serverParams?.GetProperty("request").ToObject <RequestChannel>(Connection.DefaultJsonSerializerOptions).Object;
                Route?.Invoke(
                    this,
                    new() { Route = route, Request = request });
                break;

            case "page":
                Page?.Invoke(
                    this,
                    new() { PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.DefaultJsonSerializerOptions) });
                break;

            case "crBackgroundPage":
                BackgroundPage?.Invoke(
                    this,
                    new() { PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.DefaultJsonSerializerOptions) });
                break;

            case "crServiceWorker":
                ServiceWorker?.Invoke(
                    this,
                    new() { WorkerChannel = serverParams?.GetProperty("worker").ToObject <WorkerChannel>(Connection.DefaultJsonSerializerOptions) });
                break;

            case "request":
                Request?.Invoke(this, serverParams?.ToObject <BrowserContextChannelRequestEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;

            case "requestFinished":
                RequestFinished?.Invoke(this, serverParams?.ToObject <BrowserContextChannelRequestEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;

            case "requestFailed":
                RequestFailed?.Invoke(this, serverParams?.ToObject <BrowserContextChannelRequestEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;

            case "response":
                Response?.Invoke(this, serverParams?.ToObject <BrowserContextChannelResponseEventArgs>(Connection.DefaultJsonSerializerOptions));
                break;
            }
        }
        internal override void OnMessage(string method, JsonElement?serverParams)
        {
            switch (method)
            {
            case "close":
                Close?.Invoke(this, EventArgs.Empty);
                break;

            case "bindingCall":
                BindingCall?.Invoke(
                    this,
                    new BindingCallEventArgs
                {
                    BidingCall = serverParams?.GetProperty("binding").ToObject <BindingCallChannel>(Connection.GetDefaultJsonSerializerOptions()).Object,
                });
                break;

            case "route":
                Route?.Invoke(
                    this,
                    new RouteEventArgs
                {
                    Route   = serverParams?.GetProperty("route").ToObject <RouteChannel>(Connection.GetDefaultJsonSerializerOptions()).Object,
                    Request = serverParams?.GetProperty("request").ToObject <RequestChannel>(Connection.GetDefaultJsonSerializerOptions()).Object,
                });
                break;

            case "page":
                Page?.Invoke(
                    this,
                    new BrowserContextPageEventArgs
                {
                    PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.GetDefaultJsonSerializerOptions()),
                });
                break;

            case "crBackgroundPage":
                BackgroundPage?.Invoke(
                    this,
                    new BrowserContextPageEventArgs
                {
                    PageChannel = serverParams?.GetProperty("page").ToObject <PageChannel>(Connection.GetDefaultJsonSerializerOptions()),
                });
                break;

            case "crServiceWorker":
                ServiceWorker?.Invoke(
                    this,
                    new WorkerChannelEventArgs
                {
                    WorkerChannel = serverParams?.GetProperty("worker").ToObject <WorkerChannel>(Connection.GetDefaultJsonSerializerOptions()),
                });
                break;
            }
        }
        internal ChromiumBrowserContext(IChannelOwner parent, string guid, BrowserContextInitializer initializer) : base(parent, guid, initializer)
        {
            if (initializer.CrBackgroundPages != null)
            {
                foreach (var pageChannel in initializer.CrBackgroundPages)
                {
                    var page = ((PageChannel)pageChannel).Object;
                    _crBackgroundPages.Add(page);
                    page.BrowserContext = this;
                    BackgroundPage?.Invoke(this, new PageEventArgs {
                        Page = page
                    });
                }
            }

            Channel.BackgroundPage += (sender, e) =>
            {
                var page = e.PageChannel.Object;
                page.BrowserContext = this;
                _crBackgroundPages.Add(page);
                BackgroundPage?.Invoke(this, new PageEventArgs {
                    Page = page
                });
            };

            if (initializer.CrServiceWorkers != null)
            {
                foreach (var workerChannel in initializer.CrServiceWorkers)
                {
                    var worker = ((WorkerChannel)workerChannel).Object;
                    ServiceWorkersList.Add(worker);
                    worker.BrowserContext = this;
                    ServiceWorker?.Invoke(this, new WorkerEventArgs(worker));
                }
            }

            Channel.ServiceWorker += (sender, e) =>
            {
                var worker = e.WorkerChannel.Object;
                ServiceWorkersList.Add(worker);
                worker.BrowserContext = this;
                ServiceWorker?.Invoke(this, new WorkerEventArgs(worker));
            };
        }
Beispiel #6
0
        public App()
        {
            FlowListView.Init();

            GatewayApi.Instance.ExpiredAccessToken += async(object sender, EventArgs e) =>
            {
                var localEnvironments = await LocalDbHelper.Instance.GetAllSavedEnvironmentsAsync();

                BlockchainEnvironment environment = localEnvironments[0];

                var authService   = ServiceContainer.Resolve <IAuthentication>();
                var loginResponse = await authService.LoginAsync(
                    $"https://login.windows.net/{environment.TenantId}",
                    environment.ResourceId,
                    environment.ClientId,
                    environment.ReturnUrl,
                    isRefresh : true);

                if (loginResponse != null)
                {
                    AppCenterHelper.TrackEvent("Refreshed Token", new Dictionary <string, string>()
                    {
                        { "username", loginResponse.Profile.DisplayableId }
                    });

                    Settings.AccessToken = loginResponse.AccessToken;
                    GatewayApi.Instance.SetAuthToken(loginResponse.AccessToken);
#if DEBUG
                    Settings.AccessTokenExpiration            = new DateTimeOffset(DateTime.Now.AddMinutes(2));
                    GatewayApi.Instance.AccessTokenExpiration = new DateTimeOffset(DateTime.Now.AddMinutes(2));
#else
                    Settings.AccessTokenExpiration            = loginResponse.ExpiresOn;
                    GatewayApi.Instance.AccessTokenExpiration = loginResponse.ExpiresOn;
#endif
                }
                else
                {
                    App.Logout(false);
                }
            };

            GatewayApi.Instance.ExceptionThrown += async(object sender, Exception e) =>
            {
                AppCenterHelper.Report(e, new Dictionary <string, string>()
                {
                    { "baseurl", GatewayApi.SiteUrl }
                });
            };

            ViewModel = new AppViewModel();

            backgroundPage = new BackgroundPage();

            var navPage       = new Xamarin.Forms.NavigationPage(backgroundPage);
            var detailNavPage = new Xamarin.Forms.NavigationPage(new ApplicationsPage());

            ContractsPage = new WorklfowInstanceListPage();

            navPage.BarBackgroundColor       = Constants.NavBarBackgroundColor;
            navPage.BarTextColor             = Constants.NavBarTextColor;
            detailNavPage.BarBackgroundColor = Constants.NavBarBackgroundColor;
            detailNavPage.BarTextColor       = Constants.NavBarTextColor;

            Master = new MasterDetailPage {
                BindingContext = ViewModel
            };
            Master.IsPresentedChanged += (object sender, EventArgs e) =>
            {
                var mdp = sender as MasterDetailPage;
                if (mdp.IsPresented)
                {
                    ((Xamarin.Forms.NavigationPage)mdp.Detail)
                    .On <iOS>()
                    .SetStatusBarTextColorMode(StatusBarTextColorMode.DoNotAdjust);
                }
                else
                {
                    ((Xamarin.Forms.NavigationPage)mdp.Detail)
                    .On <iOS>()
                    .SetStatusBarTextColorMode(StatusBarTextColorMode.MatchNavigationBarTextLuminosity);
                }
            };

            Master.Master = new MasterPage {
                BindingContext = ViewModel
            };
            Master.Detail = detailNavPage;
            Master.SetBinding(MasterDetailPage.IsPresentedProperty, nameof(AppViewModel.MenuPresented), BindingMode.TwoWay);

            Xamarin.Forms.NavigationPage.SetHasNavigationBar(detailNavPage, false);

            try
            {
                MainPage = navPage;
            }
            catch (Exception e)
            {
                AppCenterHelper.Report(e);
            }
        }
Beispiel #7
0
 public BackgroundSteps()
 {
     backgroundPage = new BackgroundPage();
 }