private void btnSetMarker2_Click(object sender, EventArgs e) { try { string strMapIconFilePath = txtMarkerIconFilePath.Text.Trim(); MapMarkerPointInfo m = new MapMarkerPointInfo { MarkerName = DateTime.Now.Second.ToString(), MarkerPoint = new MapPointInfo { dblLon = Convert.ToDouble(txtSelectedMapPointLon.Text), dblLat = Convert.ToDouble(txtSelectedMapPointLat.Text) }, MarkerDisplayValue = DateTime.Now.ToString(), MarkerDisplayTag = "123", MarkerIconFilePath = Environment.CurrentDirectory + "\\MapFile\\MarkerFile\\" + strMapIconFilePath, }; m.MarkerRightClickEvent += MarkerRightClick; mapControl1.SetMapMarker(m); } catch (Exception ex) { string x = ex.ToString(); //取值异常不做处理 } }
public bool MarkerRightClick(object sender, object MarkerRightClickValue) { bool bolResult = false; MapMarkerPointInfo m = (MapMarkerPointInfo)sender; StringBuilder sbDisplayInfo = new StringBuilder(); sbDisplayInfo.Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); sbDisplayInfo.Append("_" + m.MarkerName); sbDisplayInfo.Append("_RightClick"); Console.WriteLine(sbDisplayInfo.ToString()); Point p = this.PointToClient(Control.MousePosition); contextMenuStrip1.Show(this, p); return(bolResult); }