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();
            //        }
            //    }

  • 相关阅读:
    BZOJ3997:[TJOI2015]组合数学(DP,Dilworth定理)
    BZOJ4807:車(组合数学,高精度)
    BZOJ4008:[HNOI2015]亚瑟王(DP,概率期望)
    BZOJ1499:[NOI2005]瑰丽华尔兹(DP,单调队列)
    洛谷1514 引水入城
    洛谷 1018 乘积最大
    八数码难题
    CODEVS 1069关押罪犯
    CODEVS 1067 机器翻译
    洛谷 P1417 烹调方案
  • 原文地址:https://www.cnblogs.com/LYunF/p/2854061.html
Copyright © 2011-2022 走看看