Displays the object context menu.
public virtual void ShowObjectContextMenu(
Point pos
)
Public Overridable Sub ShowObjectContextMenu( _
ByVal pos As Point _
)
public:
virtual void ShowObjectContextMenu(
Point pos
)
pos
Specifies the location at which the menu should be displayed.
Call the CanShowObjectContextMenu property to determine whether the object context menu can be displayed at this time. The context menu used is the AnnAutomationObject.ContextMenu for the object type currently bring edited. If the value of AnnAutomationObject.ContextMenu is null (Nothing in VB), this method will not do anything.
This AnnAutomation will call this method when the user right-clicks the mouse cursor over the currently selected (edited) object. If the user clicks outside any selected objects, the ShowContextMenu method will be called instead. You can call this method to display this context menu manually (for example, as a result from clicking on a certain menu item in your application).
If the AnnAutomationManager.ContextMenu value is null (Nothing in VB), this method will not do anything.
This example shows the object context menu
using Leadtools;
using Leadtools.Annotations;
using Leadtools.WinForms;
using Leadtools.Drawing;
public void AnnAutomation_ShowObjectContextMenu(AnnAutomation automation)
{
// first add a new object to the automation
AnnRectangleObject rectObj = new AnnRectangleObject();
rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);
rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));
rectObj.Brush = new AnnSolidBrush(Color.Yellow);
automation.Container.Objects.Add(rectObj);
automation.Viewer.Invalidate(rectObj.InvalidRectangle);
// make sure no objects are selected in the automation
automation.SelectNone();
// show the object context menu (this should show a message informing you that no objects are currently selected (bring edited)
ShowContextMenu(automation);
// select (edit) the object we have just added
automation.StartEditing(rectObj, false);
// show the object context menu (should show the object context menu)
ShowContextMenu(automation);
}
private void ShowContextMenu(AnnAutomation automation)
{
// check if we can show the context menu
if (automation.CanShowObjectContextMenu)
{
// use the right-bottom position of the object invalid rectangle as the position of the menu
Rectangle rc = automation.CurrentEditObject.InvalidRectangle;
Point pos = new Point(rc.Right, rc.Bottom);
automation.ShowObjectContextMenu(pos);
}
else
MessageBox.Show("Cannot show the object context menu because no object is currently being edited (selected)");
}
Imports Leadtools
Imports Leadtools.Annotations
Imports Leadtools.WinForms
Imports Leadtools.Drawing
Public Sub AnnAutomation_ShowObjectContextMenu(ByVal automation As AnnAutomation)
' first add a new object to the automation
Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)
rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))
rectObj.Brush = New AnnSolidBrush(Color.Yellow)
automation.Container.Objects.Add(rectObj)
automation.Viewer.Invalidate(rectObj.InvalidRectangle)
' make sure no objects are selected in the automation
automation.SelectNone()
' show the object context menu (this should show a message informing you that no objects are currently selected (bring edited)
ShowContextMenu(automation)
' select (edit) the object we have just added
automation.StartEditing(rectObj, False)
' show the object context menu (should show the object context menu)
ShowContextMenu(automation)
End Sub
Private Sub ShowContextMenu(ByVal automation As AnnAutomation)
' check if we can show the context menu
If automation.CanShowObjectContextMenu Then
' use the right-bottom position of the object invalid rectangle as the position of the menu
Dim rc As Rectangle = automation.CurrentEditObject.InvalidRectangle
Dim pos As Point = New Point(rc.Right, rc.Bottom)
automation.ShowObjectContextMenu(pos)
Else
MessageBox.Show("Cannot show the object context menu because no object is currently being edited (selected)")
End If
End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET