private void SetDefaultSymbol(ILineElement elem)
        {
            ILineSymbol          defaultLineSym = null;
            String               esriStylePath;
            IStyleGallery        styleGallery = new StyleGalleryClass();
            IStyleGalleryStorage styleStor    = (IStyleGalleryStorage)styleGallery;

            esriStylePath = styleStor.DefaultStylePath + "ESRI.style";

            IEnumStyleGalleryItem styleItems = styleGallery.get_Items("Line Symbols", esriStylePath, "Dashed");

            styleItems.Reset();
            IStyleGalleryItem styleGalleryItem = styleItems.Next();

            while (!(styleGalleryItem == null))
            {
                if (styleGalleryItem.Name == "Dashed 4:4")
                {
                    defaultLineSym       = (ILineSymbol)styleGalleryItem.Item;
                    defaultLineSym.Width = 1.50;
                    IRgbColor rgbColor = new RgbColorClass();
                    rgbColor.Red          = 255;
                    rgbColor.Blue         = 0;
                    rgbColor.Green        = 0;
                    rgbColor.Transparency = 50;
                    defaultLineSym.Color  = rgbColor;
                    break;
                }
                else
                {
                    styleGalleryItem = styleItems.Next();
                }
            }
            elem.Symbol = defaultLineSym;
        }
Exemplo n.º 2
0
        /*从文件获取符号
         *
         */
        private ISymbol getSymbolByName(string symbolstyle, string name)
        {
            ISymbol result    = null;
            string  stylepath = System.Configuration.ConfigurationSettings.AppSettings["SymbolPath"];
            //符号管理对象
            IStyleGallery pStyleGallery = new StyleGalleryClass();
            //符号文件管理, 设定符号文件
            IStyleGalleryStorage  pStyleStorage = pStyleGallery as IStyleGalleryStorage;
            IEnumStyleGalleryItem pEnumStyleGall;
            IStyleGalleryItem     pStyleItem;
            string pp = pStyleStorage.DefaultStylePath;

            pStyleStorage.AddFile(stylepath);
            //根据类型取得不同符号集
            if (symbolstyle == "1")
            {
                pEnumStyleGall = pStyleGallery.get_Items("Marker Symbols", stylepath, "");
            }
            else if (symbolstyle == "2")
            {
                pEnumStyleGall = pStyleGallery.get_Items("Line Symbols", stylepath, "");
            }
            else if (symbolstyle == "3")
            {
                pEnumStyleGall = pStyleGallery.get_Items("Fill Symbols", stylepath, "");
            }
            else
            {
                return(null);
            }
            pEnumStyleGall.Reset();
            pStyleItem = pEnumStyleGall.Next();

            while (pStyleItem != null)       //Loop through and access each marker
            {
                if (pStyleItem.Name == name) //根据符号名称获取符号
                {
                    result = pStyleItem.Item as ISymbol; break;
                }

                pStyleItem = pEnumStyleGall.Next();
            }
            return(result);
        }
        private void SetDefaultSymbol(ILineElement elem)
        {
            ILineSymbol defaultLineSym = null;
            String esriStylePath;
            IStyleGallery styleGallery = new StyleGalleryClass();
            IStyleGalleryStorage styleStor = (IStyleGalleryStorage)styleGallery;
            esriStylePath = styleStor.DefaultStylePath + "ESRI.style";

            IEnumStyleGalleryItem styleItems = styleGallery.get_Items("Line Symbols",esriStylePath,"Dashed");
            styleItems.Reset();
            IStyleGalleryItem styleGalleryItem = styleItems.Next();
            while (!(styleGalleryItem == null))
            {
                if (styleGalleryItem.Name == "Dashed 4:4")
                {
                    defaultLineSym = (ILineSymbol)styleGalleryItem.Item;
                    defaultLineSym.Width = 1.50;
                    IRgbColor rgbColor = new RgbColorClass();
                    rgbColor.Red = 255;
                    rgbColor.Blue = 0;
                    rgbColor.Green = 0;
                    rgbColor.Transparency = 50;
                    defaultLineSym.Color = rgbColor;
                    break;
                }
                else
                {
                    styleGalleryItem = styleItems.Next();
                }
            }
            elem.Symbol = defaultLineSym;
        }