Click or drag to resize
AB4D logo

DXView Class

DXView is a WPF control that can show scene rendered by DXScene. The rendered scene can be shown in WPF as a D3DImage (when using DirectXImage as PresentationType) or as DirectX overlay (when using DirectXOverlay).
Inheritance Hierarchy
SystemObject
  System.Windows.ThreadingDispatcherObject
    System.WindowsDependencyObject
      System.Windows.MediaVisual
        System.WindowsUIElement
          System.WindowsFrameworkElement
            Ab3d.DirectX.ControlsDXView
              Ab3d.DirectX.ControlsDXViewportView

Namespace: Ab3d.DirectX.Controls
Assembly: Ab3d.DXEngine.Wpf (in Ab3d.DXEngine.Wpf.dll) Version: 7.0.8865.1045
Syntax
C#
public abstract class DXView : FrameworkElement, 
	IDisposableDXResource, IDXResource, IDisposable

The DXView type exposes the following members.

Constructors
 NameDescription
Public methodDXView Constructor
Public methodDXView(DXDevice) Constructor
Public methodDXView(DXScene) Constructor
Public methodDXView(DXView, Boolean) Constructor of a child DXView that will render DXScene defined in the masterDXView.
Top
Properties
 NameDescription
Public propertyBackgroundColor Gets or sets a background color for DXView (this color is used to clear the DirectX back buffer). Default color is Transparent.
Public propertyChildDXViews When this DXView is a master DXView (some other DXView objects were created by passing this DXView in a constructor), then the method returns a list of child DXView objects. Otherwise null is returned.
Public propertyD3DHost Gets D3DHost control (set only when DirectXOverlay PresentationType is used)
Public propertyDisposables Disposables can be used to simply add IDisposable objects to a list that is automatically disposed when this object is disposed.
Public propertyDpiScaleX Gets or sets a double that represents a DPI scale factor in X direction: 1 means 96 DPI, 1.5 means 144 DPI, etc. (double.NaN is default value and means system default DPI setting - on loaded the double.NaN value is replaced by the system default DPI value).
Public propertyDpiScaleY Gets or sets a double that represents a DPI scale factor in Y direction: 1 means 96 DPI, 1.5 means 144 DPI, etc. (double.NaN is default value and means system default DPI setting - on loaded the double.NaN value is replaced by the system default DPI value).
Public propertyDXFinalPixelSize Gets size of shown rendering area in pixels (DXRenderSize is multiplied by DpiScale). In case of super-sampling this value is smaller than DXRenderPixelSize.
Public propertyDXImage Gets used DXImage control (set only when DirectXImage PresentationType is used)
Public propertyDXRenderPixelSize Gets size in pixels of back buffer that is used to render the 3D scene (DXRenderSize is multiplied by DpiScale and with SupersamplingFactor). To get size of shown rendering area in pixels (this size multiplied by dpi scale) see DXFinalPixelSize.
Public propertyDXRenderSize Gets size of shown rendering area in WPF units. To get size of shown rendering area in pixels (this size multiplied by dpi scale) see DXFinalPixelSize. To get size of back buffer that is used by rendering (this size multiplied by dpi scale and super-sampling factor, see the DXRenderPixelSize
Public propertyDXScene Gets used DXScene that contains the WPF scene converted into DXSceneNode objects
Public propertyGraphicsProfiles Gets or sets an array of GraphicsProfile objects that specify graphics settings that are supported by this DXView.
Public propertyId Gets a unique id of this component
Public propertyIsAutomaticallyUpdatingDXScene Gets or sets a Boolean that specifies if DXView is calling DXScene's Update (checking for changed in all SceneNodes) on every WPF's rendering event. When IsAutomaticallyUpdatingDXScene is set to false, this can improve performance but you need to manually call Update method after each change of the objects. Default value is true.
Public propertyIsDisposed Gets a Boolean that specifies if this resource has been disposed.
Public propertyIsSceneInitialized Gets a Boolean that specifies if the DXView has been initialized by InitializeScene method where DXScene was initialized with the UsedGraphicsProfile (also creates DXScene, DXDevice and other related objects).
Public propertyIsTransparencySortingEnabled Gets or sets a Boolean that specifies if sorting transparent objects by their distance to the camera is enabled. This property sets the DXScene.IsTransparencySortingEnabled property. Default value is false. See remarks for more info.
Public propertyIsWaitingInBackgroundUntilRendered Gets or sets a Boolean value that is used only when PresentationType is set to DirectXImage. In DirectXImage presentation type the DXEngine needs to wait until graphics card finish rendering the scene. Then the engine can inform (invalidate) the WPF's D3DImage that the shared texture is prepared. When IsWaitingInBackgroundUntilRendered property is true (by default) then the CompleteRenderingStep is not waiting on the main thread. Instead the waiting is done on the background thread and when it is completed then the invalidation is done on the main thread. When IsWaitingInBackgroundUntilRendered is false, then the waiting is done on the main thread.
Public propertyMasterDXView When MasterDXView is set, then this DXView is a child DXView and renders the 3D scene defined in the masterDXView.DXScene.
Public propertyPresentationType Gets or sets an enum that specifies how the 3D scene is presented to the WPF rendering engine. Default value is DirectXImage.
Public propertyUsedGraphicsProfile Gets a GraphicsProfile that is used by DXView.
Top
Methods
 NameDescription
Public methodBeginInit BeginInit begins initializing the DXView. The DXView will not render the scene until the EndInit is calls. This allows to make multiple changes without rendering the scene after each change.
(Overrides FrameworkElementBeginInit)
Public methodStatic memberCollect3DObjectNames Collect3DObjectNames gets names of all internal fields in parentObject that contains internal fields defined in XAML (for example Window or UserControl) that are derived from Visual3D, Model3D or DXSceneViewChild and stores them in Dictionary of object as key and object name as value.
Public methodCreateObjectNames CreateObjectNames uses reflection on parentObject (Window or UserControl) to get the names of internal fields that are created from XAML. This method calls Collect3DObjectNames method.
Public methodDispose Dispose
Public methodDumpRenderingSteps Writes string that contains details about all RenderingSteps in the DXScene that is used to render this DXView to the console (when the application is debugged in Visual Studio the string is written to Output window). When using child DXViews, then their RenderingSteps are written too.
Public methodEndInit EndInit needs to be called after BeginInit was called for the changes to take effect.
(Overrides FrameworkElementEndInit)
Public methodStatic memberGetDpiScale Returns the dpiScaleX and dpiScaleY of the specified WPF visual (can be window or any other WPF control).
Public methodStatic memberGetDXAttributeCollection Gets the value of the DXAttributeCollectionProperty from the specified element
Public methodGetRenderingStepsDumpString Returns string that contains details about all RenderingSteps in the DXScene that is used to render this DXView. When using child DXViews, then their RenderingSteps are shown too.
Public methodGetSceneNodeForWpfObject GetSceneNodeForWpfObject returns the SceneNode in DXScene that was created to represent the wpfObject. The method returns null if SceneNode is not found.
Public methodInitializeScene Initialize the DXScene or WPF 3D. This method is usually called in DXView Loaded event but it can be called manually before Loaded event to create the DXScene, DXDevice and other related objects.
Public methodLogUserMessage LogUserLabel can be used to add custom user message to DXEngine log file. This method work only with debug DXEngine build and with enabled logging. It added the "USER MESSAGE: " prefix to log entry.
Public methodRefresh Forces update and rendering of the scene
Public methodRenderScene(Boolean) RenderScene rendered the scene. If forceUpdate is false (by default) then the scene is rendered only if there are any changes in the scene nodes.
Public methodRenderScene(Boolean, Boolean) RenderScene rendered the scene. If forceRender is false then the scene is rendered only if there are any changes in the scene nodes. If forceUpdate is true then the RenderingQueues are always regenerated (otherwise RenderingQueues are regenerated only when this is required because of the changes).
Public methodRenderToBitmap RenderToBitmap renders the 3D scene to bitmap. The size of the bitmap is the same as the current size of this DXView.DXRenderPixelSize. See also other overrides of RenderToBitmap method: RenderToBitmap(Int32, Int32, Int32, Int32, Boolean), RenderToBitmap(Int32, Int32, Int32, Double, Double), RenderToBitmap(Int32, Int32, Int32, Int32, Double, Double, Boolean), RenderToBitmap(WriteableBitmap, Int32, Int32), RenderToBitmap(DXViewRenderedBitmapReadyDelegate, Int32, Int32, Int32, Int32, Double, Double, Boolean).
Public methodRenderToBitmap(WriteableBitmap, Int32, Int32) RenderToBitmap renders the 3D scene the specified WriteableBitmap. See also other overrides of RenderToBitmap method: RenderToBitmap, RenderToBitmap(Int32, Int32, Int32, Int32, Boolean), RenderToBitmap(Int32, Int32, Int32, Double, Double), RenderToBitmap(Int32, Int32, Int32, Int32, Double, Double, Boolean), RenderToBitmap(DXViewRenderedBitmapReadyDelegate, Int32, Int32, Int32, Int32, Double, Double, Boolean).
Public methodRenderToBitmap(Int32, Int32, Int32, Double, Double) RenderToBitmap renders the 3D scene to bitmap with specified width, height, multi-sampling and super-sampling count and DPI. See also other overrides of RenderToBitmap method: RenderToBitmap, RenderToBitmap(Int32, Int32, Int32, Int32, Boolean), RenderToBitmap(Int32, Int32, Int32, Int32, Double, Double, Boolean), RenderToBitmap(WriteableBitmap, Int32, Int32), RenderToBitmap(DXViewRenderedBitmapReadyDelegate, Int32, Int32, Int32, Int32, Double, Double, Boolean).
Public methodRenderToBitmap(Int32, Int32, Int32, Int32, Boolean) RenderToBitmap renders the 3D scene to bitmap with specified width, height, multi-sampling count and DPI. See also other overrides of RenderToBitmap method: RenderToBitmap, RenderToBitmap(Int32, Int32, Int32, Double, Double), RenderToBitmap(Int32, Int32, Int32, Int32, Double, Double, Boolean), RenderToBitmap(WriteableBitmap, Int32, Int32), RenderToBitmap(DXViewRenderedBitmapReadyDelegate, Int32, Int32, Int32, Int32, Double, Double, Boolean).
Public methodRenderToBitmap(Int32, Int32, Int32, Int32, Double, Double, Boolean) RenderToBitmap renders the 3D scene to bitmap with specified width, height, multi-sampling and super-sampling count and DPI. See also other overrides of RenderToBitmap method: RenderToBitmap, RenderToBitmap(Int32, Int32, Int32, Int32, Boolean), RenderToBitmap(Int32, Int32, Int32, Double, Double), RenderToBitmap(WriteableBitmap, Int32, Int32).
Public methodRenderToBitmap(DXViewRenderedBitmapReadyDelegate, Int32, Int32, Int32, Int32, Double, Double, Boolean) RenderToBitmap renders the 3D scene and then calls the specified renderedBitmapReadyCallback where user can copy rendered bitmap from the mapped GPU mapped memory to main memory. See remarks for a code sample for a OnRenderedBitmapReady method. See also other overrides of RenderToBitmap method: RenderToBitmap, RenderToBitmap(Int32, Int32, Int32, Int32, Boolean), RenderToBitmap(Int32, Int32, Int32, Double, Double), RenderToBitmap(Int32, Int32, Int32, Int32, Double, Double, Boolean).
Public methodStatic memberSetDXAttributeCollection Sets the DXAttributeCollectionProperty to the specified element
Public methodSetObjectNames(DictionaryObject, String) SetObjectNames sets a dictionary with object as key and name as value that can be used to name the created SceneNodes. This method must be called before the RootNode is created.
Public methodSetObjectNames(DictionaryString, Object) SetObjectNames sets a dictionary with object as key and name as value that can be used to name the created SceneNodes. This method must be called before the RootNode is created.
Public methodUpdate Update method checks all child SceneNodes and checks if any changes has been created and if rendering is required.
Top
Events
 NameDescription
Public eventDefaultSystemAdapterChanged DefaultSystemAdapterChanged event is triggered when the default system adapter (the primary system GPU) is changed. This means that it is not longer possible to share a DXEngine's texture with WPF. DXEngine will need to switch to WritableBitmap that is much slower than shared texture because the rendered scene needs to be copied from GPU memory to to CPU memory. In this case it is recommended to save the current scene, dispose the DXViewportView and create a new DXViewportView that will use the new graphics card.
Public eventDisposing Occurs when when Dispose is called.
Public eventDXRenderSizeChanged Called when the size of the rendering area is changed. Also called after the back buffers are initialized for the first time.
Public eventDXSceneDeviceCreated Called when the DXScene and DirectX 11 device have been created and when UsedGraphicsProfile was set, but before it is fully initialized (DXImage, D3DHOst, DirectX buffers and views are not created yet). This method can be used to change some properties the created DXScene object that is set to the DXScene property. Once all the DirectX objects has been initialized (all the buffers and views are created), the DXSceneInitialized event is triggered. Note that when DXScene is not created because a WPF 3D rendering is used, then the Wpf3DRenderingInitialized event is called.
Public eventDXSceneInitialized Called after the DXScene has been fully initialized - the device, buffers and views are created. In Wpf3D mode the event is triggered after the Wpf3D has been initialized. To be notified after the DXScene, DirectX device and UsedGraphicsProfile would be set and before the DirectX buffers and views are created, use the DXSceneDeviceCreated event.
Public eventGraphicsProfileRejected GraphicsProfileRejected event is fired when a GraphicsProfile is rejected.
Public eventSceneRendered Called after the scene has been rendered (with WPF 3D rendering this is called from CompositionTarget.Rendering event handler.
Public eventSceneUpdating Called when the scene is being updated and before it is rendered.
Public eventWpf3DRenderingInitialized Wpf3DRenderingInitialized event is called when WPF 3D rendering graphics profile is initialized. This rendering profile can be selected because user selected this profile (Wpf3D was the only profile in the GraphicsProfiles collection) or because no DirectX 11 rendering can be initialized (usually because of the problems with the drivers or some other problems). When a DirectX 11 rendering is initialized, then the DXSceneDeviceCreated event is called.
Top
Fields
 NameDescription
Public fieldStatic memberBackgroundColorProperty BackgroundColorProperty
Public fieldStatic memberDefaultGraphicsProfiles Gets an array of GraphicsProfile that are used by default.
Public fieldStatic memberDXAttributeCollectionProperty DXAttributeCollectionProperty is a DependencyProperty that is used to add DXEngine's attributes to WPF objects.
Public fieldStatic memberRootDXSceneViewNodeName Gets the name of the Root node name
Top
Attached Properties
 NameDescription
Public propertyDXAttributeCollection DXAttributeCollectionProperty is a DependencyProperty that is used to add DXEngine's attributes to WPF objects.
Top
See Also