private void mapControl_MouseDownEvent(object sender, _DMapEvents_MouseDownEvent e) { if (e.button == 2 && listLabel.Visible) { ListViewItem x = listLabel.Items[listLabel.SelectedIndices[0]]; string type = x.SubItems[1].Text; FormEnterLabel enter = new FormEnterLabel(preSelectedShape.ToString(), type); enter.ShowDialog(); string str_ = enter.label; String[] rowData = new String[3]; rowData[0] = preSelectedShape.ToString(); rowData[1] = type; rowData[2] = str_; ListViewItem item = new ListViewItem(rowData); listLabel.Items.RemoveAt(preSelectedShape); listLabel.Items.Insert(preSelectedShape, item); } if (!toolGetValues.Checked) { return; } Shape shp = new Shape(); if (e.button == 1) // left button { Shapefile sf = mapControl.get_Shapefile(mapControl.NumLayers - 1); shp.Create(ShpfileType.SHP_POINT); MapWinGIS.Point pnt = new MapWinGIS.Point(); double x = 0.0; double y = 0.0; mapControl.PixelToProj(e.x, e.y, ref x, ref y); Console.WriteLine(x.ToString() + "," + y.ToString()); pnt.x = x; pnt.y = y; int index = shp.numPoints; shp.InsertPoint(pnt, ref index); index = sf.NumShapes; if (!sf.EditInsertShape(shp, ref index)) { MessageBox.Show("Failed to insert shape: " + sf.ErrorMsg[sf.LastErrorCode]); return; } mapControl.Redraw(); } else { return; } int row; int column; double X = 0; double Y = 0; mapControl.PixelToProj(e.x, e.y, ref X, ref Y); MapWinGIS.Image img = mapControl.get_Image(0); img.ProjectionToImage(X, Y, out column, out row); double[] vals = new double[img.NoBands]; for (int i = 1; i <= img.NoBands; i++) { GdalRasterBand rst = img.get_Band(i); double pVal; rst.get_Value(row, column, out pVal); vals[i - 1] = pVal; } FormRasterValue uiRasterValues = new FormRasterValue(vals); uiRasterValues.ShowDialog(); shp.Clear(); }