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< DisplayZoomEventArgs > | ActualZoomCenterChanged |
Bubbling routed event that is fired when the ActualZoomCenter changes. | |
EventHandler< DisplayZoomEventArgs > | ActualZoomFactorChanged |
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< ImageSourceChangedEventArgs > | ImageSourceChanged |
Bubbling event that is fired when the ImageSource changes. | |
EventHandler< DisplayZoomEventArgs > | ZoomCenterChanged |
Bubbling event that is fired when the ZoomCenter property is changed. | |
EventHandler< DisplayZoomEventArgs > | ZoomFactorChanged |
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< Image > | ImageObserver [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< DisplayZoomEventArgs > | ActualZoomCenterChanged |
Bubbling routed event that is fired when the ActualZoomCenter changes. | |
EventHandler< DisplayZoomEventArgs > | ActualZoomFactorChanged |
Bubbling routed event that is fired when the ActualZoomFactor changes. | |
EventHandler< DisplayZoomEventArgs > | ZoomCenterChanged |
Bubbling event that is fired when the ZoomCenter property is changed. | |
EventHandler< DisplayZoomEventArgs > | ZoomFactorChanged |
Bubbling event that is fired when the ZoomFactor property is changed. | |
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:
Example on how to place a standard WPF Rectangle
on the display:
If you want to do less typing and be more clear about your intentions you can write the above example like that:
|
protected |
Intercepted to arrange the adorners.
arrangeBounds | Bounding size of the display. |
|
protected |
Intercepted to measure the adorners.
constraint | Constraint size of this control. |
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.
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.
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.
image | Image to display; null if just the image data is to be redisplayed. |
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.
point | Point relative to the image source pixels. |
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.
point | Point relative to the image source pixels. |
coordinateType | Defines whether the image coordinate system is incorporated in the calculation. |
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.
point | Point as relative to this display. |
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.
point | Point as relative to this display. |
coordinateType | Defines whether the image coordinate system is incorporated in the calculation. |
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.
rect | Rectangle relative to the image source pixels. |
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.
rect | Rectangle relative to this display. |
|
static |
Backing store for the IsMouseOverInfoEnabled property.
See MouseOverInfoTypes for additional information which overlays are shown.
|
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.
|
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.
|
staticget |
Gets the command that is used to decrease the zoom factor one step.
This resembles Ctrl-MouseWheelDown.
|
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.
|
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.
|
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.
|
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.
|
get |
Gets the the displayed image region shown width.
Shown part of the image in device independent pixels.
|
get |
Gets the horizontal offset to the displayed image.
Horizontal offset from the display's left border in device independent pixels.
|
get |
Gets the vertical offset to the displayed image.
Vertical offset from the display's top border in device independent pixels.
|
get |
Gets the the displayed image region shown width.
Shown part of the image in device independent pixels.
|
staticget |
Gets the command that is used to increase the zoom factor one step.
This resembles Ctrl-MouseWheelUp.
|
get |
|
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.
|
getset |
Gets/sets whether the display is to be redrawn as soon as the image data has been updated.
Default is true
.
|
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.
|
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.
|
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.
|
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.