Inheritance: Windows.UI.Xaml.Media.TileBrush, IWebViewBrush
Example #1
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);
						  };
		}
Example #2
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 Button_ShowText(object sender, RoutedEventArgs e)
 {
     WebViewBrush b = new WebViewBrush();
     b.SourceName = "webview";
     b.Redraw();
     rectangle.Fill = b;
     webview.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
 }
 private void MainWebView_OnLoadCompleted(object sender, NavigationEventArgs e)
 {
     var brush = new WebViewBrush();
     brush.SetSource(MainWebView);
     brush.Redraw();
     RectWebViewBrush.Fill = brush;
     RectWebViewBrush.Visibility = Visibility.Visible;
     MainWebView.Visibility = Visibility.Collapsed;
 }
Example #5
0
 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;
     }
 }
        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;
        }
        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;
        }
Example #8
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());
        }
        WebViewBrush GetWebViewBrush(WebView webView)
        {
            // resize width to content
            var originalWidth = webView.Width;
            var widthString = webView.InvokeScript("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 = webView.InvokeScript("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
            {
                SourceName = webView.Name,
                Stretch = Stretch.Uniform
            };
            brush.Redraw();

            // reset, return
            webView.Width = originalWidth;
            webView.Height = originalHeight;
            webView.Visibility = originalVisibilty;
            return brush;
        }
Example #10
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);
        }
Example #11
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);
            }
        }
Example #12
0
        private void SetPreviewState(Windows.UI.Xaml.Visibility visibility)
        {
            if (visibility == Windows.UI.Xaml.Visibility.Collapsed)
            {
                var brush = new WebViewBrush();
                brush.SetSource(Preview);

                PreviewCanvas.Fill = brush;
                Preview.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
            else
            {
                Preview.Visibility = Windows.UI.Xaml.Visibility.Visible;
                PreviewCanvas.Fill = new SolidColorBrush(Windows.UI.Colors.Transparent);
            }
        }
Example #13
0
        private void BrushEditor(bool b)
        {
            if (b)
            {
                if (rectEditor.Visibility == Windows.UI.Xaml.Visibility.Visible)
                {
                    WebViewBrush brush = new WebViewBrush();
                    brush.SourceName = "htmlEditor";
                    brush.Redraw();
                    rectEditor.Fill = brush;
                    htmlEditor.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }
            }
            else
            {
                htmlEditor.Visibility = Windows.UI.Xaml.Visibility.Visible;
                rectEditor.Fill = new SolidColorBrush(Windows.UI.Colors.Transparent);
            }

        }
Example #14
0
 private void ShowWebRect()
 {
     if (webBrush == null)
     {
         webBrush = new WebViewBrush();
         webBrush.SetSource(outputBox);
         outputRect.Fill = webBrush;
     }
     webBrush.Redraw();
     outputBox.Visibility = Visibility.Collapsed;
 }
		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);
			}
		}
 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;
 }
        /// <summary>
        /// Creates the WebViewBrush and fills our rectangle control with it
        /// </summary>
        private void CreateAndSetWebViewBrush()
        {
            // Get a brush from the WebView's content (a screen shot basically)
            WebViewBrush wvbBrush = new WebViewBrush();
            wvbBrush.SourceName = "wvBrowser";
            wvbBrush.Redraw();

            // Fill the Rectangle object with the brush
            rectWebViewBrush.Fill = wvbBrush;
        }