Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

480 483


Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

480 483

  1. 1. ISSN: 2278 – 1323 International Journal of Advanced Research in Computer Engineering & Technology Volume 1, Issue 4, June 2012 Application Development Using WPF Shirish Patil, Sameer Soni, Pranali Dhete and Dr B.B. Meshram VJTI, Mumbai, India Email: VJTI, Mumbai, India Email: VJTI, Mumbai, India Email: soni.sameer88@gmail.comABSTRACTThe paper focuses on the application development using WPF. It covers the overall architecture of WPF.The programming models of the WPF shows how code and XAML is separated and how XAML objectscan be accessed. We already have display technologies User32, GDI,GDI+,DirectX but still manydevelopers go for WPF because these display technologies have their own limitations, that are overcomein WPF. Paper also focuses on hardware acceleration using WPF.Keywords-- WPF, XAML, Display Technology, DirectX I.NTRODUCTIONWindows Presentation Foundation (WPF) is thenew presentation API in WinFX. WPF represents amajor step forward in User Interface technology.WPF is a two and three dimensional graphicsengine. It has the all equivalent common usercontrols like buttons, check boxes sliders etc. It hasfixed and flow format documents. WPF has all ofthe capabilities of HTML and Flash. It has 2D and3D vector graphics, animation, multimedia as welldata binding capabilities. WPF supports XAML,XAML is a declarative XML-based language bywhich user can define object and properties inXML. XAML document is loaded by a XAMLparser. XAML parser instantiates objects and settheir properties. XAML describes objects,properties and there relation in between them.Using XAML, user can create any kind of objectsthat means graphical or non-graphical. WPF parsesthe XAML document and instantiates the objectsand creates the relation as defined by XAML. Inother words XAML is a XML document whichdefines objects and properties and WPF loads thisdocument in actual memory. Fig. 1 Architecture of WPF II. ARCHITECTURE OF WPF Above figure shows the overall architecture ofAll WPF applications start with two threads, one WPF. It has three major sections Presentation core,for managing the UI and another background Presentation framework and Media Integrationthread for handling the rendering and repainting. layer (milcore). Milcore is written in unmanagedRendering and repainting is managed by WPF code in order to enable tight integration withitself. Fig 1. Shows the architecture of WPF. DirectX. DirectX engine is responsible for all display in WPF, allowing for efficient hardware and software rendering. 480 All Rights Reserved © 2012 IJARCET
  2. 2. ISSN: 2278 – 1323 International Journal of Advanced Research in Computer Engineering & Technology Volume 1, Issue 4, June 2012Managed Layer: - The public API exposed is only script allowed in XAML only. Real applicationsvia this layer. Majority of WPF is in managed code. require event handling, data access, calling services, accessing files, etc., which requirePresentation Framework:- It holds the top level programmatic code. Also user can embed C# or VBWPF elements, including those that represents code in script blocks within XAML. It mustwindows, controls, panels, styles etc. It also compile into assembly. It provides Loseimplements the end user presentation featureincluding time dependent, story based animations IntelliSense, colour coding, and compile timeand data binding. checking.Presentation Core: Presentation Core provides a Code Only:-In this model WPF objects are allmanaged wrapper for MIL and implements the core defined as .NET classes. Users can instantiate usingservices for WPF such as UI Element and visual a programming model similar to Windows Forms.from which all shapes and controls derived in It is instructive for understanding WPF, notPresentation Framework. practical for real world development. It is not productive. In this model design tools will all beWindows Base:- Windows Base hold more basic based on XAML mark-up. Element hierarchy canelements which are capable to be reused outside the be more compactly and cleanly represented inWPF environment like Dispatcher objects andDependency object. XAML XAML and Code :- XAML very expressive forUnmanaged Layer:-This layer mainly consist ofmilCore and windows code. static layout of UI and initial configuration of properties. It is human readable. It is easier formilCore:- The composition engine is the native tools to parse. Programmatic code needed forcomponent of WPF application. It is called as dynamic behaviour of applications.Media Integration Layer. The purpose of themilCore is to interface directly with DirecX and XAML and Code Separationprovide basic support for 2D and 3D surface.It isinterface between DirectX and CLR. The most important features of WPF, separating the XAML from the code to be handled. So designersWindows Codes: Windows code is low level API can independently work on the presentation of thewhich is used for imaging support in WPF application and developers can actually write theapplications like image processing, scaling etc. It code logic independent of how the presentation is.comprises of a number of codes whichencode/decodes images into vector graphics thatwould be rendered into WPF screenCore Operating System LayerUser32:- It decides which goes where on thescreen. It is the primary core API which everyapplication uses. User32 actually manages memoryand process separation.DirectX: - As said previously WPF uses directXinternally. DirectX talks with drivers and rendersthe content. DirectX is the low level API throughwhich WPF renders all graphics. Fig 2 XMAL code III. WPF PROGRAMMING MODELXAML only:-In this model user can load rawXAML “pages” into Internet Explorer. No designtime compilation required. Limited set offunctionality is available. It supports static content,data binding, and animations. No code behind or 481 All Rights Reserved © 2012 IJARCET
  3. 3. ISSN: 2278 – 1323 International Journal of Advanced Research in Computer Engineering & Technology Volume 1, Issue 4, June 2012 IV. WPF and Other Display Technologies We already have User32, GDI, GDI+, DirectX but still we go for WPF because these display technologies have their own limitations, that limitations are overcome in WPF. User32:- This provides the windows look and feel for buttons and textboxes and other UI elements. User32 lacked drawing capabilities. Fig 3 Code behind File GDI (Graphics device interface):- GDI not only provided drawing capabilities but also provided aAbove is the code snippet, which shows a XAML high level of abstraction on the hardware display.Infile and the code completely detached from the other words it encapsulates all complexities ofXAML presentation.Number 1 indicates same class hardware in the GDI i.e. MainWindow and number 2 indicatessame method name i.e. button1_Click. In order to GDI+:- GDI+ which basically extends GDI andassociate a class with XAML file user need to provides extra functionalities like jpg and PNGspecify the x: Class attribute. Any event specified support, gradient shading and anti-aliasing. Theon the XAML object can be connected by defining biggest issue with GDI API was it did not usea method with sender and event values. User can hardware acceleration and did not have animationsee from the above code snippet we have linked the and 3D support.MyClickEvent to an event in the behind code.To access XAML objects in behind code user just DirectX: - The issue of hardware acceleration isneed to define them with the same name as given in solved in DirectX. DirectX exploited hardwarethe XAML document. For instance in the below acceleration, had support for 3D, full colourcode snippet we named the object as objtext and graphics, media streaming facility and lot more.the object is defined with the same name in the This API no matured when it comes to gamingbehind code. industry. WPF: - WPF stands on the top of directX you can not only build simple UI elements but also go one step further and develop special UI elements like Grid, Flow Document, and Ellipse. In other words WPF is a wrapper which is built over DirectX. Still for game development DirectX is used. But for slight animation WPF is the best option. V. Hardware acceleration with WPF Hardware acceleration is a process in which we use hardware to perform some functions rather than performing those functions using the software which is running in the CPU. WPF exploits hardware acceleration in a two tier manner. WPF API first detects the level of hardware acceleration using parameters like RAM of video card, per pixel value etc. Depending on that it either uses Tier 0, Tier 1 or Tier 2 Rendering mode. Fig 4 Accessing XAML object 482 All Rights Reserved © 2012 IJARCET
  4. 4. ISSN: 2278 – 1323 International Journal of Advanced Research in Computer Engineering & Technology Volume 1, Issue 4, June 2012 VII.REFERENCES [1]. G Trygve M. H. Reenskaug, “MVC XEROX PARC1978-79”(undated). index.html [2]. Trygve Reenskaug - MODELS - VIEWS – CONTROLLERS. 12-MVC.pdf [3]. Introduction to WPF .NET Framework 4. us/library/aa970268.aspx [4]. XAML in WPF. us/library/ms747122.aspx [5]. Introduction to Model/View/ViewModel pattern for building WPF apps – John Gossman. /10/08/478683.aspx [6]. Steve Burbeck, “Applications Programming in Smalltalk-80(TM): How to use Model-View- Fig. 5 Hardware acceleration in WPF Controller (MVC)”, March 4, 1997. http://st-Tier 0:- If the video card does not support hardware then WPF uses Tier 0 rendering mode. [7] Mike Potel, “MVP: Model-View-Presenter TheIn other words it uses software acceleration. This Taligent Programming Model for C++ and Java”.corresponds to working of DirectX version less TaligentInc1996.than 7.0. [8].Microsoft Corporation. “Model View PresentterTier 1:- If the video card supports partial hardware Pattern” (undated).acceleration then WPF uses Tier 1 rendering mode. corresponds to working of DirectX versionbetween 7.0 And 9.0. us/library/cc304760.aspx [9]. Microsoft Corporation, “Introducing WindowsTier 2:- If the video card supports hardware Presentation Foundation” (undated).acceleration then WPF uses Tier 2 rendering mode. corresponds to working of DirectX version spxequal or greater than 9.0. [10]. Microsoft Corporation, “XAML Overview” (undated). VI.CONCLUSION us/library/ms752059.aspx Paper describes the overall architecture of WPF.How code is separated from XAML. Programming [11]. Arlen Feldman, Maxx Daymon, “WPF inmodel shows separation of code behind and Action with Visual Studio 2008”. ManningXAML, which is very useful for the WPF Publications Co, 2009, pp 283-285.developers. Paper shows how WPF is better than [12]. Flexible GUI in Robotics Applications Usingother display technologies.WPF has the ability to Windows Presentation Foundation Framework andmake very rich UIs. Using WPF to achieve Model View ViewModel Pattern - Fran Jarnjak,animation and special effects are easier. Hardware IEEE 2010acceleration is better as compared to other displaytechnologies. [13]. Ergonomics Research and CNC machine tools in the interface design of the application - IEEE 2008 483 All Rights Reserved © 2012 IJARCET