# Chris Pietschmann

## Search Keyword Highlighter BlogEngine.NET v1.3 Extension

In my previous blog, I used the se_hilite.js file from Scott Yang to hightlight the search keywords people used to search for my site when they are referred to my site via the search engines. This is functionality that I want to maintain, and I couldn't find an existing extension. So, I decided to write one. This is a really simple extension, and a neat feature to have. Here it is... [More]

## Calculate Distance Between Geocodes in C# and JavaScript

There are times when I need code to calculate the distance between two geocodes (Lat/Long points). I don't need it very often and until now I didn't have a code snippet that I could jus copy and paste. I was searching and found Rob Conery's LINQ and Geocoding post. It's an interesting post and he includes a sample of how to use Lambda expressions in C# 3.0 to calculate the distance between two geocodes in Miles. I decided to copy his code snippet and make sure it works in .NET 2.0 and also conv... [More]

## 2008 Microsoft Launch Event and Free Software

On February 27th in Los Angeles, CA, Microsoft is kicking off a series of "HEROES happen {here}" launch events nationwide. These are the official launch events for Windows Server 2008, Visual Studio 2008, and SQL Server 2008. And, one of the best parts is everyone that takes part in one of the events will be taking home a promotional kit with versions of all three products. Since the Milwaukee event isn't until May 8th, I've registered for the Chicago event on March 11th. I don't want to w... [More]

## .NET: How to Alias Namespaces and Data Types

One of the little known features of .NET is that you can give complete namespaces and data types alias's that you can reference them with in code. Aliasing Data Types For this example we'll give a different name to the integer data type: In VB.NET: Imports MyInteger = System.Int32; In C#: using MyInteger = System.Int32; Now to use the alias in code: In VB.NET: Public myVariable As MyInteger = 4; In C#: MyInteger myVariable = 4; Aliasing Namespaces For this example, lets assume ... [More]

## Microsoft to release .NET Framework 3.5 as Shared Source!

Scott Guthrie announced on his blog today, that Microsoft will be releasing the source code for .NET 3.5 as shared source under the Microsoft Reference License (MS-RL). You will also be able to enable debugging support within Visual Studio 2008 for the .NET Framework. This is really cool. I have always used .NET Reflector to peek into the source of the framework, but now I'll actually be able to look at the code itself. More Info:Releasing the Source Code for the .NET Framework Libraries ... [More]

## Parallel FX Library: Optimize your code for Multi-Core machines

I was reading the October 2007 edition of MSDN Magazine and came across an article titled "Parallel Performance: Optimize Managed Code For Multi-Core Machines." At first I thought that this was just another article explaining how to use the ThreadPool in .NET to improve the performance of you app, but they are actually talking about the new Parallel FX Library that is about to reach its first CTP. What is this Parallel FX Library? Simple... It's a .NET library that is designed to make is much ... [More]

## Creating an IDE? Use the Visual Studio 2008 shell as your base.

Starting with Visual Studio 2008, you'll be able to use the Visual Studio 2008 Shell as the starting point to create your own development tools. The Visual Studio Shell will be available as part of the Visual Studio 2008 SDK, but I believe we'll have to wait until VS'08 RTM's before we'll be able to play with creating apps using the shell. On the Visual Studio 2008 Shell page, there's a screenshot of Floorplan designer built using the VS'08 Shell. This looks like a really neat feature that... [More]

## .NET 3.5: How to Convert from one TimeZone to another

The ability to convert directly from one timezone to another is coming (finally!) in .NET 3.5 via the addition of the System.TimeZoneInfo object. Example C# Code:DateTime oldTime = new DateTime(2007, 6, 23, 10, 0, 0);TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");DateTime newTime = TimeZoneInfo.ConvertTime(oldTime, timeZone1, timeZone2);

## .NET 3.5: How to Convert from one TimeZone to another

The ability to convert directly from one timezone to another is coming (finally!) in .NET 3.5 via the addition of the System.TimeZoneInfo object. Example C# Code:DateTime oldTime = new DateTime(2007, 6, 23, 10, 0, 0);TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");DateTime newTime = TimeZoneInfo.ConvertTime(oldTime, timeZone1, timeZone2);

## C#/VB.NET: Extension Methods

Over a year ago I posted a question about doing a SQL-like IN operation in .NET. Here's the examples I posted of how it could work: Dim arrNames() AS String = New Array{"CHRIS", "TOM", "TYLER"} If strName IN arrNames Then    'do something End If Now, this would be a powerful feature since you wouldn't be required to write code that loops through the array or collection. Well, I saw some good news today posted by Scott Guthrie. ... [More]

## Visual Studio 2005 Add-In: Get the total number of line of code in your solution

Here's a Visual Studio 2005 Add-In that shows you the total lines of code within your solution/project. It also show the breakout of each individual file. Currently it doesn't include line counts from files within any WebSites that are included inside your solution. But overall this Addin is simple and to the point. Besides, it's open source so you can fix/modify it in any way you'd like. Visual Studio 2005 Line Counter Add-In + Source Code

## C# .NET: Convert System.Drawing.Color to HTML color

Here is a small example of how to convert a System.Drawing.Color to the HTML color format (Hex value or HTML color name value) and back. System.Drawing.Color c = System.Drawing.ColorTranslator.FromHtml("#F5F7F8"); String strHtmlColor = System.Drawing.ColorTranslator.ToHtml(c);

## Scrape Geocodes from Google Maps w/ C#

I need to geocode some addresses once in a while and I notice if you view the source of the Google Maps page, the geocodes are right there. So instead of looking at the source of the page manually, I just created a little app that scrapes them from the page for me and places them into textboxes. Below is a small code snippet I wrote that does just that. It's not perfect but it is simple and it just plain works. string lat = "";string lng = "";string address = "1 Microsoft Way, Redmond WA"; ... [More]

## .NET Framework - Check if Windows booted in Normal or Safe Mode

Heres a really small code sample on how to check which mode Windows was booted up in (Normal or Safe Mode). This works in .NET 1.x and 2.0.   1 'This code checks to see which mode Windows has booted up in.  2 Select Case System.Windows.Forms.SystemInformation.BootMode  3 Case BootMode.FailSafe  4      'The computer was booted using only the basic files and drivers.  5      'This is the same as Safe Mode  6 Case BootMode.FailS... [More]