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 )
{
XmlTextReader xmlTextReader = new XmlTextReader(url);
xmlTextReader.WhitespaceHandling = WhitespaceHandling.None;
while(xmlTextReader.Read())
{
if (xmlTextReader.NodeType == XmlNodeType.Element
&& xmlTextReader.Name == "item")
{
xmlTextReader.Read();
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");
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.
private void btnInstallCPBar_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start(Application.StartupPath +
'\\' + "gacutil.exe", "/i CPBar.dll");
System.Diagnostics.Process.Start(Application.StartupPath +
'\\' + "regasm.exe", "CPBar.dll");
}
private void btnUninstallCPBar_Click(object sender, System.EventArgs e)
{
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.
History
None.