예제 #1
0
 /* 鼠标交互:
  * 1. OnMouseDown
  * 2. OnDoubleClick
  * 3. OnMouseMove
  */
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     //IMapControlEvents2_OnMouseDownEvent e 的e.x和e.MapX有什么区别?
     if (miAddFeature.Checked == true)
     {
         //AddPoint模式
         if (miAddPoint.Checked == true)
         {
             //if (!AddPoint(e.mapX, e.mapY))
             //MessageBox.Show("添加点失败!");
             AddPoint(e.mapX, e.mapY);
         }
         //AddLine模式
         else if (miAddLine.Checked == true)
         {
             //问题在于,需要有个地方来存放INewLineFeedback——现在试着使用全局变量
             //如果类的全局变量为空,为类全局变量新建实例
             if (drawAndAddLine == null)
             {
                 drawAndAddLine = new DrawAndAddLine(axMapControl1.Map);
                 drawAndAddLine.OnMouseDown(e.button, e.shift, e.x, e.y);
             }
             //不为空,则在其中添加点
             else
             {
                 drawAndAddLine.OnMouseDown(e.button, e.shift, e.x, e.y);
             }
         }
         else if (miAddPolygon.Checked == true)
         {
             if (drawAndAddPolygon == null)
             {
                 drawAndAddPolygon = new DrawAndAddPolygon(axMapControl1.Map);
                 drawAndAddPolygon.OnMouseDown(e.button, e.shift, e.x, e.y);
             }
             //不为空,则在其中添加点
             else
             {
                 drawAndAddPolygon.OnMouseDown(e.button, e.shift, e.x, e.y);
             }
         }
     }
 }
예제 #2
0
 private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)
 {
     if (miAddFeature.Checked == true)
     {
         if (miAddLine.Checked == true)
         {
             //结束添加线时,双击,此时首先会调用OnMouseDown,添加最后一个点
             //if (!AddLine(drawAndAddLine.OnDoubleClick(e.button, e.shift, e.x, e.y)))
             AddLine(drawAndAddLine.OnDoubleClick(e.button, e.shift, e.x, e.y));
             //MessageBox.Show("添加线失败!");
             //置空还原
             drawAndAddLine = null;
         }
         else if (miAddPolygon.Checked == true)
         {
             //结束添加线时,双击,此时首先会调用OnMouseDown,添加最后一个点
             //if (!AddPolygon(drawAndAddLine.OnDoubleClick(e.button, e.shift, e.x, e.y)))
             AddPolygon(drawAndAddPolygon.OnDoubleClick(e.button, e.shift, e.x, e.y));
             //MessageBox.Show("添加面失败!");
             //置空还原
             drawAndAddPolygon = null;
         }
     }
 }