Beispiel #1
0
        /// <summary>
        /// 移除图元
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="element">图元</param>
        /// <returns></returns>
        public bool RemoveElement(string layerName, MapFrame.Core.Interface.IMFElement element)
        {
            if (element == null)
            {
                return(true);
            }
            var layer = lyMgr.GetLayer(layerName);

            if (layer == null)
            {
                return(true);
            }
            IElementFactory elementFactory = null;

            switch (element.ElementType)
            {
            case ElementTypeEnum.Point:
                elementFactory = pointFac;
                break;

            case ElementTypeEnum.Line:
                elementFactory = lineFac;
                break;

            case ElementTypeEnum.Polygon:
                elementFactory = polygonFac;
                break;

            case ElementTypeEnum.Text:
                elementFactory = textFac;
                break;

            case ElementTypeEnum.Circle:
                elementFactory = circleFac;
                break;

            case ElementTypeEnum.Picture:
                elementFactory = pointIcoFac;
                break;
            }

            if (elementFactory == null)
            {
                return(false);
            }

            bool ret = elementFactory.RemoveElement(element, layer);

            element.Dispose();

            this.Refresh();
            return(ret);
        }