[mapguide-commits] r4564 - in trunk/Tools/Maestro: Localization/da-DK/Maestro/Strings Maestro

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sat Jan 30 14:23:57 EST 2010


Author: ksgeograf
Date: 2010-01-30 14:23:57 -0500 (Sat, 30 Jan 2010)
New Revision: 4564

Modified:
   trunk/Tools/Maestro/Localization/da-DK/Maestro/Strings/Profiling.da-DK.resx
   trunk/Tools/Maestro/Maestro/FormMain.cs
   trunk/Tools/Maestro/Maestro/Profiling.Designer.cs
   trunk/Tools/Maestro/Maestro/Profiling.cs
   trunk/Tools/Maestro/Maestro/Profiling.resx
   trunk/Tools/Maestro/Maestro/Program.cs
Log:
Maestro:
Fixed cosmetic issues with Profiling, and cleaned up the code.

Modified: trunk/Tools/Maestro/Localization/da-DK/Maestro/Strings/Profiling.da-DK.resx
===================================================================
--- trunk/Tools/Maestro/Localization/da-DK/Maestro/Strings/Profiling.da-DK.resx	2010-01-30 19:22:17 UTC (rev 4563)
+++ trunk/Tools/Maestro/Localization/da-DK/Maestro/Strings/Profiling.da-DK.resx	2010-01-30 19:23:57 UTC (rev 4564)
@@ -151,7 +151,7 @@
     <comment>A message written in the log when profiling runtime map rendering</comment>
   </data>
   <data name="LogMessageRenderingScales" xml:space="preserve">
-    <value>Rendering af zoomeniveauer:</value>
+    <value>Rendering af zoom niveauer:</value>
     <comment>A message written in the log when profiling a scale rendering</comment>
   </data>
   <data name="LogMessageRuntimeLayer" xml:space="preserve">

Modified: trunk/Tools/Maestro/Maestro/FormMain.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/FormMain.cs	2010-01-30 19:22:17 UTC (rev 4563)
+++ trunk/Tools/Maestro/Maestro/FormMain.cs	2010-01-30 19:23:57 UTC (rev 4564)
@@ -2455,7 +2455,7 @@
             if (ei == null || ei.Resource == null)
                 return;
 
-            Profiling dlg = new Profiling(ei.Resource, m_connection);
+            Profiling dlg = new Profiling(ei.Resource, edi.ResourceId, m_connection);
             dlg.ShowDialog(this);
         }
 

Modified: trunk/Tools/Maestro/Maestro/Profiling.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/Profiling.Designer.cs	2010-01-30 19:22:17 UTC (rev 4563)
+++ trunk/Tools/Maestro/Maestro/Profiling.Designer.cs	2010-01-30 19:23:57 UTC (rev 4564)
@@ -32,6 +32,7 @@
             this.panel1 = new System.Windows.Forms.Panel();
             this.CancelBtn = new System.Windows.Forms.Button();
             this.Results = new System.Windows.Forms.TextBox();
+            this.backgroundWorker = new System.ComponentModel.BackgroundWorker();
             this.panel1.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -54,6 +55,14 @@
             this.Results.Name = "Results";
             this.Results.ReadOnly = true;
             // 
+            // backgroundWorker
+            // 
+            this.backgroundWorker.WorkerReportsProgress = true;
+            this.backgroundWorker.WorkerSupportsCancellation = true;
+            this.backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker_DoWork);
+            this.backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker_RunWorkerCompleted);
+            this.backgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker_ProgressChanged);
+            // 
             // Profiling
             // 
             resources.ApplyResources(this, "$this");
@@ -77,5 +86,6 @@
         private System.Windows.Forms.Panel panel1;
         private System.Windows.Forms.Button CancelBtn;
         private System.Windows.Forms.TextBox Results;
+        private System.ComponentModel.BackgroundWorker backgroundWorker;
     }
 }
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro/Profiling.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/Profiling.cs	2010-01-30 19:22:17 UTC (rev 4563)
+++ trunk/Tools/Maestro/Maestro/Profiling.cs	2010-01-30 19:23:57 UTC (rev 4564)
@@ -31,103 +31,38 @@
     public partial class Profiling : Form
     {
         private ServerConnectionI m_connection;
-        private System.Threading.Thread m_thread;
-        private System.Threading.AutoResetEvent m_event;
         private object m_item;
-        private bool m_cancel;
-        private bool m_done;
-        private WriteStringDelegate m_writer;
+        private string m_resourceId;
 
         private OSGeo.MapGuide.MaestroAPI.RuntimeClasses.RuntimeMap m_tempmap;
 
 
-        public Profiling(object item, ServerConnectionI connection)
+        public Profiling(object item, string resourceId, ServerConnectionI connection)
             : this()
         {
             m_connection = connection;
             m_item = item;
-            m_thread.Start();
+            m_resourceId = resourceId;
         }
 
         private Profiling()
         {
             InitializeComponent();
-            m_cancel = false;
-            m_done = false;
             m_tempmap = null;
-            m_writer = new WriteStringDelegate(WriteString);
-            m_event = new System.Threading.AutoResetEvent(false);
-            m_thread = new System.Threading.Thread(new System.Threading.ThreadStart(RunThread));
-            m_thread.IsBackground = true;
         }
 
-        private void RunThread()
-        {
-            m_event.WaitOne();
-
-            if (m_item as FeatureSource != null)
-            {
-                ProfileFeatureSource(m_item as FeatureSource);
-            }
-            else if (m_item as LayerDefinition != null)
-            {
-                ProfileLayerDefinition(m_item as LayerDefinition);
-            }
-            else if (m_item as MapDefinition != null)
-            {
-                ProfileMapDefinition(m_item as MapDefinition);
-            }
-            else
-            {
-                WriteString(Strings.Profiling.LogMessageUnsupportedResourceType);
-            }
-
-            SignalDone();
-        }
-
-        private delegate void SignalDoneDelegate();
-        private void SignalDone()
-        {
-            if (this.InvokeRequired)
-                this.Invoke(new SignalDoneDelegate(SignalDone));
-            else
-            {
-                CancelBtn.Text = Strings.Profiling.CloseButtonText;
-                WriteString(Strings.Profiling.LogMessageDone);
-                m_done = true;
-            }
-        }
-
-        private delegate void WriteStringDelegate(string text);
-        private void WriteString(string text)
-        {
-            if (this.InvokeRequired)
-                this.Invoke(new WriteStringDelegate(WriteString), text);
-            else
-            {
-                bool scroll = Math.Abs((Results.SelectionStart + Results.SelectionLength) - Results.Text.Length) < 20;
-
-                Results.Text += text + "\r\n";
-                if (scroll)
-                {
-                    Results.SelectionLength = 0;
-                    Results.SelectionStart = Results.Text.Length;
-                    Results.ScrollToCaret();
-                }
-            }
-        }
-
         private void CancelBtn_Click(object sender, EventArgs e)
         {
-            if (m_done)
+            if (!backgroundWorker.IsBusy)
                 this.Close();
-            else
-                m_cancel = true;
+            else if (!backgroundWorker.CancellationPending)
+                backgroundWorker.CancelAsync();
         }
 
         private void ProfileFeatureSource(FeatureSource fs)
         {
-            m_writer(string.Format(Strings.Profiling.LogMessageFeatureSource, fs.ResourceId));
+            string resourceId = fs == m_item ? m_resourceId : fs.ResourceId;
+            backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.LogMessageFeatureSource, resourceId)));
         }
 
         private void SetTempLayer(string resourceId)
@@ -171,13 +106,15 @@
 
         private void ProfileLayerDefinition(LayerDefinition ldef)
         {
-            if (m_cancel)
+            if (backgroundWorker.CancellationPending)
                 return;
 
+            string resourceId = ldef == m_item ? m_resourceId : ldef.ResourceId;
+
             MakeTempMap();
 
-            m_writer(string.Format(Strings.Profiling.LogMessageLayerDefinition, ldef.ResourceId));
-            using (new Timer(Strings.Profiling.LogMessageRuntimeLayer, m_writer))
+            backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.LogMessageLayerDefinition, resourceId)));
+            using (new Timer(Strings.Profiling.LogMessageRuntimeLayer, backgroundWorker))
             {
                 try
                 {
@@ -190,8 +127,11 @@
                     mdef.Layers.Add(mltype);
                     m_connection.ResetFeatureSourceSchemaCache();
 
+                    if (backgroundWorker.CancellationPending)
+                        return;
+
                     OSGeo.MapGuide.MaestroAPI.RuntimeClasses.RuntimeMap map = new OSGeo.MapGuide.MaestroAPI.RuntimeClasses.RuntimeMap(mdef);
-                    using (new Timer(Strings.Profiling.LogMessageIdentifyFetching, m_writer))
+                    using (new Timer(Strings.Profiling.LogMessageIdentifyFetching, backgroundWorker))
                     {
                         //map.Layers[0].Parent = map;
                         map.Layers[0].Visible = true;
@@ -200,114 +140,163 @@
                 }
                 catch (Exception ex)
                 {
-                    m_writer(string.Format(Strings.Profiling.LayerDefinitionProfilingError, ldef.ResourceId, ex.Message));
+                    backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.LayerDefinitionProfilingError, resourceId, ex.Message)));
                 }
             }
 
-                LayerDefinition lx = (LayerDefinition)Utility.XmlDeepCopy(ldef);
-                if (lx.Item as VectorLayerDefinitionType != null || lx.Item as GridLayerDefinitionType != null)
+            if (backgroundWorker.CancellationPending)
+                return;
+
+            LayerDefinition lx = (LayerDefinition)Utility.XmlDeepCopy(ldef);
+            if (lx.Item as VectorLayerDefinitionType != null || lx.Item as GridLayerDefinitionType != null)
+            {
+                using (new Timer(Strings.Profiling.LogMessageRenderingScales, backgroundWorker))
                 {
-                    using (new Timer(Strings.Profiling.LogMessageRenderingScales, m_writer))
+                    if (lx.Item as VectorLayerDefinitionType != null)
                     {
-                        if (lx.Item as VectorLayerDefinitionType != null)
+                        VectorLayerDefinitionType vlx = lx.Item as VectorLayerDefinitionType;
+                        VectorScaleRangeTypeCollection ranges = vlx.VectorScaleRange;
+
+                        foreach (VectorScaleRangeType vsr in ranges)
                         {
-                            VectorLayerDefinitionType vlx = lx.Item as VectorLayerDefinitionType;
-                            VectorScaleRangeTypeCollection ranges = vlx.VectorScaleRange;
+                            if (backgroundWorker.CancellationPending)
+                                return;
 
-                            foreach (VectorScaleRangeType vsr in ranges)
+                            string tmp1 = new ResourceIdentifier(Guid.NewGuid().ToString(), ResourceTypes.LayerDefiniton, m_connection.SessionID);
+
+                            try
                             {
-                                string tmp1 = new ResourceIdentifier(Guid.NewGuid().ToString(), ResourceTypes.LayerDefiniton, m_connection.SessionID);
+                                double minscale = vsr.MinScaleSpecified ? vsr.MinScale : 0;
+                                double maxscale = vsr.MaxScaleSpecified ? vsr.MaxScale : 10000000;
 
-                                try
-                                {
-                                    double minscale = vsr.MinScaleSpecified ? vsr.MinScale : 0;
-                                    double maxscale = vsr.MaxScaleSpecified ? vsr.MaxScale : 10000000;
+                                vlx.VectorScaleRange = new VectorScaleRangeTypeCollection();
+                                vsr.MaxScaleSpecified = false;
+                                vsr.MinScaleSpecified = false;
+                                vlx.VectorScaleRange.Add(vsr);
 
-                                    vlx.VectorScaleRange = new VectorScaleRangeTypeCollection();
-                                    vsr.MaxScaleSpecified = false;
-                                    vsr.MinScaleSpecified = false;
-                                    vlx.VectorScaleRange.Add(vsr);
+                                m_connection.SaveResourceAs(lx, tmp1);
 
-                                    m_connection.SaveResourceAs(lx, tmp1);
+                                if (backgroundWorker.CancellationPending)
+                                    return;
 
+                                OSGeo.MapGuide.MaestroAPI.FdoSpatialContextList lst = m_connection.GetSpatialContextInfo(vlx.ResourceId, false);
 
-                                    OSGeo.MapGuide.MaestroAPI.FdoSpatialContextList lst = m_connection.GetSpatialContextInfo(vlx.ResourceId, false);
+                                if (lst.SpatialContext != null && lst.SpatialContext.Count >= 1)
+                                {
+                                    m_tempmap.CoordinateSystem = lst.SpatialContext[0].CoordinateSystemWkt;
+                                    if (string.IsNullOrEmpty(m_tempmap.CoordinateSystem))
+                                        m_tempmap.CoordinateSystem = @"LOCAL_CS[""*XY-M*"", LOCAL_DATUM[""*X-Y*"", 10000], UNIT[""Meter"", 1], AXIS[""X"", EAST], AXIS[""Y"", NORTH]]";
+                                    m_tempmap.Extents = new OSGeo.MapGuide.MaestroAPI.Box2DType();
+                                    m_tempmap.Extents.MinX = double.Parse(lst.SpatialContext[0].Extent.LowerLeftCoordinate.X, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture);
+                                    m_tempmap.Extents.MinY = double.Parse(lst.SpatialContext[0].Extent.LowerLeftCoordinate.Y, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); ;
+                                    m_tempmap.Extents.MaxX = double.Parse(lst.SpatialContext[0].Extent.UpperRightCoordinate.X, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); ;
+                                    m_tempmap.Extents.MaxY = double.Parse(lst.SpatialContext[0].Extent.UpperRightCoordinate.Y, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); ;
+                                }
 
-                                    if (lst.SpatialContext != null && lst.SpatialContext.Count >= 1)
-                                    {
-                                        m_tempmap.CoordinateSystem = lst.SpatialContext[0].CoordinateSystemWkt;
-                                        if (string.IsNullOrEmpty(m_tempmap.CoordinateSystem))
-                                            m_tempmap.CoordinateSystem = @"LOCAL_CS[""*XY-M*"", LOCAL_DATUM[""*X-Y*"", 10000], UNIT[""Meter"", 1], AXIS[""X"", EAST], AXIS[""Y"", NORTH]]";
-                                        m_tempmap.Extents = new OSGeo.MapGuide.MaestroAPI.Box2DType();
-                                        m_tempmap.Extents.MinX = double.Parse(lst.SpatialContext[0].Extent.LowerLeftCoordinate.X, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture);
-                                        m_tempmap.Extents.MinY = double.Parse(lst.SpatialContext[0].Extent.LowerLeftCoordinate.Y, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); ;
-                                        m_tempmap.Extents.MaxX = double.Parse(lst.SpatialContext[0].Extent.UpperRightCoordinate.X, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); ;
-                                        m_tempmap.Extents.MaxY = double.Parse(lst.SpatialContext[0].Extent.UpperRightCoordinate.Y, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture); ;
-                                    }
+                                SetTempLayer(tmp1);
+                                m_connection.SaveRuntimeMap(m_tempmap.ResourceID, m_tempmap);
 
-                                    SetTempLayer(tmp1);
-                                    m_connection.SaveRuntimeMap(m_tempmap.ResourceID, m_tempmap);
+                                if (backgroundWorker.CancellationPending)
+                                    return;
 
-                                    using (new Timer(string.Format(Strings.Profiling.LogMessageScaleRange, minscale, maxscale), m_writer))
-                                    {
-                                        //TODO: Use extents rather than scale
-                                        //using (System.IO.Stream s = m_connection.RenderRuntimeMap(tmp2, m.Extents, 1024, 800, 96))
-                                        using (System.IO.Stream s = m_connection.RenderRuntimeMap(m_tempmap.ResourceID, ((m_tempmap.Extents.MaxX - m_tempmap.Extents.MinX) / 2) + m_tempmap.Extents.MinX, ((m_tempmap.Extents.MaxY - m_tempmap.Extents.MinY) / 2) + m_tempmap.Extents.MinY, 50000, 1024, 800, 96))
-                                            new Bitmap(s).Dispose();
-                                    }
-                                }
-                                finally
+                                using (new Timer(string.Format(Strings.Profiling.LogMessageScaleRange, minscale, maxscale), backgroundWorker))
                                 {
-                                    try { m_connection.DeleteResource(tmp1); }
-                                    catch { }
+                                    //TODO: Use extents rather than scale
+                                    //using (System.IO.Stream s = m_connection.RenderRuntimeMap(tmp2, m.Extents, 1024, 800, 96))
+                                    using (System.IO.Stream s = m_connection.RenderRuntimeMap(m_tempmap.ResourceID, ((m_tempmap.Extents.MaxX - m_tempmap.Extents.MinX) / 2) + m_tempmap.Extents.MinX, ((m_tempmap.Extents.MaxY - m_tempmap.Extents.MinY) / 2) + m_tempmap.Extents.MinY, 50000, 1024, 800, 96))
+                                        new Bitmap(s).Dispose();
                                 }
                             }
+                            finally
+                            {
+                                try { m_connection.DeleteResource(tmp1); }
+                                catch { }
+                            }
+                        }
 
-                        }
                     }
                 }
+            }
 
-            m_writer("\r\n");
+            if (backgroundWorker.CancellationPending)
+                return;
+
+            backgroundWorker.ReportProgress(0, ("\r\n"));
         }
 
         private void ProfileMapDefinition(MapDefinition mdef)
         {
-            m_writer(string.Format(Strings.Profiling.LogMessageMapDefinition, mdef.ResourceId));
+            if (backgroundWorker.CancellationPending)
+                return;
 
-            using(new Timer(Strings.Profiling.LogMessageRuntimeMap, m_writer))
+            string resourceId = mdef == m_item ? m_resourceId : mdef.ResourceId;
+
+            backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.LogMessageMapDefinition, resourceId)));
+
+            using (new Timer(Strings.Profiling.LogMessageRuntimeMap, backgroundWorker))
+            {
                 foreach (MapLayerType ml in mdef.Layers)
                 {
                     try
                     {
+                        if (backgroundWorker.CancellationPending)
+                            return;
+
                         LayerDefinition ldef = mdef.CurrentConnection.GetLayerDefinition(ml.ResourceId);
                         ProfileLayerDefinition(ldef);
                     }
                     catch (Exception ex)
                     {
-                        m_writer(string.Format(Strings.Profiling.LayerDefinitionProfilingError, ml.ResourceId, ex.Message));
+                        backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.LayerDefinitionProfilingError, ml.ResourceId, ex.Message)));
                     }
                 }
 
-            if (m_cancel)
+                if (mdef.BaseMapDefinition != null && mdef.BaseMapDefinition.BaseMapLayerGroup != null)
+                {
+                    foreach (BaseMapLayerGroupCommonType g in mdef.BaseMapDefinition.BaseMapLayerGroup)
+                        if (g.BaseMapLayer != null)
+                            foreach (BaseMapLayerType ml in g.BaseMapLayer)
+                                try
+                                {
+                                    if (backgroundWorker.CancellationPending)
+                                        return;
+
+                                    LayerDefinition ldef = mdef.CurrentConnection.GetLayerDefinition(ml.ResourceId);
+                                    ProfileLayerDefinition(ldef);
+                                }
+                                catch (Exception ex)
+                                {
+                                    backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.LayerDefinitionProfilingError, ml.ResourceId, ex.Message)));
+                                }
+                }
+            }
+
+            if (backgroundWorker.CancellationPending)
                 return;
 
             try
             {
+                if (backgroundWorker.CancellationPending)
+                    return;
+
                 m_connection.ResetFeatureSourceSchemaCache();
-                using (new Timer(Strings.Profiling.LogMessageRuntimeMapTotal, m_writer))
+                using (new Timer(Strings.Profiling.LogMessageRuntimeMapTotal, backgroundWorker))
                     new OSGeo.MapGuide.MaestroAPI.RuntimeClasses.RuntimeMap(mdef);
             }
             catch (Exception ex)
             {
-                m_writer(string.Format(Strings.Profiling.RuntimeMapProfilingError, mdef.ResourceId, ex.Message));
+                backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.RuntimeMapProfilingError, resourceId, ex.Message)));
             }
 
             string tmp2 = new ResourceIdentifier(Guid.NewGuid().ToString(), ResourceTypes.RuntimeMap, m_connection.SessionID);
 
             try
             {
+                if (backgroundWorker.CancellationPending)
+                    return;
+
                 m_connection.CreateRuntimeMap(tmp2, mdef);
-                using (new Timer(Strings.Profiling.LogMessageRenderingMap, m_writer))
+                using (new Timer(Strings.Profiling.LogMessageRenderingMap, backgroundWorker))
                 {
                     //TODO: Use extents rather than scale
                     //using (System.IO.Stream s = m_connection.RenderRuntimeMap(tmp2, mdef.Extents, 1024, 800, 96))
@@ -320,7 +309,7 @@
             }
             catch (Exception ex)
             {
-                m_writer(string.Format(Strings.Profiling.MapRenderingError, mdef.ResourceId, ex.Message));
+                backgroundWorker.ReportProgress(0, (string.Format(Strings.Profiling.MapRenderingError, resourceId, ex.Message)));
             }
             finally
             {
@@ -335,14 +324,14 @@
             private string m_text;
             private bool m_isDisposed;
             private DateTime m_begin;
-            private WriteStringDelegate m_writer;
+            private BackgroundWorker m_worker;
 
-            public Timer(string text, WriteStringDelegate writer)
+            public Timer(string text, BackgroundWorker worker)
             {
                 m_begin = DateTime.Now;
                 m_isDisposed = false;
                 m_text = text;
-                m_writer = writer;
+                m_worker = worker;
             }
 
             #region IDisposable Members
@@ -353,8 +342,8 @@
                 {
                     TimeSpan ts = DateTime.Now - m_begin;
                     m_isDisposed = true;
-                    m_writer(m_text + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00") + "." + ts.Milliseconds.ToString("000"));
-                    m_writer = null;
+                    m_worker.ReportProgress(0, (m_text + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00") + "." + ts.Milliseconds.ToString("000")));
+                    m_worker = null;
                     m_text = null;
                 }
             }
@@ -364,14 +353,66 @@
 
         private void Profiling_Load(object sender, EventArgs e)
         {
-            m_event.Set();
+            backgroundWorker.RunWorkerAsync();
         }
 
         private void Profiling_FormClosing(object sender, FormClosingEventArgs e)
         {
-            if (e.CloseReason == CloseReason.UserClosing)
-                m_cancel = true;
+            if (backgroundWorker.IsBusy)
+            {
+                e.Cancel = true;
+
+                if (!backgroundWorker.CancellationPending)
+                    backgroundWorker.CancelAsync();
+            }
         }
 
+        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
+        {
+            if (m_item as FeatureSource != null)
+            {
+                ProfileFeatureSource(m_item as FeatureSource);
+            }
+            else if (m_item as LayerDefinition != null)
+            {
+                ProfileLayerDefinition(m_item as LayerDefinition);
+            }
+            else if (m_item as MapDefinition != null)
+            {
+                ProfileMapDefinition(m_item as MapDefinition);
+            }
+            else
+            {
+                backgroundWorker.ReportProgress(0, Strings.Profiling.LogMessageUnsupportedResourceType);
+            }
+        }
+
+        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+        {
+            CancelBtn.Text = Strings.Profiling.CloseButtonText;
+            WriteString(Strings.Profiling.LogMessageDone);
+        }
+
+        private void WriteString(string message)
+        {
+            if (string.IsNullOrEmpty(message))
+                return;
+
+            bool scroll = Math.Abs((Results.SelectionStart + Results.SelectionLength) - Results.Text.Length) < 20;
+
+            Results.Text += message + "\r\n";
+            if (scroll)
+            {
+                Results.SelectionLength = 0;
+                Results.SelectionStart = Results.Text.Length;
+                Results.ScrollToCaret();
+            }
+        }
+
+        private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
+        {
+            WriteString(e.UserState as string);
+        }
+
     }
 }
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro/Profiling.resx
===================================================================
--- trunk/Tools/Maestro/Maestro/Profiling.resx	2010-01-30 19:22:17 UTC (rev 4563)
+++ trunk/Tools/Maestro/Maestro/Profiling.resx	2010-01-30 19:23:57 UTC (rev 4564)
@@ -201,6 +201,9 @@
   <data name="&gt;&gt;Results.ZOrder" xml:space="preserve">
     <value>0</value>
   </data>
+  <metadata name="backgroundWorker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
   <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
@@ -216,6 +219,12 @@
   <data name="$this.Text" xml:space="preserve">
     <value>Profiling</value>
   </data>
+  <data name="&gt;&gt;backgroundWorker.Name" xml:space="preserve">
+    <value>backgroundWorker</value>
+  </data>
+  <data name="&gt;&gt;backgroundWorker.Type" xml:space="preserve">
+    <value>System.ComponentModel.BackgroundWorker, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </data>
   <data name="&gt;&gt;$this.Name" xml:space="preserve">
     <value>Profiling</value>
   </data>

Modified: trunk/Tools/Maestro/Maestro/Program.cs
===================================================================
--- trunk/Tools/Maestro/Maestro/Program.cs	2010-01-30 19:22:17 UTC (rev 4563)
+++ trunk/Tools/Maestro/Maestro/Program.cs	2010-01-30 19:23:57 UTC (rev 4564)
@@ -30,32 +30,8 @@
 		[STAThread()]
 		public static void Main(string[] args)
 		{
-            //System.Text.RegularExpressions.Regex m_filenameTransformer = new System.Text.RegularExpressions.Regex(@"[^A-Za-z0-9\.-\/]");
-            //System.Text.RegularExpressions.Match m = m_filenameTransformer.Match("xx���");
+            //MaestroAPI.HttpServerConnection con = new OSGeo.MapGuide.MaestroAPI.HttpServerConnection(new Uri("http://localhost/mapguide"), "Administrator", "admin", "da", true);
 
-            /*MaestroAPI.HttpServerConnection con = new OSGeo.MapGuide.MaestroAPI.HttpServerConnection(new Uri("http://localhost:8008/mapguide"), "Administrator", "admin", "da", true);
-            con.CreateRuntimeMap("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
-            MaestroAPI.MapLayerType mlt = new OSGeo.MapGuide.MaestroAPI.MapLayerType();
-            mlt.ResourceId = "Library://Samples/Sheboygan/Layers/Buildings.LayerDefinition";
-            mlt.Parent = con.GetMapDefinition("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
-            MaestroAPI.RuntimeClasses.RuntimeMapLayer rml = new OSGeo.MapGuide.MaestroAPI.RuntimeClasses.RuntimeMapLayer(mlt);*/
-            //MaestroAPI.FeatureSetReader fs = con.QueryFeatureSource("Library://JammerbugtGrundsalg/sqlite.FeatureSource", "Grunde", null, new string[] { "ID" });
-            //fs.Read();
-            //MaestroAPI.LayerDefinition ldef = con.CreateResourceObject<MaestroAPI.LayerDefinition>();
-
-            /*MaestroAPI.ResourceIdentifier ri = new OSGeo.MapGuide.MaestroAPI.ResourceIdentifier("Library://folder/");
-            string s = ri.Folder;
-            ri.Folder = "xfolder";
-            ri.Folder = "Library://yfolder";
-            ri = new OSGeo.MapGuide.MaestroAPI.ResourceIdentifier("Library://folder/mapdef.LayerDefinition");
-            ri.Folder = "xfolder";
-            ri.Folder = "Library://yfolder";
-            ri.Folder = "";
-            ri = new OSGeo.MapGuide.MaestroAPI.ResourceIdentifier("Library://");
-            s = ri.Folder;*/
-
-
-
 			try
 			{
 				Application.EnableVisualStyles();



More information about the mapguide-commits mailing list