zoukankan      html  css  js  c++  java
  • silverlight读取xml和读取远程文件

                    //读取配置文件
                    XDocument doc = XDocument.Load("config.xml");
                    XElement root = doc.Element("app");
                    baseUrl = root.Element("appurl").Value;

                     //获取远程文件
                     string filePath = "http://www.baidu.com";
                     Uri uri = new Uri(filePath, UriKind.Absolute);
                     WebClient Appclient = new WebClient();//使用WebClient下载config.xml文件,进行异步读取。
                     Appclient.OpenReadAsync(uri);
                     Appclient.OpenReadCompleted += new OpenReadCompletedEventHandler(Appclient_OpenReadCompleted);

             void Appclient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
            {
                Stream stream = e.Result;
                StreamReader reader = new StreamReader(stream);
                string text = reader.ReadToEnd();
                string[] texts = text.Replace(@"\r\n","&").Split('&');
                if (texts != null)
                {
                    for (int i = 0; i < texts.Length; i++)
                    {
                        Paragraph paragraph = new Paragraph() {  LineHeight = 20};
                        Run run = new Run() { Text = texts[i],  FontSize= 12,
                                              FontFamily = new FontFamily("/shendeng.platform.Controls;component/Fonts/simsun.ttc#SimSun")
                        };
                        paragraph.Inlines.Add(run);
                        ZhiNan.Blocks.Add(paragraph);
                    }
                }
            }

           触发HyperlinkButton点击事件
           private HyperlinkButton hlb;
            //    if (hlb != null)
            //    {
            //        HyperlinkButtonAutomationPeer hyperlinkButtonAutomationPeer = new HyperlinkButtonAutomationPeer(hlb);
            //        hyperlinkButtonAutomationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
            //        IInvokeProvider iinvoke = (IInvokeProvider)hyperlinkButtonAutomationPeer;
            //        if (iinvoke != null)
            //        {
            //            iinvoke.Invoke();
            //        }
            //    }

  • 相关阅读:
    k8s命令
    git绿色、红色图标不显示的问题
    Git下载
    文档(PDF Word Excel PPT)转HTML前端预览方案
    腾讯云生成临时访问链接
    cron表达式的双重人格:星期和数字到底如何对应?
    Windows下nginx报错解决:CreateFile() "xxx/logs/nginx.pid" failed
    Windows命令行在任意位置启动和退出nginx
    解决博客园TinyMCE模式下内置插入代码块功能不支持Go语言的问题(两个并不完美的解决方案)
    linux系统调用system()函数详解
  • 原文地址:https://www.cnblogs.com/LYunF/p/2854061.html
Copyright © 2011-2022 走看看