Beispiel #1
0
        /// <summary>
        /// Loads use profiles from the XML backup.
        /// </summary>
        /// <returns></returns>
        private static List<Profile> DemoProfile()
        {
            List<Profile> output = new List<Profile>();

            Profile demoProfile = new Profile(Guid.Empty);
            demoProfile.Name = "Demo";
            demoProfile.Description = "Select this profile to get a glimpse at what GetFacts can do...";
            output.Add(demoProfile);

            Site ignRss = new Site(new Guid("a6268b26-13c3-8d53-1e34-8f862f168475"));
            ignRss.Name = "IGN Video reviews";
            ignRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher";
            ignRss.Uri = new Uri("http://feeds.ign.com/ign/video-reviews");
            demoProfile.Add(ignRss);

            Site devBestOfRss = new Site(new Guid("b99b539a-67e0-4079-8a76-0468f302ff2c"));
            devBestOfRss.Name = "Developpez.net - Débats sur le développement, le best of";
            devBestOfRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher";
            devBestOfRss.Uri = new Uri("http://www.developpez.net/forums/external.php?type=RSS2&forumids=40");
            demoProfile.Add(devBestOfRss);

            Site devEmploiRss = new Site(new Guid("efbb9d1e-e644-4530-9b3d-95c8fb381339"));
            devEmploiRss.Name = "Developpez.net - Emploi";
            devEmploiRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher";
            devEmploiRss.Uri = new Uri("http://www.developpez.net/forums/external.php?type=RSS2&forumids=258");
            demoProfile.Add(devEmploiRss);

            Site slateFrRss = new Site(new Guid("af3b0618-f4de-4772-b0d2-a6de8b5edd27"));
            slateFrRss.Name = "Slate.fr";
            slateFrRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher";
            slateFrRss.Uri = new Uri("http://www.slate.fr/rss.xml");
            demoProfile.Add(slateFrRss);

            Site rue89Rss = new Site(new Guid("cd614176-e942-4da2-ab21-d6e1d367ee82"));
            rue89Rss.Name = "Rue89";
            rue89Rss.FetcherPlugin = "GetFacts.Plugins.RssFetcher";
            rue89Rss.Uri = new Uri("http://www.rue89.com/feed");
            demoProfile.Add(rue89Rss);

            Site clubicRss = new Site(new Guid("89ba3fca-09b4-4c84-9bed-1b8d12034fe3"));
            clubicRss.Name = "clubic.com";
            clubicRss.FetcherPlugin = "GetFacts.Plugins.RssFetcher";
            clubicRss.Uri = new Uri("http://www.clubic.com/articles.rss");
            demoProfile.Add(clubicRss);

            return output;
        }
Beispiel #2
0
        private static List<Profile> Load(string srcFile)
        {
            Hashtable profiles = new Hashtable();

            // read xml
            using (FileStream fs = File.Open(srcFile, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader sr = new StreamReader(fs, Encoding.Unicode))
                {
                    using (XmlReader input = XmlReader.Create(sr))
                    {
                        while (input.Read())
                        {
                            if (input.NodeType == XmlNodeType.Element)
                            {
                                if (input.Name == "profile")
                                {
                                    using (XmlReader subTree = input.ReadSubtree())
                                    {
                                        Profile p = new Profile(subTree);
                                        profiles[p.Guid] = p;
                                    }
                                }
                                if (input.Name == "site")
                                {
                                    string guid = input.GetAttribute("profile");
                                    Guid profileId = new Guid(guid);

                                    using (XmlReader subTree = input.ReadSubtree())
                                    {
                                        Site s = new Site(subTree);
                                        Profile p = (Profile)profiles[profileId];
                                        p.Add(s);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            List<Profile> output = new List<Profile>();
            foreach (Profile p in profiles.Values)
            {
                output.Add(p);
            }
            return output;
        }
Beispiel #3
0
 internal ProfileNameNode(BetterListBox l, Profile p)
     : base(p.Name)
 {
     this._profileListBox = l;
     this.profile = p;
 }
Beispiel #4
0
 private void addProfileButton_Click(object sender, EventArgs e)
 {
     Profile p = new Profile();
     Add(p);
 }
Beispiel #5
0
 private void SiteToXml(Profile p, Site s, XmlTextWriter w)
 {
     w.WriteStartElement("site");
     w.WriteAttributeString("profile", p.Guid.ToString());
     w.WriteElementString("guid", s.Guid.ToString());
     w.WriteElementString("name", s.Name);
     w.WriteElementString("url", s.Uri.ToString());
     w.WriteElementString("plugin", s.FetcherPlugin);
     w.WriteElementString("layout", s.LayoutPlugin);
     w.WriteEndElement();
 }
Beispiel #6
0
 internal ProfileDescriptionNode(Profile p)
     : base(p.Description)
 {
     this.profile = p;
 }
Beispiel #7
0
 private void Add(Profile p)
 {
     profileListBox.Items.Add(p);
     profileListBox.SelectedItem = p;
 }
Beispiel #8
0
 private void Remove(Profile p)
 {
     profileListBox.Items.Remove(p);
 }
Beispiel #9
0
 private void ProfileToXml(Profile p, XmlTextWriter w)
 {
     w.WriteStartElement("profile");
     w.WriteElementString("guid", p.Guid.ToString());
     w.WriteElementString("name", p.Name);
     w.WriteElementString("description", p.Description);
     w.WriteEndElement();
 }
Beispiel #10
0
        private void Display(Profile p)
        {
            // Clear the tree view
            sitesTreeView.Nodes.Clear();

            if (p != null)
            {
                // Create nodes for the profile configuration
                TreeNode profileNode = CreateProfileNodes(p);

                // Create node for Rss feeds
                TreeNode rssFeedsNode = sitesTreeView.Nodes.Add("GetFacts.Plugins.RssFetcher", GFResources.GetString("RSS_FEEDS"));

                // Create nodes for the sites that use the RssFetcher plugin
                foreach (Site s in p.Sites)
                {
                    CreateSiteNodes(s);
                }

                profileNode.Expand();
                rssFeedsNode.Expand();

                sitesSplitContainer.Visible = true;
            }

            else
            {
                sitesSplitContainer.Visible = false;
            }
        }
Beispiel #11
0
        private ProfileNameNode CreateProfileNodes(Profile p)
        {
            ProfileNameNode profileNameNode = new ProfileNameNode(profileListBox,p);
            sitesTreeView.Nodes.Add(profileNameNode);

            ProfileDescriptionNode profileDescriptionNode = new ProfileDescriptionNode(p);
            profileNameNode.Nodes.Add(profileDescriptionNode);

            return profileNameNode;
        }