CVB.Net 14.0
Display Class Reference

Displays images with optional overlays and zoom control. More...

Inherits ItemsControl, and IDisplay.

Inherited by ImageEditor.

Public Member Functions

 Display ()
 Creates an empty display.
 
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...
 
override void OnApplyTemplate ()
 Invoked whenever application code or internal processes call System.Windows.FrameworkElement.ApplyTemplate.
 
Point TranslatePointToImage (Point point)
 Translates a point relative to this display to coordinates that are relative to the ImageSource content pixels. More...
 
Point TranslatePointToImage (Point point, CoordinateSystemType coordinateType)
 Translates a point relative to this display 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 display. More...
 
Point TranslatePointFromImage (Point point, CoordinateSystemType coordinateType)
 Translates a point relative to the ImageSource content pixels to coordinates relative to this display. More...
 
WinRect TranslateRectToImage (WinRect rect)
 Translates a rect relative to this display 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 display. More...
 
void RedrawImage ()
 Redraws the display based on the set IDisplay.Image. 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 ActualZoomFactor.
 
static readonly DependencyProperty ImageProperty
 Backing store for Image.
 
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 HighBitScaleModeProperty
 Backing store for Display.HighBitScaleMode.
 
static readonly DependencyProperty HorizontalScrollBarHeightProperty
 Backing store of the HorizontalScrollBarHeight 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 DependencyProperty IsAnimatedProperty
 Backing store for the IsAnimated property.
 
static readonly DependencyProperty IsAnimationInProgressProperty
 Backing store for the read only IsAnimationInProgress property.
 
static readonly DependencyProperty IsInStretchModeProperty
 Backing store for read only IsInStretchMode.
 
static DependencyProperty IsMouseOverInfoEnabledProperty
 Backing store for the IsMouseOverInfoEnabled property. More...
 
static readonly DependencyProperty IsZoomActiveProperty
 Backing store for the IsZoomActive.
 
static readonly DependencyProperty IsZoomAdornerVisibleProperty
 Backing store for the IsZoomAdornerVisible property.
 
static readonly DependencyProperty MeasureLineAdornerProperty
 Backing store of the MeasureLineAdorner property.
 
static readonly DependencyProperty MouseOverImageInfoAnchorBottomProperty
 Backing store for the MouseOverImageInfoAnchorBottom property.
 
static readonly DependencyProperty MouseOverImageInfoAnchorRightProperty
 Backing store for the MouseOverImageInfoAnchorRight property.
 
static readonly DependencyProperty MouseOverInfoTypesProperty
 Backing store of the MouseOverInfoTypes property.
 
static readonly DependencyProperty OverlayCanvasProperty
 Backing store for OverlayCanvas.
 
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 VerticalScrollBarWidthProperty
 Backing store for the VerticalScrollBarWidth property.
 
static readonly DependencyProperty ZoomCenterProperty
 Backing store for ZoomCenter.
 
static readonly DependencyProperty ZoomFactorProperty
 Backing store for ZoomFactor.
 
const string PART_DisplayCanvas = "PART_DisplayCanvas"
 The name of the DisplayCanvas part.
 

Protected Member Functions

override Size ArrangeOverride (Size arrangeBounds)
 Intercepted to arrange the adorners. More...
 
override Size MeasureOverride (Size constraint)
 Intercepted to measure the adorners. 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...
 
Stemmer.Cvb.Image Image [get, set]
 Gets/sets a Stemmer.Cvb.Image as the image source of this display. More...
 
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...
 
HighBitScaleMode HighBitScaleMode [get, set]
 Gets/sets the Stemmer.Cvb.HighBitScaleMode used by this display.
 
double HorizontalScrollBarHeight [get]
 Gets the height of the horizontal scroll bar. More...
 
BitmapSource ImageSource [get, set]
 Image source of this display.
 
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 IsAnimated [get, set]
 Gets/sets whether ZoomCenter or ZoomFactor changes are animated.
 
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 IsMouseOverInfoEnabled [get, set]
 Gets/sets whether the mouse over info adorners are active.
 
bool IsZoomActive [get]
 Gets whether this control is currently in zoom mode despite stretch mode. More...
 
bool IsZoomAdornerVisible [get, set]
 Gets/sets whether the zoom adorner is visible or not.
 
MeasureLineAdorner MeasureLineAdorner [get]
 Gets the MeasureLineAdorner object.
 
double MouseOverImageInfoAnchorBottom [get, set]
 Gets/sets the right anchor line for the image information adorner.
 
double MouseOverImageInfoAnchorRight [get, set]
 Gets/sets the right anchor line for the image information adorner.
 
MouseOverInformation MouseOverInfoTypes [get, set]
 Gets/sets the mouse-over adorner types.
 
DisplayCanvas OverlayCanvas [get]
 Gets the overlay canvas of this display.
 
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...
 
double VerticalScrollBarWidth [get]
 Gets the width of the vertical scroll bar. More...
 
Point ZoomCenter [get, set]
 Gets/sets the zoom center. More...
 
double ZoomFactor [get, set]
 The current zoom factor of the image. More...
 
static RoutedCommand ActualSizeZoom [get]
 Gets the command that is used to set the zoom factor to 100%.
 
static RoutedCommand DecreaseZoom [get]
 Gets the command that is used to decrease the zoom factor one step. More...
 
static RoutedCommand IncreaseZoom [get]
 Gets the command that is used to increase the zoom factor one step. More...
 
static RoutedCommand StretchZoom [get]
 Gets the command that is used to switch to the stretch zoom mode.
 
- 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

Displays images with optional overlays and zoom control.

Windows Presentation Foundation implementation of the CVB display.

To use the display 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 in the XAML file:
    \<cvb:Display /\>
    Displays images with optional overlays and zoom control.
    Definition: Display.cs:114

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

\<cvb:Display 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:Display\>
This canvas displays an image in the background and arranges its children according to the pixel coor...
Definition: DisplayCanvas.cs:239
BitmapSource ImageSource
Image source of this display.
Definition: Display.cs:535

If you want to do less typing and be more clear about your intentions you can write the above example like that:

\<cvb:Display ImageSource="C:\Program Files\Stemmer Imaging\Common Vision Blox\Tutorial\Clara.bmp"\>
\<cvb:ImageOverlay OverlayX="50" OverlayY="85" OverlayWidth="40" OverlayHeight="25"
\<Rectangle StrokeThickness="1" Stroke="Red" /\>
\</cvb:ImageOverlay\>
\</cvb:Display\>
Stemmer.Cvb.Wpf.Controls.Display overlay placed on the displayed image.
Definition: ImageOverlay.cs:19
AutoScaleContent
Determines whether the content is automatically scaled by the canvas via a render transform or not.
Definition: DisplayCanvas.cs:111

Member Function Documentation

◆ ArrangeOverride()

override Size ArrangeOverride ( Size  arrangeBounds)
protected

Intercepted to arrange the adorners.

Parameters
arrangeBoundsBounding size of the display.
Returns
The size of the control.

◆ MeasureOverride()

override Size MeasureOverride ( Size  constraint)
protected

Intercepted to measure the adorners.

Parameters
constraintConstraint size of this control.
Returns
The desired size of this control.

◆ 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.

◆ 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; null if just the image data is to be redisplayed.
Returns
Task to wait on for completion. The task's state will be canceled if it was not used for actually updating the display.

◆ TranslatePointFromImage() [1/2]

Point TranslatePointFromImage ( Point  point)

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

Dependent on the ActualZoomFactor the translated coordinates may contain fractions.

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

◆ TranslatePointFromImage() [2/2]

Point TranslatePointFromImage ( Point  point,
CoordinateSystemType  coordinateType 
)

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

Dependent on the ActualZoomFactor 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 display.

◆ TranslatePointToImage() [1/2]

Point TranslatePointToImage ( Point  point)

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

Dependent on the ActualZoomFactor the translated coordinates may contain fractions.

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

◆ TranslatePointToImage() [2/2]

Point TranslatePointToImage ( Point  point,
CoordinateSystemType  coordinateType 
)

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

Dependent on the ActualZoomFactor the translated coordinates may contain fractions.

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

◆ TranslateRectFromImage()

WinRect TranslateRectFromImage ( WinRect  rect)

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

Dependent on the ActualZoomFactor the translated coordinates may contain fractions.

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

◆ TranslateRectToImage()

WinRect TranslateRectToImage ( WinRect  rect)

Translates a rect relative to this display 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 display.
Returns
Translated rectangle value relative to the image source pixels.

Member Data Documentation

◆ IsMouseOverInfoEnabledProperty

DependencyProperty IsMouseOverInfoEnabledProperty
static

Backing store for the IsMouseOverInfoEnabled property.

See MouseOverInfoTypes for additional information which overlays are shown.

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.

◆ DecreaseZoom

RoutedCommand DecreaseZoom
staticget

Gets the command that is used to decrease the zoom factor one step.

This resembles Ctrl-MouseWheelDown.

◆ 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.

◆ HorizontalScrollBarHeight

double HorizontalScrollBarHeight
get

Gets the height of the horizontal scroll bar.

I know, lookless controls and you shouldn't do that, but it is so very useful for laying out things...

Height of the actual horizontal scroll bar; 0 if none is shown.

◆ Image

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 Stemmer.Cvb.Images from non-UI threads.

◆ 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 display's left border in device independent pixels.

◆ ImageViewportVerticalOffset

double ImageViewportVerticalOffset
get

Gets the vertical offset to the displayed image.

Vertical offset from the display's 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.

◆ IncreaseZoom

RoutedCommand IncreaseZoom
staticget

Gets the command that is used to increase the zoom factor one step.

This resembles Ctrl-MouseWheelUp.

◆ 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.

◆ 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 used in stretch mode.

Implements IDisplay.

◆ VerticalScrollBarWidth

double VerticalScrollBarWidth
get

Gets the width of the vertical scroll bar.

I know, lookless controls and you shouldn't do that, but it is so very useful for laying out things...

Width of the actual vertical scroll bar; 0 if none is shown.

◆ 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.

See also
DisplayCanvas.ZoomFactor

Implements IDisplay.