Ejemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            //Call the EnumerateDrawingSectionResources API of Drawing Service and bind the result to the grid view
            var list = _drawSvc.EnumerateDrawingSectionResources(_drawingSourceId, _section.Name);

            grdResources.DataSource = list.SectionResource;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Extracts the specified symbols to the given folder
        /// </summary>
        /// <param name="targetFolder"></param>
        /// <param name="symbols"></param>
        /// <param name="progressCallback"></param>
        public void ExtractSymbols(string targetFolder, IEnumerable <string> symbols, Action <int, int> progressCallback)
        {
            Check.ArgumentNotEmpty(targetFolder, nameof(targetFolder));
            Check.ThatArgumentIsFolder(targetFolder, nameof(targetFolder));

            if (symbols == null)
            {
                ExtractSymbols(targetFolder);
            }
            else
            {
                IDrawingService drawSvc = (IDrawingService)_conn.GetService((int)ServiceType.Drawing);
                IDrawingSource  ds      = PrepareSymbolDrawingSource(_conn, _symbolLibId);

                //Each section in the symbols.dwf represents a symbol
                var sectionList = drawSvc.EnumerateDrawingSections(ds.ResourceID);
                var symbolNames = new HashSet <string>(symbols);
                int processed   = 0;

                foreach (var sect in sectionList.Section)
                {
                    var sectResources = drawSvc.EnumerateDrawingSectionResources(ds.ResourceID, sect.Name);

                    if (!symbolNames.Contains(sect.Title))
                    {
                        continue;
                    }

                    foreach (var res in sectResources.SectionResource)
                    {
                        if (res.Role.ToUpper() == StringConstants.Thumbnail.ToUpper())
                        {
                            ExtractSymbol(targetFolder, drawSvc, ds, sect, res);
                            processed++;
                            if (progressCallback != null)
                            {
                                progressCallback(processed, symbolNames.Count);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Creates an image-based Symbol Definition in the specified folder for each image symbol in the Symbol Library.
        ///
        /// Any existing resource names are overwritten
        /// </summary>
        /// <param name="targetFolder"></param>
        public void ExtractSymbols(string targetFolder)
        {
            Check.ArgumentNotEmpty(targetFolder, nameof(targetFolder));
            Check.ThatPreconditionIsMet(ResourceIdentifier.IsFolderResource(targetFolder), $"{nameof(ResourceIdentifier)}.{nameof(ResourceIdentifier.IsFolderResource)}({nameof(targetFolder)})");

            IDrawingService drawSvc = (IDrawingService)_conn.GetService((int)ServiceType.Drawing);
            IDrawingSource  ds      = PrepareSymbolDrawingSource(_conn, _symbolLibId);

            //Each section in the symbols.dwf represents a symbol
            var sectionList = drawSvc.EnumerateDrawingSections(ds.ResourceID);

            foreach (var sect in sectionList.Section)
            {
                var sectResources = drawSvc.EnumerateDrawingSectionResources(ds.ResourceID, sect.Name);

                foreach (var res in sectResources.SectionResource)
                {
                    if (res.Role.ToUpper() == StringConstants.Thumbnail.ToUpper())
                    {
                        ExtractSymbol(targetFolder, drawSvc, ds, sect, res);
                    }
                }
            }
        }