WPF and "Twistori": Part 1

I don’t really use Twitter but I’m surrounded by folks that do and I’m more and more aware of its impact as if you turn up to any kind of event or gathering these days then you’ll know that someone will come along and say whether it’s being reported well/badly in the various tweets that it’s generating.

Because of this, I wasn’t aware of “Twistori” but Marc pointed it out to me the other week and said that it’d be cool if we had an internal application that did something similar that we could maybe use to display on a plasma TV somewhere or perhaps on a projector.

So, I set about building something simple with WPF that uses the Twitter (RESTful) API ( I stress that word “simple” as I didn’t really want to go off into days and days of effort 🙂 and so I thought I’d share that here.

Ultimately, the application ended up looking like this;

image

and it has an application configuration file that looks like this;

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="searchTermsConfiguration"
             type="SearchTermsConfig.SearchTermsConfiguration,TwitterAtomFeedLibrary"/>
  </configSections>
  
  <!-- Set language to "en", "fr", etc. -->
  
  <searchTermsConfiguration language="en">
    <searchTerms>
      <!-- isIncluded is a bool (true/false) which can be changed in the UI anyway -->      
      <!-- filter is an enum which can be;
            Positive
            Negative
            PositiveAndNegative (not the same as "All" below)
            All
      -->
      <searchTerm term="Microsoft"
                  isIncluded="true"
                  filter="All"/>

      <searchTerm term="Windows"
                  isIncluded="true"
                  filter="All"/>

    </searchTerms>
  </searchTermsConfiguration>
</configuration>

which drives what it does which is, essentially;

  1. Wake up every N seconds
  2. Visit the next search term in the list up on the left (Microsoft, Windows, etc) that has flagged itself as being active
  3. Check to see if we have some stored ATOM items for that search term. If not, go grab up some of those things from Twitter and move to the next term whilst they download asynchronously
  4. Once we find an ATOM item, display it in the area on the right of the screen and highlight which search term it relates to in the listbox on the left hand side of the screen.

so, it’s pretty simple and the UI largely involves a ListBox, some CheckBoxes, some TextBlocks, an Image and a few layout panels and animations.

Note that the background image is taken from www.hdwallpapers.net so I’m not sure whether I should really be distributing it like this and I’ll take it out if someone asks me to.

Here’s the app for download. All bugs mine (of course) and I know there’s one or two in there. The next post will start to look at putting something very similar to this together.