Example #1
0
        // 地图点击事件
        private void Map_ElementClickEvent(object sender, MFElementClickEventArgs e)
        {
            if (e.Element == null)
            {
                return;
            }

            switch (e.Element.ElementType)
            {
            case ElementTypeEnum.Picture:
                IMFPicture picture = e.Element as IMFPicture;
                if (picture == null)
                {
                    return;
                }

                if (prevPicture != null)
                {
                    prevPicture.HightLight(false);
                }

                picture.HightLight(true);
                prevPicture = picture;

                if (e.MouseEventArgs.Button == MouseButtons.Right)
                {
                    Point screenLocation = new Point(e.MouseEventArgs.X + this.Parent.Location.X + this.Parent.Parent.Location.X + this.Parent.Parent.Parent.Location.X + this.Parent.Parent.Parent.Parent.Location.X, e.MouseEventArgs.Y + this.Parent.Location.Y + this.Parent.Parent.Location.Y + this.Parent.Parent.Parent.Location.Y + this.Parent.Parent.Parent.Parent.Location.Y);
                    contextMenuStrip1.Show(screenLocation);
                }
                break;

            default:
                if (bEdit == true && e.Element != null)
                {
                    // 只能编辑已绘制的图元
                    var editElement = drawElements.Find(o => o.ElementName == e.Element.ElementName);
                    if (editElement != null)
                    {
                        toolBox.EditElement(editElement);
                    }
                }
                break;
            }
        }
Example #2
0
        // 鼠标点击点事件
        private void mapControl_OnMarkerClick(GMapMarker item, MouseEventArgs e)
        {
            if (MapFrame.GMap.Common.Utils.bPublishEvent == false)
            {
                return;
            }
            if (item.Tag == null)
            {
                return;
            }

            IMFElement element = item.Tag as IMFElement;

            MFElementClickEventArgs args = new MFElementClickEventArgs();

            args.Element        = element;
            args.MouseEventArgs = e;
            if (ElementClickEvent != null)
            {
                ElementClickEvent.Invoke(this, args);
            }
        }