About the Feature editing with the control commands Sample
[C#]
EditProperties.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Display;
namespace EditPropertiesDialog
{
public class EditProperties : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtSketchWidth;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnSketchColor;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.TextBox txtPrecision;
private System.Windows.Forms.Label lblStream;
private System.Windows.Forms.TextBox txtStreamCount;
private System.Windows.Forms.TextBox txtTolerance;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.CheckBox chkStretch;
private IEngineEditProperties m_engineEditProperties = new EngineEditorClass();
private bool bSketchColor;
private int R;
private int B;
private int G;
private System.ComponentModel.Container components = null;
public EditProperties()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnSketchColor = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.txtSketchWidth = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.label8 = new System.Windows.Forms.Label();
this.txtPrecision = new System.Windows.Forms.TextBox();
this.lblStream = new System.Windows.Forms.Label();
this.txtStreamCount = new System.Windows.Forms.TextBox();
this.txtTolerance = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.chkStretch = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnSketchColor);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.txtSketchWidth);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Location = new System.Drawing.Point(8, 144);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(160, 96);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Sketch Symbol";
//
// btnSketchColor
//
this.btnSketchColor.Location = new System.Drawing.Point(72, 56);
this.btnSketchColor.Name = "btnSketchColor";
this.btnSketchColor.Size = new System.Drawing.Size(64, 24);
this.btnSketchColor.TabIndex = 3;
this.btnSketchColor.Text = "Pick Color";
this.btnSketchColor.Click += new System.EventHandler(this.btnSketchColor_Click);
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 24);
this.label3.TabIndex = 2;
this.label3.Text = "Color:";
//
// txtSketchWidth
//
this.txtSketchWidth.Location = new System.Drawing.Point(72, 24);
this.txtSketchWidth.Name = "txtSketchWidth";
this.txtSketchWidth.Size = new System.Drawing.Size(64, 20);
this.txtSketchWidth.TabIndex = 1;
this.txtSketchWidth.Text = "";
this.txtSketchWidth.TextChanged += new System.EventHandler(this.txtSketchWidth_TextChanged);
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(48, 24);
this.label2.TabIndex = 0;
this.label2.Text = "Width:";
//
// label8
//
this.label8.Location = new System.Drawing.Point(8, 16);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(104, 16);
this.label8.TabIndex = 4;
this.label8.Text = "Report Precision:";
//
// txtPrecision
//
this.txtPrecision.Location = new System.Drawing.Point(113, 14);
this.txtPrecision.Name = "txtPrecision";
this.txtPrecision.Size = new System.Drawing.Size(56, 20);
this.txtPrecision.TabIndex = 5;
this.txtPrecision.Text = "";
this.txtPrecision.TextChanged += new System.EventHandler(this.txtPrecision_TextChanged);
//
// lblStream
//
this.lblStream.Location = new System.Drawing.Point(8, 48);
this.lblStream.Name = "lblStream";
this.lblStream.Size = new System.Drawing.Size(104, 16);
this.lblStream.TabIndex = 4;
this.lblStream.Text = "Stream Count:";
//
// txtStreamCount
//
this.txtStreamCount.Location = new System.Drawing.Point(113, 48);
this.txtStreamCount.Name = "txtStreamCount";
this.txtStreamCount.Size = new System.Drawing.Size(56, 20);
this.txtStreamCount.TabIndex = 7;
this.txtStreamCount.Text = "";
this.txtStreamCount.TextChanged += new System.EventHandler(this.txtStreamCount_TextChanged);
//
// txtTolerance
//
this.txtTolerance.Location = new System.Drawing.Point(113, 80);
this.txtTolerance.Name = "txtTolerance";
this.txtTolerance.Size = new System.Drawing.Size(56, 20);
this.txtTolerance.TabIndex = 9;
this.txtTolerance.Text = "";
this.txtTolerance.TextChanged += new System.EventHandler(this.txtTolerance_TextChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(104, 16);
this.label1.TabIndex = 4;
this.label1.Text = "Stream Tolerance:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 112);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(104, 16);
this.label4.TabIndex = 4;
this.label4.Text = "Stretch Geometry:";
//
// chkStretch
//
this.chkStretch.Location = new System.Drawing.Point(112, 104);
this.chkStretch.Name = "chkStretch";
this.chkStretch.Size = new System.Drawing.Size(16, 32);
this.chkStretch.TabIndex = 11;
//
// EditProperties
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(177, 253);
this.Controls.Add(this.chkStretch);
this.Controls.Add(this.label4);
this.Controls.Add(this.txtTolerance);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtStreamCount);
this.Controls.Add(this.lblStream);
this.Controls.Add(this.txtPrecision);
this.Controls.Add(this.label8);
this.Controls.Add(this.groupBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "EditProperties";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Edit Properties";
this.Closing += new System.ComponentModel.CancelEventHandler(this.EditProperties_Closing);
this.Load += new System.EventHandler(this.EditProperties_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void EditProperties_Load(object sender, System.EventArgs e)
{
//Populate form with current IEngineProperties values
txtPrecision.Text = m_engineEditProperties.ReportPrecision.ToString();
txtSketchWidth.Text = m_engineEditProperties.SketchSymbol.Width.ToString();
txtStreamCount.Text = m_engineEditProperties.StreamGroupingCount.ToString();
txtTolerance.Text = m_engineEditProperties.StreamTolerance.ToString();
if (m_engineEditProperties.StretchGeometry)
chkStretch.Checked = true;
else
chkStretch.Checked = false;
txtPrecision.Focus();
}
private void EditProperties_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
//Update precision property
if (txtPrecision.Text != "")
m_engineEditProperties.ReportPrecision = Convert.ToInt32(txtPrecision.Text);
//Update stream grouping count
if (txtStreamCount.Text != "")
m_engineEditProperties.StreamGroupingCount = Convert.ToInt32(txtStreamCount.Text);
//Update stream tolerance
if (txtTolerance.Text != "")
m_engineEditProperties.StreamTolerance = Convert.ToInt32(txtTolerance.Text);
//Update stretch geometry property
if (chkStretch.Checked)
m_engineEditProperties.StretchGeometry = true;
else
m_engineEditProperties.StretchGeometry = false;
//Update sketch symbol property
if (bSketchColor || txtSketchWidth.Text != "")
{
ILineSymbol lineSymbol = m_engineEditProperties.SketchSymbol;
if(bSketchColor)
{
IRgbColor color = new RgbColorClass();
color.Red = R;
color.Blue = B;
color.Green = G;
lineSymbol.Color = color;
}
if (txtSketchWidth.Text != "")
{
lineSymbol.Width = Convert.ToInt32(txtSketchWidth.Text);
}
m_engineEditProperties.SketchSymbol = lineSymbol;
}
}
private void btnSketchColor_Click(object sender, System.EventArgs e)
{
//Create a new color dialog
ColorDialog colorDialog = new ColorDialog();
//Prevent the user from selecting a custom color
colorDialog.AllowFullOpen = false;
//Allows the user to obtain help (default is false)
colorDialog.ShowHelp = true;
if (colorDialog.ShowDialog() == DialogResult.OK)
{
R = Convert.ToInt32(colorDialog.Color.R);
B = Convert.ToInt32(colorDialog.Color.B);
G = Convert.ToInt32(colorDialog.Color.G);
bSketchColor = true;
}
}
private void txtSketchWidth_TextChanged(object sender, System.EventArgs e)
{
//Validate sketch width
try
{
if (txtSketchWidth.Text != "")
Convert.ToInt32(txtSketchWidth.Text);
}
catch (FormatException)
{
MessageBox.Show("Sketch width should be a numeric value", "Error sketch width");
txtSketchWidth.Text = "";
txtSketchWidth.Focus();
}
}
private void txtPrecision_TextChanged(object sender, System.EventArgs e)
{
//Validate precision
try
{
if (txtPrecision.Text != "")
Convert.ToInt32(txtPrecision.Text);
}
catch (FormatException)
{
MessageBox.Show("Precision should be a numeric value", "Error precision");
txtPrecision.Text = "";
txtPrecision.Focus();
}
}
private void txtStreamCount_TextChanged(object sender, System.EventArgs e)
{
//Validate tolerance
try
{
if (txtStreamCount.Text != "")
Convert.ToInt32(txtStreamCount.Text);
}
catch (FormatException)
{
MessageBox.Show("Stream count should be a numeric value", "Error Stream Count");
txtStreamCount.Text = "";
txtStreamCount.Focus();
}
}
private void txtTolerance_TextChanged(object sender, System.EventArgs e)
{
//Validate tolerance
try
{
if (txtTolerance.Text != "")
Convert.ToInt32(txtTolerance.Text);
}
catch (FormatException)
{
MessageBox.Show("Stream Tolerance should be a numeric value", "Error Stream Tolerance");
txtTolerance.Text = "";
txtTolerance.Focus();
}
}
}
}
[Visual Basic .NET]
EditProperties.vb
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.Display
Imports System.Windows.Forms
Public Class EditProperties
Inherits System.Windows.Forms.Form
Private m_engineEditProperties As New EngineEditorClass
Private bSketchColor As Boolean
Private R As Integer, B As Integer, G As Integer
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents chkStretch As System.Windows.Forms.CheckBox
Friend WithEvents label4 As System.Windows.Forms.Label
Friend WithEvents txtTolerance As System.Windows.Forms.TextBox
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents txtStreamCount As System.Windows.Forms.TextBox
Friend WithEvents lblStream As System.Windows.Forms.Label
Friend WithEvents txtPrecision As System.Windows.Forms.TextBox
Friend WithEvents label8 As System.Windows.Forms.Label
Friend WithEvents groupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents btnSketchColor As System.Windows.Forms.Button
Friend WithEvents label3 As System.Windows.Forms.Label
Friend WithEvents txtSketchWidth As System.Windows.Forms.TextBox
Friend WithEvents label2 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.chkStretch = New System.Windows.Forms.CheckBox
Me.label4 = New System.Windows.Forms.Label
Me.txtTolerance = New System.Windows.Forms.TextBox
Me.label1 = New System.Windows.Forms.Label
Me.txtStreamCount = New System.Windows.Forms.TextBox
Me.lblStream = New System.Windows.Forms.Label
Me.txtPrecision = New System.Windows.Forms.TextBox
Me.label8 = New System.Windows.Forms.Label
Me.groupBox1 = New System.Windows.Forms.GroupBox
Me.btnSketchColor = New System.Windows.Forms.Button
Me.label3 = New System.Windows.Forms.Label
Me.txtSketchWidth = New System.Windows.Forms.TextBox
Me.label2 = New System.Windows.Forms.Label
Me.groupBox1.SuspendLayout()
Me.SuspendLayout()
'
'chkStretch
'
Me.chkStretch.Location = New System.Drawing.Point(112, 96)
Me.chkStretch.Name = "chkStretch"
Me.chkStretch.Size = New System.Drawing.Size(16, 32)
Me.chkStretch.TabIndex = 20
'
'label4
'
Me.label4.Location = New System.Drawing.Point(8, 104)
Me.label4.Name = "label4"
Me.label4.Size = New System.Drawing.Size(104, 16)
Me.label4.TabIndex = 15
Me.label4.Text = "Stretch Geometry:"
'
'txtTolerance
'
Me.txtTolerance.Location = New System.Drawing.Point(112, 72)
Me.txtTolerance.Name = "txtTolerance"
Me.txtTolerance.Size = New System.Drawing.Size(56, 20)
Me.txtTolerance.TabIndex = 19
Me.txtTolerance.Text = ""
'
'label1
'
Me.label1.Location = New System.Drawing.Point(8, 72)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(104, 16)
Me.label1.TabIndex = 13
Me.label1.Text = "Stream Tolerance:"
'
'txtStreamCount
'
Me.txtStreamCount.Location = New System.Drawing.Point(112, 40)
Me.txtStreamCount.Name = "txtStreamCount"
Me.txtStreamCount.Size = New System.Drawing.Size(56, 20)
Me.txtStreamCount.TabIndex = 18
Me.txtStreamCount.Text = ""
'
'lblStream
'
Me.lblStream.Location = New System.Drawing.Point(8, 40)
Me.lblStream.Name = "lblStream"
Me.lblStream.Size = New System.Drawing.Size(104, 16)
Me.lblStream.TabIndex = 14
Me.lblStream.Text = "Stream Count:"
'
'txtPrecision
'
Me.txtPrecision.Location = New System.Drawing.Point(112, 8)
Me.txtPrecision.Name = "txtPrecision"
Me.txtPrecision.Size = New System.Drawing.Size(56, 20)
Me.txtPrecision.TabIndex = 17
Me.txtPrecision.Text = ""
'
'label8
'
Me.label8.Location = New System.Drawing.Point(8, 8)
Me.label8.Name = "label8"
Me.label8.Size = New System.Drawing.Size(104, 16)
Me.label8.TabIndex = 16
Me.label8.Text = "Report Precision:"
'
'groupBox1
'
Me.groupBox1.Controls.Add(Me.btnSketchColor)
Me.groupBox1.Controls.Add(Me.label3)
Me.groupBox1.Controls.Add(Me.txtSketchWidth)
Me.groupBox1.Controls.Add(Me.label2)
Me.groupBox1.Location = New System.Drawing.Point(8, 136)
Me.groupBox1.Name = "groupBox1"
Me.groupBox1.Size = New System.Drawing.Size(160, 96)
Me.groupBox1.TabIndex = 12
Me.groupBox1.TabStop = False
Me.groupBox1.Text = "Sketch Symbol"
'
'btnSketchColor
'
Me.btnSketchColor.Location = New System.Drawing.Point(72, 56)
Me.btnSketchColor.Name = "btnSketchColor"
Me.btnSketchColor.Size = New System.Drawing.Size(64, 24)
Me.btnSketchColor.TabIndex = 3
Me.btnSketchColor.Text = "Pick Color"
'
'label3
'
Me.label3.Location = New System.Drawing.Point(16, 64)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(48, 24)
Me.label3.TabIndex = 2
Me.label3.Text = "Color:"
'
'txtSketchWidth
'
Me.txtSketchWidth.Location = New System.Drawing.Point(72, 24)
Me.txtSketchWidth.Name = "txtSketchWidth"
Me.txtSketchWidth.Size = New System.Drawing.Size(64, 20)
Me.txtSketchWidth.TabIndex = 1
Me.txtSketchWidth.Text = ""
'
'label2
'
Me.label2.Location = New System.Drawing.Point(16, 24)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(48, 24)
Me.label2.TabIndex = 0
Me.label2.Text = "Width:"
'
'EditProperties
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(176, 238)
Me.Controls.Add(Me.chkStretch)
Me.Controls.Add(Me.label4)
Me.Controls.Add(Me.txtTolerance)
Me.Controls.Add(Me.label1)
Me.Controls.Add(Me.txtStreamCount)
Me.Controls.Add(Me.lblStream)
Me.Controls.Add(Me.txtPrecision)
Me.Controls.Add(Me.label8)
Me.Controls.Add(Me.groupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Name = "EditProperties"
Me.Text = "Edit Properties"
Me.groupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub EditProperties_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Populate form with current IEngineProperties values
txtPrecision.Text = m_engineEditProperties.ReportPrecision.ToString()
txtSketchWidth.Text = m_engineEditProperties.SketchSymbol.Width.ToString()
txtStreamCount.Text = m_engineEditProperties.StreamGroupingCount.ToString()
txtTolerance.Text = m_engineEditProperties.StreamTolerance.ToString()
If (m_engineEditProperties.StretchGeometry) Then
chkStretch.Checked = True
Else
chkStretch.Checked = False
End If
txtPrecision.Focus()
End Sub
Private Sub EditProperties_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
'Update precision property
If (txtPrecision.Text <> "") Then
m_engineEditProperties.ReportPrecision = Convert.ToInt32(txtPrecision.Text)
End If
'Update stream grouping count
If (txtStreamCount.Text <> "") Then
m_engineEditProperties.StreamGroupingCount = Convert.ToInt32(txtStreamCount.Text)
End If
'Update stream tolerance
If (txtTolerance.Text <> "") Then
m_engineEditProperties.StreamTolerance = Convert.ToInt32(txtTolerance.Text)
End If
'Update stretch geometry property
If (chkStretch.Checked) Then
m_engineEditProperties.StretchGeometry = True
Else
m_engineEditProperties.StretchGeometry = False
End If
'Update sketch symbol property
If (bSketchColor Or txtSketchWidth.Text <> "") Then
Dim lineSymbol As ILineSymbol
lineSymbol = m_engineEditProperties.SketchSymbol
If (bSketchColor) Then
dim color as new RgbColorClass()
color.Red = R
color.Blue = B
color.Green = G
lineSymbol.Color = color
End If
If (txtSketchWidth.Text <> "") Then
lineSymbol.Width = Convert.ToInt32(txtSketchWidth.Text)
End If
m_engineEditProperties.SketchSymbol = lineSymbol
End If
End Sub
Private Sub btnSketchColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSketchColor.Click
'Create a new color dialog
Dim colorDialog As New ColorDialog
'Prevent the user from selecting a custom color
colorDialog.AllowFullOpen = False
'Allows the user to obtain help (default is false)
colorDialog.ShowHelp = True
If (colorDialog.ShowDialog() = Windows.Forms.DialogResult.OK) Then
R = Convert.ToInt32(colorDialog.Color.R)
B = Convert.ToInt32(colorDialog.Color.B)
G = Convert.ToInt32(colorDialog.Color.G)
bSketchColor = True
End If
End Sub
Private Sub txtSketchWidth_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSketchWidth.TextChanged
'Validate sketch width
Try
If (txtSketchWidth.Text <> "") Then
Convert.ToInt32(txtSketchWidth.Text)
End If
Catch
MessageBox.Show("Sketch width should be a numeric value", "Error sketch width")
txtSketchWidth.Text = ""
txtSketchWidth.Focus()
End Try
End Sub
Private Sub txtPrecision_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPrecision.TextChanged
'Validate precision
Try
If (txtPrecision.Text <> "") Then
Convert.ToInt32(txtPrecision.Text)
End If
Catch
MessageBox.Show("Precision should be a numeric value", "Error precision")
txtPrecision.Text = ""
txtPrecision.Focus()
End Try
End Sub
Private Sub txtStreamCount_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtStreamCount.TextChanged
'Validate tolerance
Try
If (txtStreamCount.Text <> "") Then
Convert.ToInt32(txtStreamCount.Text)
End If
Catch
MessageBox.Show("Stream count should be a numeric value", "Error Stream Count")
txtStreamCount.Text = ""
txtStreamCount.Focus()
End Try
End Sub
Private Sub txtTolerance_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTolerance.TextChanged
'Validate tolerance
Try
If (txtTolerance.Text <> "") Then
Convert.ToInt32(txtTolerance.Text)
End If
Catch
MessageBox.Show("Stream Tolerance should be a numeric value", "Error Stream Tolerance")
txtTolerance.Text = ""
txtTolerance.Focus()
End Try
End Sub
End Class