Windows Presentation Foundation: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m Bot: Aggiungo: cs:Windows Presentation Foundation |
Nessun oggetto della modifica |
||
Riga 5:
WPF è basato su un sistema di [[grafica vettoriale]] che si appoggia alle [[DirectX]] per sfruttare l'accelerazione [[hardware]] delle moderne schede grafiche. WPF può essere impiegato per realizzare applicativi eseguibili anche all'interno del browser [[Microsoft Internet Explorer]] o di altri browser avanzati, purché sia presente il Framework. Il linguaggio usato per la creazione di una interfaccia utente in WPF è l'[[XAML]] (eXtensible Application Markup Language), basato su [[XML]].
==Architettura==
L'architettura di Windows Presentation Foundation si basa sia su codice gestito che su codice nativo. Comunque, le API pubbliche esposte sono disponibili soltato come codice gestito.
Mentre la maggior parte di WPF è in codice gestito, il motore di composizione che renderizza le applicazioni WPF è un componente nativo. Il suo nome è Media Integration Layer (MIL) e risiede in ''"milcore.dll"''. Esso si interfaccia direttamente con DirectX e provvede il supporto di base per le superfici 2D e 3D, la manipolazione controllata nel tempo dei contenuti di una superfice con una vista per esporre animazioni costruite ad alto livello, componendo gli elementi individuali di una applicazione WPF nella scena finale 3D che rappresenta la UI dell'applicazione e la renderizza sullo schermo. I media codec sono anche implemtntati come codice non gestito, e sono forniti da ''"windowscodecs.dll"''. Nella parte gestita PresentationCore (''"presentationcore.dll"'') fornisce un wrapper per MIL e implementa il cuore dei servizi per WPF, includendo un gestore delle proprietà che è consapevole delle dipendenze che esistono tra chi produce e chi consuma determinate proprietà, un sistema di dispatching per mezzo di un oggetto Dispatcher per implementare un sistema ad eventi specializzato e servizi i quali possono implementare un sistema di impaginazione legato alla dimensione degli elementi della UI. PresentationFramework (''"presentationframework.dll"'') implementa le novità incluse layouts, time-dependent, story-board based animations, and data binding.
<!--
WPF exposes a property system for objects which inherit from DependencyObject, that is aware of the dependencies between the consumers of the property, and can trigger actions based on changes in properties. Properties can be either hard coded values or expressions, which are specific expressions that evaluate to a result. In the initial release, however, the set of expressions supported is closed.[6] The value of the properties can be inherited from parent objects as well. WPF properties support change notifications, which invoke bound behaviors whenever some property of some element is changed. Custom behaviors can be used to propagate a property change notification across a set of WPF objects. This is used by the layout system to trigger a recalculation of the layout on property-changes, thus exposing a declarative programming style for WPF, whereby almost everything, from setting colors and positions to animating elements can be achieved by setting properties.[6] This allows WPF applications to be written in XAML, which is a declarative mark-up language, by binding the keywords and attributes directly to WPF classes and properties.
The UI elements of a WPF application are maintained as a class of Visual objects. Visual objects provide a managed interface to a composition tree which is maintained by Media Integration Layer (MIL). Each element of WPF creates and adds one or more composition nodes to the tree. The composition nodes contain rendering instructions, such as clipping and transformation instructions, along with other visual attributes. Thus the entire application is represented as a collection of composition nodes, which are stored in a buffer in the system memory. Periodically, MIL walks the tree and executes the rendering instructions in each node, thus compositing each element on to a DirectX surface, which is then rendered on screen. MIL uses the painter's algorithm, where all the components are rendered from back of the screen to the front, which allows complex effects like transparencies to be easily achieved. This rendering process is hardware accelerated using the GPU.[6] The composition tree is cached by MIL, creating a retained mode graphics, so that any changes to the composition tree needs only to be incrementally communicated to MIL. This also frees the applications of managing repainting the screen, MIL can do that itself as it has all the information necessary. Animations can be implemented as time-triggered changes to the composition tree. On the user visible side, animations are specified declaratively, by setting some animation effect to some element via a property and specifying the duration. The code-behind updates the specific nodes of the tree, via Visual objects, to represent both the intermediate states at specified time intervals as well as the final state of the element. MIL will render the changes to the element automatically.
All WPF applications start with two threads: one for managing the UI and another background thread for handling rendering and repainting.[7] Rendering and repainting is managed by WPF itself, without any developer intervention. The UI thread houses the Dispatcher (via an instance of DispatcherObject), which maintains a queue of UI operations that need to be performed (as a tree of Visual objects), sorted by priority. UI events, including changing a property that affects the layout, and user interaction events raised are queued up in the dispatcher, which invokes the handlers for the events. Microsoft recommends that the event handlers only update the properties to reflect new content for application responsiveness; the new content be generated or retrieved in a background thread.[7] The render thread picks up a copy of the visual tree and walks the tree calculating which components will be visible and renders them to Direct3D surfaces. The render thread also caches the visual tree, so only changes to the tree need to be communicated, which will result in updating only the changed pixels. WPF supports an extensible layout model. Layout is divided into two phases: Measure and Arrange. The Measure phase recursively calls all elements and determine the size they will take. In the Arrange phase, the child elements are recursively arranged by their parents, invoking the layout algorithm of the layout module in use.[6][8]
-->
[[Categoria:Microsoft Windows]]
|