toolcreatepolyline.cs

来自「进行二次开发的嵌入式开发工具」· CS 代码 · 共 47 行

CS
47
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using HiMap.Carto;
using HiMap.MapControls.Tools;
using HiMap.Geometry;


namespace HiMap
{
    /// <summary>
    /// Tool for create polylines
    /// </summary>
    public class ToolCreatePolyline : ToolCreatePoint
    {
        public ToolCreatePolyline(Form frm, IFeatureLayer layer):base(frm,layer)
        {
        }
        protected override void OnToolCreate(HiMap.MapControls.MapControl Map)
        {
            base.OnToolCreate(Map);
            MePic = new PicCtrl(_frm, Map, listPoint, listPoint1, PicType.Polyline);
        }
        protected override void Btn3Click(object sender, EventArgs e)
        {
            if (listPoint.Count < 2)
            {
                System.Windows.Forms.MessageBox.Show("A line must have 2 nodes least, continue to draw.");
                return;
            }
            IFeatureClass cls = (IFeatureClass)_layer.Class;
            IFeature feat = null;
            IPointCollection line = new PolylineClass();
            for (int i = 0; i < listPoint.Count; i++)
            {
                feat = cls.CreateFeature();
                line.AddPoint(listPoint[i]);
            }
            feat.Shape = line;
            feat.Save();
            BtnExitClick(null, null);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?