Delen via


Witty weaving

Witty is a Twitter client that is a neat little WPF application. Having removed Snitter from my application list, there was one little piece missing. A "Clear" button.

This is where I wanted to be:

witty

Functionally, it clears the list of tweets and leaves you with a nice blank sheet.

Time to download the source code and see what I could do about the missing Clear button.

  1. The Witty source code is on Google code, available via SVN. Download and install TortoiseSVN for x64

  2. SVN installed. Copy in URL to TortoiseSVN and grab all the code and stuff

  3. Oh, I need something to look at the code. Time to install Visual Studio C# 2008 Express. This is a free-of-charge version of Visual Studio. Whilst Witty is created in the full version of Visual Studio, the Express version will do me fine.

  4. Click on the Witty.sln (the project file that remembers all the includes and stuff) and VS launches.

  5. Now, does the Witty source code compile and run? Press F5 (compile, debug and run) and watch. WooHoo. Witty compiles and runs!

  6. OK, UI and code tweaking time.

  7. Click on the MainWindow.xaml for the application. The .xaml is the user interface description part of WPF. As it is XML, you can copy and paste text around to either break things to make good things happen. In this instance, I copy and paste the "Options" definition and make a new button

     <Button Content="Options" Height="20" x:Name="OptionsButton" Click="OptionsButton_Click" MinWidth="25" MinHeight="20" FontSize="9" DockPanel.Dock="Right" Margin="0,0,10,0" IsEnabled="False" Width="50" />
    <Button Content="Clear" Height="20" x:Name="ClearButton" Click="ClearButton_Click" MinWidth="25" MinHeight="20" FontSize="9" DockPanel.Dock="Right" Margin="0,0,10,0" IsEnabled="True" Width="50" />
    
  8. Wire the clear button to an unwritten piece of code. As you can see in the above piece of xaml, once clicked, "ClearButton_click" is fired.

  9. The list of Recent tweets is kept in a collection named tweets. All I need to do is empty it. I think the way that Witty works is that the userinterface for the list is bound to the tweets collection. Experiment time.

  10. Go into the MainWindows.xaml and put into function that clears the collection of tweets:

     private void ClearButton_Click(object sender, RoutedEventArgs e)
    {
                clearTweets();
     }
    
     private void clearTweets()
    {
                this.tweets.Clear();
    }
    
  11. F5, log in, click button. The list clears. It works!

There are more steps to make really make this work in Witty. Inside Witty there is this "updated since" that I have yet to understand.

Why am I sharing with you?

The joy of just noodling around with things. It is a way of learning new things. Basketweaving for the Mind.

Comments