CVB.Net 14.0
DisplayCanvas Class Reference

This canvas displays an image in the background and arranges its children according to the pixel coordinates of the image. More...

Inherits Panel, IDisplay, and IScrollInfo.

Public Member Functions

bool GetIsAnimated (Visual visual)
 Gets the animated status of the ZoomCenter and ZoomFactor changes. More...
 
void SetIsAnimated (Visual visual, bool isAnimated)
 Sets the animated status of the ZoomCenter and ZoomFactor changes. More...
 
 DisplayCanvas ()
 Creates an empty display canvas.
 
Point TranslatePointToImage (Point point)
 Translates a point relative to this panel to coordinates that are relative to the ImageSource content pixels. More...
 
Point TranslatePointToImage (Point point, PixelCoordinateSystem correction)
 Translates a point relative to this panel to coordinates that are relative to the ImageSource content pixels. More...
 
Point TranslatePointToImage (Point point, CoordinateSystemType coordinateType)
 Translates a point relative to this panel to coordinates that are relative to the ImageSource content pixels. More...
 
Point TranslatePointFromImage (Point point)
 Translates a point relative to the ImageSource content pixels to coordinates relative to this panel. More...
 
Point TranslatePointFromImage (Point point, CoordinateSystemType coordinateType)
 Translates a point relative to the ImageSource content pixels to coordinates relative to this panel. More...
 
WinRect TranslateRectToImage (WinRect rect)
 Translates a rect relative to this panel to coordinates that are relative to the ImageSource content pixels. More...
 
WinRect TranslateRectToImage (WinRect rect, CoordinateSystemType coordinateType)
 Translates a rect relative to this panel to coordinates that are relative to the ImageSource content pixels. More...
 
WinRect TranslateRectFromImage (WinRect rect)
 Translates a rect relative to the ImageSource content pixels to coordinates relative to this panel. More...
 
WinRect TranslateRectFromImage (WinRect rect, CoordinateSystemType coordinateType)
 Translates a rect relative to the ImageSource content pixels to coordinates relative to this panel. More...
 
Size TranslateSizeToImage (Size size)
 Translates a size relative to this panel to a size relative to the ImageSource content pixels. More...
 
Size TranslateSizeFromImage (Size size)
 Translates a size relative to the ImageSource content pixels to a size relative to this panel. More...
 
void RedrawImage ()
 Redraws the display based on the set IDisplay.Image. More...
 
Task RedrawImageAsync ()
 Redraws the display based on the set IDisplay.Image when the display is rendered the next time. More...
 
Task SetImageAsync (Image image)
 Sets a new image asynchronously. More...
 
void LineDown ()
 Scrolls down within content by one logical unit (image pixel). More...
 
void LineLeft ()
 Scrolls left within content by one logical unit (image pixel). More...
 
void LineRight ()
 Scrolls right within content by one logical unit (image pixel). More...
 
void LineUp ()
 Scrolls up within content by one logical unit (image pixel). More...
 
WinRect MakeVisible (Visual visual, WinRect rectangle)
 Forces content to scroll until the coordinate space of a Visual object is visible. More...
 
void MouseWheelDown ()
 Scrolls a line down.
 
void MouseWheelLeft ()
 Same es DisplayCanvas.LineLeft.
 
void MouseWheelRight ()
 Same es DisplayCanvas.LineRight.
 
void MouseWheelUp ()
 Scrolls a line up.
 
void PageDown ()
 Scrolls down within content by one page (view port). More...
 
void PageLeft ()
 Scrolls left within content by one page (view port). More...
 
void PageRight ()
 Scrolls right within content by one page (view port). More...
 
void PageUp ()
 Scrolls up within content by one page (view port). More...
 
void SetHorizontalOffset (double offset)
 Sets the amount of horizontal offset. More...
 
void SetVerticalOffset (double offset)
 Sets the amount of vertical offset. More...
 
void SetOffset (double offsetX, double offsetY)
 Sets the amount of horizontal and vertical offset. More...
 
void RedrawImage ()
 Redraws the display based on the set IDisplay.Image. More...
 

Static Public Member Functions

static double GetBottom (Visual visual)
 Gets the value of the attached BottomProperty for the given visual . More...
 
static void SetBottom (Visual visual, double length)
 Sets the value of the attached BottomProperty for the given visual . More...
 
static HighBitScaleMode GetHighBitScaleMode (Visual visual)
 Gets the Stemmer.Cvb.HighBitScaleMode from the given visual . More...
 
static void SetHighBitScaleMode (Visual visual, HighBitScaleMode scaleMode)
 Sets the scaleMode to the given visual . More...
 
static AutoScaleContent GetAutoScaleContent (Visual visual)
 Gets the value of the AutoScaleContentProperty from the given visual . More...
 
static void SetAutoScaleContent (Visual visual, AutoScaleContent autoScale)
 Sets the autoScale value to the given visual . More...
 
static double GetLeft (Visual visual)
 Gets the value of the attached LeftProperty from the given visual . More...
 
static void SetLeft (Visual visual, double length)
 Sets the value of the attached LeftProperty for the given visual . More...
 
static LengthUnit GetLengthUnit (Visual visual)
 Gets the attached LengthUnitProperty for the given visual . More...
 
static void SetLengthUnit (Visual visual, LengthUnit unit)
 Sets the attached LengthUnitProperty for the given visual . More...
 
static int GetMaxDecodePixelHeight (Visual visual)
 Gets the attached MaxDecodePixelHeightProperty for the given visual . More...
 
static void SetMaxDecodePixelHeight (Visual visual, int value)
 Sets the attached MaxDecodePixelHeightProperty for the given visual . More...
 
static int GetMaxDecodePixelWidth (Visual visual)
 Gets the attached MaxDecodePixelWidthProperty for the given visual . More...
 
static void SetMaxDecodePixelWidth (Visual visual, int value)
 Sets the attached MaxDecodePixelWidthProperty for the given visual . More...
 
static PixelCoordinateSystem GetPixelCoordinateSystem (Visual visual)
 Gets the attached PixelCoordinateSystemProperty for the given visual . More...
 
static void SetPixelCoordinateSystem (Visual visual, PixelCoordinateSystem coordinateSystem)
 Sets the attached PixelCoordinateSystemProperty to the given visual . More...
 
static double GetRight (Visual visual)
 Gets the value of the attached RightProperty for the given visual . More...
 
static void SetRight (Visual visual, double length)
 Sets the value of the attached RightProperty for the given visual . More...
 
static double GetTop (Visual visual)
 Gets the value of the attached TopProperty for the given visual . More...
 
static void SetTop (Visual visual, double length)
 Sets the value of the attached TopProperty for the given visual . More...
 
static Point GetZoomCenter (DependencyObject d)
 Gets the attached zoom center property from the given dependency object d . More...
 
static void SetZoomCenter (DependencyObject d, Point center)
 Sets the attached zoom center property on the given dependency object d . More...
 
static double GetZoomFactor (DependencyObject d)
 Gets the zoom factor from the given dependency object d . More...
 
static void SetZoomFactor (DependencyObject d, double factor)
 Sets the zoom factor to the given dependency object d . More...
 

Static Public Attributes

static readonly RoutedEvent ActualZoomCenterChangedEvent
 Backing store for ActualZoomCenterChanged.
 
static readonly RoutedEvent ActualZoomFactorChangedEvent
 Backing store for ActualZoomFactorChanged.
 
static readonly RoutedEvent ImageDataUpdatedEvent
 Backing store for the ImageDataUpdated event.
 
static readonly RoutedEvent ImageSourceChangedEvent
 Backing store for the ImageSourceChanged event.
 
static readonly RoutedEvent ZoomCenterChangedEvent
 Backing store for ZoomCenterChanged.
 
static readonly RoutedEvent ZoomFactorChangedEvent
 Backing store for ZoomFactorChanged.
 
static readonly DependencyProperty ActualZoomCenterProperty
 Backing store for read-only ActualZoomCenter.
 
static readonly DependencyProperty ActualZoomFactorProperty
 Backing store for read-only ActualZoomFactor.
 
static readonly DependencyProperty AnimationDurationProperty
 Backing store for AnimationDuration.
 
static readonly DependencyProperty ImageProperty
 Backing store for Image.
 
static readonly DependencyProperty DisplayBitmapSizeLimitProperty
 DisplayBitmapSizeLimit dependency property.
 
static readonly DependencyProperty ImageObserverProperty
 Backing store for the read only ImageObserver dependency property.
 
static readonly DependencyProperty FrameTimeMinProperty
 Backing store of the FrameTimeMin property.
 
static readonly DependencyProperty ImageSourceProperty
 Backing store for ImageSource.
 
static readonly DependencyProperty ImageViewportHeightProperty
 Backing store of the ImageViewportHeight property.
 
static readonly DependencyProperty ImageViewportHorizontalOffsetProperty
 Backing store of the ImageViewportHorizontalOffset property.
 
static readonly DependencyProperty ImageViewportVerticalOffsetProperty
 Backing store of the ImageViewportVerticalOffset property.
 
static readonly DependencyProperty ImageViewportWidthProperty
 Backing store of the ImageViewportWidth property.
 
static readonly DependencyProperty IsAnimationInProgressProperty
 Backing store for the read only IsAnimationInProgress property.
 
static readonly DependencyProperty IsInStretchModeProperty
 Backing store for read only IsInStretchMode.
 
static readonly DependencyProperty IsZoomActiveProperty
 Backing store for the IsZoomActive.
 
static readonly DependencyProperty PixelRasterMinExtentProperty
 Backing store for the PixelRasterMinExtent property.
 
static readonly DependencyProperty PixelRasterVisibleProperty
 Backing store the PixelRasterVisible property.
 
static readonly DependencyProperty RedrawOnImageDataUpdatedProperty
 Backing store of the RedrawOnImageDataUpdated property.
 
static readonly DependencyProperty StretchZoomFactorProperty
 Backing store for read only StretchZoomFactor.
 
static readonly DependencyProperty ZoomTransformProperty
 Backing store for ZoomTransform.
 
static readonly DependencyProperty BottomProperty
 Backing store for the Bottom attached property. More...
 
static readonly DependencyProperty HighBitScaleModeProperty
 Backing store for the DisplayCanvas.HighBitScaleMode attached property.
 
static DependencyProperty IsAnimatedProperty
 Backing store for the IsAnimated attached property. More...
 
static readonly DependencyProperty AutoScaleContentProperty
 Defines whether or not the overlays in the canvas are automatically scaled according to the zoom factor. More...
 
static readonly DependencyProperty LeftProperty
 Backing store for the Left attached property. More...
 
static readonly DependencyProperty LengthUnitProperty
 Backing store for the LengthUnit attached property. More...
 
static readonly DependencyProperty MaxDecodePixelHeightProperty
 Backing store for the MaxDecodePixelHeightProperty attached property. More...
 
static readonly DependencyProperty MaxDecodePixelWidthProperty
 Backing store for the MaxDecodePixelWidthProperty attached property. More...
 
static readonly DependencyProperty PixelCoordinateSystemProperty
 Backing store for the PixelCoordinateSystem attached property. More...
 
static readonly DependencyProperty RightProperty
 Backing store for the Right attached property. More...
 
static readonly DependencyProperty TopProperty
 Backing store for the Top attached property. More...
 
static readonly DependencyProperty ZoomCenterProperty
 Backing store for the ZoomCenter attached property.
 
static readonly DependencyProperty ZoomFactorProperty
 Backing store for the ZoomFactor attached property.
 

Protected Member Functions

override Size ArrangeOverride (Size arrangeBounds)
 Called to arrange and size the content of an object. More...
 
override Size MeasureOverride (Size availableSize)
 Measures the size in layout required for child elements and determines a size for this control. More...
 
override void OnVisualChildrenChanged (DependencyObject visualAdded, DependencyObject visualRemoved)
 Called when children are added/removed. More...
 
override void OnRender (DrawingContext dc)
 Renders the zoomed image to the background. More...
 

Properties

EventHandler< DisplayZoomEventArgsActualZoomCenterChanged
 Bubbling routed event that is fired when the ActualZoomCenter changes.
 
EventHandler< DisplayZoomEventArgsActualZoomFactorChanged
 Bubbling routed event that is fired when the ActualZoomFactor changes.
 
EventHandler< RoutedEventArgs > ImageDataUpdated
 Bubbling event that is fired when the display's image data is updated.
 
EventHandler< ImageSourceChangedEventArgsImageSourceChanged
 Bubbling event that is fired when the ImageSource changes.
 
EventHandler< DisplayZoomEventArgsZoomCenterChanged
 Bubbling event that is fired when the ZoomCenter property is changed.
 
EventHandler< DisplayZoomEventArgsZoomFactorChanged
 Bubbling event that is fired when the ZoomFactor property is changed.
 
Point ActualZoomCenter [get]
 Gets the rendered zoom center of this display. More...
 
double ActualZoomFactor [get]
 Gets the rendered zoom factor of this display. More...
 
Duration AnimationDuration [get, set]
 Duration for panning and zoom animations.
 
Image Image [get, set]
 Gets/sets a Stemmer.Cvb.Image as the image source of this display. More...
 
long DisplayBitmapSizeLimit [get, set]
 Out Display is capable of transferring responsibility for zoom handling to the GPU by committing the CVB image data to a WriteableBitmap object. However, WriteableBitmaps are afflicted by a bug in the WPF runtime that seems to be triggered depending on the bitmap's size (see for example this discussion here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/d4f943eb-630e-48ac-a8f8-00e539bb7856/wpf-crashes-with-error-hresult-0x88980406-at?forum=wpf We are currently working around this issue by limiting the size of the WriteableBitmap that is generated (if a Cvb image that is too big is set on the Image property an OutOfMemoryException will be raised). As the size limit cannot be determined by any means available to us, we are working with a definable limit. The default has been chosen to a size that we have found to generally work well on our systems.
 
IObserver< ImageImageObserver [get]
 Gets the observer to receive new Image pushes. More...
 
Duration FrameTimeMin [get, set]
 Gets or sets the minimal frame time for displaying new frames. More...
 
System.Windows.Media.Imaging.BitmapSource ImageSource [get, set]
 Image source of this display. More...
 
double ImageViewportHeight [get]
 Gets the the displayed image region shown width. More...
 
double ImageViewportHorizontalOffset [get]
 Gets the horizontal offset to the displayed image. More...
 
double ImageViewportVerticalOffset [get]
 Gets the vertical offset to the displayed image. More...
 
double ImageViewportWidth [get]
 Gets the the displayed image region shown width. More...
 
bool IsAnimationInProgress [get]
 Gets whether the default animation is currently active.
 
bool IsInStretchMode [get]
 Gets whether the stretch mode is active and not the zoom mode. More...
 
bool IsZoomActive [get]
 Gets whether this control is currently in zoom mode despite stretch mode. More...
 
double PixelRasterMinExtent [get, set]
 Gets/sets the minimum extent (width/height) of a pixel until the pixel raster is shown.
 
bool PixelRasterVisible [get, set]
 Gets/sets whether a pixel raster is shown in higher zoom levels.
 
bool RedrawOnImageDataUpdated [get, set]
 Gets/sets whether the display is to be redrawn as soon as the image data has been updated. More...
 
double StretchZoomFactor [get]
 Gets the zoom factor as if in the case as if this control would be in stretch mode. More...
 
Transform ZoomTransform [get]
 The transform affecting the zoom parameters. More...
 
HighBitScaleMode HighBitScaleMode [get, set]
 Gets/sets the Stemmer.Cvb.HighBitScaleMode used by this display canvas.
 
bool IsAnimated [get, set]
 Gets/sets whether interactive zoom center/factor changes are animated.
 
Point ZoomCenter [get, set]
 Gets/sets the zoom center. More...
 
double ZoomFactor [get, set]
 The current zoom factor of the image. More...
 
Size PixelSize [get]
 Gets the size of one ImageSource pixel. More...
 
bool CanHorizontallyScroll [get, set]
 Gets or sets a value that indicates whether scrolling on the horizontal axis is possible.
 
bool CanVerticallyScroll [get, set]
 Gets or sets a value that indicates whether scrolling on the vertical axis is possible.
 
double ExtentHeight [get]
 Gets the vertical size of the image, including the content that is not visible, in device independent pixels. More...
 
double ExtentWidth [get]
 Gets the horizontal size of the image, including the content that is not visible, in device independent pixels. More...
 
double HorizontalOffset [get]
 Gets the horizontal offset of the scrolled content. More...
 
ScrollViewer ScrollOwner [get, set]
 Gets or sets a System.Windows.Controls.ScrollViewer element that controls scrolling behavior.
 
double VerticalOffset [get]
 Gets the vertical offset of the scrolled content. More...
 
double ViewportHeight [get]
 Gets the vertical size of the view port for this content. More...
 
double ViewportWidth [get]
 Gets the horizontal size of the view port for this content. More...
 
- Properties inherited from IDisplay
Point ActualZoomCenter [get]
 Gets the rendered zoom center of this display. More...
 
double ActualZoomFactor [get]
 Gets the rendered zoom factor of this display. More...
 
Image Image [get, set]
 Gets/sets a Stemmer.Cvb.Image as the image source of this display. More...
 
HighBitScaleMode HighBitScaleMode [get, set]
 Gets/sets the Stemmer.Cvb.HighBitScaleMode used by this display.
 
BitmapSource ImageSource [get, set]
 Image source of this display. More...
 
bool IsAnimated [get, set]
 Gets/sets whether ZoomCenter or ZoomFactor changes are animated.
 
bool IsAnimationInProgress [get]
 Gets whether the control's internal animation is in progress.
 
bool IsInStretchMode [get]
 Gets whether the stretch mode is active and not the zoom mode. More...
 
bool IsZoomActive [get]
 Gets whether this control is currently in zoom mode and the zoom factor is greater than one. More...
 
double StretchZoomFactor [get]
 Gets the zoom factor as if in the case as if this control would be in stretch mode. More...
 
Point ZoomCenter [get, set]
 Gets/sets the zoom center. More...
 
double ZoomFactor [get, set]
 The current zoom factor of the image. More...
 

Additional Inherited Members

- Events inherited from IDisplay
EventHandler< DisplayZoomEventArgsActualZoomCenterChanged
 Bubbling routed event that is fired when the ActualZoomCenter changes.
 
EventHandler< DisplayZoomEventArgsActualZoomFactorChanged
 Bubbling routed event that is fired when the ActualZoomFactor changes.
 
EventHandler< DisplayZoomEventArgsZoomCenterChanged
 Bubbling event that is fired when the ZoomCenter property is changed.
 
EventHandler< DisplayZoomEventArgsZoomFactorChanged
 Bubbling event that is fired when the ZoomFactor property is changed.
 

Detailed Description

This canvas displays an image in the background and arranges its children according to the pixel coordinates of the image.

To use the display canvas in your projects, follow these steps:

  1. Reference this assembly in your solution
  2. Add the control's namespace to your root element of the markup file:
    xmlns:cvb="http://www.commonvisionblox.com/wpf"
  3. Use the display canvas in the XAML file:
    \<cvb:DisplayCanvas /\>
    This canvas displays an image in the background and arranges its children according to the pixel coor...
    Definition: DisplayCanvas.cs:239

Example on how to place a standard WPF Rectangle on the canvas:

\<cvb:DisplayCanvas ImageSource="C:\Program Files\Stemmer Imaging\Common Vision Blox\Tutorial\Clara.bmp"\>
\<Rectangle StrokeThickness="1" Stroke="Red"
cvb:DisplayCanvas.Left="50" cvb:DisplayCanvas.Right="90"
cvb:DisplayCanvas.Top="85" cvb:DisplayCanvas.Bottom="110"
cvb:DisplayCanvas.AutoScaleContent="Off" /\>
\</cvb:DisplayCanvas\>
System.Windows.Media.Imaging.BitmapSource ImageSource
Image source of this display.
Definition: DisplayCanvas.cs:890

Member Function Documentation

◆ ArrangeOverride()

override Size ArrangeOverride ( Size  arrangeBounds)
protected

Called to arrange and size the content of an object.

Used to update layout dependent properties.

Parameters
arrangeBoundsThe computed size that is used to arrange the content.
Returns
The size of the control.

◆ GetAutoScaleContent()

static AutoScaleContent GetAutoScaleContent ( Visual  visual)
static

Gets the value of the AutoScaleContentProperty from the given visual .

Parameters
visualThe element from which the property value is read.
Returns
Whether or not the item is scaled.

◆ GetBottom()

static double GetBottom ( Visual  visual)
static

Gets the value of the attached BottomProperty for the given visual .

Parameters
visualThe element to which the property value is read.
Returns
Offset from the canvas bottom border. Default is double.NaN

.

◆ GetHighBitScaleMode()

static HighBitScaleMode GetHighBitScaleMode ( Visual  visual)
static

Gets the Stemmer.Cvb.HighBitScaleMode from the given visual .

Parameters
visualThe element from which the property value is read.
Returns
The Stemmer.Cvb.HighBitScaleMode of the object; default is Stemmer.Cvb.HighBitScaleMode.Default.

◆ GetIsAnimated()

bool GetIsAnimated ( Visual  visual)

Gets the animated status of the ZoomCenter and ZoomFactor changes.

Parameters
visualThe element to get the value from.
Returns
true if value sets are animated; false if not.

◆ GetLeft()

static double GetLeft ( Visual  visual)
static

Gets the value of the attached LeftProperty from the given visual .

Parameters
visualThe element from which the property value is read.
Returns
Offset from the canvas left border. Default is double.NaN

.

◆ GetLengthUnit()

static LengthUnit GetLengthUnit ( Visual  visual)
static

Gets the attached LengthUnitProperty for the given visual .

Parameters
visualThe element to which the property value is read.
Returns
Current unit being used.

◆ GetMaxDecodePixelHeight()

static int GetMaxDecodePixelHeight ( Visual  visual)
static

Gets the attached MaxDecodePixelHeightProperty for the given visual .

Parameters
visualThe element to which the property value is read.
Returns
Current value being used.

◆ GetMaxDecodePixelWidth()

static int GetMaxDecodePixelWidth ( Visual  visual)
static

Gets the attached MaxDecodePixelWidthProperty for the given visual .

Parameters
visualThe element to which the property value is read.
Returns
Current value being used.

◆ GetPixelCoordinateSystem()

static PixelCoordinateSystem GetPixelCoordinateSystem ( Visual  visual)
static

Gets the attached PixelCoordinateSystemProperty for the given visual .

Parameters
visualThe element to read the property value from.
Returns
Pixel coordinate system.

◆ GetRight()

static double GetRight ( Visual  visual)
static

Gets the value of the attached RightProperty for the given visual .

Parameters
visualThe element to which the property value is read.
Returns
Offset from the canvas right border. Default is double.NaN

.

◆ GetTop()

static double GetTop ( Visual  visual)
static

Gets the value of the attached TopProperty for the given visual .

Parameters
visualThe element to which the property value is read.
Returns
Offset from the canvas top border. Default is double.NaN

.

◆ GetZoomCenter()

static Point GetZoomCenter ( DependencyObject  d)
static

Gets the attached zoom center property from the given dependency object d .

This method makes the attached property accessible from XAML.

Parameters
dDependency object to get attached property from.
Returns
Point in the bitmap source which is the center of the zoomed ViewportHeight port. Coordinates are in bitmap pixels.

◆ GetZoomFactor()

static double GetZoomFactor ( DependencyObject  d)
static

Gets the zoom factor from the given dependency object d .

A zoom factor larger than 1.0 magnifies the displayed image; values smaller than 1.0 zoom out whereas 1.0 displays the image as is (this resembles System.Windows.Media.Stretch.None). The special value 0.0 identifies the panorama or stretch mode which resembles System.Windows.Media.Stretch.Uniform (the default). Values smaller 0.0 are invalid.

This method makes the attached property accessible from XAML.

Parameters
dDependency object to get the zoom factor from.
Returns
The current zoom factor.

◆ LineDown()

void LineDown ( )

Scrolls down within content by one logical unit (image pixel).

Snaps to image pixel units.

◆ LineLeft()

void LineLeft ( )

Scrolls left within content by one logical unit (image pixel).

Snaps to image pixel units.

◆ LineRight()

void LineRight ( )

Scrolls right within content by one logical unit (image pixel).

Snaps to image pixel units.

◆ LineUp()

void LineUp ( )

Scrolls up within content by one logical unit (image pixel).

Snaps to image pixel units.

◆ MakeVisible()

WinRect MakeVisible ( Visual  visual,
WinRect  rectangle 
)

Forces content to scroll until the coordinate space of a Visual object is visible.

In most cases, the returned rectangle is a transformed version of the input rectangle. In some cases, such as when the input rectangle cannot fit entirely within the view port, the return value may be smaller.

Parameters
visualA Visual to become visible.
rectangleA bounding rectangle that identifies the coordinate space to make visible.
Returns
A Rect that is visible.

◆ MeasureOverride()

override Size MeasureOverride ( Size  availableSize)
protected

Measures the size in layout required for child elements and determines a size for this control.

Parameters
availableSizeThe available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.
Returns
The size that this element determines it needs during layout, based on the availableSize and the displayed image source size.

◆ OnRender()

override void OnRender ( DrawingContext  dc)
protected

Renders the zoomed image to the background.

Parameters
dcDrawing context of this canvas.

◆ OnVisualChildrenChanged()

override void OnVisualChildrenChanged ( DependencyObject  visualAdded,
DependencyObject  visualRemoved 
)
protected

Called when children are added/removed.

Parameters
visualAddedAdded visual.
visualRemovedRemoved visual.

◆ PageDown()

void PageDown ( )

Scrolls down within content by one page (view port).

Snaps to image pixel units.

◆ PageLeft()

void PageLeft ( )

Scrolls left within content by one page (view port).

Snaps to image pixel units.

◆ PageRight()

void PageRight ( )

Scrolls right within content by one page (view port).

Snaps to image pixel units.

◆ PageUp()

void PageUp ( )

Scrolls up within content by one page (view port).

Snaps to image pixel units.

◆ RedrawImage()

void RedrawImage ( )

Redraws the display based on the set IDisplay.Image.

This method only works with a set Stemmer.Cvb.Image and redraws this display with the image's content. This method does nothing if only a BitmapSource is set.

Implements IDisplay.

◆ RedrawImageAsync()

Task RedrawImageAsync ( )

Redraws the display based on the set IDisplay.Image when the display is rendered the next time.

If multiple redraws are to be done in one render phase, only one is performed.

Attention: Image drawing is performed in the UI thread. Thus if you Task.Wait() on the returned Task from the UI thread, the application will dead lock.

Otherwise it is safe to call this method from non-UI threads.

Returns
Task to wait on for completion. The task's state will be canceled if it was not used for actually updating the display.

◆ SetAutoScaleContent()

static void SetAutoScaleContent ( Visual  visual,
AutoScaleContent  autoScale 
)
static

Sets the autoScale value to the given visual .

Parameters
visualThe element to which the property value is set.
autoScaleWhether or not the item is scaled.

◆ SetBottom()

static void SetBottom ( Visual  visual,
double  length 
)
static

Sets the value of the attached BottomProperty for the given visual .

Parameters
visualThe element from which the property value is written.
lengthOffset from the canvas bottom border.

◆ SetHighBitScaleMode()

static void SetHighBitScaleMode ( Visual  visual,
HighBitScaleMode  scaleMode 
)
static

Sets the scaleMode to the given visual .

Parameters
visualThe element to which the property value is written.
scaleModeNew scale mode.

◆ SetHorizontalOffset()

void SetHorizontalOffset ( double  offset)

Sets the amount of horizontal offset.

Parameters
offsetThe degree to which content is horizontally offset from the containing view port in device independent pixels.

◆ SetImageAsync()

Task SetImageAsync ( Image  image)

Sets a new image asynchronously.

If multiple image s are to be displayed in one render phase, only the newest is rendered.

Attention: Image drawing is performed in the UI thread. Thus if you Task.Wait() on the returned Task from the UI thread, the application will dead lock.

Otherwise it is safe to call this method from non-UI threads.

Parameters
imageImage to display.
Returns
Task to wait on for completion. The task's state will be canceled if it was not used for actually updating the display.

◆ SetIsAnimated()

void SetIsAnimated ( Visual  visual,
bool  isAnimated 
)

Sets the animated status of the ZoomCenter and ZoomFactor changes.

Parameters
visualThe element to set the value on.
isAnimatedtrue if value sets are animated; false for not.

◆ SetLeft()

static void SetLeft ( Visual  visual,
double  length 
)
static

Sets the value of the attached LeftProperty for the given visual .

Parameters
visualThe element to which the property value is written.
lengthOffset from the canvas left border.

◆ SetLengthUnit()

static void SetLengthUnit ( Visual  visual,
LengthUnit  unit 
)
static

Sets the attached LengthUnitProperty for the given visual .

Parameters
visualThe element to which the property value is written.
unitUnit to be used.

◆ SetMaxDecodePixelHeight()

static void SetMaxDecodePixelHeight ( Visual  visual,
int  value 
)
static

Sets the attached MaxDecodePixelHeightProperty for the given visual .

Parameters
visualThe element to which the property value is written.
valueValue to be used.

◆ SetMaxDecodePixelWidth()

static void SetMaxDecodePixelWidth ( Visual  visual,
int  value 
)
static

Sets the attached MaxDecodePixelWidthProperty for the given visual .

Parameters
visualThe element to which the property value is written.
valueValue to be used.

◆ SetOffset()

void SetOffset ( double  offsetX,
double  offsetY 
)

Sets the amount of horizontal and vertical offset.

Parameters
offsetXThe degree to which content is horizontally offset from the containing view port in device independent pixels.
offsetYThe degree to which content is vertically offset from the containing view port in device independent pixels.

◆ SetPixelCoordinateSystem()

static void SetPixelCoordinateSystem ( Visual  visual,
PixelCoordinateSystem  coordinateSystem 
)
static

Sets the attached PixelCoordinateSystemProperty to the given visual .

Parameters
visualThe element to which the property value is written.
coordinateSystemCoordinate system to use.

◆ SetRight()

static void SetRight ( Visual  visual,
double  length 
)
static

Sets the value of the attached RightProperty for the given visual .

Parameters
visualThe element to which the property value is written.
lengthOffset from the canvas right border.

◆ SetTop()

static void SetTop ( Visual  visual,
double  length 
)
static

Sets the value of the attached TopProperty for the given visual .

Parameters
visualThe element to which the property value is written.
lengthOffset from the canvas top border.

◆ SetVerticalOffset()

void SetVerticalOffset ( double  offset)

Sets the amount of vertical offset.

Parameters
offsetThe degree to which content is vertically offset from the containing view port in device independent pixels.

◆ SetZoomCenter()

static void SetZoomCenter ( DependencyObject  d,
Point  center 
)
static

Sets the attached zoom center property on the given dependency object d .

This method makes the attached property accessible from XAML.

Parameters
dDependency object to set attached property on.
centerPoint in the bitmap source which is the center of the zoomed view port. Coordinates are in bitmap pixels.

◆ SetZoomFactor()

static void SetZoomFactor ( DependencyObject  d,
double  factor 
)
static

Sets the zoom factor to the given dependency object d .

A zoom factor larger than 1.0 magnifies the displayed image; values smaller than 1.0 zoom out whereas 1.0 displays the image as is (this resembles System.Windows.Media.Stretch.None). The special value 0.0 identifies the panorama or stretch mode which resembles System.Windows.Media.Stretch.Uniform (the default). Values smaller 0.0 are invalid.

This method makes the attached property accessible from XAML.

Parameters
dDependency object to set the zoom factor to.
factorThe new zoom factor.

◆ TranslatePointFromImage() [1/2]

Point TranslatePointFromImage ( Point  point)

Translates a point relative to the ImageSource content pixels to coordinates relative to this panel.

Dependent on the ActualZoomFactor the translated coordinates may contain fractions. This method behaves as if you would call

TranslatePointFromImage(point, CoordinateSystemType.PixelCoordinates)
CoordinateSystemType
Enumeration of the different available coordinate systems that an Area of interest may be defined in.
Definition: AreaOfInterest.cs:21

.

Parameters
pointPoint relative to the image source pixels.
Returns
Translated point value relative to this panel.

◆ TranslatePointFromImage() [2/2]

Point TranslatePointFromImage ( Point  point,
CoordinateSystemType  coordinateType 
)

Translates a point relative to the ImageSource content pixels to coordinates relative to this panel.

Dependent on the ActualZoomFactor and the image coordinate system the translated coordinates may contain fractions.

Parameters
pointPoint relative to the image source pixels.
coordinateTypeDefines whether the image coordinate system is incorporated in the calculation.
Returns
Translated point value relative to this panel.

◆ TranslatePointToImage() [1/3]

Point TranslatePointToImage ( Point  point)

Translates a point relative to this panel to coordinates that are relative to the ImageSource content pixels.

Dependent on the ActualZoomFactor the translated coordinates may contain fractions. This method behaves as if you would call

TranslatePointToImage(point, CoordinateSystemType.PixelCoordinates)

.

Parameters
pointPoint as relative to this panel.
Returns
Translated point value relative to the image source pixels.

◆ TranslatePointToImage() [2/3]

Point TranslatePointToImage ( Point  point,
CoordinateSystemType  coordinateType 
)

Translates a point relative to this panel to coordinates that are relative to the ImageSource content pixels.

Dependent on the ActualZoomFactor and the image coordinate system the translated coordinates may contain fractions.

Parameters
pointPoint as relative to this panel.
coordinateTypeDefines whether the image coordinate system is incorporated in the calculation.
Returns
Translated point value relative to the image source pixels.

◆ TranslatePointToImage() [3/3]

Point TranslatePointToImage ( Point  point,
PixelCoordinateSystem  correction 
)

Translates a point relative to this panel to coordinates that are relative to the ImageSource content pixels.

Parameters
pointPoint as relative to this panel.
correctionCoordinate type for correction. By default, a pixel coordinate is considered to be in the left top corner (parameter value LeftTop). With Barycentric correction it may be shifted to the center, which is sometimes useful.
Returns
Translated coordinate.

◆ TranslateRectFromImage() [1/2]

WinRect TranslateRectFromImage ( WinRect  rect)

Translates a rect relative to the ImageSource content pixels to coordinates relative to this panel.

Dependent on the ActualZoomFactor the translated coordinates may contain fractions. This method behaves as if you would call

WinRect TranslateRectFromImage(WinRect rect)
Translates a rect relative to the ImageSource content pixels to coordinates relative to this panel.
Definition: DisplayCanvas.cs:2557

.

Parameters
rectRectangle relative to the image source pixels.
Returns
Translated rectangle value relative to this panel.

◆ TranslateRectFromImage() [2/2]

WinRect TranslateRectFromImage ( WinRect  rect,
CoordinateSystemType  coordinateType 
)

Translates a rect relative to the ImageSource content pixels to coordinates relative to this panel.

Dependent on the ActualZoomFactor the translated coordinates may contain fractions.

Parameters
rectRectangle relative to the image source pixels.
coordinateTypeDefines whether the image coordinate system is incorporated in the calculation.
Returns
Translated rectangle value relative to this panel.

◆ TranslateRectToImage() [1/2]

WinRect TranslateRectToImage ( WinRect  rect)

Translates a rect relative to this panel to coordinates that are relative to the ImageSource content pixels.

Dependent on the ActualZoomFactor the translated coordinates may contain fractions. This method behaves as if you would call

WinRect TranslateRectToImage(WinRect rect)
Translates a rect relative to this panel to coordinates that are relative to the ImageSource content...
Definition: DisplayCanvas.cs:2500

.

Parameters
rectRectangle relative to this panel.
Returns
Translated rectangle value relative to the image source pixels.

◆ TranslateRectToImage() [2/2]

WinRect TranslateRectToImage ( WinRect  rect,
CoordinateSystemType  coordinateType 
)

Translates a rect relative to this panel to coordinates that are relative to the ImageSource content pixels.

Dependent on the ActualZoomFactor the translated coordinates may contain fractions.

Parameters
rectRectangle relative to this panel.
coordinateTypeDefines whether the image coordinate system is incorporated in the calculation.
Returns
Translated rectangle value relative to the image source pixels.

◆ TranslateSizeFromImage()

Size TranslateSizeFromImage ( Size  size)

Translates a size relative to the ImageSource content pixels to a size relative to this panel.

Dependent on the ActualZoomFactor the translated size may contain fractions.

Parameters
sizeSize relative to the image source pixels.
Returns
Translated size relative to this panel.

◆ TranslateSizeToImage()

Size TranslateSizeToImage ( Size  size)

Translates a size relative to this panel to a size relative to the ImageSource content pixels.

Dependent on the ActualZoomFactor the translated size may contain fractions.

Parameters
sizeSize relative to this panel.
Returns
Translated size relative to the image source pixels.

Member Data Documentation

◆ AutoScaleContentProperty

readonly DependencyProperty AutoScaleContentProperty
static

Defines whether or not the overlays in the canvas are automatically scaled according to the zoom factor.

Gets/sets whether or not the overlay in the canvas is automatically scaled according to the zoom factor.

Default is AutoScaleContent.RenderTransform.

◆ BottomProperty

readonly DependencyProperty BottomProperty
static

Backing store for the Bottom attached property.

Gets/sets the offset from the bottom border for a child element.

Default is double.NaN for not used.

◆ IsAnimatedProperty

DependencyProperty IsAnimatedProperty
static

Backing store for the IsAnimated attached property.

Gets/sets whether interactive zoom center/factor changes are animated.

Default is true.

◆ LeftProperty

readonly DependencyProperty LeftProperty
static

Backing store for the Left attached property.

Gets/sets the offset from the left border for a child element.

Default is double.NaN for not used.

◆ LengthUnitProperty

readonly DependencyProperty LengthUnitProperty
static

Backing store for the LengthUnit attached property.

Defines whether the layout properties are measured in image pixels (default) or in device independent pixels as displayed by the canvas.

By setting this property you can define whether the overlay should be aligned according to the underlying image (image pixels) or against the canvas (device independent pixels).

Default is LengthUnit.ImagePixel.

◆ MaxDecodePixelHeightProperty

readonly DependencyProperty MaxDecodePixelHeightProperty
static

Backing store for the MaxDecodePixelHeightProperty attached property.

Gets/sets maximal decode height for the ImageSource.

Decodes the ImageSource image at this maximal resolution if unequal 0. If only one of the decode properties is set, the aspect ratio is preserved.

0 is default and doesn't change the ImageSource size.

◆ MaxDecodePixelWidthProperty

readonly DependencyProperty MaxDecodePixelWidthProperty
static

Backing store for the MaxDecodePixelWidthProperty attached property.

Gets/sets maximal decode height for the ImageSource.

Decodes the ImageSource image at this maximal resolution if unequal 0. If only one of the decode properties is set, the aspect ratio is preserved.

0 is default and doesn't change the ImageSource size.

◆ PixelCoordinateSystemProperty

readonly DependencyProperty PixelCoordinateSystemProperty
static

Backing store for the PixelCoordinateSystem attached property.

Defines the location of a point in a pixel.

This attached works in conjunction with the LengthUnitProperty if it is set to LengthUnit.ImagePixel. It is ignored for LengthUnit.DeviceIndependentPixel.

This defines where overlays are placed in the canvas. Either at the left-top location or in the center of the pixel/barycentric (default).

◆ RightProperty

readonly DependencyProperty RightProperty
static

Backing store for the Right attached property.

Gets/sets the offset from the right border for a child element.

Default is double.NaN for not used.

◆ TopProperty

readonly DependencyProperty TopProperty
static

Backing store for the Top attached property.

Gets/sets the offset from the top for a child element.

Default is double.NaN for not used.

Property Documentation

◆ ActualZoomCenter

Point ActualZoomCenter
get

Gets the rendered zoom center of this display.

This is the actual value of the rendered control. Default is a point with double.NaN coordinates.

This property is a calculated value based on the ZoomCenter and System.Windows.FrameworkElement.ActualWidth and System.Windows.FrameworkElement.ActualHeight by the layout system. The value is set by the layout system itself, based on an actual rendering pass, and may therefore lag slightly behind the set value of properties such as ZoomFactor that are the basis of the input change.

Because this value is calculated, you should be aware that there could be multiple or incremental reported changes to it as a result of various operations by the layout system. The layout system may be calculating required measure space for child elements, constraints by the parent element, and so on.

Implements IDisplay.

◆ ActualZoomFactor

double ActualZoomFactor
get

Gets the rendered zoom factor of this display.

This is the actual value of the rendered control. Default is double.NaN.

This property is a calculated value based on the ZoomFactor and System.Windows.FrameworkElement.ActualWidth and System.Windows.FrameworkElement.ActualHeight by the layout system. The value is set by the layout system itself, based on an actual rendering pass, and may therefore lag slightly behind the set value of properties such as ZoomFactor that are the basis of the input change.

Because this value is calculated, you should be aware that there could be multiple or incremental reported changes to it as a result of various operations by the layout system. The layout system may be calculating required measure space for child elements, constraints by the parent element, and so on.

Implements IDisplay.

◆ ExtentHeight

double ExtentHeight
get

Gets the vertical size of the image, including the content that is not visible, in device independent pixels.

A System.Double that represents, in device independent pixels, the full vertical size of the image.

◆ ExtentWidth

double ExtentWidth
get

Gets the horizontal size of the image, including the content that is not visible, in device independent pixels.

A System.Double that represents, in device independent pixels, the full horizontal size of the image.

◆ FrameTimeMin

Duration FrameTimeMin
getset

Gets or sets the minimal frame time for displaying new frames.

This time defines the minimal duration a frame is displayed. This means that redraw operations are postponed to this value's duration since the last redraw. This effectively reduces the display frame rate.

Default is no minimal frame time.

◆ HorizontalOffset

double HorizontalOffset
get

Gets the horizontal offset of the scrolled content.

A System.Double that represents, in device independent pixels, the horizontal offset.

Valid values are between zero and the ExtentWidth minus the ViewportWidth.

◆ Image

Image Image
getset

Gets/sets a Stemmer.Cvb.Image as the image source of this display.

If this property is set the ImageSource property is readonly.

Implements IDisplay.

◆ ImageObserver

IObserver<Image> ImageObserver
get

Gets the observer to receive new Image pushes.

If multiple Images are to be displayed in one render phase, only the newest is rendered.

It is safe to push see Stemmer.Cvb.Images from non-UI threads.

◆ ImageSource

System.Windows.Media.Imaging.BitmapSource ImageSource
getset

Image source of this display.

If DisplayCanvas.Image is set, this property is readonly.

Implements IDisplay.

◆ ImageViewportHeight

double ImageViewportHeight
get

Gets the the displayed image region shown width.

Shown part of the image in device independent pixels.

◆ ImageViewportHorizontalOffset

double ImageViewportHorizontalOffset
get

Gets the horizontal offset to the displayed image.

Horizontal offset from the canvas' left border in device independent pixels.

◆ ImageViewportVerticalOffset

double ImageViewportVerticalOffset
get

Gets the vertical offset to the displayed image.

Vertical offset from the canvas' top border in device independent pixels.

◆ ImageViewportWidth

double ImageViewportWidth
get

Gets the the displayed image region shown width.

Shown part of the image in device independent pixels.

◆ IsInStretchMode

bool IsInStretchMode
get

Gets whether the stretch mode is active and not the zoom mode.

True if stretch mode is active; false if zoom mode is active.

The stretch mode was called panorama mode in the CVB Display ActiveX control.

Implements IDisplay.

◆ IsZoomActive

bool IsZoomActive
get

Gets whether this control is currently in zoom mode despite stretch mode.

This control is either in zoom mode (true value) or in panorama/stretch mode (false value).

Implements IDisplay.

◆ PixelSize

Size PixelSize
get

Gets the size of one ImageSource pixel.

Size in device independent pixels; double.NaN if no display is possible.

◆ RedrawOnImageDataUpdated

bool RedrawOnImageDataUpdated
getset

Gets/sets whether the display is to be redrawn as soon as the image data has been updated.

Default is true.

◆ StretchZoomFactor

double StretchZoomFactor
get

Gets the zoom factor as if in the case as if this control would be in stretch mode.

The zoom factor that would be

Implements IDisplay.

◆ VerticalOffset

double VerticalOffset
get

Gets the vertical offset of the scrolled content.

A System.Double that represents, in device independent pixels, the vertical offset.

Valid values are between zero and the ExtentHeight minus the ViewportHeight.

◆ ViewportHeight

double ViewportHeight
get

Gets the vertical size of the view port for this content.

A System.Double that represents, in device independent pixels, the visible vertical size of the image.

◆ ViewportWidth

double ViewportWidth
get

Gets the horizontal size of the view port for this content.

A System.Double that represents, in device independent pixels, the visible horizontal size of the image.

◆ ZoomCenter

Point ZoomCenter
getset

Gets/sets the zoom center.

Point in the bitmap source which is the center of the zoomed view port. Coordinates are in bitmap pixels.

Implements IDisplay.

◆ ZoomFactor

double ZoomFactor
getset

The current zoom factor of the image.

A zoom factor larger than 1.0 magnifies the displayed image; values smaller than 1.0 zoom out whereas 1.0 displays the image as is (this resembles System.Windows.Media.Stretch.None). The special value 0.0 identifies the panorama or stretch mode which resembles System.Windows.Media.Stretch.Uniform (the default). Values smaller 0.0 are invalid.

To get the actual value, e.g. in panorama/stretch mode, use the ActualZoomFactor property.

Implements IDisplay.

◆ ZoomTransform

Transform ZoomTransform
get

The transform affecting the zoom parameters.

Default value is the Transform.Identity transform.

The behavior is like the render transform of a UIElement as the actual ZoomCenter and ZoomFactor values are not changed.