/// <summary>
        /// Handler to execute when SettingsPane is requiring for commands
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void MainPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
        {
            args.Request.ApplicationCommands.Clear();
            var jkCommand = new SettingsCommand("ppolicy", "Política de Privacidad",
                                                (handler) =>
            {
                var settingsHelper = new SettingsWindowHelper();

                //Render WebView contents in brush
                var brush = new WebViewBrush();
                brush.SetSource(WebViewControl);
                brush.Redraw();
                //Fill rectangle with brush texture
                RgWebViewRenderingSurface.Fill = brush;

                WebViewControl.Visibility = Visibility.Collapsed;

                //Show the settings flyout
                //send Action to be executed when Settings window be closed
                settingsHelper.ShowFlyout(new PrivacyPolicyUC(),
                                          () => WebViewControl.Visibility = Visibility.Visible
                                          );
            });

            args.Request.ApplicationCommands.Add(jkCommand);
        }
Beispiel #2
0
        public MainPage()
        {
            InitializeComponent();
            _timer.Interval        = new TimeSpan(0, 0, 0, 0, 500);
            _timer.Tick           += TimerTick;
            _closeWebView.Interval = new TimeSpan(0, 0, 0, 0, 500);
            _closeWebView.Tick    += (s, e) =>
            {
                _closeWebView.Stop();
                wv.Visibility           = Visibility.Visible;
                webRectangle.Visibility = Visibility.Collapsed;
            };
            wv.LoadCompleted    += wv_LoadCompleted;
            BottomAppBar.Opened += (s, e) => SwitchWebViewForWebViewBrush();
            BottomAppBar.Closed += (s, e) => SwitchWebViewBrushForWebView();

            _webBrush = new WebViewBrush();
            _webBrush.SetSource(wv);
            webRectangle.Fill = _webBrush;

            Messenger.Default.Register <HideWebviewMessage>(this, o => SwitchWebViewForWebViewBrush());
            Messenger.Default.Register <ShowWebViewMessage>(this, o => SwitchWebViewBrushForWebView());
            Loaded += (s, e) =>
            {
                Editor.AddHandler(RightTappedEvent, (RightTappedEventHandler)RichEditBox_Tapped, true);
                VisualStateManager.GoToState(this, ViewModel.Distraction ? "FullScreenLandscapeOrWide" : "DistractionFree", false);
            };
        }
Beispiel #3
0
        private void SettingsUIManager_SettingsCharmOpened(object sender, EventArgs e)
        {
            WebViewBrush b = new WebViewBrush();

            b.SourceName = "AuthView";
            b.Redraw();
            AuthViewHider.Fill  = b;
            AuthView.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
        private void AppBar_Opened(object sender, object e)
        {
            WebViewBrush wvb = new WebViewBrush();

            wvb.SourceName = "contentView";
            wvb.Redraw();
            contentViewRect.Fill   = wvb;
            contentView.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
Beispiel #5
0
        private void RedrawBrush()
        {
            var wb = new WebViewBrush
            {
                SourceName = "TheWebView",
                Stretch    = Stretch.UniformToFill
            };

            wb.Redraw();
            BrushDisplay.Fill = wb;
        }
Beispiel #6
0
 /// <summary>
 /// When the ComboBox opens we have an airspace conflict and the ComboBox cannot render its content over
 /// the WebView.  Therefore, we create a WebViewBrush and set the WebView as its source and call the Redraw() method
 /// which will take a visual snapshot of the WebView.  We then use that brush to fill our Rectangle.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 //<snippetWebViewBrushCode>
 void ComboBox1_DropDownOpened(object sender, object e)
 {
     if (Rect1.Visibility == Windows.UI.Xaml.Visibility.Visible)
     {
         WebViewBrush b = new WebViewBrush();
         b.SourceName = "WebView6";
         b.Redraw();
         Rect1.Fill          = b;
         WebView6.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
     }
 }
Beispiel #7
0
 private void ShowWebRect()
 {
     if (webBrush == null)
     {
         webBrush = new WebViewBrush();
         webBrush.SetSource(outputBox);
         outputRect.Fill = webBrush;
     }
     webBrush.Redraw();
     outputBox.Visibility = Visibility.Collapsed;
 }
        private void OnAppBarOpened(object sender, object e)
        {
            if (webViewBrush == null)
            {
                webViewBrush = new WebViewBrush();
                webViewBrush.SetSource(_webViewWrapper.WebView as WebView);
            }

            webViewBrush.Redraw();
            contentViewRect.Fill = webViewBrush;
            ((WebView)_webViewWrapper.WebView).Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
Beispiel #9
0
        private void StartProgress()
        {
            // see http://code.msdn.microsoft.com/windowsapps/How-to-put-a-ProgressRing-a92f2530
            Progress.IsActive   = true;
            Progress.Visibility = Windows.UI.Xaml.Visibility.Visible;
            WebViewBrush brush = new WebViewBrush();

            brush.SourceName = "ResultsWindow";
            brush.Redraw();
            MaskRectangle.Fill       = brush;
            MaskRectangle.Visibility = Windows.UI.Xaml.Visibility.Visible;
            ResultsWindow.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
Beispiel #10
0
        public static async Task FlyoutOpenAsync(Rectangle webViewRect, WebView webView)
        {
            var b = new WebViewBrush();

            b.SourceName = webView.Name;
            b.Redraw();

            webViewRect.Fill = b;

            await Task.Delay(100);

            webView.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
Beispiel #11
0
        async Task <WebViewBrush> GetWebViewBrush(Windows.UI.Xaml.Controls.WebView webView)
        {
            // resize width to content
            var _OriginalWidth = webView.Width;
            var _WidthString   = await webView.InvokeScriptAsync("eval",
                                                                 new[] { "document.body.scrollWidth.toString()" });

            int _ContentWidth;

            if (!int.TryParse(_WidthString, out _ContentWidth))
            {
                throw new Exception(string.Format("failure/width:{0}", _WidthString));
            }

            webView.Width = _ContentWidth;

            // resize height to content
            var _OriginalHeight = webView.Height;

            var _HeightString = await webView.InvokeScriptAsync("eval",
                                                                new[] { "document.body.scrollHeight.toString()" });

            int _ContentHeight;

            if (!int.TryParse(_HeightString, out _ContentHeight))
            {
                throw new Exception(string.Format("failure/height:{0}", _HeightString));
            }

            webView.Height = _ContentHeight;

            // create brush
            var _OriginalVisibilty = webView.Visibility;

            webView.Visibility = Windows.UI.Xaml.Visibility.Visible;

            var _Brush = new WebViewBrush
            {
                Stretch    = Stretch.Uniform,
                SourceName = webView.Name
            };


            _Brush.Redraw();


            // webView.Width = _OriginalWidth;
            //webView.Height = _OriginalHeight;
            webView.Visibility = _OriginalVisibilty;
            return(_Brush);
        }
Beispiel #12
0
 /// <summary>
 /// Fills the web view brush so controls can correctly overlay the web view control.
 /// </summary>
 /// <param name="page">The page.</param>
 /// <param name="bottomAppBar">The bottom app bar.</param>
 /// <param name="rectanglePlaceholder">The rectangle web view placeholder.</param>
 /// <param name="webView">The web view.</param>
 internal static void FillWebViewBrush(Page page, AppBar bottomAppBar, Rectangle rectanglePlaceholder, WebView webView)
 {
     try
     {
         WebViewBrush webViewBrush = new WebViewBrush();
         webViewBrush.SourceName = webView.Name;
         webViewBrush.Redraw();
         rectanglePlaceholder.Fill = webViewBrush;
         webView.Visibility        = Visibility.Collapsed;
     }
     catch (Exception ex)
     {
         LogFile.Instance.LogError("", "", ex.ToString());
     }
 }
Beispiel #13
0
        public async Task <WebViewBrush> GetWebViewBrush(WebView webView)
        {
            // resize width to content
            double originalWidth = webView.Width;
            var    widthString   = await webView.InvokeScriptAsync("eval", new[] { "document.body.scrollWidth.toString()" });

            int contentWidth;

            if (!int.TryParse(widthString, out contentWidth))
            {
                throw new Exception(string.Format("failure/width:{0}", widthString));
            }

            webView.Width = contentWidth;

            // resize height to content
            double originalHeight = webView.Height;
            var    heightString   = await webView.InvokeScriptAsync("eval", new[] { "document.body.scrollHeight.toString()" });

            int contentHeight;

            if (!int.TryParse(heightString, out contentHeight))
            {
                throw new Exception(string.Format("failure/height:{0}", heightString));
            }

            webView.Height = contentHeight;

            // create brush
            var originalVisibilty = webView.Visibility;

            webView.Visibility = Windows.UI.Xaml.Visibility.Visible;

            WebViewBrush brush = new WebViewBrush
            {
                SourceName = webView.Name,
                Stretch    = Stretch.Uniform
            };

            brush.Redraw();

            // reset, return
            webView.Width      = originalWidth;
            webView.Height     = originalHeight;
            webView.Visibility = originalVisibilty;

            return(brush);
        }
        private void SpinAndWait(bool bNewVal)
        {
            WebViewBrush brush = new WebViewBrush();

            brush.SourceName = "wbCineworld";
            brush.Redraw();
            MaskRectangle.Fill = brush;

            this.wbCineworld.Visibility = bNewVal ? Windows.UI.Xaml.Visibility.Collapsed : Windows.UI.Xaml.Visibility.Visible;
            this.MaskRectangle.Opacity  = bNewVal ? 0.5 : 1;

            this.MaskRectangle.Visibility = bNewVal ? Windows.UI.Xaml.Visibility.Visible : Windows.UI.Xaml.Visibility.Collapsed;

            this.gProgress.Visibility = bNewVal ? Windows.UI.Xaml.Visibility.Visible : Windows.UI.Xaml.Visibility.Collapsed;
            this.prProgress.IsActive  = bNewVal;
        }
Beispiel #15
0
        private async Task <Rectangle> PrepareWebViewForPrintingAsync()
        {
            var widthString = await _webView.InvokeScriptAsync("eval", new[] { "document.body.scrollWidth.toString()" });

            int contentWidth;

            if (!int.TryParse(widthString, out contentWidth))
            {
                throw new Exception(string.Format("failure/width:{0}", widthString));
            }

            _webView.Width = contentWidth;

            // resize height to content
            var heightString = await _webView.InvokeScriptAsync("eval", new[] { "document.body.scrollHeight.toString()" });

            int contentHeight;

            if (!int.TryParse(heightString, out contentHeight))
            {
                throw new Exception(string.Format("failure/height:{0}", heightString));
            }

            _webView.Height = contentHeight;

            WebViewBrush brush = new WebViewBrush();

            brush.SetSource(_webView);
            brush.Stretch = Stretch.Uniform;

            brush.Redraw();

            // Send to printer
            var rect = new Rectangle
            {
                Fill   = brush,
                Width  = contentWidth,
                Height = contentHeight
            };

            return(rect);
        }
Beispiel #16
0
        UIElement GenerateWebViewPanel(Windows.Foundation.Size paperSize, int pageNumber)
        {
            var printArea = new Windows.Foundation.Size(paperSize.Width * (1 - 2 * ApplicationContentMarginLeft), paperSize.Height * (1 - 2 * ApplicationContentMarginTop));

            var scale        = printArea.Width / _webView.Width;
            var scaledHeight = _webView.Height * scale;

            var translateY = -printArea.Height * pageNumber;

            var rect = new Windows.UI.Xaml.Shapes.Rectangle
            {
                Tag = new TranslateTransform {
                    Y = translateY
                },
                Margin = new Windows.UI.Xaml.Thickness(ApplicationContentMarginLeft * paperSize.Width, ApplicationContentMarginTop * paperSize.Height, ApplicationContentMarginLeft * paperSize.Width, ApplicationContentMarginTop * paperSize.Height),
            };
            var panel = new Windows.UI.Xaml.Controls.Grid
            {
                Height   = paperSize.Height,
                Width    = paperSize.Width,
                Children = { rect },
            };

            rect.Loaded += (s, e) =>
            {
                var sRect = s as Windows.UI.Xaml.Shapes.Rectangle;
                System.Diagnostics.Debug.WriteLine("rect.Loaded: rect: {" + sRect.Width + "," + sRect.Height + "}  e: " + e.OriginalSource?.ToString());
                var brush = new WebViewBrush
                {
                    SourceName = _webView.Name,
                    Stretch    = Stretch.Uniform,
                };
                brush.Redraw();
                brush.AlignmentY = AlignmentY.Top;
                brush.AlignmentX = AlignmentX.Left;
                brush.Transform  = rect.Tag as TranslateTransform;
                rect.Fill        = brush;
            };
            rect.Visibility = Visibility.Visible;
            return(panel);
        }
Beispiel #17
0
        private void MakePage()
        {
            var brush = new WebViewBrush
            {
                Stretch = (Windows.UI.Xaml.Media.Stretch)Windows.UI.Xaml.Media.Stretch.Uniform
            };

            brush.SetSource(ViewToPrint);
            brush.Redraw();


            rectangle.Width  = 800;
            rectangle.Height = 800;
            rectangle.Fill   = brush;
            brush.Stretch    = (Windows.UI.Xaml.Media.Stretch)Windows.UI.Xaml.Media.Stretch.UniformToFill;
            brush.AlignmentY = AlignmentY.Top;
            brush.AlignmentX = AlignmentX.Left;
            rectangle.Name   = "MyWebViewRectangle";

            rectangle.Visibility = Windows.UI.Xaml.Visibility.Visible;
        }
Beispiel #18
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (wbMain.Visibility == Visibility.Collapsed)
     {
         MaskRectangle.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
         AreaRectangle.Visibility = cbFrame.IsChecked == true ? Windows.UI.Xaml.Visibility.Visible : Windows.UI.Xaml.Visibility.Collapsed;
         wbMain.Visibility        = Visibility.Visible;
         btnCapture.Content       = "New Subtitle Area";
         NotifyUser("Web mode", NotifyType.StatusMessage);
     }
     else
     {
         brush            = new WebViewBrush();
         brush.SourceName = "wbMain";
         brush.Redraw();
         MaskRectangle.Visibility = Windows.UI.Xaml.Visibility.Visible;
         AreaRectangle.Visibility = Windows.UI.Xaml.Visibility.Visible;
         MaskRectangle.Fill       = brush;
         brush.Redraw();
         wbMain.Visibility  = Visibility.Collapsed;
         btnCapture.Content = "* SET AREA MODE *";
         NotifyUser("Capture mode", NotifyType.StatusMessage);
     }
 }
Beispiel #19
0
        /// <summary>
        /// Invoked whenever application code or internal processes (such as a rebuilding layout pass) call ApplyTemplate. In simplest terms, this means the method is called just before a UI element displays in your app. Override this method to influence the default post-template logic of a class.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _layoutRoot        = GetTemplateChild(LayoutRootPanelName) as Panel;
            _webView           = (WebView)GetTemplateChild(WebViewName);
            _webViewBrush      = GetTemplateChild(WebViewBrushName) as WebViewBrush;
            _addressBar        = GetTemplateChild(AddressBarName) as TextBox;
            _titleBar          = GetTemplateChild(TitleTextBlockName) as TextBlock;
            _favIconImage      = GetTemplateChild(FavIconImageName) as Image;
            _progressIndicator = GetTemplateChild(ProgressIndicatorName) as ProgressBar;
            _backButton        = GetTemplateChild(BackButtonName) as Button;
            _forwardButton     = GetTemplateChild(ForwardButtonName) as Button;
            _goButton          = GetTemplateChild(GoButtonName) as Button;
            _stopButton        = GetTemplateChild(StopButtonName) as Button;
            _refreshButton     = GetTemplateChild(RefreshButtonName) as Button;
            _addressAppBar     = GetTemplateChild(AddressAppBarName) as CustomAppBar;
            _titleAppBar       = GetTemplateChild(TitleAppBarName) as CustomAppBar;

            VisualStateManager.GoToState(this, AddressBarUnfocusedStateName, true);

            if (_addressBar != null)
            {
                _addressBar.KeyDown     += OnAddressBarKeyDown;
                _addressBar.KeyUp       += OnAddressBarKeyUp;
                _addressBar.GotFocus    += OnAddressBarGotFocus;
                _addressBar.LostFocus   += OnAddressBarLostFocus;
                _addressBar.TextChanged += OnAddressBarTextChanged;
            }

            if (_backButton != null)
            {
                _backButton.IsEnabled = false;
                _backButton.Click    += OnBackButtonClick;
            }
            if (_forwardButton != null)
            {
                _forwardButton.IsEnabled = false;
                _forwardButton.Click    += OnForwardButtonClick;
            }
            if (_goButton != null)
            {
                //_goButton.IsEnabled = false;
                _goButton.Click += OnGoButtonClick;
            }
            if (_stopButton != null)
            {
                _stopButton.IsEnabled = false;
                _stopButton.Click    += OnStopButtonClick;
            }
            if (_refreshButton != null)
            {
                _refreshButton.IsEnabled = false;
                _refreshButton.Click    += OnRefreshButtonClick;
            }
            if (_addressAppBar != null)
            {
                _addressAppBar.Opened += OnAppBarOpenedOrClosed;
                _addressAppBar.Closed += OnAppBarOpenedOrClosed;
            }
            if (_titleAppBar != null)
            {
                _titleAppBar.Opened += OnAppBarOpenedOrClosed;
                _titleAppBar.Closed += OnAppBarOpenedOrClosed;
            }

            _webView.NavigationCompleted += OnNavigationCompleted;

            if (this.Source != null)
            {
                _webView.Source = this.Source;
            }
            else
            {
                this.Source = _webView.Source;
            }

            if (_pendingNavigation)
            {
                Navigate(this.Source);
            }
        }