Beispiel #1
0
        private void getTweet()
        {
            XmlDocument rssDoc;
            XmlNode     nodeChannel = new XmlDocument();
            XmlNode     nodeItem;

            int no = 0;

            try{
                XmlTextReader reader = new XmlTextReader(MainClass.Settings.TweetUrl);
                rssDoc = new XmlDocument();
                rssDoc.Load(reader);
                for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
                {
                    if (rssDoc.ChildNodes[i].Name == "statuses")
                    {
                        nodeChannel = rssDoc.ChildNodes[i];
                    }
                }
                for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
                {
                    if (nodeChannel.ChildNodes[i].Name == "status")
                    {
                        nodeItem = nodeChannel.ChildNodes[i];
                        string label = nodeItem["text"].InnerText;
                        label = label.Replace("&", "");
                        string url = MainClass.Settings.TweetBaseUrl + nodeItem["id"].InnerText;

                        listTwet.Add(new WebObject(label, url, "", label));

                        no++;
                    }
                    if (no >= MainClass.Settings.MaxRssTweetMessageCount)
                    {
                        break;
                    }
                }
            } catch {
            }

            Gtk.Application.Invoke(delegate
            {
                if (listTwet.Count > 1)
                {
                    webCacheFile.ListTweet = listTwet;
                }
                else
                {
                    if ((webCacheFile.ListTweet == null) && (webCacheFile.ListTweet.Count < 1))
                    {
                        btnTwitLoad.Label = MainClass.Languages.Translate("error_loat_tweet");
                        webCacheFile.SaveWebCache();
                        return;
                    }
                }

                //tblRss.NRows =(uint)webCacheFile.ListTweet.Count+1;
                btnTwitLoad.Destroy();

                for (int i = 0; i < webCacheFile.ListTweet.Count; i++)
                {
                    WebButton lb = new WebButton();
                    //lb.Label =webCacheFile.ListTweet[i].Title;
                    lb.LinkUrl      = webCacheFile.ListTweet[i].Url;
                    lb.HoverMessage = webCacheFile.ListTweet[i].Title;
                    ////lb.Description =webCacheFile.ListTweet[i].HoverMessage;
                    string label = webCacheFile.ListTweet[i].Title;

                    /*if (label.Length >115) {
                     *      label = label.Substring(0,55)+"...";
                     * }*/
                    lb.UseSmall = true;
                    lb.Label    = label;
                    //Pixbuf pbx =
                    Gtk.Image img = new Gtk.Image(MainClass.Tools.GetIconFromStock("twitter12.png", IconSize.Menu));

                    tblTwitt.Attach(img, (uint)0, (uint)1, (uint)(i + 1), (uint)(i + 2), AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
                    tblTwitt.Attach(lb, (uint)1, (uint)2, (uint)(i + 1), (uint)(i + 2), AttachOptions.Fill, AttachOptions.Shrink, 0, 0);
                }
                tblTwitt.ShowAll();
                webCacheFile.SaveWebCache();
            });
        }