Monday, March 31, 2008, 09:04 PM
Posted by Ruben Steins
In the March edition of MSDN Magazine, Charles Petzold writes an interesting article on Vector Graphics and the WPF Shape class. In this he describes several of the things to be mindful of when creating your own Shapes. Since Windows Presentation Foundation has Shapes Posted by Ruben Steins
... elevated to a status nearly equal to to controls, often participating in layout and receiving mouse, keyboard and stylus input.
This means there are a number of things to take into account, such as the performance issues that might arise from allocating to much memory on the heap in some of the frequently used methods:
Because DefiningGeometry can be called at any time, and particularly whenever any property that affects the primitive changes, it's important to implement DefiningGeometry without routinely allocating memory from the heap. If every call to DefiningGeometry results in a heap allocation, eventually the Microsoft® .NET Framework garbage collector will need to take action. You should try to purge your DefiningGeometry code of any class instantiations, and you should also be aware of implicit heap allocations associated with some methods. Next I'll show you several techniques for avoiding heap allocations in your Shape derivatives.
In the article he supplies ample code-samples as well as the complete source of all the examples as a download. I especially like his ParallelPath shape!





( 2.8 / 43 )

Calendar



