Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Lots of DrawingVisual items in a UIElement questions

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 06-13-2006   #1 (permalink)
John Dunn
Guest


 

Lots of DrawingVisual items in a UIElement questions

My application needs to draw a number of objects on the screen. Each of these
objects can be moved, resized and edited by the user. An object is more
complicated than just a rectangle - each one requires multiple drawing calls
to render.

Right now I have implemented a UIElement and added custom code to implement
VisualChildrenCount and GetVisualChild but I'm not entirely sure if that's
the most efficient way to accomplish what I need. I have a few questions that
hopefully someone can help me with.

1. Is this the best way to go about this? There might be 100s of objects on
screen at once. Some of the objects will be redrawn based on asynchronous
network communication on the order of 10 or 20 times a second. Do
DrawingVisuals require enough memory that I'd be better off doing my own
object management and redraw logic? It seems like it'd be difficult to do - I
don't see an obvious way to invalidate a portion of a DrawingVisual so I
though having each object being a DrawingVisual might be a way around that.

2. If I redraw one of my objects will all objects need to be redrawn as well?

3. What's the proper way to implement Z-Order. Do I need to modify my
VisualCollection so SendToBack sends it to the front of the list while
SendToFront does the opposite?

4. Is there a way to make my UIElement have a 'background'? Right now the
UIElement only gets MouseEvents where objects have been drawn. I've drawn a
large rectangle as a background but that doesn't seem like the best solution
to me.

5. What's required to get a ScrollViewer to work with my UIElement. I've
placed it inside of the ScrollViewer but the scroll bars don't appear.

Thanks-

John Dunn

My System SpecsSystem Spec
Old 06-15-2006   #2 (permalink)
Fred Vandervelde
Guest


 

Re: Lots of DrawingVisual items in a UIElement questions

Hi John,

There's a post entitled "DrawingContext.Close() is slow for many Geometries
drawn" where another poster and I go into a little detail with regards to
our own implementations. As with any new technology, we're all attempting
to find the most performant path, but I believe even MS can't tell us for
certain just yet - there are very few samples or applications out there that
tax WPF from this perspective.

On to your questions:

1. See my posts in the other thread for insight into my implementation and
it's performance. As far as I can tell, you need to trust WPF's composition
engine to render things efficiently, and in many cases it does appear to do
fairly well, but possibly not so in others. Outside of using a
DrawingContext inside a DrawingVisual's Render() method (which really is not
the same thing), I haven't seen anything that looks like it may allow the
user to control invalidation and redraw. (Although I haven't searched for
it either)

2. Invalidation, redraw, and optimization surrounding these tasks is up to
WPF, as far as I can tell. You modify the color (brush) of an object, WPF
handles the invalidation and redraw.

3. In the past, yes (that is how I have done it as well). If I remember
correctly however, Panel based classes like Canvas should now support some
type of ZOrder - this is new in beta 2. I presume it's probably through the
use of an attached property - the release notes should point you where you
need to go, as I haven't yet done this myself.

4. I don't know, sorry.

5. I have been using a Canvas inside of a scrollviewer. My Custom class
based on FrameworkElement is the only child element of the canvas, and the
scrollviewer seems to work as it should, although when I apply a
ScaleTransformation I'm not quite sure everything is behaving quite right.

Hope this helps,

Fred


"John Dunn" <JohnDunn@discussions.microsoft.com> wrote in message
news:BF51F2A0-076C-4F4D-9F75-81EE3BFC9ED5@microsoft.com...
> My application needs to draw a number of objects on the screen. Each of
> these
> objects can be moved, resized and edited by the user. An object is more
> complicated than just a rectangle - each one requires multiple drawing
> calls
> to render.
>
> Right now I have implemented a UIElement and added custom code to
> implement
> VisualChildrenCount and GetVisualChild but I'm not entirely sure if that's
> the most efficient way to accomplish what I need. I have a few questions
> that
> hopefully someone can help me with.
>
> 1. Is this the best way to go about this? There might be 100s of objects
> on
> screen at once. Some of the objects will be redrawn based on asynchronous
> network communication on the order of 10 or 20 times a second. Do
> DrawingVisuals require enough memory that I'd be better off doing my own
> object management and redraw logic? It seems like it'd be difficult to
> do - I
> don't see an obvious way to invalidate a portion of a DrawingVisual so I
> though having each object being a DrawingVisual might be a way around
> that.
>
> 2. If I redraw one of my objects will all objects need to be redrawn as
> well?
>
> 3. What's the proper way to implement Z-Order. Do I need to modify my
> VisualCollection so SendToBack sends it to the front of the list while
> SendToFront does the opposite?
>
> 4. Is there a way to make my UIElement have a 'background'? Right now the
> UIElement only gets MouseEvents where objects have been drawn. I've drawn
> a
> large rectangle as a background but that doesn't seem like the best
> solution
> to me.
>
> 5. What's required to get a ScrollViewer to work with my UIElement. I've
> placed it inside of the ScrollViewer but the scroll bars don't appear.
>
> Thanks-
>
> John Dunn



My System SpecsSystem Spec
Closed Thread
Update your Vista Drivers Update Your Drivers Now!!

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie has lots of questions - Please answer whichever you like species8350 Vista General 3 04-14-2007 05:41 PM
Problem with autosizing content when working at DrawingVisual level John Dunn Avalon 0 11-17-2006 12:10 PM
Commandbindings of UIelement viRtual Avalon 1 08-08-2006 10:59 PM
How to remove an uielement in a tabitem? wisenighthsu@ulead.com.tw Avalon 1 07-11-2006 07:20 AM
Loading an XAML file into a DrawingVisual John Dunn Avalon 3 06-22-2006 11:29 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51