Example #1
0
        private void LoadHTMLContent()
        {
            // WebViewControl.Navigate(new Uri("ms-appx-web:///html/BasicDirectionalNavigation.html"));
            WebViewControl.Navigate(new Uri("http://www.microsoft.com"));

            WebViewControl.Focus(FocusState.Programmatic);
        }
Example #2
0
        /// <summary>
        /// Navigates the webview to the application package
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadFromPackage_Click()
        {
            string url = "ms-appx-web:///html/html_example2.html";

            WebViewControl.Navigate(new Uri(url));
            rootPage.NotifyUser($"Navigated to {url}", NotifyType.StatusMessage);
        }
Example #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string url = "ms-appx-web:///Htm/About.html";

            WebViewControl.Navigate(new Uri(url));
            //rootPage.NotifyUser($"Navigated to {url}", NotifyType.StatusMessage);
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            WebViewControl.Navigate(new Uri("http://www.microsoft.com"));

            // Register for the share event
            DataTransferManager.GetForCurrentView().DataRequested += DataTransferManager_DataRequested;
        }
Example #5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var url = new Uri("https://www.bing.com/");

            if (e.Parameter is string)
            {
                Uri.TryCreate(e.Parameter.ToString(), UriKind.RelativeOrAbsolute, out url);
            }
            //var url = new Uri("https://cn.bing.com/images/");images/search?form=EDNTHT&mkt=zh-cn
            WebViewControl.Navigate(url);
        }
Example #6
0
        /*
         * private async void MainPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
         * {
         *  DataRequestDeferral deferral = e.Request.GetDeferral();
         *  e.Request.Data.Properties.Title = "Golzin";
         *  Uri www = new Uri("http://viish.co.nf");
         *  e.Request.Data.SetText("Hello World, Golzin' your score: " + ant_value + "\n download in: " + www);
         *
         *
         *  StorageFile image = await GetFileFromBitmap(bmp);
         *
         *  if (image != null)
         *  {
         *      List<IStorageItem> storageItems = new List<IStorageItem>();
         *      storageItems.Add(image);
         *      e.Request.Data.SetStorageItems(storageItems);
         *
         *      //e.Request.Data.SetBitmap(RandomAccessStreamReference.CreateFromFile(image));
         *      //e.Request.Data.Properties.Thumbnail = RandomAccessStreamReference.CreateFromFile(image);
         *  }
         *  //else
         *  //{
         *  //    e.Request.Data.SetText(e.Request.Data.Properties.Description);
         *  //}
         *
         *
         *  deferral.Complete();
         * }
         *
         *
         *
         * private async Task<StorageFile> GetFileFromBitmap(WriteableBitmap writeableBitmp)
         * {
         *  string fileName = "MyImage.png";
         *
         *  //salvar arquivo no cell
         *  //StorageFolder localFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync("golzin", CreationCollisionOption.ReplaceExisting);
         *  //StorageFile file = await localFolder.CreateFileAsync(fileName + ".png", CreationCollisionOption.GenerateUniqueName);
         *
         *  StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);//LocalFolder//TemporaryFolder
         *
         *  using (IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite))
         *  {
         *      BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
         *      Stream pixelStream = writeableBitmp.PixelBuffer.AsStream();
         *      byte[] pixels = new byte[pixelStream.Length];
         *      await pixelStream.ReadAsync(pixels, 0, pixels.Length);
         *      encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore,
         *                  (uint)writeableBitmp.PixelWidth,
         *                  (uint)writeableBitmp.PixelHeight,
         *                  96.0,
         *                  96.0,
         *                  pixels);
         *      await encoder.FlushAsync();
         *  }
         *
         *  return file;
         * }
         */


        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            WebViewControl.Navigate(HomeUri);

            StatusBar statusBar = StatusBar.GetForCurrentView();
            await statusBar.HideAsync();

            //await statusBar.ShowAsync();
            HardwareButtons.BackPressed += this.MainPage_BackPressed;
        }
        /// <exception cref="ArgumentException">The provided <paramref name="source"/> is a relative URI.</exception>
        internal void Navigate(Uri source)
        {
            Verify.IsNotNull(_webViewControl);

            if (_webViewControl != null)
            {
                // Cancel any outstanding navigation
                // TODO: Does this show a cancel page? Can we suppress that?
                _webViewControl.Stop();

                LastNavigation = Guid.NewGuid();

                if (source == null)
                {
                    NavigatingToAboutBlank = true;
                    source = WebViewDefaults.AboutBlankUri;
                }
                else
                {
                    CleanInternalState();
                }

                // Absolute URI only. Not sure what the host would be if using relative
                if (!source.IsAbsoluteUri)
                {
                    throw new ArgumentException(DesignerUI.E_WEBVIEW_NOT_ABSOLUTE_URI, nameof(source));
                }

                // TODO: Handle POPUP window
                // TODO: Handle navigation for frame

                // TODO: Security for partial trust (e.g. about:blank is not allowed)
                // If we are navigating to "about:blank" internally as a result of setting source to null
                // or navigating to string, do not demand WebPermission
                if (!NavigatingToAboutBlank)
                {
                    Security.DemandWebPermission(source);
                }

                // TODO: Sanitize URI containing invalid UTF-8 sequences
                try
                {
                    _webViewControl.Navigate(source);
                }
                catch (Exception)
                {
                    // Clear internal state if navigation fails
                    CleanInternalState();

                    throw;
                }
            }
        }
 private void NavigateWebview()
 {
     try
     {
         Uri targetUri = new Uri("http://dev.dentall.site:8085/#/appointment");
         WebViewControl.Navigate(targetUri);
     }
     catch (UriFormatException ex)
     {
         // Bad address
     }
 }
Example #9
0
 private void NavigateToURL(MarkStringContent linkMark)
 {
     try
     {
         Uri targetUri = new Uri(linkMark.content);
         WebViewControl.Navigate(targetUri);
     }
     catch (UriFormatException)
     {
         System.Diagnostics.Debug.WriteLine("Address is invalid, try again.");
     }
 }
Example #10
0
 public void NavigateToFile(string url)
 {
     if (string.IsNullOrWhiteSpace(config.ExternalHost))
     {
         var uri = webview.BuildLocalStreamUri("spidereye", url);
         webview.NavigateToLocalStreamUri(uri, streamResolver);
     }
     else
     {
         var uri = UriTools.Combine(config.ExternalHost, url);
         webview.Navigate(uri);
     }
 }
 /// <summary>
 /// Helper to perform the navigation in webview
 /// </summary>
 /// <param name="url"></param>
 private void NavigateWebview(string url)
 {
     try
     {
         Uri targetUri = new Uri(url);
         WebViewControl.Navigate(targetUri);
     }
     catch (UriFormatException ex)
     {
         // Bad address
         AppendLog($"Address is invalid, try again. Error: {ex.Message}.");
     }
 }
Example #12
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.Back)
            {
                if (localSettings.Values["NightScoutURL"] != null)
                {
                    NightScoutURL = localSettings.Values["NightScoutURL"].ToString();
                }
            }
            if (NightScoutURL != null)
            {
                WebViewControl.Navigate(new Uri(NightScoutURL));
                HardwareButtons.BackPressed += this.MainPage_BackPressed;
            }
        }
Example #13
0
        /// <summary>
        /// Navigates the webview to the local state directory
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void LoadFromLocalState_Click()
        {
            // Create a file in a subdirectory.
            // The ms-appdata protocol isolates top-level subdirectories from each other.

            StorageFolder stateFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("NavigateToState", CreationCollisionOption.OpenIfExists);

            StorageFile htmlFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///html/html_example2.html"));

            await htmlFile.CopyAsync(stateFolder, "test.html", NameCollisionOption.ReplaceExisting);

            string url = "ms-appdata:///local/NavigateToState/test.html";

            WebViewControl.Navigate(new Uri(url));
            rootPage.NotifyUser($"Navigated to {url}", NotifyType.StatusMessage);
        }
Example #14
0
        public void LoadUri(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException(nameof(uri));
            }

            if (uri.IsAbsoluteUri)
            {
                webview.Navigate(uri);
            }
            else
            {
                var localUri = webview.BuildLocalStreamUri("spidereye", uri.ToString());
                webview.NavigateToLocalStreamUri(localUri, EdgeUriToStreamResolver.Instance);
            }
        }
        private async void ReadLatestPosts(MenuFlyoutItem[] menuItems)
        {
            var feedClient = new SyndicationClient();

            try
            {
                var feedData = await feedClient.RetrieveFeedAsync(new Uri("http://ytechie.com/rss"));

                var itemNumber = 0;
                foreach (var feedItem in feedData.Items)
                {
                    if (itemNumber < 10)
                    {
                        menuItems[itemNumber].Text       = feedItem.Title.Text;
                        menuItems[itemNumber].Visibility = Visibility.Visible;

                        string linkUri;
                        if (feedItem.Links.Count > 0)
                        {
                            linkUri = feedItem.Links[0].Uri.AbsoluteUri;
                        }
                        else
                        {
                            return;
                        }

                        //We have to run this on the UI thread:
                        menuItems[itemNumber].Click += (sender, args) => Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            WebViewControl.Navigate(new Uri(linkUri));
                        });
                    }
                    itemNumber++;
                }
            }
            catch (Exception)
            {
                menuItems[0].Text = "Error Reading Feed!";
            }
        }
Example #16
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            RootContainer    = GetTemplateChild("RootContainer") as Grid;
            ContentContainer = GetTemplateChild("ContentContainer") as Grid;

            WebViewControl = GetTemplateChild("WebViewControl") as WebView;

            if (WebViewControl != null)
            {
                WebViewControl.NavigationStarting             -= WebViewControl_NavigationStarting;
                WebViewControl.NavigationStarting             += WebViewControl_NavigationStarting;
                WebViewControl.NavigationCompleted            -= WebViewControl_NavigationCompleted;
                WebViewControl.NavigationCompleted            += WebViewControl_NavigationCompleted;
                WebViewControl.NavigationFailed               -= WebViewControl_NavigationFailed;
                WebViewControl.NavigationFailed               += WebViewControl_NavigationFailed;
                WebViewControl.UnsupportedUriSchemeIdentified -= WebViewControl_UnsupportedUriSchemeIdentified;
                WebViewControl.UnsupportedUriSchemeIdentified += WebViewControl_UnsupportedUriSchemeIdentified;

                if (Uri.TryCreate(AuthorizeUrl, UriKind.Absolute, out var authorizeUri))
                {
                    WebViewControl.Navigate(authorizeUri);
                }
            }

            HideButton = GetTemplateChild("HideButton") as Button;

            if (HideButton != null)
            {
                HideButton.Click += HideButton_Click;
            }

            BackgroundBorder = GetTemplateChild("BackgroundBorder") as Border;

            ProgressRingControl = GetTemplateChild("ProgressRingControl") as ProgressRing;

            RefreshrLayout();
        }
 public OAuthWebViewPage()
 {
     this.InitializeComponent();
     WebViewControl.Navigate(new Uri("https://contosocabs.azurewebsites.net/uber/login"));
 }
Example #18
0
 /// <summary>
 /// 导航到初始主页。
 /// </summary>
 private void HomeAppBarButton_Click(object sender, RoutedEventArgs e)
 {
     WebViewControl.Navigate(HomeUri);
 }
Example #19
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            WebViewControl.Navigate(HomeUri);

            HardwareButtons.BackPressed += this.MainPage_BackPressed;
        }
Example #20
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     WebViewControl.Navigate(new Uri("http://www.bing.com"));
 }
Example #21
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     WebViewControl.Navigate(new Uri("https://www.bing.com/search?q=site%3Amicrosoft.com+filetype%3Apdf"));
 }
 public Scenario4_ScriptNotify()
 {
     this.InitializeComponent();
     WebViewControl.Navigate(new Uri("ms-appx-web:///html/scriptNotify_example.html"));
 }
 /// <summary>
 /// Wird aufgerufen, wenn diese Seite in einem Rahmen angezeigt werden soll.
 /// </summary>
 /// <param name="e">Ereignisdaten, die beschreiben, wie diese Seite erreicht wurde.
 /// Dieser Parameter wird normalerweise zum Konfigurieren der Seite verwendet.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     WebViewControl.Navigate(HomeUri);
 }
Example #24
0
        public static async Task <WebAuthenticationResult> AuthenticateAsync(
            Uri requestUri, Uri callbackUri, Window parentWindow)
        {
            var            webViewControlProcess = new WebViewControlProcess();
            WebViewControl webViewControl        = null;

            var webViewWindow = new WebAuthenticationWindow();

            webViewWindow.Owner = parentWindow;

            // Response details
            string responseData = "";
            uint   responseCode = 0;
            var    status       = WebAuthenticationStatus.Success;

            webViewWindow.Loaded += async(_, __) =>
            {
                await Task.Delay(200);

                webViewControl = await webViewControlProcess.CreateWebViewControlAsync(
                    new WindowInteropHelper(webViewWindow).Handle.ToInt64(),
                    new Windows.Foundation.Rect(0, 0, webViewWindow.ActualWidth, webViewWindow.ActualHeight));

                webViewControl.NavigationStarting += (s, e) =>
                {
                    // Check for the Uri first -- localhost will give a 404
                    // but we might already have the data we want
                    if (e.Uri.ToString().StartsWith(callbackUri.ToString()))
                    {
                        responseData = e.Uri.ToString();
                        webViewWindow.DialogResult = true;
                    }
                };

                webViewControl.NavigationCompleted += (s, e) =>
                {
                    if (!e.IsSuccess)
                    {
                        webViewWindow.DialogResult = false;
                        responseCode = (uint)e.WebErrorStatus;
                    }
                };

                webViewControl.Navigate(requestUri);
            };

            var dialogResult = await ShowDialogAsync(webViewWindow);

            if (dialogResult.HasValue)
            {
                status = dialogResult.Value ? WebAuthenticationStatus.Success : WebAuthenticationStatus.Error;
            }
            else
            {
                status = WebAuthenticationStatus.Canceled;
            }

            webViewControlProcess.Terminate();

            return(new WebAuthenticationResult(responseData, responseCode, status));
        }
Example #25
0
        public void WebViewControl_ScriptNotify(object sender, NotifyEventArgs e)
        {
            string[] result = e.Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (result.Length == 2 && result[0].StartsWith("/search?"))
            {
                SaveSearchQuery(result[1]);
                return;
            }
            if (result.Length == 2 && result[0].StartsWith("https:"))
            {
                SaveSearchQuery(result[1]);
                WebViewControl.Navigate(new Uri(result[0]));
                return;
            }

            //As 联想词添加
            if (result.Length >= 3 && result[1] == "3")
            {
                var keyword = result[0].Trim();
                SaveSearchQuery(keyword);
                var Flag = (QueryEntryFlag)int.Parse(result[1]);

                var list = result.ToList();
                list.RemoveRange(0, 2);
                list.ForEach(item => {
                    var tempRS = new PageQueryEntry()
                    {
                        Keywords = keyword,
                        Content  = item,
                        Flag     = Flag,
                        isFirst  = viewModel.Querys.Where(x => x.Keywords == keyword).Count() == 0,
                    };
                    if (!viewModel.Querys.Contains(tempRS))
                    {
                        viewModel.Querys.Add(tempRS);
                    }
                    UpdateKeywordsList();
                });
            }
            else if (result.Length == 3 && 0 == viewModel.Querys.Count(x => x.Keywords == result[0] && x.Content == result[1]))
            {
                var flag   = (QueryEntryFlag)int.Parse(result[2]);
                var tempRS = new PageQueryEntry()
                {
                    Keywords = result[0],
                    Content  = result[1],
                    Flag     = flag,
                    isFirst  = viewModel.Querys.Where(x => x.Keywords == result[0]).Count() == 0,
                };
                if (!viewModel.Querys.Contains(tempRS))
                {
                    viewModel.Querys.Add(tempRS);
                }
                UpdateKeywordsList();
            }
            //测试Web 弹出信息
            //var dialog = new ContentDialog()
            //{
            //    Title = "ScriptNotify",
            //    Content = e.Value,
            //    PrimaryButtonText = "Ok",
            //    SecondaryButtonText = "Cancel",
            //    FullSizeDesired = false,
            //};
            //await dialog.ShowAsync();
        }
 private void HomeButton_OnClick(object sender, RoutedEventArgs e)
 {
     WebViewControl.Navigate(new Uri("http://www.ytechie.com"));
 }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     WebViewControl.Navigate(new Uri("https://www.youtube.com/watch?v=XVfOe5mFbAE"));
 }
Example #28
0
 private void ExpensesAppBarButton_Click(object sender, RoutedEventArgs e)
 {
     WebViewControl.Navigate(ExpenseUri);
 }