views:

200

answers:

1

You know how System.Drawing.Rectangle was replaced by System.Windows.Int32Rect? (As far as non-floating-point shapes are concerned ...)

Is there a similar new object for an integer point or size? If not, I'll just use System.Drawing - but that kinda seems like a minor mix of two platforms that ought not to me mixed.

Anyway, what do you think about this?

+2  A: 

The drawing primitives in WPF store all measurements/locations values in doubles - apparently all except Int32Rect, as you pointed out. The reasoning behind this design is due to how WPF is not bound directly from pixel-to-display - it uses "device independent pixels" (DIPs) which can be scaled for whatever device on which it is being rendered. This gives WPF the ability to scale and translate everything that it is displaying very easily.

As for System.Windows.Int32Rect, the only place I see it being used inside the API is for capturing and cropping pixels. This makes sense - when doing a screen capture, you're wanting to get exactly the pixels that are currently displayed on the device.

James Kolpack
This makes sense. I was hoping they would make a simple Int32Point as well, for similar purposes. There are times when integers are all you need --- and when you are dealing with only whole numbers, floating-point values will actually damage your accuracy since they are never the exact number you want.
Giffyguy
I should add that this is for code-behind functions, not display stuff. I'm not working in an area where DIPs mean anything to me, so all of the floating-based UI libraries aren't really suited for what I'm trying to create purely in memory.
Giffyguy