Table of Contents

Class CameraController

Namespace
HelixToolkit.Wpf
Assembly
HelixToolkit.Wpf.dll

Provides a control that manipulates the camera by mouse and keyboard gestures.

public class CameraController : Grid, IAnimatable, ISupportInitialize, IFrameworkInputElement, IInputElement, IQueryAmbient, IAddChild
Inheritance
CameraController
Implements
Inherited Members
Extension Methods

Constructors

CameraController()

Initializes a new instance of the CameraController class.

public CameraController()

Fields

CameraModeProperty

Identifies the CameraMode dependency property.

public static readonly DependencyProperty CameraModeProperty

Field Value

DependencyProperty

CameraProperty

Identifies the Camera dependency property.

public static readonly DependencyProperty CameraProperty

Field Value

DependencyProperty

CameraRotationModeProperty

Identifies the CameraRotationMode dependency property.

public static readonly DependencyProperty CameraRotationModeProperty

Field Value

DependencyProperty

ChangeFieldOfViewCursorProperty

Identifies the ChangeFieldOfViewCursor dependency property.

public static readonly DependencyProperty ChangeFieldOfViewCursorProperty

Field Value

DependencyProperty

DefaultCameraProperty

Identifies the DefaultCamera dependency property.

public static readonly DependencyProperty DefaultCameraProperty

Field Value

DependencyProperty

EnabledProperty

Identifies the Enabled dependency property.

public static readonly DependencyProperty EnabledProperty

Field Value

DependencyProperty

FixedRotationPointEnabledProperty

Identifies the FixedRotationPointEnabled dependency property.

public static readonly DependencyProperty FixedRotationPointEnabledProperty

Field Value

DependencyProperty

FixedRotationPointProperty

Identifies the FixedRotationPoint dependency property.

public static readonly DependencyProperty FixedRotationPointProperty

Field Value

DependencyProperty

InertiaFactorProperty

Identifies the InertiaFactor dependency property.

public static readonly DependencyProperty InertiaFactorProperty

Field Value

DependencyProperty

InfiniteSpinProperty

Identifies the InfiniteSpin dependency property.

public static readonly DependencyProperty InfiniteSpinProperty

Field Value

DependencyProperty

IsChangeFieldOfViewEnabledProperty

Identifies the IsChangeFieldOfViewEnabled dependency property.

public static readonly DependencyProperty IsChangeFieldOfViewEnabledProperty

Field Value

DependencyProperty

IsInertiaEnabledProperty

Identifies the IsInertiaEnabled dependency property.

public static readonly DependencyProperty IsInertiaEnabledProperty

Field Value

DependencyProperty

IsMoveEnabledProperty

Identifies the IsMoveEnabled dependency property.

public static readonly DependencyProperty IsMoveEnabledProperty

Field Value

DependencyProperty

IsPanEnabledProperty

Identifies the IsPanEnabled dependency property.

public static readonly DependencyProperty IsPanEnabledProperty

Field Value

DependencyProperty

IsRotationEnabledProperty

Identifies the IsRotationEnabled dependency property.

public static readonly DependencyProperty IsRotationEnabledProperty

Field Value

DependencyProperty

IsTouchZoomEnabledProperty

Identifies the IsTouchZoomEnabled dependency property.

public static readonly DependencyProperty IsTouchZoomEnabledProperty

Field Value

DependencyProperty

IsZoomEnabledProperty

Identifies the IsZoomEnabled dependency property.

public static readonly DependencyProperty IsZoomEnabledProperty

Field Value

DependencyProperty

LeftRightPanSensitivityProperty

Identifies the LeftRightPanSensitivity dependency property.

public static readonly DependencyProperty LeftRightPanSensitivityProperty

Field Value

DependencyProperty

LeftRightRotationSensitivityProperty

Identifies the LeftRightRotationSensitivity dependency property.

public static readonly DependencyProperty LeftRightRotationSensitivityProperty

Field Value

DependencyProperty

LookAtChangedEvent

The look at (target) point changed event

public static readonly RoutedEvent LookAtChangedEvent

Field Value

RoutedEvent

MaximumFieldOfViewProperty

Identifies the MaximumFieldOfView dependency property.

public static readonly DependencyProperty MaximumFieldOfViewProperty

Field Value

DependencyProperty

MinimumFieldOfViewProperty

Identifies the MinimumFieldOfView dependency property.

public static readonly DependencyProperty MinimumFieldOfViewProperty

Field Value

DependencyProperty

ModelUpDirectionProperty

Identifies the ModelUpDirection dependency property.

public static readonly DependencyProperty ModelUpDirectionProperty

Field Value

DependencyProperty

MoveSensitivityProperty

Identifies the MoveSensitivity dependency property.

public static readonly DependencyProperty MoveSensitivityProperty

Field Value

DependencyProperty

PageUpDownZoomSensitivityProperty

Identifies the PageUpDownZoomSensitivity dependency property.

public static readonly DependencyProperty PageUpDownZoomSensitivityProperty

Field Value

DependencyProperty

PanCursorProperty

Identifies the PanCursor dependency property.

public static readonly DependencyProperty PanCursorProperty

Field Value

DependencyProperty

RotateAroundMouseDownPointProperty

Identifies the RotateAroundMouseDownPoint dependency property.

public static readonly DependencyProperty RotateAroundMouseDownPointProperty

Field Value

DependencyProperty

RotateCursorProperty

Identifies the RotateCursor dependency property.

public static readonly DependencyProperty RotateCursorProperty

Field Value

DependencyProperty

RotationSensitivityProperty

Identifies the RotationSensitivity dependency property.

public static readonly DependencyProperty RotationSensitivityProperty

Field Value

DependencyProperty

ShowCameraTargetProperty

Identifies the ShowCameraTarget dependency property.

public static readonly DependencyProperty ShowCameraTargetProperty

Field Value

DependencyProperty

SnapMouseDownPointProperty

Identifies the SnapMouseDownPoint dependency property.

public static readonly DependencyProperty SnapMouseDownPointProperty

Field Value

DependencyProperty

SpinReleaseTimeProperty

Identifies the SpinReleaseTime dependency property.

public static readonly DependencyProperty SpinReleaseTimeProperty

Field Value

DependencyProperty

UpDownPanSensitivityProperty

Identifies the UpDownPanSensitivity dependency property.

public static readonly DependencyProperty UpDownPanSensitivityProperty

Field Value

DependencyProperty

UpDownRotationSensitivityProperty

Identifies the UpDownRotationSensitivity dependency property.

public static readonly DependencyProperty UpDownRotationSensitivityProperty

Field Value

DependencyProperty

ViewportProperty

Identifies the Viewport dependency property.

public static readonly DependencyProperty ViewportProperty

Field Value

DependencyProperty

ZoomAroundMouseDownPointProperty

Identifies the ZoomAroundMouseDownPoint dependency property.

public static readonly DependencyProperty ZoomAroundMouseDownPointProperty

Field Value

DependencyProperty

ZoomCursorProperty

Identifies the ZoomCursor dependency property.

public static readonly DependencyProperty ZoomCursorProperty

Field Value

DependencyProperty

ZoomRectangleCursorProperty

Identifies the ZoomRectangleCursor dependency property.

public static readonly DependencyProperty ZoomRectangleCursorProperty

Field Value

DependencyProperty

ZoomSensitivityProperty

Identifies the ZoomSensitivity dependency property.

public static readonly DependencyProperty ZoomSensitivityProperty

Field Value

DependencyProperty

ZoomedByRectangleEvent

The zoomed by rectangle event

public static readonly RoutedEvent ZoomedByRectangleEvent

Field Value

RoutedEvent

Properties

ActualCamera

Gets ActualCamera.

public ProjectionCamera? ActualCamera { get; }

Property Value

ProjectionCamera

BackViewCommand

Gets the back view command.

public static RoutedCommand BackViewCommand { get; }

Property Value

RoutedCommand

BottomViewCommand

Gets the bottom view command.

public static RoutedCommand BottomViewCommand { get; }

Property Value

RoutedCommand

Camera

Gets or sets Camera.

public ProjectionCamera Camera { get; set; }

Property Value

ProjectionCamera

CameraLookDirection

Gets or sets CameraLookDirection.

public Vector3D CameraLookDirection { get; set; }

Property Value

Vector3D

CameraMode

Gets or sets CameraMode.

public CameraMode CameraMode { get; set; }

Property Value

CameraMode

CameraPosition

Gets or sets CameraPosition.

public Point3D CameraPosition { get; set; }

Property Value

Point3D

CameraRotationMode

Gets or sets CameraRotationMode.

public CameraRotationMode CameraRotationMode { get; set; }

Property Value

CameraRotationMode

CameraTarget

Gets or sets CameraTarget.

public Point3D CameraTarget { get; set; }

Property Value

Point3D

CameraUpDirection

Gets or sets CameraUpDirection.

public Vector3D CameraUpDirection { get; set; }

Property Value

Vector3D

ChangeFieldOfViewCommand

Gets the change field of view command.

public static RoutedCommand ChangeFieldOfViewCommand { get; }

Property Value

RoutedCommand

ChangeFieldOfViewCursor

Gets or sets the change field of view cursor.

public Cursor ChangeFieldOfViewCursor { get; set; }

Property Value

Cursor

The change field of view cursor.

ChangeLookAtCommand

Gets the change look at command.

public static RoutedCommand ChangeLookAtCommand { get; }

Property Value

RoutedCommand

DefaultCamera

Gets or sets the default camera (used when resetting the view).

public ProjectionCamera DefaultCamera { get; set; }

Property Value

ProjectionCamera

The default camera.

Enabled

Gets or sets a value indicating whether Enabled.

public bool Enabled { get; set; }

Property Value

bool

FixedRotationPoint

Gets or sets a value indicating the center of rotation.

public Point3D FixedRotationPoint { get; set; }

Property Value

Point3D

true if rotation around a fixed point is enabled; otherwise, false .

FixedRotationPointEnabled

Gets or sets a value indicating whether to rotate around a fixed point.

public bool FixedRotationPointEnabled { get; set; }

Property Value

bool

true if rotation around a fixed point is enabled; otherwise, false .

FrontViewCommand

Gets the front view command.

public static RoutedCommand FrontViewCommand { get; }

Property Value

RoutedCommand

InertiaFactor

Gets or sets InertiaFactor.

public double InertiaFactor { get; set; }

Property Value

double

InfiniteSpin

Gets or sets a value indicating whether InfiniteSpin.

public bool InfiniteSpin { get; set; }

Property Value

bool

IsActive

Gets a value indicating whether IsActive.

public bool IsActive { get; }

Property Value

bool

IsChangeFieldOfViewEnabled

Gets or sets a value indicating whether field of view can be changed.

public bool IsChangeFieldOfViewEnabled { get; set; }

Property Value

bool

IsInertiaEnabled

Gets or sets a value indicating whether inertia is enabled for the camera manipulations.

public bool IsInertiaEnabled { get; set; }

Property Value

bool

true if inertia is enabled; otherwise, false.

IsMoveEnabled

Gets or sets a value indicating whether move is enabled.

public bool IsMoveEnabled { get; set; }

Property Value

bool

true if move is enabled; otherwise, false .

IsOrthographicCamera

Gets a value indicating whether IsOrthographicCamera.

protected bool IsOrthographicCamera { get; }

Property Value

bool

IsPanEnabled

Gets or sets a value indicating whether pan is enabled.

public bool IsPanEnabled { get; set; }

Property Value

bool

IsPerspectiveCamera

Gets a value indicating whether IsPerspectiveCamera.

protected bool IsPerspectiveCamera { get; }

Property Value

bool

IsRotationEnabled

Gets or sets a value indicating whether IsRotationEnabled.

public bool IsRotationEnabled { get; set; }

Property Value

bool

IsTouchZoomEnabled

Gets or sets a value indicating whether touch zoom (pinch gesture) is enabled.

public bool IsTouchZoomEnabled { get; set; }

Property Value

bool

true if touch zoom is enabled; otherwise, false .

IsZoomEnabled

Gets or sets a value indicating whether IsZoomEnabled.

public bool IsZoomEnabled { get; set; }

Property Value

bool

LeftRightPanSensitivity

Gets or sets the sensitivity for pan by the left and right keys.

public double LeftRightPanSensitivity { get; set; }

Property Value

double

The pan sensitivity.

Remarks

Use -1 to invert the pan direction.

LeftRightRotationSensitivity

Gets or sets the sensitivity for rotation by the left and right keys.

public double LeftRightRotationSensitivity { get; set; }

Property Value

double

The rotation sensitivity.

Remarks

Use -1 to invert the rotation direction.

LeftViewCommand

Gets the left view command.

public static RoutedCommand LeftViewCommand { get; }

Property Value

RoutedCommand

LimitFPS

Gets or sets a value indicating whether [limit FPS].

public bool LimitFPS { get; set; }

Property Value

bool

true if [limit FPS]; otherwise, false.

MaximumFieldOfView

Gets or sets the maximum field of view.

public double MaximumFieldOfView { get; set; }

Property Value

double

The maximum field of view.

MinimumFieldOfView

Gets or sets the minimum field of view.

public double MinimumFieldOfView { get; set; }

Property Value

double

The minimum field of view.

ModelUpDirection

Gets or sets the model up direction.

public Vector3D ModelUpDirection { get; set; }

Property Value

Vector3D

MoveSensitivity

Gets or sets the move sensitivity.

public double MoveSensitivity { get; set; }

Property Value

double

The move sensitivity.

OrthographicCamera

Gets OrthographicCamera.

protected OrthographicCamera? OrthographicCamera { get; }

Property Value

OrthographicCamera

PageUpDownZoomSensitivity

Gets or sets the sensitivity for zoom by the page up and page down keys.

public double PageUpDownZoomSensitivity { get; set; }

Property Value

double

The zoom sensitivity.

Remarks

Use -1 to invert the zoom direction.

PanCommand

Gets the pan command.

public static RoutedCommand PanCommand { get; }

Property Value

RoutedCommand

PanCursor

Gets or sets the pan cursor.

public Cursor PanCursor { get; set; }

Property Value

Cursor

The pan cursor.

PerspectiveCamera

Gets PerspectiveCamera.

protected PerspectiveCamera? PerspectiveCamera { get; }

Property Value

PerspectiveCamera

ResetCameraCommand

Gets the reset camera command.

public static RoutedCommand ResetCameraCommand { get; }

Property Value

RoutedCommand

RightViewCommand

Gets the right view command.

public static RoutedCommand RightViewCommand { get; }

Property Value

RoutedCommand

RotataAroundClosestVertexComplexity

Efficiency option, lower values decrease computation time for camera interaction when RotateAroundMouseDownPoint or ZoomAroundMouseDownPoint is set to true in inspect mode. Note: Will mostly save on computation time once the bounds are already calculated and cashed within the MeshGeometry3D.

public int RotataAroundClosestVertexComplexity { get; set; }

Property Value

int

RotateAroundMouseDownPoint

Gets or sets a value indicating whether to rotate around the mouse down point.

public bool RotateAroundMouseDownPoint { get; set; }

Property Value

bool

true if rotation around the mouse down point is enabled; otherwise, false .

RotateCommand

Gets the rotate command.

public static RoutedCommand RotateCommand { get; }

Property Value

RoutedCommand

RotateCursor

Gets or sets the rotate cursor.

public Cursor RotateCursor { get; set; }

Property Value

Cursor

The rotate cursor.

RotationSensitivity

Gets or sets the rotation sensitivity (degrees/pixel).

public double RotationSensitivity { get; set; }

Property Value

double

The rotation sensitivity.

ShowCameraTarget

Gets or sets a value indicating whether to show a target adorner when manipulating the camera.

public bool ShowCameraTarget { get; set; }

Property Value

bool

SnapMouseDownPoint

Gets or sets a value indicating whether to snap the mouse down point to a model.

public bool SnapMouseDownPoint { get; set; }

Property Value

bool

true if snapping the mouse down point is enabled; otherwise, false .

SpinReleaseTime

Gets or sets the max duration of mouse drag to activate spin.

public int SpinReleaseTime { get; set; }

Property Value

int

Remarks

If the time between mouse down and mouse up is less than this value, spin is activated.

TopViewCommand

Gets the top view command.

public static RoutedCommand TopViewCommand { get; }

Property Value

RoutedCommand

UpDownPanSensitivity

Gets or sets the sensitivity for pan by the up and down keys.

public double UpDownPanSensitivity { get; set; }

Property Value

double

The pan sensitivity.

Remarks

Use -1 to invert the pan direction.

UpDownRotationSensitivity

Gets or sets the sensitivity for rotation by the up and down keys.

public double UpDownRotationSensitivity { get; set; }

Property Value

double

The rotation sensitivity.

Remarks

Use -1 to invert the rotation direction.

Viewport

Gets or sets Viewport.

public Viewport3D Viewport { get; set; }

Property Value

Viewport3D

ZoomAroundMouseDownPoint

Gets or sets a value indicating whether to zoom around mouse down point.

public bool ZoomAroundMouseDownPoint { get; set; }

Property Value

bool

true if zooming around the mouse down point is enabled; otherwise, false .

ZoomCommand

Gets the zoom command.

public static RoutedCommand ZoomCommand { get; }

Property Value

RoutedCommand

ZoomCursor

Gets or sets the zoom cursor.

public Cursor ZoomCursor { get; set; }

Property Value

Cursor

The zoom cursor.

ZoomExtentsCommand

Gets the zoom extents command.

public static RoutedCommand ZoomExtentsCommand { get; }

Property Value

RoutedCommand

ZoomRectangleCommand

Gets the zoom rectangle command.

public static RoutedCommand ZoomRectangleCommand { get; }

Property Value

RoutedCommand

ZoomRectangleCursor

Gets or sets the zoom rectangle cursor.

public Cursor ZoomRectangleCursor { get; set; }

Property Value

Cursor

The zoom rectangle cursor.

ZoomSensitivity

Gets or sets ZoomSensitivity.

public double ZoomSensitivity { get; set; }

Property Value

double

Methods

AddMoveForce(double, double, double)

Adds the specified move force.

public void AddMoveForce(double dx, double dy, double dz)

Parameters

dx double

The delta x.

dy double

The delta y.

dz double

The delta z.

AddMoveForce(Vector3D)

Adds the specified move force.

public void AddMoveForce(Vector3D delta)

Parameters

delta Vector3D

The delta.

AddPanForce(double, double)

Adds the specified pan force.

public void AddPanForce(double dx, double dy)

Parameters

dx double

The delta x.

dy double

The delta y.

AddPanForce(Vector3D)

The add pan force.

public void AddPanForce(Vector3D pan)

Parameters

pan Vector3D

The pan.

AddRotateForce(double, double)

The add rotate force.

public void AddRotateForce(double dx, double dy)

Parameters

dx double

The delta x.

dy double

The delta y.

AddZoomForce(double)

Adds the zoom force.

public void AddZoomForce(double delta)

Parameters

delta double

The delta.

AddZoomForce(double, Point3D)

Adds the zoom force.

public void AddZoomForce(double delta, Point3D zoomOrigin)

Parameters

delta double

The delta.

zoomOrigin Point3D

The zoom origin.

ChangeDirection(Vector3D, double)

Changes the direction of the camera.

public void ChangeDirection(Vector3D lookDir, double animationTime = 500)

Parameters

lookDir Vector3D

The look direction.

animationTime double

The animation time.

ChangeDirection(Vector3D, Vector3D, double)

Changes the direction of the camera.

public void ChangeDirection(Vector3D lookDir, Vector3D upDir, double animationTime = 500)

Parameters

lookDir Vector3D

The look direction.

upDir Vector3D

The up direction.

animationTime double

The animation time.

HideRectangle()

Hides the rectangle.

public void HideRectangle()

HideTargetAdorner()

Hides the target adorner.

public void HideTargetAdorner()

LookAt(Point3D, double)

Change the "look-at" point.

[Obsolete]
public void LookAt(Point3D target, double animationTime)

Parameters

target Point3D

The target.

animationTime double

The animation time.

OnLookAtChanged()

Raises the LookAtChanged event.

protected virtual void OnLookAtChanged()

OnManipulationCompleted(ManipulationCompletedEventArgs)

Called when the ManipulationCompleted event occurs.

protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e)

Parameters

e ManipulationCompletedEventArgs

The data for the event.

OnManipulationDelta(ManipulationDeltaEventArgs)

Called when the ManipulationDelta event occurs.

protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)

Parameters

e ManipulationDeltaEventArgs

The data for the event.

OnManipulationStarted(ManipulationStartedEventArgs)

Called when the ManipulationStarted event occurs.

protected override void OnManipulationStarted(ManipulationStartedEventArgs e)

Parameters

e ManipulationStartedEventArgs

The data for the event.

OnMouseDown(MouseButtonEventArgs)

Invoked when an unhandled MouseDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnMouseDown(MouseButtonEventArgs e)

Parameters

e MouseButtonEventArgs

The MouseButtonEventArgs that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.

OnStylusSystemGesture(StylusSystemGestureEventArgs)

Invoked when an unhandled StylusSystemGesture attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnStylusSystemGesture(StylusSystemGestureEventArgs e)

Parameters

e StylusSystemGestureEventArgs

The StylusSystemGestureEventArgs that contains the event data.

OnZoomedByRectangle()

Raises the ZoomedByRectangle event.

protected virtual void OnZoomedByRectangle()

PushCameraSetting()

Push the current camera settings on an internal stack.

public void PushCameraSetting()

ResetCamera()

Resets the camera.

public void ResetCamera()

ResetCameraUpDirection()

Resets the camera up direction.

public void ResetCameraUpDirection()

RestoreCameraSetting()

Restores the most recent camera setting from the internal stack.

public bool RestoreCameraSetting()

Returns

bool

The restore camera setting.

RestoreCursor()

Restores the cursor from the cursor stack.

public void RestoreCursor()

SetCursor(Cursor)

Sets the cursor and pushes the current cursor to the cursor stack.

public void SetCursor(Cursor cursor)

Parameters

cursor Cursor

The cursor.

Remarks

Use RestoreCursor() to restore the cursor again.

ShowRectangle(Rect, Color, Color)

Shows the rectangle.

public void ShowRectangle(Rect rect, Color color1, Color color2)

Parameters

rect Rect

The rectangle.

color1 Color

The color 1.

color2 Color

The color 2.

ShowTargetAdorner(Point)

Shows the target adorner.

public void ShowTargetAdorner(Point position)

Parameters

position Point

The position.

StartSpin(Vector, Point, Point3D)

Starts the spin.

public void StartSpin(Vector speed, Point position, Point3D aroundPoint)

Parameters

speed Vector

The speed.

position Point

The position.

aroundPoint Point3D

The spin around point.

StopSpin()

Stops the spin.

public void StopSpin()

UpdateRectangle(Rect)

Updates the rectangle.

public void UpdateRectangle(Rect rect)

Parameters

rect Rect

The rectangle.

Zoom(double)

Zooms by the specified delta value.

public void Zoom(double delta)

Parameters

delta double

The delta value.

ZoomExtents(double)

Zooms to the extents of the model.

public void ZoomExtents(double animationTime = 200)

Parameters

animationTime double

The animation time (milliseconds).

Events

LookAtChanged

Occurs when the look at/target point changed.

public event RoutedEventHandler LookAtChanged

Event Type

RoutedEventHandler

ZoomedByRectangle

Occurs when the view is zoomed by rectangle.

public event RoutedEventHandler ZoomedByRectangle

Event Type

RoutedEventHandler