Hi Juan,
This issue is very hard to fix, we will keep trying to solve it.
As below is a workaround for this issue.
Regards,
Don
using System;
using System.Windows.Forms;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.DesktopEdition;
namespace CSharpWinformsSamples
{
public class ExtentInteractiveOverlayForContext : ExtentInteractiveOverlay
{
private bool contextMenuJustClosed = false;
public bool ContextMenuJustClosed
{
get { return contextMenuJustClosed; }
set { contextMenuJustClosed = value; }
}
protected override InteractiveResult MouseDownCore(InteractionArguments interactionArguments)
{
if (!contextMenuJustClosed)
{
return base.MouseDownCore(interactionArguments);
}
else
{
contextMenuJustClosed = false;
return new InteractiveResult();
}
}
}
public partial class AddSimpleMarkers : UserControl
{
public AddSimpleMarkers()
{
InitializeComponent();
}
private void Form_Load(object sender, EventArgs e)
{
ContextMenuStrip context = new System.Windows.Forms.ContextMenuStrip();
context.Items.Add(" test1 ");
context.Closed += context_Closed;
winformsMap1.ContextMenuStrip = context;
winformsMap1.ExtentOverlay = new ExtentInteractiveOverlayForContext();
winformsMap1.MapClick += new EventHandler<MapClickWinformsMapEventArgs>(winformsMap1_MapClick);
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);
WorldMapKitWmsDesktopOverlay worldMapKitOverlay = new WorldMapKitWmsDesktopOverlay();
//winformsMap1.Overlays.Add(worldMapKitOverlay);
SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay();
markerOverlay.MapControl = winformsMap1;
winformsMap1.Overlays.Add("MarkerOverlay", markerOverlay);
winformsMap1.Refresh();
}
void context_Closed(object sender, ToolStripDropDownClosedEventArgs e)
{
(winformsMap1.ExtentOverlay as ExtentInteractiveOverlayForContext).ContextMenuJustClosed = true;
}
private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)
{
if (e.MouseButton != MapMouseButton.Left)
{
return;
}
SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["MarkerOverlay"];
Marker marker = new Marker(e.WorldLocation);
marker.Image = Properties.Resources.AQUA;
marker.Width = 20;
marker.Height = 34;
marker.YOffset = -17;
markerOverlay.Markers.Add(marker);
winformsMap1.Refresh();
}
#region Component Designer generated code
private System.ComponentModel.IContainer components = null;
private GroupBox gbxDescrition;
private WinformsMap winformsMap1;
private Label label1;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.gbxDescrition = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.winformsMap1 = new ThinkGeo.MapSuite.DesktopEdition.WinformsMap();
this.gbxDescrition.SuspendLayout();
this.SuspendLayout();
//
// gbxDescrition
//
this.gbxDescrition.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.gbxDescrition.Controls.Add(this.label1);
this.gbxDescrition.Location = new System.Drawing.Point(480, -1);
this.gbxDescrition.Name = "gbxDescrition";
this.gbxDescrition.Size = new System.Drawing.Size(257, 55);
this.gbxDescrition.TabIndex = 4;
this.gbxDescrition.TabStop = false;
this.gbxDescrition.Text = "Description";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(7, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(251, 26);
this.label1.TabIndex = 0;
this.label1.Text = "This sample shows how to add markers by click\r\n event on the map.";
//
// winformsMap1
//
this.winformsMap1.BackColor = System.Drawing.Color.White;
this.winformsMap1.Dock = System.Windows.Forms.DockStyle.Fill;
this.winformsMap1.Location = new System.Drawing.Point(0, 0);
this.winformsMap1.Name = "winformsMap1";
this.winformsMap1.Size = new System.Drawing.Size(740, 528);
this.winformsMap1.TabIndex = 5;
this.winformsMap1.Text = "winformsMap1";
//
// AddMyOwnCustomDataToAFeatureLayer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.gbxDescrition);
this.Controls.Add(this.winformsMap1);
this.Name = "AddMyOwnCustomDataToAFeatureLayer";
this.Size = new System.Drawing.Size(740, 528);
this.Load += new System.EventHandler(this.Form_Load);
this.gbxDescrition.ResumeLayout(false);
this.gbxDescrition.PerformLayout();
this.ResumeLayout(false);
}
#endregion
}
}