PGCodeWorks"/
This Month
November 2007
Sun Mon Tue Wed Thu Fri Sat
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
Search
View Article  TFS: Work Item Search

I've been using this plugin now for the past few months. You would not believe the difference it makes.

This plugin puts a little search box right into Visual Studio to make it easy to find work items.  It is an addin for Team Foundation Client (Team Explorer) and is accessible from the Team menu when you're connected to a Team Foundation Server and is also avalible from a VS Toolbar.  You just type in some search text and it runs a work item query for you showing you results across the work item store.



Source: Codeplex project "Search Work Items"

View Article  Useful macro for creating Visual Studio 2005 dependent (nested) items
Check out this useful macro for visual studio 2005 dependent (nested) items. Useful for breaking up large classes into partials when refactoring doesn't make sense. I found it useful when you want, for example one integration test class per implementation class and the test class is getting a bit large.



Source: http://www.delarou.net/weblog/PermaLink,guid,a81a2d9d-02de-4fe1-ad8d-ee2fee97cf20.aspx

Visual Studio .NET Macro for nesting project items

This macro enables you to nest project items inside Visual Studio .NET. Until now, there is no easy way to nest project items through the Visual Studio IDE, you can only do it by manipulating the project (.csproj or .vbproj) file and adding the DependentUpon element.

Inside the IStaySharp.vsmacros file there is a macro called 'Create Dependency' which allows you to nest two selected items. I have even created a video (672,18 KB) to illustrate how to configure and use the macro.

View Article  Visual Studio Unit Test and the evil vsmdi

During a recent project we found a recurring problem where the test view of the unit (& integration) test projects would not load and we could not run tests. This was typically seen by the Test View load progress bar sitting at around 99%. This just adds to the list of "features" of VSTS Unit Test that make life oh so irritating

It is due to the corruption of the *.vsmdi files in the visual studio solution which is caused by auto-merging the content of the file or having the test view property window open when getting the latest version.

The problem is outlined in this blog post (also note the comments for possible workarounds)

Source: http://kjellsj.blogspot.com/2006/04/vsmdi-file-weak-spot-of-vsts-test.html

View Article  Creating a custom AJAX control - DateTimePicker

Lately I decided to see how easy was to create AJAX custom controls specifically using the included javascript libraries. I thought it might be useful to try to use the included javascript libraries to enable client side access to the selected value from a custom control.

The example I will use is a date time picker which uses the calendar extender from the ajax control toolkit for the date and a simple drop down for the time. Much like outlook, the date is pickable from a textbox and the time in a list of 15 minute intervals. The goal is to allow the client and server side code to have access to the same DateTime type without having to do any work parsing the strings in the HTML elements on the page.

Usage Pattern

The control on the client page looks like the following.

<pgc:DateTimePicker ID="dtpMyDate" runat="server" TimeInterval="15" Format="dd/MM/yyyy"/>

The client script needed to get the value from the control is as follows

function displayClientDate()
{
    alert( $find( "dtpMyDate" ).get_selectedDateTime().format("dddd dd MMMM yyyy HH:mm") );
}

....and that's it! The screenshot below shows the output.

The Implementation

To implement the custom control described above we have to implement the IScriptControl interface from the AJAX Extensions as well as the standard CompositeControl. This requires that we implement a few methods on our control above and beyond the standard control methods, these are the GetScriptReferences and the GetScriptDescriptors methods.

GetScriptReferences allows us to add in the client script files to the output sent to the user. This tells the ScriptManager on the page to send down our client script file.

protected virtual IEnumerable<ScriptReference> GetScriptReferences()
{
    ScriptReference ProtoReference = newScriptReference();
    ProtoReference.Path = Page.ClientScript.GetWebResourceUrl(this.GetType(), "PGCodeWorks.AjaxControls.DateTimePicker.DateTimePicker.js");
    return newScriptReference[] { ProtoReference };
}

GetScriptDescriptors allows us to tell the control which variables to pass through to the client script. These variables are set on the client when the page is sent down and allow us to use the same javascript object to represent multiple controls on one page with different instances and properties.

protectedvirtualIEnumerable<ScriptDescriptor> GetScriptDescriptors()
{
    ScriptBehaviorDescriptor descriptor = newScriptBehaviorDescriptor("PGCodeWorks.DateTimePicker", this.ClientID);

    descriptor.AddProperty("textBoxClientID", this.txtDate.ClientID);
    descriptor.AddProperty("dropDownClientID", this.ddlTime.ClientID);
    descriptor.AddProperty("selectedDateTime", this._selectedDateTime);
    descriptor.AddProperty("dateFormat", this.ceCalExtender.Format);
    descriptor.AddProperty("timeFormat", this._timeFormat);
    descriptor.AddProperty("timeInterval", this._timeInterval);

    return newScriptDescriptor[] { descriptor };

}

Then, after implementing the rest of our control we need to add the client script .js file to the solution and mark it as an embedded resource. To make the file embed itself within the DLL select the file in solution explorer and change the "Build Action" in the properties window. Also you must add a reference to it in the AssemblyInfo.cs file.

The actual file follows the object-oriented javascript approach to allow properties etc on the prototype model. Below is the structure of the .js file (some code has been cut-out to save space).

// Register the namespace for the control

Type.registerNamespace('PGCodeWorks');

//

// Define the control properties

//

PGCodeWorks.DateTimePicker = function(element) {

    PGCodeWorks.DateTimePicker.initializeBase(this, [element]);

   

    // Set properties to null

    this._textBoxClientID = null;

    this._dropDownClientID = null;

    // *** Code Truncated ***

}

//

//

PGCodeWorks.DateTimePicker.prototype = {

    initialize : function() {

        PGCodeWorks.DateTimePicker.callBaseMethod(this, 'initialize');

        this._onDateTimeChangeHandler = Function.createDelegate(this, this._onDateTimeChange);

        this._onDateChangeHandler = Function.createDelegate(this, this._onDateChange);

        this._onTimeChangeHandler = Function.createDelegate(this, this._onTimeChange);

        $addHandler($get(this._textBoxClientID), 'change' , this._onDateChangeHandler );

                    

        $addHandler($get(this._dropDownClientID), 'change', this._onTimeChangeHandler);

       

   

    },

   

    dispose : function() {

        $removeHandler($get(this._textBoxClientID), 'change' , this._onDateChangeHandler );

        $removeHandler($get(this._dropDownClientID), 'change', this._onTimeChangeHandler);

        

        PGCodeWorks.DateTimePicker.callBaseMethod(this, 'dispose');

    },

   

    //

    // Custom Methods

    //

    setDateTimeValues : function() {

        // Get Values

        var strDate = $get(this._textBoxClientID).value;

        var strTime = $get(this._dropDownClientID).value;

        var strTimeFormat = this._timeFormat;

        if( strDate != null && strDate != "" )

        {

            if( strTime == null || strTime == "" )

            {

                strTime = "00:00";

                strTimeFormat = "HH:mm";

            }

            var totalDateTimeFormat = this._dateFormat + ' ' + strTimeFormat;

            var newDate = Date.parseInvariant(  strDate + ' ' + strTime, totalDateTimeFormat  );

            this.set_selectedDateTime( newDate );

            //alert( this._selectedDateTime );

        }

    },

   

    //

    // Event delegates

    //

    _onDateTimeChange : function(e) {

        this.setDateTimeValues();

    },

   

    _onDateChange : function(e) {

        this.setDateTimeValues();

    },

    _onTimeChange : function(e) {

        this.setDateTimeValues();

    },

    //

    // Control properties

    //

    get_textBoxClientID : function() {

        return this._textBoxClientID;

    },

    set_textBoxClientID : function(value) {

        if (this._textBoxClientID !== value) {

            this._textBoxClientID = value;

            this.raisePropertyChanged('textBoxClientID');

        }

    },


    // *** Code Truncated ***

   

    get_timeInterval : function() {

        return this._timeInterval;

    },

   

    set_timeInterval : function(value) {

        if(this._timeInterval != value) {

            this._timeInterval = value;

            this.raisePropertyChanged('timeInterval');

        }

    }

   

} // end of prototype declaration

// Optional descriptor for JSON serialization.

PGCodeWorks.DateTimePicker.descriptor = {

    properties: [   {name: 'textBoxClientID', type: String},

                    {name: 'dropDownClientID', type: String},

                    {name: 'selectedDateTime', type: Date},

                    {name: 'dateFormat', type: String},

                    {name: 'timeFormat', type: String},

                    {name: 'timeInterval', type: Number} ]

}

// Register the class as a type that inherits from Sys.UI.Control.

PGCodeWorks.DateTimePicker.registerClass('PGCodeWorks.DateTimePicker', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

The above code has allowed the client to be able to call the javascript object representing the overall control and retrieve it's selectedDateTime property.

How Does it Work?

The libraries provided with the ASP.Net AJAX Extensions allow us to create composite controls which we can deal with as a single object on the client using object-oriented javascript. Using the patterns and examples given on the AJAX web site we can recreate the types of functionality in the AjaxControlToolkit and start building rich client side experiences.

In this example we have simply provided a public method on our object which grabs the values from the controls on the page and uses the type extensions in AJAX to provide a similar experience in client side development as we experience on the server side. To extend this example I have created a RequiredFieldValidator and a CompareValidator which will work with the above control and I hope to post this when it has been cleaned up.

The full code and solution for this example is available here

View Article  Enterprise Library 3.0 Released - with some really nice features

The Microsoft Patterns and Practices team have just released Enterprise Library 3.0 - April 2007. This is the full RTM version of EntLib with some really neat new features:

  • Validation Application Block. Allows you to centrally define validation rules using configuration or attributes, and easily validate data from anywhere in your application, including deep integration with Windows Forms, ASP.NET and WCF.


  • Policy Injection Application Block. Provides a powerful approach for separating cross-cutting concerns from business logic using declarative policies that are attached at runtime to methods on your objects.


  • Application Block Software Factory. Dramatically simplifies the process of building application blocks and providers through the magic of guidance automation.


  • Visual Studio-integrated Configuration Editor. Edit Enterprise Library configuration files directly within Visual Studio.


  • Environmental Overrides. Use the configuration tool to specify configuration settings that are common or different across multiple environments, and merge this information into configuration files to be deployed with your applications.


  • WCF Integration. Easily integrate the Logging, Exception Handling and Validation Application Blocks into service interfaces built using Windows Communication Foundation.


  • Pre-compiled, strong-named binaries. No need to compile and strong name the code unless you want to manage and evolve the code yourself.

I had a play with the Visual Studio integration and Environmental Overrides functionality over the weekend (yeh, I know) - I'm glad they eventually added this stuff in. Olaf Conijn was building these as add ons before he was assimilated.

Source: Tom Hollanders Blog

Visual Studio Integration Screenshots

Web.Config context menu

Web.Config editing UI
View Article  Expression Web now available on MSDN subscriptions

Microsoft have finally listened to all the developers (who are also designers) rightfully throwing our toys out of our prams and included Expression Web Designer and possibly some other Expression badged products in the MSDN subscription downloads.

"...we received a lot of questions about why we did not include some of these products, particularly Expression Web, within customers’ MSDN subscriptions.........Based on this feedback, I am pleased to say that we will be making Expression Web available starting today to all MSDN Premium subscribers"

This is really good news. The presumption that developers never need to use the latest CSS and HTML tools as they don't do design is ridiculous. Those of us building functional internal web solutions rarely get the option of enlisting the services of a dedicated designer, leaving the lonely developer to struggle with whatever tools are available to accomplish design.

Source: Somasegar's blog