当前位置: 首页>>代码示例>>C#>>正文


C# WebView.NavigateToString方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Controls.WebView.NavigateToString方法的典型用法代码示例。如果您正苦于以下问题:C# WebView.NavigateToString方法的具体用法?C# WebView.NavigateToString怎么用?C# WebView.NavigateToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Controls.WebView的用法示例。


在下文中一共展示了WebView.NavigateToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSchedule

        public async Task<string> GetSchedule(string user)
        {
            StringBuilder sb = new StringBuilder();

            try
            {

                UnityDataAccess uda = new UnityDataAccess();

               // string sToken = await uda.GetToken(objUnityData.UnitySvcUser, objUnityData.UnitySvcPwd, user);


                string strDate = DateTime.Now.ToString(@"MM/dd/yyyy");


                string sJson = await uda.Magic("GetSchedule", objUnityData.UnityAppUser, objUnityData.UnityAppName, "", objUnityData.Token, strDate, "", "", "", "", "", "");
                return sJson;
            }
            catch (Exception ex)
            {
                WebView wc = new WebView();
                wc.NavigateToString(ex.Message);
                Window.Current.Content = wc;
                return ""; 

            }
                
        }
开发者ID:bdecori,项目名称:win8,代码行数:28,代码来源:TaskingObject.cs

示例2: GetSchedule

        public async Task<string> GetSchedule(string user)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                string strDate = DateTime.Now.ToString(@"MM/dd/yyyy");


                string sJson = await UnityDataService.Magic(UnityDataAccessActions.GetSchedule, UnityDataService.UnityAppUser, UnityDataService.UnityAppName, "", UnityDataService.Token, strDate, "", "", "", "", "", "");
                return sJson;
            }
            catch (Exception ex)
            {
                WebView wc = new WebView();
                wc.NavigateToString(ex.Message);
                Window.Current.Content = wc;
                return "";
            }
        }
开发者ID:bdecori,项目名称:win8,代码行数:20,代码来源:TaskDataService.cs

示例3: GetUserAgent

        private static Task<string> GetUserAgent()
        {
            var tcs = new TaskCompletionSource<string>();

            WebView webView = new WebView();

            string htmlFragment =
              @"<html>
                    <head>
                        <script type='text/javascript'>
                            function GetUserAgent() 
                            {
                                return navigator.userAgent;
                            }
                        </script>
                    </head>
                </html>";

            webView.NavigationCompleted += async (sender, e) =>
            {
                try
                {
                    //Invoke the javascript when the html load is complete
                    string result = await webView.InvokeScriptAsync("GetUserAgent", null);

                    //Set the task result
                    tcs.TrySetResult(result);
                }
                catch (Exception ex)
                {
                    tcs.TrySetException(ex);
                }
            };

            //Load Html
            webView.NavigateToString(htmlFragment);

            return tcs.Task;
        }
开发者ID:mbmccormick,项目名称:Authenticator,代码行数:39,代码来源:FeedbackHelper.cs

示例4: SetDefaultBrowserAgent

        /// <summary>
        /// Установить агент.
        /// </summary>
        /// <returns>Агент.</returns>
        public async Task SetDefaultBrowserAgent()
        {
            var tcs = new TaskCompletionSource<string>(TaskCreationOptions.None);
            var ww = new WebView();
            ww.NavigateToString(@"<html>
    <head>
        <script type='text/javascript'>
            function getUserAgent() 
            { 
                return navigator.userAgent; 
            }
        </script>
    </head>
    <body>
    </body>
</html>");
            ww.NavigationCompleted += async (sender1, e1) =>
            {
                try
                {
                    var ua = await ww.InvokeScriptAsync("getUserAgent", new string[0]);
                    tcs.TrySetResult(ua);
                }
                catch (Exception ex)
                {
                    tcs.TrySetException(ex);
                }
            };
            var task = tcs.Task;
            var tua = await task;
            BrowserUserAgent = tua;
        }
开发者ID:Opiumtm,项目名称:DvachBrowser3,代码行数:36,代码来源:MakabaEngineConfig.cs

示例5: ChatBoxTool

 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="wv"></param>
 public ChatBoxTool(WebView wv)
 {
     _chat_box = wv;
     _chat_box.NavigateToString(_bastChatHtml);          
 }
开发者ID:jango2015,项目名称:Blogs,代码行数:9,代码来源:ChatBoxTool.cs

示例6: SetHtml

 public static void SetHtml(WebView webView, string html)
 {
     webView.NavigateToString(html);
 }
开发者ID:CuiXiaoDao,项目名称:MyGit,代码行数:4,代码来源:WebViewBehaviour.cs

示例7: GetUserAgent

 private void GetUserAgent()
 {
     // Only get user agent if running on UI thread
     if (CoreWindow.GetForCurrentThread() != null)
     {
         var dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
         dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate()
         {
             // Create a new WebView and get user agent
             WebView wv = new WebView();
             wv.Visibility = Visibility.Collapsed;
             wv.ScriptNotify += new NotifyEventHandler(UserAgentScriptNotify);
             string html =
                 "<html><head><script type='text/javascript'>function GetUserAgent() {" +
                 "window.external.notify(navigator.userAgent);}" +
                 "</script></head>" +
                 "<body onload='GetUserAgent();'></body></html>";
             wv.NavigateToString(html);
         });
     }
 }
开发者ID:app-tracking,项目名称:sdk-release,代码行数:21,代码来源:MobileAppTracker.cs

示例8: LoadWebContent

        private void LoadWebContent(WebView browser, Item selectedItem)
        {
            #if WINDOWS_APP
            if (AppSettings.MaximizeYoutubeVideos)
            {
                var youtubeLink = Regex.Match(selectedItem.Description, @"(https?:)?//w*\.?youtube.com/watch[^'\""<>]+").Value;

                if (youtubeLink.Length > 0)
                {
                    //Youtube videos get full screen
                    browser.Navigate(new Uri(youtubeLink));
                    return;
                }
            }
            #endif

            var bc = AppSettings.BackgroundColorOfDescription[0] == '#' ? AppSettings.BackgroundColorOfDescription : FetchBackgroundColor();

            var fc = AppSettings.FontColorOfDescription[0] == '#' ? AppSettings.FontColorOfDescription : FetchFontColor();

            string scriptOptions = string.Empty;
            string disableHyperLinksJS = "<script type='text/javascript'>window.onload = function() {   var anchors = document.getElementsByTagName(\"a\"); for (var i = 0; i < anchors.length; i++) { anchors[i].onclick = function() {return(false);}; }};</script>";
            string disableOpeningHyperLinksInNewTabJS = "<script type='text/javascript'>window.onload = function() {   var anchors = document.getElementsByTagName(\"a\"); for (var i = 0; i < anchors.length; i++) { anchors[i].target = \"_self\"; }};</script>";
            string launchPhoneCallJS = @"<script type='text/javascript'>  function callOutToCSharp(stringParameter){window.external.notify(stringParameter.toLocaleString());} window.onload = function() {   var regex = /((\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4})/, replacement = '<input type=""button"" value=""$1"" onclick=""callOutToCSharp(\'launchPhoneCall:$1\');"" />'; function replaceText(el) { if (el.nodeType === 3) { if (regex.test(el.data)) { var temp_div = document.createElement('div'); temp_div.innerHTML = el.data.replace(regex, replacement); var nodes = temp_div.childNodes; while (nodes[0]) { el.parentNode.insertBefore(nodes[0],el); } el.parentNode.removeChild(el); } } else if (el.nodeType === 1) { for (var i = 0; i < el.childNodes.length; i++) { replaceText(el.childNodes[i]);  }  }} replaceText(document.body); } </script>";

            if (AppSettings.DisableHyperLinksInItemDescriptionView)
                scriptOptions = scriptOptions + disableHyperLinksJS;
            if (AppSettings.DisableOpeningHyperLinksInNewTab)
                scriptOptions = scriptOptions + disableOpeningHyperLinksInNewTabJS;
            #if WINDOWS_PHONE_APP
            if (AppSettings.EnableParsingPhoneNumbersPhone8X)
                scriptOptions = scriptOptions + launchPhoneCallJS;
            #endif

            var webcontent = "<!doctype html><HTML>" +
            "<HEAD>" +
            "<meta name=\"viewport\" content=\"width=320, user-scrollable=no\" />"
            +
                scriptOptions
            +
            "<style type='text/css'>a img {border: 0;}</style>" +
            "</HEAD>" +
            "<BODY style=\"background-color:" + bc + ";color:" + fc + ";-ms-touch-action: pan-y;" + "\">" +
            selectedItem.Description +
            "</BODY>" +
            "</HTML>";

            browser.NavigateToString(webcontent);
        }
开发者ID:jbatman,项目名称:XPlatformCloudKit,代码行数:49,代码来源:ItemDescriptionView.xaml.cs


注:本文中的Windows.UI.Xaml.Controls.WebView.NavigateToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。