Click here to Skip to main content
12,298,406 members (44,768 online)
Click here to Skip to main content
Add your own
alternative version

Stats

76.2K views
1.8K downloads
33 bookmarked
Posted

CPBar for latest article briefs (RSS feed)

, 6 Jul 2003
Rate this:
Please Sign up or sign in to vote.
This article is about creating a vertical explorer bar which displays CodeProject's latest article briefs from its RSS feed.

Introduction

I have implement this explorer bar with the help of the BandObject base class as well as this article Extending Explorer with Band Objects using .NET and Windows Forms. This vertical explorer bar actually consumes the RSS feed for CodeProject's latest article briefs at http://www.codeproject.com/webservices/articlerss.aspx, extract the details of each article and then display them in a scrolling fashion.

An overview of CPBar design

The CodeProjectBar object is something like a form which you can just drag and drop controls from the toolbox. As for ScrollScreen, it is a custom control that holds many RichLabel objects and coordinate their scrolling through the use of a timer. The RichLabel object does nothing more than just organizing and formatting the data for display. Besides that, it is also supposed to hide the caret. (See Issues yet to address section) 

Consuming CP's RSS Feed

The diagram above shows part of what is contained in the RSS feed file. Each item tag represent an article brief and between them contains information such as article title, description, author, etc. So to extract them, here is what I have done.

private void DownloadCPRSSFeed(string url /* url of the rss feed */)
{
    XmlTextReader xmlTextReader = new XmlTextReader(url);

    // We don't want to handle whitespaces
    xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;

    // Read through the xml document
    while(xmlTextReader.Read())
    {
        // Check if this is an element of name "item", continue reading
        if (xmlTextReader.NodeType == XmlNodeType.Element 
               && xmlTextReader.Name == "item")
        {
            // Continue read
            xmlTextReader.Read();

            // Get the content for each element. Although I am 
            // not interested in the "category"
            // data, i still need to follow the order so that 
            // I can reach the date section.
            string title = xmlTextReader.ReadElementString("title");
            string desc = xmlTextReader.ReadElementString("description");
            string link = xmlTextReader.ReadElementString("link");
            string author = xmlTextReader.ReadElementString("author");
            string category = xmlTextReader.ReadElementString("category");
            string date = xmlTextReader.ReadElementString("pubDate");

            // Add an item for these data to our scroll screen
            scrollArticlesScreen.AddItem(date, title, link, author, desc);
        }
    }
}

Setting up the CPBar

This is a simple setup program to install the CPBar onto your machine. Below shows the code for the installation and uninstallation part.

// Install
private void btnInstallCPBar_Click(object sender, System.EventArgs e)
{            
    // Run "gacutil.exe /i CPBar.dll" and "regasm CPBar.dll"
    System.Diagnostics.Process.Start(Application.StartupPath + 
         '\\' + "gacutil.exe", "/i CPBar.dll");
    System.Diagnostics.Process.Start(Application.StartupPath + 
         '\\' + "regasm.exe", "CPBar.dll");
}

// Uninstall
private void btnUninstallCPBar_Click(object sender, System.EventArgs e)
{
    // Run "regasm /u CPBar.dll" and "gacutil.exe /u CPBar.dll"
    System.Diagnostics.Process.Start(Application.StartupPath + '\\' 
         + "regasm.exe", "/u CPBar.dll");
    System.Diagnostics.Process.Start(Application.StartupPath + '\\' 
         + "gacutil.exe", "/u CPBar.dll");
}

Issues yet to address

Here are some issues that i have encountered but until now, I still couldn't find solution for them.

  • Hand cursor not shown when it is over link in RichLabel (but the link still works)
  • This is actually not the case when the ScrollScreen is not hosted in CodeProjectBar. i.e. I created another application and drag my ScrollScreen control onto it.

  • Caret is still visible when RichLabel is being clicked
  • I couldn't find any method like HideCaret() or something like that in C#.

History

None.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Weiye Chen
Singapore Singapore
No Biography provided

You may also be interested in...

Comments and Discussions

 
QuestionControlling Sidebar from BHO Pin
Alex Shneyder9-Oct-07 17:22
memberAlex Shneyder9-Oct-07 17:22 
QuestionKeeping track of the main page state, and getting url from the address bar Pin
Alex Shneyder5-Oct-07 10:39
memberAlex Shneyder5-Oct-07 10:39 
Generalhi Pin
hassannasar21-Feb-06 18:11
memberhassannasar21-Feb-06 18:11 
GeneralRe: hi Pin
Weiye Chen21-Feb-06 22:49
memberWeiye Chen21-Feb-06 22:49 
Generaldidn't found any bar Pin
hassannasar17-Feb-06 15:15
memberhassannasar17-Feb-06 15:15 
GeneralRe: didn't found any bar Pin
Weiye Chen19-Feb-06 1:07
memberWeiye Chen19-Feb-06 1:07 
GeneralRe: didn't found any bar Pin
hassannasar19-Feb-06 17:15
memberhassannasar19-Feb-06 17:15 
GeneralNo another browser Pin
Cataldo Esposito19-Jun-05 22:42
memberCataldo Esposito19-Jun-05 22:42 
GeneralRe: No another browser Pin
Weiye Chen3-Jul-05 18:42
memberWeiye Chen3-Jul-05 18:42 
GeneralCould this be like IE's "MyFavorite" Pin
khwu20-Jul-03 1:48
memberkhwu20-Jul-03 1:48 
GeneralRe: Could this be like IE's "MyFavorite" Pin
Weiye Chen20-Jul-03 3:05
memberWeiye Chen20-Jul-03 3:05 
GeneralRe: Could this be like IE's "MyFavorite" Pin
khwu20-Jul-03 3:40
memberkhwu20-Jul-03 3:40 
QuestionWhat excellent??? Pin
Manuel Salvatore7-Jul-03 21:31
memberManuel Salvatore7-Jul-03 21:31 
AnswerRe: What excellent??? Pin
Jerry Maguire8-Jul-03 22:24
memberJerry Maguire8-Jul-03 22:24 
GeneralRe: What excellent??? Pin
Weiye Chen9-Jul-03 2:10
memberWeiye Chen9-Jul-03 2:10 
GeneralExcellent! Pin
Kant7-Jul-03 17:10
memberKant7-Jul-03 17:10 
GeneralRe: Excellent! Pin
Weiye Chen7-Jul-03 17:44
memberWeiye Chen7-Jul-03 17:44 
GeneralVery nice, just one problem so far... Pin
leppie7-Jul-03 16:45
memberleppie7-Jul-03 16:45 
GeneralRe: Very nice, just one problem so far... Pin
Weiye Chen7-Jul-03 17:38
memberWeiye Chen7-Jul-03 17:38 
GeneralRe: Very nice, just one problem so far... Pin
leppie7-Jul-03 17:51
memberleppie7-Jul-03 17:51 
GeneralRe: Very nice, just one problem so far... Pin
leppie7-Jul-03 17:53
memberleppie7-Jul-03 17:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160525.2 | Last Updated 7 Jul 2003
Article Copyright 2003 by Weiye Chen
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid