хм.. а почему предлагаете С++??
вроде как с++ сложнее с шарпа, поэтому и не хотелось бы себе усложнять жизнь или может я чего то не понимаю
Вот пример того, что хотелось бы понимать и создавать самому:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace HelpFunctions.Forms
{
public partial class DrawRectangleForm : Form
{
#region Variables
List<ILayer> m_mapLayers = null;
ILayer m_layerToEdit = null;
IActiveView refresh = null;
IPoint m_pointX = null;
IEditor m_editor = null;
BaseClass baseClass = null;
#endregion
public DrawRectangleForm(List<ILayer> m_mapLayers, IHookHelper m_hookHelper, IPoint m_pointXY, IEditor m_editor)
{
InitializeComponent();
this.refresh = m_hookHelper.ActiveView;
this.m_pointX = m_pointXY;
this.txt_X.Text = m_pointXY.X.ToString();
this.txt_Y.Text = m_pointXY.Y.ToString();
this.m_editor = m_editor;
this.m_mapLayers = m_mapLayers;
baseClass = new BaseClass(m_hookHelper);
if (m_editor != null)
{
if (m_editor.CurrentTask.Name == "Create New Feature")
{
if (m_editor.EditState == esriEditState.esriStateNotEditing)
{
FillComboboxWithMapLayers(m_mapLayers);
}
else
{
IEditLayers m_editLayer = m_editor as IEditLayers;
if (m_editLayer.CurrentLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
{
this.cmb_layers.Items.Add(m_editLayer.CurrentLayer.Name);
cmb_layers.SelectedIndex = 0;
}
else
{
MessageBox.Show("Слой, находящийся на редактировании не является полигональным", "Ошибка геометрии", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.Close();
}
}
}
else
{
MessageBox.Show("Текущая задача должна быть <Create New Feature>", "Рисование прямоугольника", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.Close();
}
}
}
private void btn_draw_Click(object sender, EventArgs e)
{
if (cmb_layers.Items.Count != 0)
{
if (!String.IsNullOrEmpty(txt_X.Text) ||
!String.IsNullOrEmpty(txt_Y.Text) ||
!String.IsNullOrEmpty(txt_width.Text) ||
!String.IsNullOrEmpty(txt_height.Text))
{
try
{
double X0 = double.Parse(txt_X.Text);
double Y0 = double.Parse(txt_Y.Text);
double width = double.Parse(txt_width.Text);
double height = double.Parse(txt_height.Text);
if (!(X0 < 0 || Y0 < 0 || width <= 0 || height <= 0))
{
if (m_editor.EditState == esriEditState.esriStateNotEditing)
{
baseClass.CreateRectangle(m_layerToEdit, X0, Y0, width, height);
this.refresh.Refresh();
this.Close();
}
else
{
baseClass.CreateRectangle(X0, Y0, width, height, m_editor);
this.refresh.Refresh();
this.Close();
}
}
else
{
MessageBox.Show("Высота и ширина не должны ровняться нулю или быть отрицательными",
"Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,
"Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Должны быть заполнены все поля",
"Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
grb_coords.Enabled = false;
grb_edges.Enabled = false;
MessageBox.Show("Либо отсутствуют слои для редактирования, либо слой не выбран",
"Ошибка выбора слоя", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FillComboboxWithMapLayers(List<ILayer> m_mapLayers)
{
cmb_layers.Tag = m_mapLayers;
if (m_mapLayers.Count != 0)
{
foreach (ILayer layer in m_mapLayers)
{
cmb_layers.Items.Add(layer.Name);
}
cmb_layers.SelectedIndex = 0;
}
else
{
grb_coords.Enabled = false;
grb_edges.Enabled = false;
btn_draw.Enabled = false;
MessageBox.Show("В проекте отсутсвуют слои для редактирования", "Внимание", MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
}
private void cmb_layers_SelectedIndexChanged(object sender, EventArgs e)
{
if (m_editor.EditState == esriEditState.esriStateNotEditing)
{
int layerToEdit = cmb_layers.SelectedIndex;
List<ILayer> m_layers = (List<ILayer>)cmb_layers.Tag;
m_layerToEdit = m_layers[layerToEdit];
}
}
}
}