Displays the object context menu.
Syntax
Visual Basic (Declaration) | |
---|
Public Overridable Sub ShowObjectContextMenu( _
ByVal pos As Point _
) |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As AnnAutomation
Dim pos As Point
instance.ShowObjectContextMenu(pos)
|
C# | |
---|
public virtual void ShowObjectContextMenu(
Point pos
) |
Managed Extensions for C++ | |
---|
public: virtual void ShowObjectContextMenu(
Point pos
) |
C++/CLI | |
---|
public:
virtual void ShowObjectContextMenu(
Point pos
) |
Parameters
- pos
- Specifies the location at which the menu should be displayed.
Example
This example shows the object context menu
Visual Basic | Copy Code |
---|
Public Sub AnnAutomation_ShowObjectContextMenu(ByVal automation As AnnAutomation)
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)
automation.SelectNone()
ShowContextMenu(automation)
automation.StartEditing(rectObj, False)
ShowContextMenu(automation)
End Sub
Private Sub ShowContextMenu(ByVal automation As AnnAutomation)
If automation.CanShowObjectContextMenu Then
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 |
C# | Copy Code |
---|
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)"); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also