Exemplo n.º 1
0
 public ReaderPage()
 {
     this.InitializeComponent();
     _brush.SourceName = "EReaderView";
     _brush.Redraw();
     WebViewBrushArea.Fill = _brush;
 }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 private async Task captureBlock()
 {
     if (brush == null)
     {
         return;
     }
     brush.Redraw();
     await CaptureAndSave(MaskRectangle, imgCapture);
 }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
0
        private void RedrawBrush()
        {
            var wb = new WebViewBrush
            {
                SourceName = "TheWebView",
                Stretch    = Stretch.UniformToFill
            };

            wb.Redraw();
            BrushDisplay.Fill = wb;
        }
Exemplo n.º 7
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;
     }
 }
Exemplo n.º 8
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;
        }
Exemplo n.º 10
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;
        }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        private void SwitchWebViewForWebViewBrush()
        {
            if (_closeWebView.IsEnabled)
            {
                _closeWebView.Stop();
            }

            if (_webBrush != null)
            {
                _webBrush.Redraw();
            }
            webRectangle.Visibility = Visibility.Visible;
            wv.Visibility           = Visibility.Collapsed;
        }
Exemplo n.º 14
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);
     }
 }
Exemplo n.º 15
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());
     }
 }
Exemplo n.º 16
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;
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
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;
        }