예제 #1
0
        private async void GoLive(IWebViewComponent viewControl)
        {
            if (Mode != ApplicationMode.Dev)
            {
                return;
            }

            var resourceLoader = new ResourceReader("SetUp.script", this);
            var createOverlay  = resourceLoader.Load("loading.js");

            viewControl.ExecuteJavascript(createOverlay);

            var updateOverlay = resourceLoader.Load("update.js");
            var messageCount  = 0;

            void OnNpmLog(string information)
            {
                if (messageCount++ < 2)
                {
                    return;
                }

                var text = JavascriptNamer.GetCreateExpression(information);
                var code = updateOverlay.Replace("{information}", text);

                viewControl.ExecuteJavascript(code);
            }

            UpdateSetUp(await _Builder.BuildFromMode(ApplicationMode.Live, OnNpmLog));
            await viewControl.SwitchViewAsync(Uri);
        }
예제 #2
0
        private async void GoLive(IWebViewComponent viewControl)
        {
            if (Mode != ApplicationMode.Dev)
            {
                return;
            }

            var resourceLoader = GetResourceReader();
            var createOverlay  = resourceLoader.Load("loading.js");

            viewControl.ExecuteJavascript(createOverlay);

            var cancellationTokenSource = new CancellationTokenSource();
            var token = cancellationTokenSource.Token;

            DebugCommands.Clear();
            DebugCommands["Cancel to live"] = new RelayToogleCommand <ICompleteWebViewComponent>
                                                  (_ =>
            {
                cancellationTokenSource.Cancel();
                UpdateCommands();
            });

            try
            {
                await Task.Run(() => DoGoLive(viewControl, token), token);
            }
            catch (TaskCanceledException)
            {
                var removeOverlay = resourceLoader.Load("removeOverlay.js");
                viewControl.ExecuteJavascript(removeOverlay);
                return;
            }

            await viewControl.SwitchViewAsync(Uri);
        }
예제 #3
0
        private async Task ChangeMode(IWebViewComponent viewControl, ApplicationMode destination, string change)
        {
            if (Mode == destination)
            {
                return;
            }

            var resourceLoader = GetResourceReader();
            var createOverlay  = resourceLoader.Load("loading.js");

            viewControl.ExecuteJavascript(createOverlay);

            var cancellationTokenSource = new CancellationTokenSource();
            var token = cancellationTokenSource.Token;

            DebugCommands.Clear();
            DebugCommands[$"Cancel {change}"] = new RelayToogleCommand <ICompleteWebViewComponent>
                                                    (_ =>
            {
                cancellationTokenSource.Cancel();
                UpdateCommands();
            });

            try
            {
                await Task.Run(() => DoChange(viewControl, destination, token), token);
            }
            catch (TaskCanceledException)
            {
                var removeOverlay = resourceLoader.Load("removeOverlay.js");
                viewControl.ExecuteJavascript(removeOverlay);
                return;
            }

            await viewControl.SwitchViewAsync(Uri);
        }
예제 #4
0
        private async Task DoGoLive(IWebViewComponent viewControl, CancellationToken token)
        {
            var resourceLoader = GetResourceReader();
            var updateOverlay  = resourceLoader.Load("update.js");

            void OnNpmLog(string information)
            {
                if (information == null)
                {
                    return;
                }

                var text = JavascriptNamer.GetCreateExpression(information);
                var code = updateOverlay.Replace("{information}", text);

                viewControl.ExecuteJavascript(code);
            }

            UpdateSetUp(await _Builder.BuildFromMode(ApplicationMode.Live, token, OnNpmLog));
        }