In most applications you want to visualize at least some results.
Then, you start by adding HSmartWindowControl to the form by double-clicking
the corresponding icon in the toolbar.
An empty (black) window appears (see figure 11.4).
HALCON XL applications:
If you already added the HALCON version of the control, but now want to use
HALCON XL, simply delete the reference to HALCON/.NET DLL in the Solution
Explorer and add a reference to HALCON/.NET XL DLL instead.
If you want to fit an image automatically without the need to double click,
you can use the operator SetPart:
WindowControl.HalconWindow.SetPart(0, 0, -2, -2);
Alternatively, you can call SetFullImagePart to resize the
image to the size of the window control:
WindowControl.SetFullImagePart(null);
The properties specific to this control are listed below in alphabetical order.
They can be adapted in the Properties window (see figure 11.4).
Note that some properties are only available for HSmartWindowControlWPF elements.
All properties of the HSmartWindowControlWPF support data binding.
Do not modify the “Brush” properties in Visual Studio.
They are disabled for HSmartWindowControlWPF to prevent undesired
side-effects.
HColor
Specifies the color of HRegion and HXLDCont objects.
HColored
Specifies the colors for displaying multiple HRegion or HXLDCont objects
in different colors.
HDisableAutoResize
If set to true, images are not automatically scaled when they are
displayed.
HDisplayCurrentObject
Displays the assigned HImage or HObject.
HDoubleClickToFitContent
If set to true (the default), double clicking resizes the content of the
HSmartWindowControl to fit the size of the control.
If the HKeepAspectRatio is also set to true, the contents are rescaled so
that the aspect ratio is maintained.
HDraw
Specifies the fill mode of HRegion objects.
If HDraw is set to 'fill', output regions are filled, if set to 'margin',
only contours are displayed.
HDrawingObjectsModifier
Specifies the modifier key to interact with drawing objects.
If a modifier key is set, the user can only interact with drawing objects
while keeping the modifier key pressed.
This is especially useful when interacting with XLD drawing objects.
By default, it is set to None.
Other possible values are Alt, Ctrl, or Shift.
HFont
Specifies the font for displaying messages in the HSmartWindowControlWPF.
HImagePart
Specifies the image part of the corresponding HALCON window.
Note that the part is specified with the values X,
Y, Width, and Height, whereas the
corresponding operator SetPart expects the four corner
points.
Note that you can modify the displayed part in your application at any time,
e.g., to display a zoomed part of the image.
See section “Visualization” for more information about
actually visualizing results.
HKeepAspectRatio
If set to true (the default), the content of the HSmartWindowControl keeps
its aspect ratio when the control is resized or zoomed.
The aspect ratio is the quotient Width/Height set at design time with
HImagePart.
HLineStyle
Specifies the contour pattern of HRegion and HXLDCont objects.
HLineWidth
Specifies the contour thickness of HRegion and HXLDCont objects.
HMoveContent
If set to true (the default), the contents of the HALCON window can be
dragged using the mouse.
HZoomContent
Specifies the behavior of the mouse wheel.
If set to WheelForwardZoomsIn (the default), the contents of the
HALCON window is zoomed in and out when moving the mouse wheel forwards and
backwards, respectively.
Setting the property to WheelBackwardZoomsIn reverses the behavior.
If set to Off, zooming using the mouse wheel is disabled.
HZoomFactor
Specifies the step size when zooming with the mouse wheel. The default is
1.41. Values must be greater than 1 and less or equal to 100.
A higher value leads to faster zooming.
The HSmartWindowControlWPF can be used to implement the Model-View-Viewmodel
(MVVM) pattern, as all properties of the control support data binding.
By adding objects to the Items collection or setting the ItemsSource property
you can specify what the control should display, also in pure XAML code.
The following example illustrates how to show an image, color a region
in “magenta”, and display a text message:
<HalconDotNet:HSmartWindowControlWPF HDraw="fill">
<!--Iconic items can be added using HIconicDisplayObjectWPFs-->
<HalconDotNet:HIconicDisplayObjectWPF IconicObject="{Binding DisplayImage}"/>
<!--Also with individual drawing properties-->
<HalconDotNet:HIconicDisplayObjectWPF IconicObject="{Binding DisplayRegion}"
HDraw="margin" HColor="magenta"/>
<!--Messages can be displayed using HMessageDisplayObjectWPFs-->
<HalconDotNet:HMessageDisplayObjectWPF HMessageText="{Binding ImageName}"/>
</HalconDotNet:HSmartWindowControlWPF>
Note that DisplayImage, DisplayRegion and ImageName have to exist
in the DataContext of the HSmartWindowControlWPF.