zoukankan      html  css  js  c++  java
  • 读取符号库文件

    /// <summary>
    /// 导入符号
    /// </summary>
    /// <param name="serverStylePath">符号库文件路径</param>
    public static void ImportSymbols(string serverStylePath)
    {
    if (string.IsNullOrEmpty(serverStylePath) || !File.Exists(serverStylePath))
    {
    return;
    }

    int iIndexPoint = serverStylePath.LastIndexOf('\');
    string strName = serverStylePath.Substring(iIndexPoint + 1);
    int imageIndex = 1;
    try
    {
    IStyleGallery pStyleGallery = new ServerStyleGalleryClass();
    SymbologyControlClass pSymbologyControlClass = new SymbologyControlClass();
    IStyleGalleryStorage pStyleGalleryStorage = pStyleGallery as IStyleGalleryStorage;
    pStyleGalleryStorage.AddFile(serverStylePath);
    pStyleGalleryStorage.TargetFile = serverStylePath;
    pStyleGallery.ImportStyle(serverStylePath);
    ISymbologyStyleClass pSymbologyStyleClass = null;
    for (int j = 0; j < pStyleGallery.ClassCount; j++)
    {
    IEnumStyleGalleryItem enumItems = null;
    try
    {
    IStyleGalleryClass styleGalleryClass = pStyleGallery.Class[j];
    enumItems = pStyleGallery.Items[styleGalleryClass.Name, "", ""];
    pSymbologyStyleClass = pSymbologyControlClass.GetStyleClass(SymbolOperate.GetTypeName(styleGalleryClass.Name));
    if (enumItems == null) continue;
    enumItems.Reset();
    IStyleGalleryItem pStyleItem = enumItems.Next();
    List<IRow> symbloList = new List<IRow>();
    while (pStyleItem != null)
    {
    IPersistStream pPersistStream = pStyleItem as IPersistStream;
    IMemoryBlobStream pBlobStream = new MemoryBlobStreamClass();
    pPersistStream.Save(pBlobStream, 0);
    IMemoryBlobStreamVariant mbsv = (IMemoryBlobStreamVariant)pBlobStream;
    object obj;
    mbsv.ExportToVariant(out obj);
    stdole.IPictureDisp picture = pSymbologyStyleClass.PreviewItem(pStyleItem, PictureWidth, PictureHeight);

    Image pImage = AxHostConverter.GetImageFromDispPicture(picture);
    SymbolLibraryRow pRow = new SymbolLibraryRow();
    pRow.SetValue(SymbolLibraryRow.FIELD_SYMBOLNAME, strName);
    pRow.SetValue(SymbolLibraryRow.FIELD_SYMBOLCLASS, styleGalleryClass.Name);
    pRow.SymbolStyle = obj as byte[];
    pRow.SymbolID = pStyleItem.ID;
    pRow.Image = SymbolOperate.GetByteByImage(pImage);
    pRow.SymbolItemName = pStyleItem.Name;
    pRow.SymbolItemCategory = pStyleItem.Category;
    symbloList.Add(pRow);
    pStyleItem = enumItems.Next();
    imageIndex++;
    if (imageIndex % 20 == 0)
    {
    GC.Collect();
    System.Windows.Forms.Application.DoEvents();
    }
    }
    SymbolLibraryTable.symbolLibraryTable.Save(symbloList);
    }
    catch
    {

    }
    finally
    {
    ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(enumItems);
    }

    }
    pStyleGallery.Clear();
    }
    catch
    {

    }
    }

  • 相关阅读:
    [BZOJ1584] [Usaco2009 Mar]Cleaning Up 打扫卫生(DP)
    [BZOJ1583] [Usaco2009 Mar]Moon Mooing 哞哞叫(队列)
    [BZOJ1582] [Usaco2009 Hol]Holiday Painting 节日画画(线段树)
    [BZOJ1579] [Usaco2009 Feb]Revamping Trails 道路升级(分层图最短路 + 堆优化dijk)
    [ZPG TEST 115] 字符串【归类思想】
    [ZPG TEST 114] 阿狸的英文名【水题】
    [USACO 2012 Open Gold] Bookshelf【优化dp】
    [USACO 2012 Mar Silver] Landscaping【Edit Distance】
    [USACO 2012 Mar Gold] Large Banner
    [USACO 2012 Feb Gold] Cow Coupons【贪心 堆】
  • 原文地址:https://www.cnblogs.com/lzh5d/p/7001563.html
Copyright © 2011-2022 走看看