[mapguide-commits] r7204 - in trunk/Tools/Maestro: Maestro Maestro.Base Maestro.Base/Editor Maestro.Base/Services Maestro.Base/Services/DragDropHandlers Maestro.Editors/Common Maestro.Editors/DrawingSource Maestro.Editors/FeatureSource/Providers/Odbc Maestro.Shared.UI MaestroAPITests MaestroAPITests/UserTestData OSGeo.MapGuide.MaestroAPI/Commands OSGeo.MapGuide.MaestroAPI/Mapping OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Nov 13 03:44:54 PST 2012


Author: jng
Date: 2012-11-13 03:44:53 -0800 (Tue, 13 Nov 2012)
New Revision: 7204

Added:
   trunk/Tools/Maestro/MaestroAPITests/UserTestData/SpaceShip.xml
Modified:
   trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
   trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs
   trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs
   trunk/Tools/Maestro/Maestro.Base/WorkbenchInitializer.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/ResourceDataCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/DrawingSource/SourceSectionCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs
   trunk/Tools/Maestro/Maestro.Shared.UI/BusyWaitDialog.cs
   trunk/Tools/Maestro/Maestro.Shared.UI/IWorkbenchInitializer.cs
   trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs
   trunk/Tools/Maestro/Maestro/Program.cs
   trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj
   trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSourceInterfaces.cs
Log:
This submission includes the following changes:
 - Another Mono hack, default the Workbench to non-minimized state on startup. This reduces the likelihood of deadlocks when background preview preparation is happening.
 - Modify the BusyWaitDialog API to allow exceptions in the worker delegate to be properly propagated back up.
 - Fix sheet extents when dropping a DWF into the Site Explorer
 - Add a new extension method to allow sheet list regeneration in a IDrawingSource
 - Add a new unit test to exercise adding of a DWF-based runtime layer

Modified: trunk/Tools/Maestro/Maestro/Program.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/Program.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro/Program.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -140,7 +140,9 @@
             // Workbench is our class from the base project, this method creates an instance
             // of the main form.
             ServiceRegistry.Initialize(() => {
-                Workbench.InitializeWorkbench(new WorkbenchInitializer());
+                //DIRTY DIRTY HACK: I'm getting tired of Mono workarounds. But background resource
+                //preview preparation has a chance of clogging up if the main window is initially maximized
+                Workbench.InitializeWorkbench(new WorkbenchInitializer(!Platform.IsRunningOnMono));
                 try
                 {
                     LoggingService.Info("Running application..."); //NOXLATE

Modified: trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -171,7 +171,10 @@
                         return errors;
                     };
                     
-                    BusyWaitDialog.Run(Strings.PrgPreSaveValidation, del, (result) => {
+                    BusyWaitDialog.Run(Strings.PrgPreSaveValidation, del, (result, ex) => {
+                        if (ex != null)
+                            throw ex;
+
                         ValidationIssue[] errors = result as ValidationIssue[];
                         if (errors.Length > 0)
                         {

Modified: trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Base/Services/DragDropHandlers/DwfFileHandler.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -26,6 +26,7 @@
 using OSGeo.MapGuide.ObjectModels;
 using Maestro.Shared.UI;
 using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.ObjectModels.DrawingSource;
 
 namespace Maestro.Base.Services.DragDropHandlers
 {
@@ -71,6 +72,10 @@
                     ds.SetResourceData(fileName, OSGeo.MapGuide.ObjectModels.Common.ResourceDataType.File, stream);
                 }
 
+                ds.RegenerateSheetList();
+                conn.ResourceService.SaveResource(ds); //Need to re-save for the next call to work
+                ds.UpdateExtents();
+
                 return true;
             }
             catch (Exception ex)

Modified: trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -171,8 +171,11 @@
                     else
                         return null;
                 };
-                Action<object> onComplete = (obj) =>
+                Action<object, Exception> onComplete = (obj, ex) =>
                 {
+                    if (ex != null)
+                        throw ex;
+
                     if (obj != null)
                     {
                         var rtMap = (RuntimeMap)obj;
@@ -288,7 +291,7 @@
                     return new UrlPreviewResult() { Url = url };
                 }
             };
-            Action<object> onComplete = (result) => {
+            Action<object, Exception> onComplete = (result, ex) => {
                 var urlResult = result as UrlPreviewResult;
                 var imgResult = result as ImagePreviewResult;
                 if (urlResult != null)

Modified: trunk/Tools/Maestro/Maestro.Base/WorkbenchInitializer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/WorkbenchInitializer.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Base/WorkbenchInitializer.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -32,6 +32,10 @@
     /// </summary>
     public class WorkbenchInitializer : IWorkbenchInitializer
     {
+        public WorkbenchInitializer(bool bStartMaximized) { this.StartMaximized = bStartMaximized; }
+
+        public bool StartMaximized { get; private set; }
+
         /// <summary>
         /// Gets the main window icon
         /// </summary>

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ResourceDataCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ResourceDataCtrl.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ResourceDataCtrl.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -207,7 +207,7 @@
         {
             //TODO: Obviously support progress
             BusyWaitDelegate method = () => { DoFileUpload(fileName); return null; };
-            BusyWaitDialog.Run(Strings.TextUploading, method, (obj) => 
+            BusyWaitDialog.Run(Strings.TextUploading, method, (obj, ex) => 
             {
                 LoadResourceData();
                 OnDataListChanged();
@@ -280,8 +280,10 @@
                                 }
                                 return null;
                             };
-                            BusyWaitDialog.Run(Strings.TextDownloading, method, (obj) => 
+                            BusyWaitDialog.Run(Strings.TextDownloading, method, (obj, ex) => 
                             {
+                                if (ex != null)
+                                    throw ex;
                                 MessageBox.Show(string.Format(Strings.FileDownloaded, fn));
                             });
                         }

Modified: trunk/Tools/Maestro/Maestro.Editors/DrawingSource/SourceSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/DrawingSource/SourceSectionCtrl.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Editors/DrawingSource/SourceSectionCtrl.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -82,12 +82,7 @@
                 _edSvc.SyncSessionCopy();
 
                 //Re-populate sheets
-                IDrawingService dwSvc = (IDrawingService)_dws.CurrentConnection.GetService((int)ServiceType.Drawing);
-                var sheets = dwSvc.EnumerateDrawingSections(_dws.ResourceID);
-                foreach (var sht in sheets.Section)
-                {
-                    _dws.AddSheet(_dws.CreateSheet(sht.Name, 0, 0, 0, 0));
-                }
+                _dws.RegenerateSheetList();
 
                 _edSvc.SyncSessionCopy();
                 //Re-calc extents

Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/Providers/Odbc/OdbcProviderCtrl.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -336,8 +336,10 @@
                     }
                     return null;
                 };
-                BusyWaitDialog.Run(Strings.TextPreparingConfigurationDocument, worker, (obj) => 
-                { 
+                BusyWaitDialog.Run(Strings.TextPreparingConfigurationDocument, worker, (obj, ex) => 
+                {
+                    if (ex != null)
+                        throw ex;
                     //Done
                 });
             }

Modified: trunk/Tools/Maestro/Maestro.Shared.UI/BusyWaitDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Shared.UI/BusyWaitDialog.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Shared.UI/BusyWaitDialog.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -52,13 +52,14 @@
         }
         
         public object ReturnValue { get; private set; }
+        public Exception Error { get; private set; }
 
-        public static void Run(string message, BusyWaitDelegate action, Action<object> onComplete)
+        public static void Run(string message, BusyWaitDelegate action, Action<object, Exception> onComplete)
         {
             Run(message, action, onComplete, true);
         }
 
-        public static void Run(string message, BusyWaitDelegate action, Action<object> onComplete, bool bPreserveThreadCulture)
+        public static void Run(string message, BusyWaitDelegate action, Action<object, Exception> onComplete, bool bPreserveThreadCulture)
         {
             if (action == null)
                 throw new ArgumentNullException("action"); //NOXLATE
@@ -69,7 +70,7 @@
             frm.lblBusy.Text = message;
             if (frm.ShowDialog() == DialogResult.OK)
             {
-                onComplete.Invoke(frm.ReturnValue);
+                onComplete.Invoke(frm.ReturnValue, frm.Error);
             }
         }
         
@@ -88,7 +89,7 @@
         {
             if (e.Error != null)
             {
-                ErrorDialog.Show(e.Error);
+                this.Error = e.Error;
             }
             else
             {

Modified: trunk/Tools/Maestro/Maestro.Shared.UI/IWorkbenchInitializer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Shared.UI/IWorkbenchInitializer.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Shared.UI/IWorkbenchInitializer.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -31,6 +31,10 @@
     public interface IWorkbenchInitializer
     {
         /// <summary>
+        /// Gets whether to start the workbench maximized
+        /// </summary>
+        bool StartMaximized { get; }
+        /// <summary>
         /// Gets the main window icon
         /// </summary>
         /// <returns></returns>

Modified: trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/Maestro.Shared.UI/WorkbenchBase.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -55,6 +55,7 @@
             _toolstripRegions = new Dictionary<string, ToolbarRegion>();
 
             this.Icon = _workbenchInitializer.GetIcon();
+            this.WindowState = init.StartMaximized ? FormWindowState.Maximized : FormWindowState.Normal;
 
             contentPanel = new DockPanel();
             contentPanel.DocumentStyle = DocumentStyle.DockingWindow;

Modified: trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/MaestroAPITests/MaestroAPITests.csproj	2012-11-13 11:44:53 UTC (rev 7204)
@@ -574,6 +574,7 @@
     <Content Include="UserTestData\odbc_example_config2.xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <Content Include="UserTestData\SpaceShip.xml" />
     <Content Include="UserTestData\wms_config_example1.xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>

Modified: trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/MaestroAPITests/RuntimeMapTests.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -39,6 +39,7 @@
     using System.Drawing;
     using OSGeo.MapGuide.ExtendedObjectModels;
     using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+    using OSGeo.MapGuide.ObjectModels.DrawingSource;
 
     [SetUpFixture]
     public class TestBootstrap
@@ -101,6 +102,9 @@
             resSvc.SetResourceData("Library://UnitTests/Data/HydrographicPolygons.FeatureSource", "UT_HydrographicPolygons.sdf", ResourceDataType.File, File.OpenRead("TestData/MappingService/UT_HydrographicPolygons.sdf"));
             resSvc.SetResourceData("Library://UnitTests/Data/Rail.FeatureSource", "UT_Rail.sdf", ResourceDataType.File, File.OpenRead("TestData/MappingService/UT_Rail.sdf"));
             resSvc.SetResourceData("Library://UnitTests/Data/Parcels.FeatureSource", "UT_Parcels.sdf", ResourceDataType.File, File.OpenRead("TestData/TileService/UT_Parcels.sdf"));
+
+            resSvc.SetResourceXmlData("Library://UnitTests/Data/SpaceShip.DrawingSource", File.OpenRead("TestData/DrawingService/SpaceShipDrawingSource.xml"));
+            resSvc.SetResourceData("Library://UnitTests/Data/SpaceShip.DrawingSource", "SpaceShip.dwf", ResourceDataType.File, File.OpenRead("TestData/DrawingService/SpaceShip.dwf"));
         }
 
         [TestFixtureTearDown]
@@ -1021,6 +1025,40 @@
             RuntimeMap mymap = mapSvc.OpenMap("Session:" + conn.SessionID + "//" + rtm.Name + ".Map");
         }
 
+        public virtual void TestMapAddDwfLayer()
+        {
+            IServerConnection conn = CreateTestConnection();
+            IMappingService mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+            string mapdefinition = "Library://UnitTests/Maps/SheboyganTiled.MapDefinition";
+            IMapDefinition mdef = (IMapDefinition)conn.ResourceService.GetResource(mapdefinition);
+            RuntimeMap rtm = mapSvc.CreateMap(mdef); // Create new runtime map
+
+            var ds = (IDrawingSource)conn.ResourceService.GetResource("Library://UnitTests/Data/SpaceShip.DrawingSource");
+            //The DWF in question can't be interrogated for extents, so flub it
+            string sheetName = string.Empty;
+            foreach (var sheet in ds.Sheet)
+            {
+                sheet.Extent = ObjectFactory.CreateEnvelope(-100000, -100000, 100000, 100000);
+                if (string.IsNullOrEmpty(sheetName))
+                    sheetName = sheet.Name;
+            }
+            conn.ResourceService.SaveResource(ds);
+            var ldf = ObjectFactory.CreateDefaultLayer(conn, LayerType.Drawing);
+            var dl = (IDrawingLayerDefinition)ldf.SubLayer;
+            dl.ResourceId = ds.ResourceID;
+            dl.Sheet = sheetName;
+            ldf.ResourceID = "Session:" + conn.SessionID + "//TestDrawing.LayerDefinition";
+            conn.ResourceService.SaveResource(ldf);
+
+            //Add our dwf layer
+            var rtLayer = mapSvc.CreateMapLayer(rtm, ldf);
+            rtm.Layers.Add(rtLayer);
+
+            rtm.Save();
+            Assert.IsFalse(rtm.IsDirty);
+            RuntimeMap mymap = mapSvc.OpenMap("Session:" + conn.SessionID + "//" + rtm.Name + ".Map");
+        }
+
         public virtual void TestResourceEvents()
         {
             bool deleteCalled = false;
@@ -1197,6 +1235,12 @@
         {
             base.TestMapManipulation5();
         }
+
+        [Test]
+        public override void TestMapAddDwfLayer()
+        {
+            base.TestMapAddDwfLayer();
+        }
     }
 
     [TestFixture(Ignore = TestControl.IgnoreLocalNativeRuntimeMapTests)]
@@ -1277,6 +1321,12 @@
         {
             base.TestLargeMapCreatePerformance();
         }
+
+        [Test]
+        public override void TestMapAddDwfLayer()
+        {
+            base.TestMapAddDwfLayer();
+        }
     }
 
     [TestFixture(Ignore = TestControl.IgnoreLocalRuntimeMapTests)]

Added: trunk/Tools/Maestro/MaestroAPITests/UserTestData/SpaceShip.xml
===================================================================
--- trunk/Tools/Maestro/MaestroAPITests/UserTestData/SpaceShip.xml	                        (rev 0)
+++ trunk/Tools/Maestro/MaestroAPITests/UserTestData/SpaceShip.xml	2012-11-13 11:44:53 UTC (rev 7204)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<LayerDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.0.0" xsi:noNamespaceSchemaLocation="LayerDefinition-1.0.0.xsd">
+  <DrawingLayerDefinition>
+    <ResourceId>Library://UnitTests/Data/SpaceShip.DrawingSource</ResourceId>
+    <Sheet>com.autodesk.dwf.ePlot_9E2723744244DB8C44482263E654F764</Sheet>
+    <LayerFilter>YELLOW,CYAN,GREEN,RED,BLUE,WHITE</LayerFilter>
+  </DrawingLayerDefinition>
+</LayerDefinition>

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -590,22 +590,10 @@
                                 this.Parent.ResourceService.SetResourceData(dsId, dataName, ResourceDataType.File, System.IO.File.OpenRead(file));
                                 cb(this, new LengthyOperationProgressArgs(string.Format(Strings.TemplateLoaded, file), current));
 
-                                var dwSvc = (IDrawingService)Parent.GetService((int)ServiceType.Drawing);
-                                var list = dwSvc.EnumerateDrawingSections(dsId);
-                                if (list.Section.Count > 0)
-                                {
-                                    foreach(var sect in list.Section)
-                                    {
-                                        var sht = ds.CreateSheet(sect.Name, 0, 0, 0, 0);
-                                        ds.AddSheet(sht);
-                                    }
-
-                                    this.Parent.ResourceService.SaveResource(ds);
-
-                                    ds.UpdateExtents();
-                                    
-                                    this.Parent.ResourceService.SaveResource(ds);
-                                }
+                                ds.RegenerateSheetList();
+                                this.Parent.ResourceService.SaveResource(ds);
+                                ds.UpdateExtents();
+                                this.Parent.ResourceService.SaveResource(ds);
                             }
                             else
                             {

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMapLayer.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -168,6 +168,10 @@
                     }
                 }
             }
+            else if (ldf.SubLayer.LayerType == LayerType.Drawing)
+            {
+                _featureSourceId = ldf.SubLayer.ResourceId;
+            }
 
             _expandInLegend = false;
             this.Name = ResourceIdentifier.GetName(ldf.ResourceID);
@@ -578,13 +582,19 @@
         /// <summary>
         /// Gets the schema name
         /// </summary>
+        /// <remarks>
+        /// For drawing layers, the schema name will always be empty
+        /// </remarks>
         public string SchemaName
         {
             get
             {
-                var tokens = this.QualifiedClassName.Split(':'); //NOXLATE
-                if (tokens.Length == 2)
-                    return tokens[0];
+                if (!this.FeatureSourceID.EndsWith("DrawingSource")) //NOXLATE
+                {
+                    var tokens = this.QualifiedClassName.Split(':'); //NOXLATE
+                    if (tokens.Length == 2)
+                        return tokens[0];
+                }
                 return string.Empty;
             }
         }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSourceInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSourceInterfaces.cs	2012-11-13 11:12:13 UTC (rev 7203)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/DrawingSourceInterfaces.cs	2012-11-13 11:44:53 UTC (rev 7204)
@@ -104,12 +104,39 @@
     public static class DrawingSourceExtensions
     {
         /// <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;
+        }
+
+        /// <summary>
         /// Updates the extents of all sheets based on their respective AutoCAD Viewport Data in the embedded PIA resource
         /// </summary>
         /// <param name="source"></param>
         public static void UpdateExtents(this IDrawingSource source)
         {
             Check.NotNull(source, "source"); //NOXLATE
+            Check.NotNull(source.CurrentConnection, "source.CurrentConection"); //NOXLATE
             Check.NotEmpty(source.ResourceID, "source.ResourceID"); //NOXLATE
 
             //Need drawing service



More information about the mapguide-commits mailing list