This example illustates how to display a custom context menu by right clicking on the ImageKit Control.

The custom context menu will have items labeled "Change Color", "Rotate", "Copy and Paste", and "Properties".

Custom Context Menu

The steps to accomplish this are:
1. Place a System.Window.Forms.ContextMenuStrip control on your form.
2. Add four TooStripMenuItems and label them "Change color" "Rotate" "Copy and paste" "Properties".
3. Set the click events.

Code Example

[Visual Basic.NET]

'Write the following code in the Form Load event etc.
     '* The EditEnabled property must be set to True when using annotation functions.

     ImageKit1.Edit.EditEnabled = True

     'Assign contextMenuStrip1 to the ImageKit control's ContextMenuStrip property
     ImageKit1.Edit.ContextMenuEnabled = False
     ImageKit1.ContextMenuStrip = contextMenuStrip1

 

'Add Events

'When custom context menu 1 is clicked, make the color of the selected object red
Private Sub Change Color ToolStripMenuItem_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Change Color ToolStripMenuItem.Click
    ImageKit1.Edit.SelectedObjectForeColor = Color.Red
End Sub

'When custom context menu 2 is clicked, rotate the selected object +30 degrees
Private Sub Rotating ToolStripMenuItem_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rotating ToolStripMenuItem.Click
    ImageKit1.Edit.SelectedObjectAngle + = 30
End Sub

'When custom context menu 3 is clicked, copy the selected object and paste it at the position where the upper left coordinates are (50, 50)
Private Sub Copy and Paste ToolStripMenuItem_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Copy and Paste ToolStripMenuItem.Click
    ImageKit1.Edit.CopySelectedObjects ()
    ImageKit1.Edit.PasteCopiedObjects (50, 50)'* The upper left is the position of (50, 50) when the angle is 0, so it may look different if it is rotating.
End Sub

'When custom context menu 4 is clicked, display the property dialog for the selected object
Private Sub Property ToolStripMenuItem_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Property ToolStripMenuItem.Click
    ImageKit1.Edit.ShowPropertyDialog ()
End Sub

 

[Visual C#.NET]

//Write the following code in the Form Load event etc.
     //* The EditEnabled property must be set to True when using annotation functions.

    ImageKit1.Edit.EditEnabled = true;

     //Assign contextMenuStrip1 to the ImageKit control's ContextMenuStrip property
     ImageKit1.Edit.ContextMenuEnabled = false;
     ImageKit1.ContextMenuStrip = contextMenuStrip1;

 

//Add Events

//When custom context menu 1 is clicked, make the color of the selected object red
private void Change Color ToolStripMenuItem_Click(object sender, EventArgs e)
{
     ImageKit1.Edit.SelectedObjectForeColor = Color.Red;
}

//When custom context menu 2 is clicked, rotate the selected object +30 degrees
private void Rotate ToolStripMenuItem_Click(object sender, EventArgs e)
{
    ImageKit1.Edit.SelectedObjectAngle += 30;
}

//When custom context menu 3 is clicked, copy the selected object and paste it at the position where the upper left coordinates are (50, 50)
private void Copy and Paste ToolStripMenuItem_Click(object sender, EventArgs e)
{
    ImageKit1.Edit.CopySelectedObjects ();
    ImageKit1.Edit.PasteCopiedObjects (50, 50); //* The upper left is the position of (50, 50) when the angle is 0, so it may look different if it is rotating.
}

//When custom context menu 4 is clicked, display the property dialog for the selected object
private void Property ToolStripMenuItem_Click(object sender, EventArgs e)
{
    ImageKit1.Edit.ShowPropertyDialog ();
}

Referenced Properties

ImageKit.Edit.ContextMenuEnabled

The ImageKit.NET3 is created by Newtone Corporation