Create a custom property dialog that will be displayed when you right click the ImageKit Control and select "Properties" in the editing context menu or when you click the "Properties" button in the ToolBarAnnotation toolbar.
Code Example
Display a dialog that sets the "Color/Text Color" and "Line Thickness"
* In addition to the main form, create a form (Form2) with a "Change color / text color" button and numericUpDown1 to set the line thickness.
Custom Dialog
[Visual Basic.NET]
* Description in the main form
'Declare the form to use to make the
custom dialog
Private WithEvents myDialog As New Form2()
'Describe the following in the Form Load
event of the main form.
'* When using annotation functions, the
following property must be set to True.
ImageKit1.Edit.EditEnabled = True
'Set the your dialog into the
CustomDialog property
ImageKit1.Edit.CustomDialog = myDialog
'Get the event that closes the custom
dialog
AddHandler myDialog.FormClosed, AddressOf myDialog_FormClosed
'Get the contents of the object for
display of the custom dialog (= myDialog (= Form2))
Private Sub ImageKit1_ObjectSelected(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ImageKit1.ObjectSelected
myDialog.ikForecolor =
ImageKit1.Edit.SelectedObjectForeColor
myDialog.ikPenWidth =
ImageKit1.Edit.SelectedObjectPenWidth
End Sub
'When the "OK" button is pressed in the
custom dialog, the settings are reflected in the object.
Private Sub myDialog_FormClosed(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.FormClosedEventArgs)
If (myDialog.DialogResult =
DialogResult.OK) Then
ImageKit1.Edit.SelectedObjectForeColor
= myDialog.ikForecolor
ImageKit1.Edit.SelectedObjectPenWidth
= myDialog.ikPenWidth
End If
End Sub
* Description in the property dialog (Form2)
'Declare variables for object
properties
Friend ikForecolor As Color
Friend ikPenWidth As Integer
'On form load, set button text color and
NumericUpDown value to current values
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
button1.ForeColor = ikForecolor
numericUpDown1.Value = ikPenWidth
End Sub
'When the color button is pressed, a
color dialog is displayed and the color is set.
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button1.Click
Dim cd As New ColorDialog()
If (cd.ShowDialog() =
DialogResult.OK) Then
button1.ForeColor
= cd.Color
End If
cd.Dispose()
End Sub
'Reflect the contents set with the "OK"
button
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles button2.Click
ikForecolor = button1.ForeColor
ikPenWidth = numericUpDown1.Value
End Sub
[Visual C#.NET]
//Declare the form to use to make the
custom dialog
private Form2 myDialog = new Form2();
//Describe the following in the Form
Load event of the main form.
//* When using annotation functions, the
following property must be set to True.
ImageKit1.Edit.EditEnabled = true;
//Set the your dialog into the
CustomDialog property
ImageKit1.Edit.CustomDialog = myDialog;
//Get the event that closes the custom
dialog
myDialog.FormClosed += new
FormClosedEventHandler(myDialog_FormClosed);
//Get the contents of the object for
display of the custom dialog (= myDialog (= Form2))
private void ImageKit1_ObjectSelected(object sender, EventArgs
e)
{
myDialog.ikForecolor =
ImageKit1.Edit.SelectedObjectForeColor;
myDialog.ikPenWidth =
ImageKit1.Edit.SelectedObjectPenWidth;
}
//When the "OK" button is pressed in the
custom dialog, the settings are reflected in the object.
void myDialog_FormClosed(object sender, FormClosedEventArgs e)
{
if (myDialog.DialogResult ==
DialogResult.OK)
{
ImageKit1.Edit.SelectedObjectForeColor
= myDialog.ikForecolor;
ImageKit1.Edit.SelectedObjectPenWidth
= myDialog.ikPenWidth;
}
}
* Description in the property dialog (Form2)
//Declare variables for object
properties
internal Color ikForecolor = Color.Black;
internal int ikPenWidth = 0;
//On form load, set button text color
and NumericUpDown value to current values
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
button1.ForeColor = ikForecolor;
numericUpDown1.Value =
ikPenWidth;
End Sub
//When the color button is pressed, a
color dialog is displayed and the color is set.
private void button1_Click(object sender, EventArgs e)
{
ColorDialog cd = new
ColorDialog();
if (cd.ShowDialog() ==
DialogResult.OK)
button1.ForeColor
= cd.Color;
cd.Dispose();
}
//Reflect the contents set with the "OK"
button
private void button2_Click(object sender, EventArgs e)
{
ikForecolor = button1.ForeColor;
ikPenWidth =
(int)numericUpDown1.Value;
}
Relevant Properties
ImageKit.Edit.CustomDialog
ImageKit.Edit.SelectedObjectForeColor
For a full list of properties, please see:
ImageKit.Edit
Members