c# - What is the difference between a UIElement and a Windows Form Control? -


if wanted create form drawing area in traditional windows form, extend panel class , override onpaint method custom drawing, so:

public class specialpanel : system.windows.forms.panel {     protected override void onpaint(painteventargs e)     {         graphics g = e.graphics;         g.drawellipse(new pen(color.red), 50, 80, 50, 10);      } } 

but in wpf if attempt extend canvas class there no onpaint method override

public class specialcanvas : canvas //error no onpaint method {     public override onpaint(painteventargs e)     {      } } 

if wanted draw canvas in way similar this:

        canvas.setleft(shape.shape, r.next(1, 1150));         canvas.settop(shape.shape, r.next(1, 500));         solidcolorbrush b = new solidcolorbrush(windows.ui.color.fromargb(255, (byte)r.next(1, 255), (byte)r.next(1, 255), (byte)r.next(1, 255)));         shape.shape.fill = b;         shape.shape.stroke = b;         cann.children.add(shape.shape); 

where cann canvas object , shape.shape rectangle.

my question is, fundamental differences between these methods of drawing form?

fundamental differences between wpf , gdi/gdi+

the windows presentation foundation (wpf) fundamentally different graphics device interface (gdi) , gdi+, requiring many aspects of programming approached in different way. topic briefly outlines major differences.

windows

applications built using gdi/gdi+ api use many windows, , reside under parent window (mdi). applications built in wpf have 1 window.

unit of measure

applications built gdi/gdi+ api use hardware pixel unit of measure. in these applications, resolution of display device increases, resulting image decreases. applications built in wpf use device-independent unit (1/96-inch) unit of measure. when dpi of system 96, 2 equivalent.

control positioning

applications built gdi+ use absolute positioning. when parent resized child elements not resized along it. applications built in wpf can use absolute, dynamic or data-bound positioning. either absolute or dynamic positioning controls positioned relative parent element.

image basis

images formed in gdi/gdi+ pixel-based, raster images. formed in wpf can scalable, vector images.

rendering engine

both gdi , gdi+ built on win32. gdi based on concept of device context, applications obtain handles device context, , use handles in order interact device. gdi+ wrapper around gdi creates c++ graphics object. wpf, on other hand, built on directx means can take advantage of hardware acceleration when performing drawing operations.

rendering mode

with gdi , gdi+, rendering uses immediate rendering: application repaints area becomes invalidated. in wpf, rendering uses retained rendering: application keeps track of drawing information system performs painting.

painting

with gdi , gdi+, clipping used determine bounds of area has become invalidated , needs painted. in wpf, painting performed front , components paint on each other.

pens , brushes

gdi , gdi+ use concept of current brush , current pen. in wpf, brush , pen must passed each drawing call.

paint region optimization

paint region optimization important part of painting gdi or gdi+. in wpf not considered.

events

gdi , gdi+ use events , event handler delegates using subscription/notification. wpf uses bubbling, tunneling, , direct event notification, , event travels , down visualtree.

video , audio

direct support video , audio not provided gdi+ or windows forms, must obtained through media player windows media player. wpf supports video , audio directly.

source: http://www.leadtools.com/help/leadtools/v18/dh/to/leadtools.topics~leadtools.topics.differencesbetweengdiandwpf.html


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -