コード例 #1
0
ファイル: HtmlView.cs プロジェクト: SaintLoong/PD
 /// <summary>
 /// 创建Html视图
 /// </summary>
 /// <param name="url">绝对URL</param>
 /// <returns></returns>
 public static UIElement CreateHtmlView(string url)
 {
     UIElement view = null;
     //var errorPage = HostAddress.Host() + "NavigateError.htm";
     if (Application.Current.IsRunningOutOfBrowser)
     {
         view = new WebBrowser() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch };
         try
         {
             /*下面这样写的原因是因为WebBrowser中URI不支持中文参数 ,所以先将URL编码*/
             var taskUrl = new Uri(url, UriKind.Absolute);
             (view as WebBrowser).Navigate(new Uri(taskUrl.AbsoluteUri, UriKind.Absolute));
         }
         catch
         {
             view = new TextBlock { Text = "对不起,系统无法找到您需要导航的页面", Foreground = new SolidColorBrush() { Color = Colors.Red } };
         }
     }
     else
     {
         view = new XamHtmlViewer() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch };
         try
         {
             (view as XamHtmlViewer).SourceUri = new Uri(url, UriKind.Absolute);
         }
         catch
         {
             view = new TextBlock { Text = "对不起,系统无法找到您需要导航的页面", Foreground = new SolidColorBrush() { Color = Colors.Black }, FontSize = 13 };
         }
     }
     return view;
 }
コード例 #2
0
ファイル: HtmlView.cs プロジェクト: SaintLoong/PD
 public static UIElement CreateHtmlView()
 {
     UIElement view = null;
     if (Application.Current.IsRunningOutOfBrowser)
     {
         view = new WebBrowser() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch };
     }
     else
     {
         view = new XamHtmlViewer() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch };
     }
     return view;
 }
コード例 #3
0
ファイル: HtmlView.cs プロジェクト: lichao7314/PD
        /// <summary>
        /// 创建Html视图
        /// </summary>
        /// <param name="url">绝对URL</param>
        /// <returns></returns>
        public static UIElement CreateHtmlView(string url)
        {
            UIElement view = null;

            //var errorPage = HostAddress.Host() + "NavigateError.htm";
            if (Application.Current.IsRunningOutOfBrowser)
            {
                view = new WebBrowser()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch
                };
                try
                {
                    /*下面这样写的原因是因为WebBrowser中URI不支持中文参数 ,所以先将URL编码*/
                    var taskUrl = new Uri(url, UriKind.Absolute);
                    (view as WebBrowser).Navigate(new Uri(taskUrl.AbsoluteUri, UriKind.Absolute));
                }
                catch
                {
                    view = new TextBlock {
                        Text = "对不起,系统无法找到您需要导航的页面", Foreground = new SolidColorBrush()
                        {
                            Color = Colors.Red
                        }
                    };
                }
            }
            else
            {
                view = new XamHtmlViewer()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch
                };
                try
                {
                    (view as XamHtmlViewer).SourceUri = new Uri(url, UriKind.Absolute);
                }
                catch
                {
                    view = new TextBlock {
                        Text = "对不起,系统无法找到您需要导航的页面", Foreground = new SolidColorBrush()
                        {
                            Color = Colors.Black
                        }, FontSize = 13
                    };
                }
            }
            return(view);
        }
コード例 #4
0
ファイル: HtmlView.cs プロジェクト: lichao7314/PD
        public static UIElement CreateHtmlView()
        {
            UIElement view = null;

            if (Application.Current.IsRunningOutOfBrowser)
            {
                view = new WebBrowser()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch
                };
            }
            else
            {
                view = new XamHtmlViewer()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch
                };
            }
            return(view);
        }