コード例 #1
0
ファイル: FormXGIS.cs プロジェクト: JokerDLord/assignment
        private void FormXGIS_MouseUp(object sender, MouseEventArgs e)
        {
            //没有打开任何图层
            if (layer == null)
            {
                return;
            }
            //未发生变化
            if (e.Location.X == MouseDownLocation.X && e.Location.Y == MouseDownLocation.Y)
            {
                if (MouseSelect)
                {
                    layer.SelectByClick(e.Location, view);
                    UpdateMap();
                }
            }
            else
            {
                XVertex v1 = view.ToMapVertex(MouseDownLocation);
                XVertex v2 = view.ToMapVertex(e.Location);

                //如果是拉框放大
                if (MouseSelect)
                {
                    XExtent extent = new XExtent(v1, v2);
                    //if (Control.ModifierKeys == Keys.Control)
                    //{
                    //    layer.PlusSelectByExtent(extent);
                    //}
                    //else
                    //{
                    //    layer.SelectByExtent(extent, Control.ModifierKeys == Keys.Shift,
                    //        Control.ModifierKeys == Keys.Control);
                    //}
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift &&
                        (Control.ModifierKeys & Keys.Control) == Keys.Control)
                    {
                        layer.SelectByExtent(extent, true, true);
                    }
                    else
                    {
                        layer.SelectByExtent(extent, Control.ModifierKeys == Keys.Shift,
                                             Control.ModifierKeys == Keys.Control);
                    }
                }
                else if (MouseZoomIn)
                {
                    XExtent extent = new XExtent(v1, v2);
                    view.UpdateExtent(extent);
                }
                else if (MousePan)
                {
                    view.OffsetCenter(v1, v2);
                }
                UpdateMap();
            }
            MouseSelect = MouseZoomIn = MousePan = false;
        }
コード例 #2
0
 private void FormXGIS_MouseUp(object sender, MouseEventArgs e)
 {
     //没有打开任何图层
     if (layer == null)
     {
         return;
     }
     //未发生变化
     if (e.Location.X == MouseDownLocation.X && e.Location.Y == MouseDownLocation.Y)
     {
         if (MouseSelect)
         {
             layer.selectByClick(e.Location, view);
             UpdateMap();
         }
     }
     else//框选
     {
         XVertex v1 = view.ToMapVertex(MouseDownLocation);
         XVertex v2 = view.ToMapVertex(e.Location);
         if (MouseSelect)
         {
             XExtent extent = new XExtent(v1, v2);
             layer.SelectByExtent(extent);
         }
         else if (MouseZoomIn)
         {
             XExtent extent = new XExtent(v1, v2);
             view.UpdateExtent(extent);
         }
         else if (MousePan)//如果是平移地图
         {
             view.OffsetCenter(v1, v2);
         }
         else if (MouseInterSelect)
         {
             XExtent extent = new XExtent(v1, v2);
             layer.SelectByInterExtent(extent);
         }
         UpdateMap();
     }
     MouseSelect = MousePan = MouseZoomIn = MouseInterSelect = false;
 }