public override void OnViewModelLoadedOverride()
        {
            Title = ViewModel.Title;

            try
            {
                MyWebView.Navigate(new Uri(ViewModel.WebsiteToDisplay));

                base.OnViewModelLoadedOverride();
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);

                LoadingContainer.Visibility = Visibility.Collapsed;
                ErrorContainer.Visibility   = Visibility.Visible;
                if (ViewModel.FallbackText != null)
                {
                    TextBlockError.Text = ViewModel.FallbackText;
                }
                else
                {
                    TextBlockError.Text = "Failed to load";
                }
            }
        }
Esempio n. 2
0
        public override void OnViewModelLoadedOverride()
        {
            try
            {
                Uri uri    = new Uri(GoogleCalendarIntegrationViewModel.Url);
                var filter = new HttpBaseProtocolFilter();

                foreach (var c in ViewModel.GetCookies())
                {
                    filter.CookieManager.SetCookie(new HttpCookie(c.Key, uri.Host, "/")
                    {
                        Value = c.Value
                    }, false);
                }

                var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri);

                MyWebView.NavigateWithHttpRequestMessage(httpRequestMessage);

                base.OnViewModelLoadedOverride();
            }
            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
            }
        }
Esempio n. 3
0
        private async void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            deviceConfiguration.DefaulUrl = Address.Text;
            await deviceConfigurationRepo.Save(deviceConfiguration);

            MyWebView.Navigate(new Uri(Address.Text));
        }
    protected override void LoadPage()
    {
        Debug.Log("Tabs LoadPage");
        if (!(bool)this.webView)
        {
            return;
        }
        MyWebView webView;

        if (!this.FindWebView(this.m_InitialOpenURL, out webView) || (UnityEngine.Object)webView == (UnityEngine.Object)null)
        {
            this.NotifyVisibility(false);
            this.webView.SetHostView((GUIView)null);
            this.webView = (MyWebView)null;
            this.InitWebView(MyGUIClip.Unclip(new Rect(0.0f, 0.0f, this.position.width, this.position.height)));
            this.RegisterWebviewUrl(this.m_InitialOpenURL, this.webView);
            this.NotifyVisibility(true);
        }
        else
        {
            if ((UnityEngine.Object)webView != (UnityEngine.Object) this.webView)
            {
                this.NotifyVisibility(false);
                webView.SetHostView((GUIView)this.m_Parent.host);
                this.webView.SetHostView((GUIView)null);
                this.webView = webView;
                this.NotifyVisibility(true);
                this.webView.Show();
            }
            this.LoadUri();
        }
    }
 void Back_Clicked(object sender, EventArgs e)
 {
     if (MyWebView.CanGoBack)
     {
         MyWebView.GoBack();
     }
 }
Esempio n. 6
0
        public WebViewPage()
        {
            StackLayout objStackLayout = new StackLayout()
            {
            };

            MyWebView webView = new MyWebView();

            WebViewPage.CurrentUrl = "http://www.example.com";
            webView.Source         = WebViewPage.CurrentUrl;

            webView.HeightRequest = 300;
            objStackLayout.Children.Add(webView);

            Button cmdButton1 = new Button();

            cmdButton1.Text = "Show Me Current Url";
            objStackLayout.Children.Add(cmdButton1);
            //
            cmdButton1.Clicked += ((o2, e2) =>
            {
                System.Diagnostics.Debug.WriteLine(CurrentUrl);
            });

            this.Content = objStackLayout;
        }
 private async void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
 {
     if (MyWebView != null)
     {
         await MyWebView.InvokeScriptAsync("eval", new string[] { "ZoomFunction(" + e.NewValue.ToString() + ");" });
     }
 }
Esempio n. 8
0
        private async void MyWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            LoadingProgressBar.Visibility = Visibility.Collapsed;

            if (!args.IsSuccess)
            {
                ContentDialog d = new ContentDialog();
                d.Title             = "Oops";
                d.Content           = "Navigation to " + args.Uri.ToString() + " failed. " + args.WebErrorStatus.ToString();
                d.PrimaryButtonText = "Ok";

                await d.ShowAsync();
            }

            if (this.isLoaded)
            {
                string m = args.Uri.Scheme + "://" + args.Uri.AbsolutePath;

                if (m != "ms-appx-web:///landingpage.html" && !this.isLoadedCompleted)
                {
                    this.isLoadedCompleted = true;

                    this.settings.AddToHistory(new SavedLink()
                    {
                        DocumentTitle = MyWebView.DocumentTitle,
                        Url           = args.Uri.ToString()
                    });
                }

                // Check for the landing page so that the user doesn't have to press
                // back an extra time
                if (m == "ms-appx-web:///landingpage.html")
                {
                    if (this.Frame.CanGoBack)
                    {
                        this.Frame.GoBack();
                    }
                }
            }

            // Inject <F5>, <CTRL + R> support for refreshing
            // <ALT + LEFT_ARROW> support to go back
            string js =
                @"window.addEventListener('keydown', function(event) {if (event.key === 'F5') {
        location.reload(true);
    }
    else if (event.ctrlKey && event.key === 'r') {
        location.reload(true);
    }
    else if (event.altKey && event.key === 'Left') {
        window.history.back();
    }
}, false);";

            if (settings.IsKeyboardShortcutsEnabled)
            {
                await MyWebView.InvokeScriptAsync("eval", new string[] { js });
            }
        }
Esempio n. 9
0
 public void InvokeJSScript(string scriptName, string[] parameters)
 {
     //retrieves the UI thread and invokes javascript on this thread
     CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         MyWebView.InvokeScriptAsync(scriptName, parameters);
     });
 }
Esempio n. 10
0
        public MainPage()
        {
            this.InitializeComponent();
            MyWebView.ScriptNotify += MyWebView_ScriptNotify;
            Uri url = MyWebView.BuildLocalStreamUri("MyTag", "/Test/HomePage.html");
            StreamUriWinRTResolver myResolver = new StreamUriWinRTResolver();

            MyWebView.NavigateToLocalStreamUri(url, myResolver);
        }
Esempio n. 11
0
        protected override void OnElementChanged(ElementChangedEventArgs <WebView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                MyWebView myWebView = e.NewElement as MyWebView;
            }
        }
Esempio n. 12
0
 private async void MyWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
 {
     // Inject our Keydown handler into the page
     string inject =
         @"document.addEventListener('keydown', function(event) {
             window.external.notify('KeyDown:' + event.which);
         });";
     await MyWebView.InvokeScriptAsync("eval", new List <string>() { inject });
 }
Esempio n. 13
0
        public void Initialize(string urlBase, string modName, MyWebView wb = null)
        {
            UrlBase = urlBase;
            ModName = modName;
            _wb     = wb;
            ZipLink = null;

            GetZipURL();
        }
 private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
 {
     if (args.IsSuccess == true)
     {
         // need to set the window.utils.windowsApp property to true so that the document will be
         // loaded using the efficient windows local file part retriever
         MyWebView.InvokeScriptAsync("eval", new string[] { "window.utils.windowsApp = true;" });
     }
 }
Esempio n. 15
0
 private void _button_Clicked(object sender, EventArgs e)
 {
     _webView = new MyWebView
     {
         Source        = "https://test.webrtc.org/",
         WidthRequest  = 1000,
         HeightRequest = 1000
     };
     stackLayout.Children.Add(_webView);
 }
Esempio n. 16
0
    private void CreateScriptObject()
    {
        if ((UnityEngine.Object) this.scriptObject != (UnityEngine.Object)null)
        {
            return;
        }

        this.scriptObject           = MyWebScriptObject.Create();//ScriptableObject.CreateInstance( typeWebScriptObject );//<WebScriptObject>();
        this.scriptObject.hideFlags = HideFlags.HideAndDontSave;
        this.scriptObject.webView   = this.webView;
    }
Esempio n. 17
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Substring(0, 7) != "http://")
            {
                MyWebView.Navigate(new Uri("http://" + textBox1.Text));
            }

            else
            {
                MyWebView.Navigate(new Uri(textBox1.Text));
            }
        }
 private void AppBarButton_Click(object sender, RoutedEventArgs e)
 {
     if (isInfoFlyoutOpen)
     {
         InfoFlyout.Hide();
     }
     else
     {
         Uri targetUri = new Uri(@"https://developers.arcgis.com/en/features/geocoding/");
         MyWebView.Navigate(targetUri);
     }
 }
 private async void TabContent_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName.Equals(nameof(Settings.ColorMode), StringComparison.Ordinal))
     {
         ApplyUiColors();
     }
     _handleSettingsArgs[0] = GetSettings();
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
     {
         await MyWebView.InvokeScriptAsync("handle_settings", _handleSettingsArgs);
     });
 }
Esempio n. 20
0
 public WebViewPage() : base("Web View")
 {
     {
         GDmain = new MyGrid();
         {
             WVmain        = new MyWebView();
             WVmain.Source = "https://codingsimplifylife.blogspot.tw/";
             GDmain.Children.Add(WVmain, 0, 0);
         }
         this.Content = GDmain;
     }
 }
Esempio n. 21
0
        private async void WebView_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string[] urlParts    = e.Value.Split('?');
            string   docLocation = urlParts[0];

            Uri docUri = new Uri("ms-appx:///" + docLocation);
            var file   = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(docUri);

            var props = await file.GetBasicPropertiesAsync();

            var fileSize = props.Size;

            string range = urlParts[1];

            string[] rangeParts = range.Split('&');

            string originalRangeStart = rangeParts[0];
            ulong  rangeStart;

            // if the range start is negative then read from the end of the file
            if (originalRangeStart.StartsWith("-"))
            {
                ulong rangeStartPositive = (ulong)Math.Abs(Convert.ToInt64(originalRangeStart));
                rangeStart = fileSize - rangeStartPositive;
            }
            else
            {
                rangeStart = Convert.ToUInt64(originalRangeStart);
            }

            // if the end range is not specified then it goes to the end of the file
            ulong rangeEnd = (rangeParts[1].Length == 0) ? fileSize : Convert.ToUInt64(rangeParts[1]);

            var stream = await file.OpenReadAsync();

            stream.Seek(rangeStart);

            // get the number of bytes to read
            uint count = (uint)(rangeEnd - rangeStart);
            var  bytes = new byte[count];

            using (var dataReader = new DataReader(stream))
            {
                await dataReader.LoadAsync(count);

                dataReader.ReadBytes(bytes);
            }

            string successFunction = string.Format("setTimeout(function() {{ window.CoreControls.PartRetrievers.WinRTPartRetriever.partSuccess('{0}', '{1}'); }}, 0);", Convert.ToBase64String(bytes), originalRangeStart);

            MyWebView.InvokeScript("eval", new string[] { successFunction });
        }
Esempio n. 22
0
        private void ItemsList_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Debug.Assert(e.OriginalSource != null, "e.OriginalSource != null");
            var _FrameworkElement = e.OriginalSource as FrameworkElement;

            if (_FrameworkElement != null)
            {
                var _Item = _FrameworkElement.DataContext as IArticle;
                Debug.Assert(_Item != null, "_Item != null");
                MyWebView.Navigate(new Uri(_Item.Url));
            }
            MyProgressRing.Visibility = Visibility.Visible;
        }
Esempio n. 23
0
 /// <exception cref="NotImplementedException">When the given url doesn't have any driver</exception>
 /// <exception cref="ArgumentException">When can't parse the url to obtain the download link</exception>
 public static IDownloadLink GetHostType(string urlBase, string modName, MyWebView wb)
 {
     foreach (var driver in Drivers.Value)
     {
         if (urlBase.Contains(driver.Key))
         {
             IDownloadLink obj = (IDownloadLink)Activator.CreateInstance(driver.Value);
             obj.Initialize(urlBase, modName, wb);
             return(obj);
         }
     }
     throw new NotImplementedException("The link " + urlBase + "comes from an unknown host");
 }
 public void Navigate(string uri)
 {
     try
     {
         MyWebView.Navigate(new Uri(uri));
         this.Visibility = Visibility.Visible;
     }
     catch
     {
         new Windows.UI.Popups.MessageDialog("Sorry. That feed's Url is invalid. :(").ShowAsync();
         this.Visibility = Visibility.Collapsed;
     }
 }
Esempio n. 25
0
        public override bool OnKeyDown(Android.Views.Keycode keyCode, Android.Views.KeyEvent e)
        {
            if (keyCode == Keycode.Back)
            {
                if (MyWebView.CanGoBack())
                {
                    MyWebView.GoBack();
                }

                return(true);
            }

            return(base.OnKeyDown(keyCode, e));
        }
Esempio n. 26
0
 private async void MyWebView_LoadCompleted(object sender, NavigationEventArgs e)
 {
     string functionString = @"var anchors = document.querySelectorAll('a');      
 for (var i = 0; i < anchors.length; i += 1) {
         anchors[i].oncontextmenu = function (e) {
             var e = e||window.event;  
             var oX = e.clientX;
             var oY = e.clientY;
             var href = this.getAttribute('href');
             window.external.notify([oX.toString(), oY.toString(), href].toString());
         };
     }";
     await MyWebView.InvokeScriptAsync("eval", new string[] { functionString });
 }
Esempio n. 27
0
        private async void MyWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            string functionString = @"var nodeList = document.getElementsByTagName ('link');
            for (var i = 0; i < nodeList.length; i++)
            {
                if ((nodeList[i].getAttribute('rel') == 'icon') || (nodeList[i].getAttribute('rel') == 'shortcut icon'))
                {
                    favicon = nodeList[i].getAttribute('href');
                    window.external.notify(favicon); 
                }
            }";

            await MyWebView.InvokeScriptAsync("eval", new string[] { functionString });
        }
Esempio n. 28
0
        private void EnsureHttps(WebView2 sender, WebView2NavigationStartingEventArgs args)
        {
            String uri = args.Uri;

            if (!uri.StartsWith("https://"))
            {
                MyWebView.ExecuteScriptAsync($"alert('{uri} is not safe, try an https link')");
                args.Cancel = true;
            }
            else
            {
                addressBar.Text = uri;
            }
        }
Esempio n. 29
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            Uri requestUri = new Uri("http://virtualdeck.azurewebsites.net/");

            // Show the pop up
            HomeContent.Visibility = Visibility.Collapsed;
            MyWebView.Visibility   = Visibility.Visible;

            MyWebView.Navigate(requestUri);

            await Task.Run(() => { waitForNavComplete.WaitOne(); });

            waitForNavComplete.Reset();
            MyWebView.Visibility   = Visibility.Collapsed;
            HomeContent.Visibility = Visibility.Visible;
        }
Esempio n. 30
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            deviceConfigurationRepo = new LocalDeviceConfigurationRepo();
            deviceConfiguration     = await deviceConfigurationRepo.Get();

            if (deviceConfiguration == null)
            {
                deviceConfiguration = new DeviceConfiguration();
            }
            else
            {
                ToggleMenu();
                Address.Text = deviceConfiguration.DefaulUrl;
                MyWebView.Navigate(new Uri(deviceConfiguration.DefaulUrl));
            }
        }
Esempio n. 31
0
        public WebViewPage()
        {
            StackLayout objStackLayout = new StackLayout()
            {
            };

            MyWebView webView = new MyWebView();
            WebViewPage.CurrentUrl = "http://www.example.com";
            webView.Source = WebViewPage.CurrentUrl;

            webView.HeightRequest = 300;
            objStackLayout.Children.Add(webView);

            Button cmdButton1 = new Button();
            cmdButton1.Text = "Show Me Current Url";
            objStackLayout.Children.Add(cmdButton1);
            //
            cmdButton1.Clicked += ((o2, e2) =>
            {
                System.Diagnostics.Debug.WriteLine(CurrentUrl);
            });

            this.Content = objStackLayout;
        }