コード例 #1
0
ファイル: LayerStyles.cs プロジェクト: yifeidong/gvms
        /// <summary>
        /// 将已设置好的样式添加到唯一值渲染中去
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="symbols"></param>
        public void SetSymbolsToValueRenderedLayer(MapObjects2.MapLayer layer, Dictionary <string, MapObjects2.Symbol> symbols)
        {
            if (layer.Renderer == null)
            {
                throw new Exception("the layer has not set a render.");
            }

            if (layer.Renderer is MapObjects2.ValueMapRenderer)
            {
                throw new Exception("the layer has a render,but not a valuerender.");
            }

            Dictionary <string, MapObjects2.Symbol> .KeyCollection oKeys = symbols.Keys;
            MapObjects2.ValueMapRenderer oValueRender = layer.Renderer as MapObjects2.ValueMapRenderer;
            int iValueIndex = -1;

            MapObjects2.Symbol oSymbol = null;

            foreach (string sKey in oKeys)
            {
                iValueIndex = this.GetValueIndexByRenderValue(oValueRender, sKey);

                if (iValueIndex != -1 && symbols.TryGetValue(sKey, out oSymbol))
                {
                    this.CopySymbolToAnother(oSymbol, oValueRender.get_Symbol((short)iValueIndex));
                }
            }
        }
コード例 #2
0
ファイル: LayerStyles.cs プロジェクト: yifeidong/gvms
        private int GetValueIndexByRenderValue(MapObjects2.ValueMapRenderer render, string renderValue)
        {
            int iValueCount = render.ValueCount;

            for (short i = 0; i < iValueCount; i++)
            {
                if (renderValue.Equals(render.get_Value(i)))
                {
                    return((int)i);
                }
            }

            return(-1);
        }