March 2009 - Posts
Are you intrigued by multi touch? The Windows Engineering team just posted a great article on how Touch was implemented in Windows 7 and on how software developers can tap into this: http://blogs.msdn.com/e7/archive/2009/03/25/touching-windows-7.aspx#comments
Check out these labs to find out how you can use Windows 7 touch with WPF 3.5 SP1: http://code.msdn.microsoft.com/WindowsTouch
This WPF 4.0 session from PDC shows you what you can expect next: http://channel9.msdn.com/pdc2008/PC03/
And here’s another cool thing this is the official quote from the WPF Tree Services & Controls Team:
We shipped some great new updates to the WPF Toolkit and WPF Futures on Codeplex earlier this week. These included an updated version of the WPF Toolkit with over 20 high-priority bug fixes for DataGrid, DatePicker, & Calendar, and also a package of WPF Themes (matching those shipped with the Silverlight Toolkit) as a new addition to the WPF Futures. We’ve also added a pointer to David Anson’s blog post with a preview of the WPF Chart Controls which are being written by the Presentation Platform Controls (PPC) team (the team who produces the Silverlight Toolkit).

Found this useful post you might want to know how to add tracing information for System.Net namespace:
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.HttpListener">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Sockets">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
<source name="System.Net.Cache">
<listeners>
<add name="System.Net"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="System.Net"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.trace.log"
traceOutputOptions = "ProcessId, DateTime"
/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
<add name="System.Net.Cache" value="Verbose" />
<add name="System.Net.HttpListener" value="Verbose" />
</switches>
</system.diagnostics>
</configuration>
I was investigate a GDI/GDI+ related bug the other day and I found out that GDI+ doesn’t render RTL text very well. In order to render it correctly you need to render it using GDI.
GDI+ Text rendering
This is done by Graphics.DrawString(…) / Graphics.MeasureString(..)
GDI Text rendering
This is done by TextRenderer.DrawText(..) / TextRenderer.MeasureText(…)
The interesting thing about GDI text measuring is that it sometimes the measured size might be larger than the maximum size so be aware of that!
Another point is to be aware of the GraphicsUnit in the Graphic.PageUnit instance vs. Font.Unit if one in pixels and the other is inches than it’s like comparing melons to oranges.
Test application
I've created this test application that might help you to see the differences between the two rendering technologies.
Additional resources
Check out the article in McKinsey and the World Economic Forum:
"McKinsey has partnered with the World Economic Forum to create an “Innovation Heat Map,” by identifying factors that are common to successful innovation hubs. As part of this effort, we have examined the evolution of hundreds of such clusters around the world and analyzed over 700 variables, including those driving innovation (business environment, government and regulation, human capital, infrastructure, and local demand) along with proxies for innovation output (for example, economic value added, journal publications, patent applications) to identify trends among the success stories. In the process, we have found patterns that suggest the critical ingredients required to grow, nurture, and sustain innovation hubs. At the same time, we have compiled thousands of data points that may be used to identify bottlenecks and benchmark the performance of cities, regions, and countries by measuring how they are evolving."
Check out Haifa and Tel Aviv (almost) – they are in the hot spring sector!

Infostrat has taken VE3D and wrapped it up in a WPF control that you can just drop right into your XAML, they also put this project, including the source, onto CodePlex under LGPL.
You just need VS 2008 and .NET 3.5 SP1.
Very cool !
Some of the features:
- Ability to use <include> tags within Xml header documentation to pull docs from external files.
- Get accessor in property required to appear before set accessor
- .generated.cs files ignored by default
Bugfixes:
- 18: Partial methods not handled correctly
- 31: Documentation rules should understand <include> element
- 56: Require get accessor before set accessor
- 63: When documenting a generic class, only allows <see cref="MyClass"/> and not <see cref="MyClass`1"/>.
- 70: Analysis of files in websites crashes Visual studio 2005 and 2008
- 74: SA1623 and SA1624 warnings appears in wrong situations
- 82: 'using' statement does not require curly brackets
- 88: Class without explicit access modifier marked as "public" instead of "internal"
- 90: False warning: SA1119: The line contains unnecessary parenthesis
- 93: Ignore .generated.cs files
- 94: Style Cop Crashes With A Blank Definition File
- 95: SA1101 isn't raised in method calls when the return value of the method is used.
- 98: VS crashed for webservices.
- 121: False syntax error with a nullable generic type reference.
- 124: LINQ operator "let" cause SA0101 when used with "condition ? true : false" syntax
- 151: False syntax error with a defaulted array.
Install link: https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sourceanalysis&ReleaseId=1425
Discussions: http://code.msdn.microsoft.com/sourceanalysis/Thread/List.aspx
Bugs: http://code.msdn.microsoft.com/sourceanalysis/WorkItem/List.aspx
I found this cool post on how to use azure blob storage to store your images.
This post includes some source code (C#) to upload the images.
Nice!
NerdDinner ASP.NET MVC Tutorial
The tutorial starts by using the File->New Project command in Visual Studio to create a brand new ASP.NET MVC project, and then incrementally adds functionality and features. Along the way it covers how to:
- Create a database
- Build a model with validation and business rules
- Implement data listing/details UI on a site using Controllers and Views
- Enable CRUD (Create, Update, Delete) data form entry
- Use the ViewModel pattern to pass information from a Controller to a View
- Re-use UI across a site using partials and master pages
- Implement efficient data paging
- Secure an application using authentication and authorization
- Use AJAX to deliver dynamic updates
- Use AJAX to add interactive map support
- Perform automated unit testing (including dependency injection and mocking)
The application the tutorial builds is called “NerdDinner”. It provides an easy way for people to organize, host and search for new topic-based dinners online:
![nerddinner_small[1] nerddinner_small[1]](http://weblogs.asp.net/blogs/scottgu/nerddinner_small1_thumb_4EA09BD3.png)
Scott Hanselman has been hosting NerdDinners for years, and came up with the idea of building the tutorial around an application that facilitates this. He is also now hosting a live custom-skinned version of the application at www.nerddinner.com)
Links
This is more of a general post on various collections and how does WPF bind to them and what are the interfaces that WPF uses in order to manage those collections.
When binding collection to an ItemsControl (TreeView, ListView, ListBox, ComboBox and etc) or to a more simple control (Button, TextBox, TextBlock and etc) WPF creates behind the scene an ICollectionView object.
This object can be one of the following types:
But what if you collection implements both IEnumerable and/or IList or/and IBindingList ,well in that case – by preference first of all BindingListCollectionView then ListCollectionView and then CollectionView. However, you can pick CollectionView type instead of some other type use by the following XAML (assuming that you bind to DataContext):
1: <CollectionViewSource x:Key="myCollection2" CollectionViewType="{x:Type CollectionView}" Source="{Binding Path=.}"/>
If your collection is editable then you can edit it while it's bounded - using IEditableObject and IEditableCollectionView.
When binding to ObservableCollection<T> the view type will be ListCollectionView, you can use CollectionViewSource.GetDefaultView([your collection]) in order to retrieve the ICollectionView object and check it's type.
In the next post I'll provide a sample on how you can bind the same collection to multiple controls and edit using IEditableObject and IEditableCollectionView, when one of them changes the other will change automatically as well.
If you are interested in using MVVM (Model View ViewModel) design pattern for your applications you should definitely take a look at the screencasts made available on Josh's site.
Implementing Model-View-ViewModel in WPF
Implementing Model-View-ViewModel in Silverlight
Implementing MVVM & Exploring UX Design Patterns
”Oslo” is the codename for Microsoft’s forthcoming modeling platform that helps you build your own textual models. Modeling is used across a wide range of domains and allows more people to participate in application design and allows developers to write applications at a much higher level of abstraction. “Oslo” consists of:
- A tool that helps people define and interact with textual models in a rich and visual manner
- A language that helps people create and use textual domain-specific languages and data models
- A relational repository that makes models available to both tools and platform components
To get started, you need the latest version of Olso itself. You get it from Microsoft "Oslo" SDK - January 2009 CTP. You'll get the SDK that contains documentation, samples, copies of the “Oslo” models written in "M", and tools designed to help you write your own models in "M", including the code name “Intellipad” tool for code name “Oslo”. You'll need Visual Studio 2008 and SQL Server 2008 to use the repository.
An excellent introduction to M is provided by Bart in a series of posts:
Stephen Elop, the president of Microsoft's Business Division recently held a presentation where he allowed the viewers to glimpse 10 years into the future.
The cool stuff are starting around 14:30.
In the February MSDN Magazine there's a very interesting article about CSE and what is changed in CLR 4.0.
It seems that the code below would wrap corrupted state exceptions thrown by the OS (such as Access Violation) and thus leaving the application non stable state when you not fixing the CSE.
1: public void SomeFunction()
2: {
3: try
4: {
5: //Do something
6: }
7: catch(Exception ex)
8: {
9: throw WrapException(ex);
10: }
11: }
So they CLR guys made some changes and thus no more CSE exception will be thrown. However, if you do have support for CSE you will have to add to do the following changes:
- If you want to recompile your code created in the Microsoft .NET Framework 3.5 and run it in the .NET Framework 4.0 without having to update the source, you can add an entry in your application configuration file: legacyCorruptedStateExceptionsPolicy=true.
- Assemblies compiled against the .NET Framework 3.5 or an earlier version of the runtime will be able to process corrupted state exceptions (in other words, maintain the old behavior) when running on the .NET Framework 4.0.
Or, recompile with System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptions attribute as following:
1: using System.Runtime.ExceptionServices;
2:
3: [HandleProcessCorruptedExceptions]
4: public void SomeFuntion()
5: {
6: try
7: {
8: //DO something
9: }
10: catch(Exception ex)
11: {
12: //Handle CSE
13: }
14: }
Note the plural suffix – HandleProcessCorruptedStateExceptions – you need to be careful from CSE thrown down the stack, if you can handle a particular CSE it doesn't mean that you know or should handle or the other – so be careful !
Read the full article
The SharpLudus project is intended to streamline digital games development through Software Factories. It provides visual languages, frameworks and tools, integrated with Visual Studio, to empower the creation of XNA games.
Check out the video and the project @ Codeplex
More Posts
Next page »