Krzysztof Cwalina on API Design

by Christoph Menge in Software

This is a rather old one (dated June 1st 2007), but I feel this one deserves it: A three-hour webcast by FxCop creator Krzysztof Cwalina who now works at Microsoft on the design of APIs, a little post mortem on the development of the .NET Framework, etc.

You can download the not-so-small file here:

http://blogs.msdn.com/kcwalina/archive/2007/06/01/FDGLecture.aspx

 

While three hours seem to be excessive, this is a really interesting webcast with a very high information density… Have fun!

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: , ,

New Prism Drop!

by Christoph Menge in .NET

Again, there is a new drop for the Prism Reference Implementation. Get it here:

http://www.codeplex.com/prism/Release/ProjectReleases.aspx?ReleaseId=12226

At the current release intervals, it’s hard to keep up ;-)

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: , ,

Custom DependencyProperties and “Auto”

by Christoph Menge in Software

While implementing a little custom control (a radial panel, actually – stay tuned what it’s good for…), I stumbled across a little problem when trying to add automatic behaviour.

Many built-in WPF Controls such as Canvas or Panel allow something like

Width="Auto"

Now, for my control I need something that accepts

AngleSpacing="Auto"
AngleSpacing="<double>"

Of course, accomplishing that is very simple, but it took me some time to find it on MSDN:

In addition to acceptable Double values, this property can also be Double.NaN. This is how you specify auto sizing behavior in code. In XAML you set the value to the string “Auto” (case insensitive) to enable the auto sizing behavior. Auto sizing behavior implies that the element will fill the height available to it. Note however that specific controls frequently supply default values through their default theme styles that will disable the auto sizing behavior unless it is specifically re-enabled.

So, the solution simply is to apply the TypeConverterAttribute as follows:

[TypeConverterAttribute(typeof(LengthConverter))]
public double AngleSpacing
{
    get { return (double)GetValue(AngleSpacingProperty); }
    set { SetValue(AngleSpacingProperty, value); }
}
public static readonly DependencyProperty AngleSpacingProperty =
    DependencyProperty.Register("AngleSpacing",
                                  typeof(double),
                                  typeof(CircularPanel),
                                  new FrameworkPropertyMetadata(45d,
                                  FrameworkPropertyMetadataOptions.AffectsArrange));

This will, however, leave us with a length converter (which is built mainly for Conversion of “pt”, “px”, etc.). There are quite a lot of type coverters available already. For a list, see http://msdn2.microsoft.com/en-us/library/system.componentmodel.typeconverter.aspx.  

In my case, I need a custom TypeConverter, which is really simple:

public class DoubleAutoConverter : TypeConverter
{
  public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
  {
    if (sourceType == typeof(string) || sourceType == typeof(double))
    {
      return true;
    }

    return base.CanConvertFrom(context, sourceType);
  }

  // Overrides the ConvertFrom method of TypeConverter.
  public override object ConvertFrom(ITypeDescriptorContext context,
     CultureInfo culture, object value)
  {
    if (value is string)
    {
      double dValue;

      if (String.Compare((string)value, "auto", true) == 0)
      {
        dValue = Double.NaN;
      }
      else
      {
        // Don't catch the exception
        dValue = Double.Parse((string)value);
      }

      return dValue;
    }

    // No need to handle the trivial case manually:
    return base.ConvertFrom(context, culture, value);
  }

  public override object ConvertTo(ITypeDescriptorContext context,
     CultureInfo culture, object value, Type destinationType)
  {
    return base.ConvertTo(context, culture, value, destinationType);
  }
}

Now, when the user specifies auto, the property will be set to Double.NaN and can be handled by the control… hopefully

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: , , ,

Tao Framework now DPI Aware!

by Christoph Menge in .NET, Software

Huge thanks to Ilmar Kruis for implementing GetDeviceCaps() in the Tao framework! With some small modifications I suggested, one can now easily develop DPI-aware OpenGL applications using C# or .NET in general! Thanks Ilmar!

I will update my article on the CodeProject about OpenGL windows in Vista soon!

See http://www.taoframework.com/

Get the latest version via SVN: https://taoframework.svn.sourceforge.net/svnroot/taoframework

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: , , ,

During the last days, I stumbled across a very annoying feature of Vista very often: The resource exhaustion manager. It tells me to close Visual Studio and the Desktop Window Manager. OK, shall I close the lid of the computer and go to sleep, too?

Annoying Feature

However, the situation gets worse when I opened mspaint and took the screenshot! Now, a low memory warning popped up. The bad thing is: There are still 1777 MB which are used for caching, according to the Task Manager! On the other hand, it reports a page file usage of 2851 / 2939 MB, and shows a graph with 2.36 of 3.00 GB Physical RAM usage – rather strange?!

Update: This post is now almost two years old, but it’s ranked pretty high in the search engines so I felt it was worth an update. Bottom line: don’t disable virtual memory. If you didn’t do so, it might have been disabled by a third party software or by accident. To re-enable, go to Control Panel -> System -> Advanced System Settings -> Advanced -> Virtual Memory. You might have to delete the existing file, pagefile.sys.

Windows is pretty smart when it comes to using resources effectively, but there is quite a bit of dark magic involved. The swap file plays an important role. If you really know what you’re doing, however, you can disable the warning.

In another thread (thanks Arthur), users report issues when using TrueCrypt, so TrueCrypt users might want to head over to Arthur’s. I haven’t checked out Microsoft Dynamic Cache Service, but I haven’t really felt the need. End Update ;-)

I see the point in caching frequently used files in the RAM, but an easy way to control this caching behavior would be nice. Due to the fact that I have installed 1GB of Intel Turbo Memory anyways, caching should have a very low priority in my case, I think.

Worst of all, I kinda saw it coming: I acquired a habit of ultra-multi-tasking when using an XP machine with 3GB of RAM … that was almost three years ago, and now that programs have a considerably larger memory consumption, I need more RAM – which is not possible unless you switch to 64 bit, which is fraught with its own perils, especially when it comes to laptops.

NOTE: I have virtual memory disabled completely.

Memory Consumption

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: , , ,

New Prism Drop!

by Christoph Menge in Software

A new Prism drop has just been released! See Glenn Block’s post here:

http://blogs.msdn.com/gblock/archive/2008/03/26/prism-drop-2.aspx

The direct link to the resource is

http://www.codeplex.com/prism/Release/ProjectReleases.aspx?ReleaseId=11976

Views are no longer added via AddViewToRegion(); rather, an IRegion can be requested and an Add method can be called to actually add the view.

Also, a sliding region has been added.

However, I feel the most important change is the introduction of the WatchList Module, which seems to be an interesting way of handling the problem with custom command routing and WPF routed commands…

Unforturnately, its 2 am in Germany right now, and I have to sleep…

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: , ,

DPI-Awareness

by Christoph Menge in Software

Due to the very high resolution of my new laptop’s display, I chose to increase its DPI so I could benefit from more readable text. Unfortunately, it turns out that there are still a number of problems:

o On 120 dpi, 11pt Segoe UI (Windows Vista’s default UI font) will have a far too large space after the small letter ‘m’.

o Many 3D-applications, including some SDKs, Samples, etc. are not DPI-Aware (also includes Doom 3!). These have to take DPI-Settings into account when projecting from/to the screen.

With more and more high-resolution devices, software vendors should start testing their applications for DPI-Awareness. It’s not a big issue in most cases, it seems.

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: ,

New Machine!

by Christoph Menge in Software

Well, due to the hardware-hunger of some of the projects I am working on, it was certainly time for a new machine so I got myself a brand new ThinkPad T61p. Very nice indeed, with a crazy WUXGA display on just 15.4″ – kewl! More pixels than you typically find on 22″. I will be posting some of my experiences with the machine here.

Very positive impressions so far: Keyboard (no surprise), loudspeakers

 First negative impression: The advanced dock has an integrated fan which is very loud!

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags:

Prism: First Reference Implementation

by Christoph Menge in Software

As Glenn Block reports, the patterns & practices Team released a reference implementation of Prism on Wednesday:

http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=prism&ReleaseId=11615

 Very interesting read! While I’m still working with the 6267 release of prism, I’m gonna update my code and write about some experiences with it soon!

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: ,

When trying to install the SmartClientSoftwareFactory May 2007 CTP, you may encounter some problems. Workarounds have been presented, for example by Ezequiel Jadib:

http://staff.southworks.net/blogs/ejadib/archive/2007/08/27/How_2D00_To_3A00_-Smart-Client-Software-Factory-_2800_SCSF_2900_-_2600_-Visual-Studio-Orcas-Beta-2.aspx

However, with the new February 2008 versions of GAX and GAT, SCSF Installation fails on my system (Vista Business) with some strange Error 2869.

Anyway, for those interested in the not-so-easy to find GAX & GAT links, these are:

Guidance Automation Extension February 2008
http://www.microsoft.com/downloads/details.aspx?familyid=DF79C099-4753-4A59-91E3-5020D9714E4E&displaylang=en

Guidance Automation Toolkit February 2008  for Visual Studio 2008 (There’s a VS-2005 version, too!)
http://www.microsoft.com/downloads/details.aspx?FamilyId=B91066B3-D1D6-4990-A45F-34CF8DBDC60C&displaylang=en

Happy Coding!

Post to Twitter Post to Delicious Post to Digg Post to Facebook

Tags: , , , ,