Craig's profileCraig Eddy's SpacePhotosBlogListsMore Tools Help

Craig Eddy

Location
Interests

My Mood Clock

Loading...
by 
by 
by 
by 
by 
by 
by 
by 

Subscribe

Craig Eddy's Space

Friends don't let friends die broke
February 24

WPF Viewer for the Windows Azure Thumbnails Sample

Not content with simply using the web role to view thumbnails generated by the Windows Azure “thumbnails” sample, I decided to write a WPF client.

Once I got my head re-wrapped around data binding with the WPF ListView (it’s amazing how quickly we forget such things when we get old), it was a piece of cake. As usual, WPF does most of the work for you.

The only drastic change I had to make was in the creation of the StorageAccountInfo instances. The storage client library uses <appSettings>-based settings, but WPF only seems to work with settings in the Project properties. So instead of using the helper methods in the storage client library (StorageAccountInfo.GetDefaultBlobStorageAccountFromConfiguration and StorageAccountInfo.GetDefaultQueueStorageAccountFromConfiguration), I just manually created instances of StorageAccountInfo:

new StorageAccountInfo(
    new Uri(Settings.Default.BlobStorageEndpoint), 
    true, Settings.Default.AccountName, 
    Settings.Default.AccountSharedKey, 
    false)


The other change was to the LINQ query used to retrieve the URL of the thumbnail image and assign it to the ListView’s ItemsSource property:

thumbnails.ItemsSource = from o in 
   GetPhotoGalleryContainer().ListBlobs("thumbnails/", 
   false) 
select o;


The code for the GetPhotoGallerContainer() method (and the methods that it calls) were copied directly from the web role project’s default.aspx.cs file. I removed the static qualifier from the copied code, as it seemed unnecessary in a WPF application.

The source code can be found at here.

February 15

Using Linq XML with the WeatherBug API

If you have access to the WeatherBug API, you can easily use LINQ queries to get to the data. I had originally thought I’d create the necessary classes and use XML serialization to load data, but this seemed like a lot of work.

Here’s some code that will load a ListView with a list of weather stations for a given latitude and longitude:

string url = string.Format( 
"http://api.wxbug.net/getStationsXML.aspx?ACode={0}&lat={1}&long={2}", myApiCode, latitude, longitude ); XDocument doc = XDocument.Load( url ); var stations = from station in doc.Root.Elements().Last().Elements() select station; foreach (var station in stations) { listView1.Items.Add(new ListViewItem( new string[] { station.Attribute("name").Value, station.Attribute("id").Value, station.Attribute("city").Value, station.Attribute("country").Value, station.Attribute("citycode").Value, station.Attribute("latitude").Value, station.Attribute("longitude").Value })); }
December 14

Which Will You Use Today?

I'm finishing up Rich DeVos' Ten Powerful Phrases for Positive People. Which of these will you use today?

  1. I'm wrong
  2. I'm sorry
  3. You can do it
  4. I believe in you
  5. I'm proud of you
  6. Thank you
  7. I need you
  8. I trust you
  9. I respect you
  10. I love you

On a side note, I was amazed to read a multi-billionaire make the following statement:

"I was a happy child despite few material possessions. I continue to be a happy person today. But my wealth has not made me any happier than when I was a kid growing up during the Depression."

Maybe, just maybe, it's that attitude & mindset that helped Rich DeVos achieve what he's achieved…

October 27

C# int.MaxValue Oddity

Be careful passing int.MaxValue to a method that may use the parameter value in a conditional expression.

The following code snippet will print False when clearly 0 (zero) should be less than int.MaxValue * 2:

Console.WriteLine("{0}", yep(int.MaxValue ));

private bool yep( int val )
{
    return ( 0 < val * 2);
}
July 03

FriendFeed Plugin For RSS Bandit

I've developed an RSS Bandit plug-in that allows you to share posts on FriendFeed.

To use the plugin, download the zip file and unzip it into your RSS Bandit plugins folder and start up RSS Bandit.

There is a configuration dialog to enter your FF nickname and remote key (which you can find here).

To share a post, just right-click and select "Share on FriendFeed". No news is good news in this case.

 

I'm looking into how to integrate more deeply with RSS Bandit and any suggestions would be appreciated!

 
Photo 1 of 12

Xbox Live GamerCard

Kregger
Xbox Live GamerCard
Reputation:
5/5 stars
Score:
1465
Zone:
Pro
Castle CrashersHexic HDCall of Duty 4The Orange BoxThe Force Unleashed

Reading...

my 'currently-reading' shelf:
 my currently-reading shelf