Tuesday, November 25, 2008
I try to use keyboard shortcuts as much as possible. Here are some that are handy when unit testing with Visual Studio:
Ctrl + R, A – Run all tests
Ctrl + R, T – Run tests in context (based on if cursor is in function, class, or namespace)
Ctrl + R, F – Runs all tests that are checked in Test Results – very handy because that window is impossible to navigate without a mouse
Ctrl + R, Ctrl + A – Run all tests in debug mode
Ctrl + R, Ctrl + T – Run all tests in context in debug mode
Ctrl + R, Ctrl + F – Run all checked tests in debug mode
Friday, November 21, 2008
The newest version of Google Sync adds a great new feature of syncing contacts. Now your Gmail contacts will stay up to date with your Blackberry contacts and vice versa.
Very nice!
Download page here.
Wednesday, November 19, 2008
TeamBuild is such a powerful tool. We use it to run our unit tests and publish our apps using ClickOnce. Recently we started using it to publish a web service. This code depends on MSBuildTasks from Tigris.
<PropertyGroup>
<DeploymentFolder>**SHARED FOLDER ON WEB SERVER**</DeploymentFolder>
<DeployServerName>**WEB SERVER NAME**</DeployServerName>
<ApplicationPoolName>ReportingWS</ApplicationPoolName>
<VirtualDirectory>ReportingWS</VirtualDirectory>
<WebBinariesLocation>$(BuildDirectoryPath)\Binaries\Release\_PublishedWebSites\ReportingWS</WebBinariesLocation>
</PropertyGroup>
<Target Name="AfterCompile">
<RemoveDir Directories="$(DeploymentFolder)" ContinueOnError="true" />
<Exec Command="xcopy /y /e /i $(WebBinariesLocation) $(DeploymentFolder)"/>
<WebDirectoryDelete VirtualDirectoryName="$(VirtualDirectory)"
ContinueOnError="true"
ServerName="$(DeployServerName)"/>
<WebDirectoryCreate VirtualDirectoryName="$(VirtualDirectory)"
VirtualDirectoryPhysicalPath="$(DeploymentFolder)"
ServerName="$(DeployServerName)"/>
</Target>
Essentially, we just copy the executable files from the Web Service to a shared folder on our web server and map a virtual directory to that shared folder.
Tuesday, November 18, 2008
This code snippet extends the functionality found in prop code snippet. It will populate the backing field in the property, check for equality in the setter and call PropertyChanged. It assumes you have a base class that handles the implementation of INotifyPropertyChanged.
When the snippet is called, it will generate code that looks like this:
private int myVar;
public int MyProperty
{
get { return myVar; }
set
{
if (!myVar.Equals(value))
{
myVar = value;
base.OnPropertyChanged("MyProperty");
}
}
}
To use this snippet, create a new text file at:
C:\users\<your user name>\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets
Call it “propINP.snippet”
Populate the contents of the file with this:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>propINP</Title>
<Author>Microsoft Corporation</Author>
<Description>Code snippet for property and backing field and INotifyPropertyChanged</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>propINP</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>type</ID>
<ToolTip>Property type</ToolTip>
<Default>int</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>property</ID>
<ToolTip>Property name</ToolTip>
<Default>MyProperty</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>field</ID>
<ToolTip>The variable backing this property</ToolTip>
<Default>myVar</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[private $type$ $field$;
public $type$ $property$
{
get { return $field$;}
set
{
if(!$field$.Equals(value))
{
$field$ = value;
base.OnPropertyChanged("$property$");
}
}
}
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Monday, November 17, 2008
On another personal note, Chels and I are expecting our first child (a strapping young man) on 12-26. My good buddy Matt, who stood at our wedding, and his wife are also expecting a few days before us. I wonder if our kids will ever figure out they were championship babies.

For a while now, one of my goals has been to run a 5K (3.1 miles) in under 20 minutes. This morning I finally broke that number.
Technorati Tags:
Running,
Nike+,
5K
Friday, November 14, 2008
According to my Blogflux search engine results for the last month, Google has not just cornered the market, they have virtually snuffed out the competition.
| Engine | Hits | Percentage |
| Google | 17596 | 98 |
| Yahoo | 202 | 1 |
| Ask Jeeves | 36 | 0 |
| AOL | 35 | 0 |
| MSN | 18 | 0 |
| Search.com | 6 | 0 |
I prefer to use web-based solutions when possible, but the other day the publish feature of google docs wasn’t working right, so I needed to install Windows Live Writer. I quickly found out that WLW doesn’t play nicely with Windows Server 2008.
Since WLW is written in .NET, I just installed it on an XP virtual machine and copied the Program Files folder over to my Server 2008 machine. Simple.
Wednesday, November 12, 2008
I went to the KU game last night with Kyle. We won very easily. On an odd note, the singer of the National Anthem was the daughter of the Emporia State coach, and was wearing a KU shirt.

Tuesday, November 11, 2008
Using colors is a simple way make your application less boring. You can change the color of the selected and unselected item in a ListBox by using code like this:
<Style TargetType="ListBoxItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightGreen"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightBlue"/>
</Style.Resources>
</Style>
This style can be put in the resources of the ListBox to just affect that ListBox, or it can be put in resources of the Window and it will apply these styles to all ListBoxes in the window. You can also use the Application.Resources of App.xaml and all ListBoxes in your application will have the same look and feel.
Monday, November 10, 2008
BrightKite is a location aware social network. It allows you to post notes and pictures at a specific place. It also will write to your
Twitter stream so your friends can keep up with your latest activity.
They also have an
API, which I had the chance to play with the other night. Here is some very simple code that will write out a list of all your friends:
public static void ListFriends(string username, string password)
{
string url = "http://brightkite.com/me/friends.xml";
WebRequest WRequest = WebRequest.Create(url) as HttpWebRequest;
WRequest.Timeout = 10000;
WRequest.Headers.Add("Authorization",
"Basic " + Convert.ToBase64String(
Encoding.ASCII.GetBytes(username + ":" + password)));
using (HttpWebResponse response = WRequest.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
XElement element = XElement.Load(reader);
foreach (XElement node in element.Elements("person"))
{
string place = node.Element("place").Element("name").Value;
string person = node.Element("fullname").Value;
Console.WriteLine("{0} checked in at {1}",person,place);
}
}
}
Friday, November 07, 2008
Like most developers, I run SQL on my main work computer. I find that the RAM usage gets quite bloated at times, so I have a handy bat file that I run to restart the SQL service, giving me my RAM back. Here are the simple steps to achieving this:
1) Right click on your desktop and create a new text document.
2) Rename file to restartSQL.bat
3) Click yes on confirmation to change a file name extension. If you did not get this error, you will need uncheck "Hide extensions for known file types" on the View tab of Folder Options.
4) Right click restartSQL.bat and select "Edit"
5) In the document that opens up, type
net stop mssqlserver
net start mssqlserver
*note if you have a named instance of SQL, change "mssqlserver" to what your instance is named
6) Close document and save changes when prompted
Now when your RAM is getting a bit high, just double click the file and it will give you your RAM back from SQL (for a little bit anyways).
P.S. I know I've been a really bad blogger and
Jeff yelled at me the other day about it. It's annoying when people give a million excuses for not blogging for the last couple of months, so I won't do that :)
Thursday, June 26, 2008
Currently DateTime.ToShortDateString will not include any "0" prefixes. I think this makes any vertical lists of dates look funky:
Here is a very simple
extension method that will append any needed leading "0" to the date:
namespace ParaPlan.Extensions
{
public static class DateHelper
{
public static string ToShortDateEqualLengthString(this DateTime dt)
{
var rv = new StringBuilder();
if (dt.Month.ToString().Length ==1)
{
rv.Append("0");
}
rv.Append(dt.Month.ToString());
rv.Append("/");
if (dt.Day.ToString().Length == 1)
{
rv.Append("0");
}
rv.Append(dt.Day.ToString());
rv.Append("/");
rv.Append(dt.Year.ToString());
return rv.ToString();
}
}
}
Changing our dates to call .ToShortDateEqualLengthString will make our listbox look much more pretty:
Friday, May 23, 2008
Al Pascual has been working on
GeoTwitter, a website (
open source on CodePlex) that add geographical context to your tweets. That is pretty cool and he is looking at ways to automate it (IP, cell GPS), but what I think is really cool is that he provides a GeoRSS feed of your tweets (with others).
Check out the site here. He posts about the project, submitting it to open source and future ideas
on his blog.
Tuesday, May 20, 2008
Using the CollectionViewSource is a good way of binding to a datasource and letting the XAML determine the sorting and grouping of the data. However, as your datasource changes, the grouping and sorting is not automatically "re-calculated", forcing your code to be smarter that it should be. I found a
class today on MSDN forums that inherits from CollectionViewSource and adds automatic refresh capabilities. This code is smart enough to resort your items, regroup your items and even add new groupings as needed.
Some good CollectionViewSource links:
Tuesday, May 13, 2008
I don't think the WPF ToogleButton has a distinct visual difference between it's checked and unchecked state. So I wanted to change the text displayed when the button was checked. So I created a trigger that looked at the IsChecked property and changed the content property accordingly. However, the default template of a ToggleButton changes it's appearance when it is checked, so certain properties are not written as expected. To fix this, I set the content property in the styles of the toggle button and it worked. Here is the code:
<ToggleButton Name="showStopsCheckBox">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Content" Value="Stops"/>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content" Value="Trips"/>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
Here is how to post to
GeeksWithBlogs from
Google Docs.
- Click New -> Document
- Select "Publish as web page" from the Share menu
- Click setup your blog
- Select "My own server/custom"
- Select "MetaWeblog API" from the drop down list
- Enter (no www) http://geekswithblogs.net//services/metablogapi.aspx
- Populate your user name, password and blog title
- Click Test
Testing publishing a post to
GeeksWithBlogs from
Google Docs.
Saturday, May 10, 2008
I just finished my presentation about consuming Google Maps at
BarCampKC. Thanks to everybody who attended.
We talked about the three different ways of using Google Maps in your applications or websites.
- Static Map Image API
- My Maps
- JavaScript API
The slideshow is available
via Google Docs or
dowload the PPT
The code is available
for download here, make sure you
change your api key.
Thursday, May 08, 2008
Chelsea and I went to the movies last night and saw Todd Reesing (the KU quarterback) and Derek Fine (former KU tight end) standing in line at the ticket counter. Turns out they went to the same movie as us too (Baby Mama - which was pretty funny).