Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact

NAVIGATION - SEARCH

Mono: WinForms finally API complete and Moonlight v1.0 is released

It's been forever since I posted anything about Mono, but this stuff deserves some attention. Mono's Winforms 2.0 is now API Complete Yesterday, it was announced that the System.Windows.Forms support in Mono (an open source implementation of the .NET Framework targeting Linux, MacOS, Windows, etc.) has finally reached a state of being API complete. This means the public API for WinForms in Mono is exactly the same as in .NET; with a total of 12,776 methods! The first check-in of WinForms occur... [More]

Add System Menu Items to WPF Window using Win32 API

Here's the simple code necessary to add some custom menu items to your applications System Menu within a WPF application. If you're not familiar, the System Menu is the menu that shows up if you click on the apps icon in the upper left or if you right click the app in the taskbar. [More]

Add System Menu Items to a Form using Windows API

This is something I used to have a code snippet for in VB6, but I haven't needed to do this in a while so I never wrote up an example in .NET. So, here's the simple code necessary to add some custom menu items to your applications System Menu. If you're not familiar, the System Menu is the menu that shows up if you click on the apps icon in the upper left or if you right click the app in the taskbar. [More]

.NET 3.5: JSON Serialization using the DataContractJsonSerializer

In ASP.NET AJAX Extensions v1.0 for ASP.NET 2.0 there is the JavaScriptSerializer class that provides JSON serialization and deserialization functionality. However, in .NET 3.5 the JavaScriptSerializer has been marked obsolete. The new object to use for JSON serialization in .NET 3.5 is the DataContractJsonSerliaizer object. I'm still new to the DataContractJsonSerializer, but here's a summary of what I've learned so far... Object to Serialize Here's a simple Person object with First Name and La... [More]

.NET: Why aren't Private Abstract methods allowed?

Sometimes when creating base objects you want to create methods that are overridable by object that inherit the base object, but keep the methods from being public. However, the compiler throws an exceptions when you try to define a method as "Private Abstract". Why doesn't the compiler like "Private Abstract" methods? The reason for this is Private methods can not be overriden. So, essentially the Abstract is useless if the method is Private. How can I create a "Private" method that's a... [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]

Introduction to LINQ

What is LINQ? LINQ (Language INtegrated Query) is more than just a new method of embedding SQL queries within code. It allows to to perform Strongly Typed queries on any kind of data, just as long as the collection of data implements the IEnumerable interface. The most important part is "Language Integrated". This allows you to more easily write queries in C# 3.0 and VB 9.0 such as:   IEnumerable<Person> filterExample1 = from Person in people     &nbs... [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]

12/2007: Code that I've Blogged over the last 6 months

Here's a list of links to all the different code that I've blogged over the last 6 months. .NET Framework .NET: How to Alias Namespaces and Data Types LunchTimeCoder: Windows Service Monitor that runs in the System Tray .NET 3.5: How to Convert from one TimeZone to another ASP.NET Google Charts API: an ASP.NET 2.0 Server Control Subsite Rewriting HttpModule for ASP.NET ASP.NET: RewritePath breaks HyperLink's ImageUrl in App_Theme file when path with slash is rewritten ASP.NET AJAX:... [More]

XNA and XBox 360: Not until you pony up some ca$h!!

I recently got an XBox 360; and until I got one I didn't fully realize what all its features are. This is a really sweet system! So, naturally I downloaded the XNA Game Studio Express to check out what's all possible with building homebrew games for the 360. After registering my gamertag with the XNA Creators Club and installing XNA Game Studio Express on my PC, I took the following steps: Go on XBox Live Marketplace and download the Free XNA Game Launcher. Run the XNA Game ... [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]

WI-INETA: Augmented Reality with .NET on 11/13/2007 with Casey Chesnut

This months Wisconsin .NET Users Group meeting (and the last one of the year) is tommorow (Nov. 13th) night. This month Casey Chesnut will be presenting on "Augmented Reality with .NET". On a related note, Casey has an article titled "/wpfAugReal: Augmented Reality with Windows Presentation Foundation" that he posted back in the beginning of October. I don't know any details of what he'll be presenting (other than the below meeting description), but I'm assuming he'll be covering some... [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]

Weekly Links - 2007-09-07

C# - GenericsC# Generics, Part 2/4: Constraints, Members, Operators - Patrick Smacchia C# Multi-Type Generic Constraints - Adam Esterline C# 2.0 Constraints on Generic Types - Dan Vallejo ASP.NET 2.0Creating a Custom ASP.NET Profile Provider - Shawn Wildermuth Misc.25 steps for building a Micro-ISV - Leon Bambrick

LunchTimeCoder.ServiceMonitor v1.1 Released

I just posted up the latest release (v1.1) of my windows service monitor app. Download LunchTimeCoder.ServiceMonitor v1.1 This is a small utility that monitors windows services running on the local machine or any maching on the local network. And notifies you via an icon in the system tray and a balloon popup telling you which services aren't running. You can also Start and Stop services from this utility. New Features in this version: Added ability to monitor services on any computer... [More]

LunchTimeCoder: Windows Service Monitor that runs in the System Tray

Yesterday I started writing a Windows Service Monitor, but I didn't finish it during my lunch time. And, since I had a little extra time last night and this morning (I'm off work today by the way), I spent some time finishing it. Yeah I know it's cheating but I'm the one who wrote the rules for this initiative anyway. This app is relatively simple, you pick what services to monitor on the local machine and it minimizes to the system tray. When a service you are monitoring stops, it will chang... [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);

Learn ASP.NET Provider Model By Example via BlogEngine.NET

I was looking through the code of the new BlogEngine.NET project last week, and noticed that it implements the ASP.NET Provider Model. Cool an example I can study! I've been trying to spend some time lately to learn more about design patterns, so this was an interesting find for me. If you look at the code for BlogEngine.NET you'll see that it is a rather simple application that demonstrates a working implementation of the ASP.NET Provider Model that you can learn from. Go check out the code a... [More]

Why not make ASP.NET Web Matrix shared source?

ASP.NET Web Matrix was the Free ASP.NET editor back in the .NET 1.x days. The tool is actually still available for download. The other day, I was thinking... Why doesn't Microsoft make ASP.NET Web Matrix available as Shared Source? Web Matrix was a really cool tool, and it's obviously been rendered obsolete by Visual Studio Express. However, there are still alot of really cool things done in the code, and I think it would be beneficial to the community if the source code were made available. ... [More]

C#: Give your object a Default Indexer Property

I've seen/used objects within the .NET Framework that have default indexer properties (ie: SqlDataReader, System.Collections.Generic.List). Now how exactly do I give my own custom object type a default indexer property? Well, it's actually rather simple. Heres an example of a Club object with a People collection of type Person that has a default indexer property set up: public class Club{  /// <summary>  /// Collection of Person objects in the Club  /// <... [More]

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]

My first look at VS'05 Team Edition for Software Testers

I've been meaning to dig in and get to know unit testing for quite some time now. Tonight I dove in and took a look at the Visual Studio 2005 Team Edition for Software Testers. Unit testing is actually quite easy to do. The Getting Started with Team System Testing Tools section in the MSDN library has some nice How-To's on getting started with unit testing using VS'05 Team Edition.

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