avr. 21

What happens if you create a new Bug in Team Foundation Server, and if you see afterwards that this is not a bug ? Usually, you would like to reject it. But... you can't! Indeed, by default Team Foundation Server allows you to resolve a bug with one of the following reasons : 

  • As Designed
  • Cannot Reproduce
  • Deferred
  • Duplicate
  • Fixed
  • Obsolete
In some cases, none of these values can do the job. So if this does not suit your need, let's see together how can we update the normal workflow to include this new value.

Use the Team Foundation Server Power Tools

This free Visual Studio extension can be found here. It will add some nice extensions to Visual Studio to help you working with the Team Foundation Server, and above all it will add a new menu in the tool menu : Process Editor.

Let's use it to update our workflow. First select the Work Item Type (WIT) you want to update

Just select the Work Item Type you want to update (here select Bug), and you will have the following screen:

Here we are interested by two tabs : 

  • The Fields tab list all the fields that are used in the Bug Work Item Type.
  • The Workflow tab show the the different status that the Work Item Type can hold, and the transition between each state

Change the list of possible values for "Resolved Reason"

When you resolve a Work Item, you have a field called Resolved Reason that holds the reason of the resolution. In our case, we need a new value Rejected. So how do we define it ?

  • Go on the Field Tab
  • Select the Resolved Reason field
  • Click on Edit
  • On the Field Definition window, select the Rules tab
  • Edit the ALLOWEDVALUES field
  • Add a new value Rejected

And here it is, you have a new resolution value, that can be used in the workflow.

Note that the list we have just updated is used when performing validation of the workflow. If we do not update this list, therefore, our workflow would be valid, but when changing the resolution of a bug, we would have an error.

Update the workflow

So now, we can go back to the main screen and select the Workflow tab. You should see something like :

What does that mean ?

  • The bug item type has three states : Active, Resolved and Closed
  • We have an entry point leading to the Active state
  • We have some transitions 
    • from Active to Resolved
    • from Resolved to Active
    • from Resolved to Close
    • from Close to Active

In our case, we want to add a new way of resolving a bug, so let's double click (or right click, and Open Details) on the transition from Active to Resolve and let's create a new Transition Reason.

Now we'll need to edit this new reason. Let's go the Fields tab and let's create a new Field reference. This Field Reference will be of type ResolvedReason and will have two Rules : COPY and ALLOWEDVALUE.

How do we parameter these two Rules ? Quite Simple. We are just copying a new value, which is Rejected, and after we'll check that the value is within the list of the allowed values.

And here we are ! We just have to check that everything is ok now.

Check that the new workflow is correct

Once we have saved our Work Item Type definition, we can open a bug and check that everything is correct.

Tags: |
avr. 20

Recently, I was needing to publish the powerpoints coming from various speakers on my server. When I have seen the size of some powerpoints (more than 20Mo) I thought it would not be a very nice user experience if my end-users were needing to download documents of such a size.

The problem

When you deal with Powerpoint documents, you will add some medias (images, cliparts, ...) to give them a better look. And of course the more medias you add, the bigger will be your powerpoint document.

As long as you work locally, this is not such a big deal. But when you need to publish your document (send it by mail, publish on internet, ...) it can bother you if you do not want your recipients or end user needing to download files of 10 or 20Mo.

Do we need such a size ? Usually, no. So what can we do ?

The Microsoft solution

Powerpoint includes a way to compress all the pictures of your document. To do that, they will reduce the quality of the images (DPI) depending of the profile (print, screen, email), and also remove the cropped parts of your images. To do that,

  • select one of your images
  • do to the Picture Tools / Format menu
  • choose Compress Pictures

This should normally help you to reduce your document size.

So is there a problem ?

This solution is nice but does not give you a lot of control about the document size. Let's imagine you have added some TIFF or BMP pictures in your powerpoint document (or doing some "Print Screen" and "CTRL+C"). Powerpoint will shrink them but will never point out that you have included some file format that are probably completely useless.

So in my view the real solution to investigate and understand the document size is to be able to check very quickly all the media that are present in your document, and check their size. The biggest ones can so be pointed as the first one to correct !

Lets use Jarod.PowerpointAnalyser

To be able to analyse the documents, I have quickly written a tool that will analyse the content of the powerpoint to help you pointing wich medias are responsible of your document size. 

How does it work ?

  1. Select the document you want to analyse by using the browse button
  2. Then click on the button Analyse
  3. Check the different medias you have and their respective size

In the given example you can clearly determine the source of the problem : 3 images of 3 and 6Mo are clearly responsible of the document size.

Which image are they ? The column Used in slides will tell you where they are used in your powerpoint. Some explanations : 

  • slide17 : your image is located in the slide number 17
  • slideMaster1 : your image is located on your first slide master
  • slideLayout1 : each slide master can be composed on several layout (empty slide, image slide, ...). In that case you image is located on the first layout

If you have several images on the same slide, you can quickly use the View link to get a preview of the image.

How to install it ?

Some limitations ?

I have quickly released this tool as a v0.1. So of course, it has a bunch of limitations (or bugs). Let's note : 

  • It can analyse only PPTX files (2007 or 2010 format), as long as they have been saved in the default format (Powerpoint Presentation *.pptx)
  • The PPTX file is locked while the tool is open
  • If you select a file that does not exist, or that is not in the correct format, the tool will crash
  • The "Image Preview" is available on all media, even if the media is NOT an image (a video for example). If you try to preview a media that is NOT an image, the tool will crash.

Are you interested in this tool ?

Do you think it is interesting? Is there anything missing to suit your needs ? Would you like to see another feature ? Leave a comment !

avr. 18

If you need to create a thumbnial on the fly of a given image, it is quite easy to do in C# as the Image object include a GetThumbnailImage method.

using ( Image originalImage = Image.FromFile(@"c:\temp\originalimage.jpg") )
   int newWidth = originalImage.Width / 2;
   int newHeight = originalImage.Height / 2;
   Image resizedImage = originalImage.GetThumbnailImage(newWidth, newHeight, null, IntPtr.Zero);

This method works fine, but may in some cases produce images of bad quality, spacially when dealing with GIF or PNG with transparency. Indeed, it will generate a Black background behind the image. You could correct this problem by handling the resize manually : 

using ( Image originalImage = Image.FromFile(@"c:\temp\originalimage.jpg") )
   int newWidth = originalImage.Width / 2;
   int newHeight = originalImage.Height / 2;

   Image resizedImage = new Bitmap(newWidth, newHeight);
   using ( Graphics g = Graphics.FromImage(resizedImage) )
      g.InterpolationMode = InterpolationMode.HighQualityBicubic;
      g.FillRectangle(Brushes.White, 0, 0, newWidth, newHeight);
      g.DrawImage(originalImage, 0, 0, newWidth, newHeight);

The resulting image will be a bit bigger (size in octet) but will handle correctly any type of image.

avr. 16

Recently, I was needed to order all the pictures that where taken during an event, but by different photographers. In Windows Explorer you can simply add a column "Date Taken" but how can we do the same by code ?

private static DateTime GetDateTaken(string imagePath)
   using ( Image myImage = Image.FromFile(imagePath) )
      PropertyItem propItem = myImage.GetPropertyItem(0x9003); // Property "Date Taken"

      //Convert date taken metadata to a DateTime object
      string sdate = Encoding.UTF8.GetString(propItem.Value).Trim();
      return DateTime.ParseExact(sdate, "yyyy:MM:dd HH:mm:ss\0", null);

And here it is ! As simple as that !

And if you want to have more information about the different property items of an image, just go to http://msdn.microsoft.com/en-us/library/ms534413

An so if you want to order the images by date it was taken, you could use a simple LINQ query : 


string path = @"C:\Temp\MyPhotos";
string[] files = Directory.GetFiles(path, "*.jpg")
                          .OrderBy(file => GetDateTaken(file)).ToArray();


janv. 23

Microsoft has launched 6 new products for web developpers. A wide set of tools from WebMatrix (complete and simple tool to develop and publish a website), to advanced libraries like ASP.NET MVC3 and NuGet.

To have more info about this, just follow the Scott Guthrie's blog : Announcing release of ASP.NET MVC 3, IIS Express, SQL CE 4, Web Farm Framework, Orchard, WebMatrix