コード例 #1
0
        private void btnInspect_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtDrawingSource.Text) || !_conn.ResourceService.ResourceExists(txtDrawingSource.Text))
            {
                MessageBox.Show("Could not find the specified drawing source. Please select a valid drawing source or upload a DWF file");
                return;
            }

            //Call the EnumerateDrawingSections API of Drawing Service
            var sections = _dwSvc.EnumerateDrawingSections(txtDrawingSource.Text);

            //Bind the Section property which is a BindingList, to the sections ListBox
            lstSections.DataSource = sections.Section;
        }
コード例 #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);
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
            /// <summary>
            /// Regenerates the sheet list in this drawing source.
            /// </summary>
            /// <param name="source">The drawing source</param>
            /// <param name="conn">The server connection</param>
            /// <returns>True if sheets were regenerated. False otherwise</returns>
            public static bool RegenerateSheetList(this IDrawingSource source, IServerConnection conn)
            {
                Check.ArgumentNotNull(source, nameof(source));
                Check.ArgumentNotNull(conn, nameof(conn));
                Check.ArgumentNotEmpty(source.ResourceID, $"{nameof(source)}.{nameof(source.ResourceID)}");

                IDrawingService dwSvc  = (IDrawingService)conn.GetService((int)ServiceType.Drawing);
                var             sheets = dwSvc.EnumerateDrawingSections(source.ResourceID);
                bool            bRegen = sheets.Section.Count > 0;

                source.RemoveAllSheets();
                if (bRegen)
                {
                    foreach (var sht in sheets.Section)
                    {
                        source.AddSheet(source.CreateSheet(sht.Name, 0, 0, 0, 0));
                    }
                }
                return(bRegen);
            }
コード例 #4
0
        /// <summary>
        /// Regenerates the sheet list in this drawing source.
        /// </summary>
        /// <param name="source"></param>
        /// <returns>True if sheets were regenerated. False otherwise</returns>
        public static bool RegenerateSheetList(this IDrawingSource source)
        {
            Check.NotNull(source, "source");
            Check.NotNull(source.CurrentConnection, "source.CurrentConection"); //NOXLATE
            Check.NotEmpty(source.ResourceID, "source.ResourceID");             //NOXLATE

            IDrawingService dwSvc  = (IDrawingService)source.CurrentConnection.GetService((int)ServiceType.Drawing);
            var             sheets = dwSvc.EnumerateDrawingSections(source.ResourceID);
            bool            bRegen = sheets.Section.Count > 0;

            source.RemoveAllSheets();
            if (bRegen)
            {
                foreach (var sht in sheets.Section)
                {
                    source.AddSheet(source.CreateSheet(sht.Name, 0, 0, 0, 0));
                }
            }
            return(bRegen);
        }
        public override IResource CreateItem(string startPoint, IServerConnection conn)
        {
            using (var picker = new ResourcePicker(conn, ResourceTypes.DrawingSource.ToString(), ResourcePickerMode.OpenResource))
            {
                picker.SetStartingPoint(startPoint);
                if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var ldf = ObjectFactory.CreateDefaultLayer(OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Drawing, new Version(1, 0, 0));
                    ldf.SubLayer.ResourceId = picker.ResourceID;
                    var dl = ((IDrawingLayerDefinition)ldf.SubLayer);
                    dl.LayerFilter = string.Empty;
                    dl.MinScale    = 0;

                    IDrawingService dwSvc  = (IDrawingService)conn.GetService((int)ServiceType.Drawing);
                    var             sheets = dwSvc.EnumerateDrawingSections(picker.ResourceID);
                    dl.Sheet = sheets.Section[0].Name;

                    return(ldf);
                }
                return(null);
            }
        }
コード例 #6
0
        /// <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);
                    }
                }
            }
        }