[mapguide-commits] r6063 - in trunk/Tools/Maestro/Maestro.Editors: . MapDefinition Properties

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Aug 14 08:59:13 EDT 2011


Author: jng
Date: 2011-08-14 05:59:13 -0700 (Sun, 14 Aug 2011)
New Revision: 6063

Added:
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.cs
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.resx
Modified:
   trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapSettingsSectionCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
Log:
Add a progress dialog to measure map definition extent calculation progress.


Modified: trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2011-08-13 08:06:08 UTC (rev 6062)
+++ trunk/Tools/Maestro/Maestro.Editors/Maestro.Editors.csproj	2011-08-14 12:59:13 UTC (rev 6063)
@@ -807,6 +807,12 @@
     <Compile Include="LoadProcedure\SqliteTransformationCtrl.Designer.cs">
       <DependentUpon>SqliteTransformationCtrl.cs</DependentUpon>
     </Compile>
+    <Compile Include="MapDefinition\ExtentCalculationDialog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="MapDefinition\ExtentCalculationDialog.Designer.cs">
+      <DependentUpon>ExtentCalculationDialog.cs</DependentUpon>
+    </Compile>
     <Compile Include="MapDefinition\FiniteScaleListCtrl.cs">
       <SubType>UserControl</SubType>
     </Compile>
@@ -2178,6 +2184,9 @@
     <Content Include="OdbcDriverMap.xml">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
+    <EmbeddedResource Include="MapDefinition\ExtentCalculationDialog.resx">
+      <DependentUpon>ExtentCalculationDialog.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Resources\areas\Acad_iso02w100.png" />
     <EmbeddedResource Include="Resources\areas\Acad_iso03w100.png" />
     <EmbeddedResource Include="Resources\areas\Acad_iso04w100.png" />

Added: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.Designer.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.Designer.cs	2011-08-14 12:59:13 UTC (rev 6063)
@@ -0,0 +1,310 @@
+namespace Maestro.Editors.MapDefinition
+{
+    partial class ExtentCalculationDialog
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.groupBox2 = new System.Windows.Forms.GroupBox();
+            this.txtUpperY = new System.Windows.Forms.TextBox();
+            this.label8 = new System.Windows.Forms.Label();
+            this.txtUpperX = new System.Windows.Forms.TextBox();
+            this.label7 = new System.Windows.Forms.Label();
+            this.txtLowerY = new System.Windows.Forms.TextBox();
+            this.label6 = new System.Windows.Forms.Label();
+            this.txtLowerX = new System.Windows.Forms.TextBox();
+            this.label5 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label9 = new System.Windows.Forms.Label();
+            this.grdCalculations = new System.Windows.Forms.DataGridView();
+            this.btnAccept = new System.Windows.Forms.Button();
+            this.btnClose = new System.Windows.Forms.Button();
+            this.label1 = new System.Windows.Forms.Label();
+            this.prgCalculations = new System.Windows.Forms.ProgressBar();
+            this.bgCalculation = new System.ComponentModel.BackgroundWorker();
+            this.lblMessage = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.txtCoordinateSystem = new System.Windows.Forms.TextBox();
+            this.groupBox2.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.grdCalculations)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // groupBox2
+            // 
+            this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+                        | System.Windows.Forms.AnchorStyles.Right)));
+            this.groupBox2.Controls.Add(this.txtUpperY);
+            this.groupBox2.Controls.Add(this.label8);
+            this.groupBox2.Controls.Add(this.txtUpperX);
+            this.groupBox2.Controls.Add(this.label7);
+            this.groupBox2.Controls.Add(this.txtLowerY);
+            this.groupBox2.Controls.Add(this.label6);
+            this.groupBox2.Controls.Add(this.txtLowerX);
+            this.groupBox2.Controls.Add(this.label5);
+            this.groupBox2.Controls.Add(this.label4);
+            this.groupBox2.Controls.Add(this.label9);
+            this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System;
+            this.groupBox2.Location = new System.Drawing.Point(12, 12);
+            this.groupBox2.Name = "groupBox2";
+            this.groupBox2.Size = new System.Drawing.Size(760, 80);
+            this.groupBox2.TabIndex = 5;
+            this.groupBox2.TabStop = false;
+            this.groupBox2.Text = "Final Extents";
+            // 
+            // txtUpperY
+            // 
+            this.txtUpperY.Location = new System.Drawing.Point(280, 50);
+            this.txtUpperY.Name = "txtUpperY";
+            this.txtUpperY.ReadOnly = true;
+            this.txtUpperY.Size = new System.Drawing.Size(96, 20);
+            this.txtUpperY.TabIndex = 9;
+            // 
+            // label8
+            // 
+            this.label8.FlatStyle = System.Windows.Forms.FlatStyle.System;
+            this.label8.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+            this.label8.Location = new System.Drawing.Point(256, 50);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(16, 16);
+            this.label8.TabIndex = 8;
+            this.label8.Text = "Y";
+            // 
+            // txtUpperX
+            // 
+            this.txtUpperX.Location = new System.Drawing.Point(144, 50);
+            this.txtUpperX.Name = "txtUpperX";
+            this.txtUpperX.ReadOnly = true;
+            this.txtUpperX.Size = new System.Drawing.Size(96, 20);
+            this.txtUpperX.TabIndex = 7;
+            // 
+            // label7
+            // 
+            this.label7.FlatStyle = System.Windows.Forms.FlatStyle.System;
+            this.label7.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+            this.label7.Location = new System.Drawing.Point(120, 50);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(16, 16);
+            this.label7.TabIndex = 6;
+            this.label7.Text = "X";
+            // 
+            // txtLowerY
+            // 
+            this.txtLowerY.Location = new System.Drawing.Point(280, 24);
+            this.txtLowerY.Name = "txtLowerY";
+            this.txtLowerY.ReadOnly = true;
+            this.txtLowerY.Size = new System.Drawing.Size(96, 20);
+            this.txtLowerY.TabIndex = 5;
+            // 
+            // label6
+            // 
+            this.label6.FlatStyle = System.Windows.Forms.FlatStyle.System;
+            this.label6.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+            this.label6.Location = new System.Drawing.Point(256, 24);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(16, 16);
+            this.label6.TabIndex = 4;
+            this.label6.Text = "Y";
+            // 
+            // txtLowerX
+            // 
+            this.txtLowerX.Location = new System.Drawing.Point(144, 24);
+            this.txtLowerX.Name = "txtLowerX";
+            this.txtLowerX.ReadOnly = true;
+            this.txtLowerX.Size = new System.Drawing.Size(96, 20);
+            this.txtLowerX.TabIndex = 3;
+            // 
+            // label5
+            // 
+            this.label5.FlatStyle = System.Windows.Forms.FlatStyle.System;
+            this.label5.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+            this.label5.Location = new System.Drawing.Point(120, 24);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(16, 16);
+            this.label5.TabIndex = 2;
+            this.label5.Text = "X";
+            // 
+            // label4
+            // 
+            this.label4.FlatStyle = System.Windows.Forms.FlatStyle.System;
+            this.label4.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+            this.label4.Location = new System.Drawing.Point(16, 50);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(80, 16);
+            this.label4.TabIndex = 1;
+            this.label4.Text = "Upper right";
+            // 
+            // label9
+            // 
+            this.label9.FlatStyle = System.Windows.Forms.FlatStyle.System;
+            this.label9.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+            this.label9.Location = new System.Drawing.Point(16, 24);
+            this.label9.Name = "label9";
+            this.label9.Size = new System.Drawing.Size(88, 16);
+            this.label9.TabIndex = 0;
+            this.label9.Text = "Lower left";
+            // 
+            // grdCalculations
+            // 
+            this.grdCalculations.AllowUserToAddRows = false;
+            this.grdCalculations.AllowUserToDeleteRows = false;
+            this.grdCalculations.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+                        | System.Windows.Forms.AnchorStyles.Left)
+                        | System.Windows.Forms.AnchorStyles.Right)));
+            this.grdCalculations.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            this.grdCalculations.Location = new System.Drawing.Point(12, 172);
+            this.grdCalculations.Name = "grdCalculations";
+            this.grdCalculations.ReadOnly = true;
+            this.grdCalculations.Size = new System.Drawing.Size(760, 116);
+            this.grdCalculations.TabIndex = 6;
+            // 
+            // btnAccept
+            // 
+            this.btnAccept.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.btnAccept.Enabled = false;
+            this.btnAccept.Location = new System.Drawing.Point(616, 327);
+            this.btnAccept.Name = "btnAccept";
+            this.btnAccept.Size = new System.Drawing.Size(75, 23);
+            this.btnAccept.TabIndex = 7;
+            this.btnAccept.Text = "Accept";
+            this.btnAccept.UseVisualStyleBackColor = true;
+            this.btnAccept.Click += new System.EventHandler(this.btnAccept_Click);
+            // 
+            // btnClose
+            // 
+            this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+            this.btnClose.Enabled = false;
+            this.btnClose.Location = new System.Drawing.Point(697, 327);
+            this.btnClose.Name = "btnClose";
+            this.btnClose.Size = new System.Drawing.Size(75, 23);
+            this.btnClose.TabIndex = 8;
+            this.btnClose.Text = "Close";
+            this.btnClose.UseVisualStyleBackColor = true;
+            this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(9, 145);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(97, 13);
+            this.label1.TabIndex = 9;
+            this.label1.Text = "Calculation Results";
+            // 
+            // prgCalculations
+            // 
+            this.prgCalculations.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+                        | System.Windows.Forms.AnchorStyles.Right)));
+            this.prgCalculations.Location = new System.Drawing.Point(12, 294);
+            this.prgCalculations.Name = "prgCalculations";
+            this.prgCalculations.Size = new System.Drawing.Size(760, 23);
+            this.prgCalculations.TabIndex = 10;
+            // 
+            // bgCalculation
+            // 
+            this.bgCalculation.WorkerReportsProgress = true;
+            this.bgCalculation.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bgCalculation_DoWork);
+            this.bgCalculation.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bgCalculation_RunWorkerCompleted);
+            this.bgCalculation.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.bgCalculation_ProgressChanged);
+            // 
+            // lblMessage
+            // 
+            this.lblMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+            this.lblMessage.AutoSize = true;
+            this.lblMessage.Location = new System.Drawing.Point(12, 332);
+            this.lblMessage.Name = "lblMessage";
+            this.lblMessage.Size = new System.Drawing.Size(0, 13);
+            this.lblMessage.TabIndex = 11;
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(28, 106);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(95, 13);
+            this.label2.TabIndex = 12;
+            this.label2.Text = "Coordinate System";
+            // 
+            // txtCoordinateSystem
+            // 
+            this.txtCoordinateSystem.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+                        | System.Windows.Forms.AnchorStyles.Right)));
+            this.txtCoordinateSystem.Location = new System.Drawing.Point(156, 103);
+            this.txtCoordinateSystem.Name = "txtCoordinateSystem";
+            this.txtCoordinateSystem.ReadOnly = true;
+            this.txtCoordinateSystem.Size = new System.Drawing.Size(616, 20);
+            this.txtCoordinateSystem.TabIndex = 13;
+            // 
+            // ExtentCalculationDialog
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(784, 362);
+            this.ControlBox = false;
+            this.Controls.Add(this.txtCoordinateSystem);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.lblMessage);
+            this.Controls.Add(this.prgCalculations);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.btnClose);
+            this.Controls.Add(this.btnAccept);
+            this.Controls.Add(this.grdCalculations);
+            this.Controls.Add(this.groupBox2);
+            this.Name = "ExtentCalculationDialog";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+            this.Text = "Calculating Extents";
+            this.groupBox2.ResumeLayout(false);
+            this.groupBox2.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.grdCalculations)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.GroupBox groupBox2;
+        private System.Windows.Forms.TextBox txtUpperY;
+        private System.Windows.Forms.Label label8;
+        private System.Windows.Forms.TextBox txtUpperX;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.TextBox txtLowerY;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.TextBox txtLowerX;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label9;
+        private System.Windows.Forms.DataGridView grdCalculations;
+        private System.Windows.Forms.Button btnAccept;
+        private System.Windows.Forms.Button btnClose;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.ProgressBar prgCalculations;
+        private System.ComponentModel.BackgroundWorker bgCalculation;
+        private System.Windows.Forms.Label lblMessage;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.TextBox txtCoordinateSystem;
+
+    }
+}
\ No newline at end of file

Added: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.cs	2011-08-14 12:59:13 UTC (rev 6063)
@@ -0,0 +1,244 @@
+#region Disclaimer / License
+// Copyright (C) 2011, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+using OSGeo.MapGuide.ObjectModels.Common;
+using OSGeo.MapGuide.ObjectModels;
+using OSGeo.MapGuide.ObjectModels.MapDefinition;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using OSGeo.MapGuide.MaestroAPI;
+
+namespace Maestro.Editors.MapDefinition
+{
+    public partial class ExtentCalculationDialog : Form
+    {
+        private IMapDefinition _mdf;
+
+        public ExtentCalculationDialog(IMapDefinition mdf)
+        {
+            InitializeComponent();
+            _mdf = mdf;
+            grdCalculations.DataSource = _results;
+
+            prgCalculations.Maximum = mdf.GetLayerCount();
+            if (mdf.BaseMap != null)
+                prgCalculations.Maximum += GetLayerCount(mdf.BaseMap);
+
+            txtCoordinateSystem.Text = mdf.CoordinateSystem;
+        }
+
+        private int GetLayerCount(IBaseMapDefinition baseMap)
+        {
+            int count = 0;
+            foreach (var grp in baseMap.BaseMapLayerGroup)
+            {
+                foreach (var layer in grp.BaseMapLayer)
+                {
+                    count++;
+                }
+            }
+            return count;
+        }
+
+        protected override void OnLoad(EventArgs e)
+        {
+            bgCalculation.RunWorkerAsync(_mdf);
+        }
+
+        enum TransformStatus
+        {
+            Pass,
+            Fail
+        }
+
+        class CalculationResult
+        {
+            public TransformStatus Status { get; set; }
+
+            public string LayerDefinition { get; set; }
+
+            public string CoordinateSystem { get; set; }
+
+            public string Extents { get; set; }
+
+            public string TransformedExtents { get; set; }
+
+            [Browsable(false)]
+            public IEnvelope TransformedResult { get; set; }
+
+            public string Messages { get; set; }
+        }
+
+        private BindingList<CalculationResult> _results = new BindingList<CalculationResult>();
+
+        public IEnvelope Extents
+        {
+            get
+            {
+                double llx;
+                double lly;
+                double urx;
+                double ury;
+                if (double.TryParse(txtLowerX.Text, out llx) &&
+                    double.TryParse(txtLowerY.Text, out lly) &&
+                    double.TryParse(txtUpperX.Text, out urx) &&
+                    double.TryParse(txtUpperY.Text, out ury))
+                {
+                    return ObjectFactory.CreateEnvelope(llx, lly, urx, ury);
+                }
+                return null;
+            }
+        }
+
+        private void btnAccept_Click(object sender, EventArgs e)
+        {
+            this.DialogResult = DialogResult.OK;
+        }
+
+        private void btnClose_Click(object sender, EventArgs e)
+        {
+            this.DialogResult = DialogResult.Cancel;
+        }
+
+        private void bgCalculation_DoWork(object sender, DoWorkEventArgs e)
+        {
+            var mdf = (IMapDefinition)e.Argument;
+            var resSvc = mdf.CurrentConnection.ResourceService;
+
+            //Accumulate layers
+            Dictionary<string, ILayerDefinition> layers = new Dictionary<string, ILayerDefinition>();
+            foreach (var lyr in mdf.MapLayer)
+            {
+                if (!layers.ContainsKey(lyr.ResourceId))
+                    layers.Add(lyr.ResourceId, (ILayerDefinition)resSvc.GetResource(lyr.ResourceId));
+            }
+            if (mdf.BaseMap != null)
+            {
+                foreach (var group in mdf.BaseMap.BaseMapLayerGroup)
+                {
+                    foreach (var layer in group.BaseMapLayer)
+                    {
+                        if (!layers.ContainsKey(layer.ResourceId))
+                            layers.Add(layer.ResourceId, (ILayerDefinition)resSvc.GetResource(layer.ResourceId));
+                    }
+                }
+            }
+
+            Check.NotNull(layers, "layers");
+            IEnvelope env = null;
+            int processed = 0;
+
+            //Begin
+            foreach (var layer in layers.Values)
+            {
+                CalculationResult res = new CalculationResult();
+                string wkt;
+                var e1 = layer.GetSpatialExtent(true, out wkt);
+                if (e1 != null)
+                {
+                    res.Extents = ExtentsToString(e1);
+                }
+                res.LayerDefinition = layer.ResourceID;
+                res.CoordinateSystem = wkt;
+
+                bool tx = false;
+                if (wkt != mdf.CoordinateSystem)
+                {
+                    tx = true;
+                    //Transform if not the same, otherwise assume either arbitrary or same as the map
+                    if (!string.IsNullOrEmpty(wkt))
+                    {
+                        e1 = Utility.TransformEnvelope(e1, wkt, mdf.CoordinateSystem);
+                        res.TransformedResult = e1;       
+                    }
+                }
+                else
+                {
+                    res.TransformedResult = e1;
+                    res.Messages = Properties.Resources.NoTransformationRequired;
+                }
+
+                if (e1 != null)
+                {
+                    res.Status = TransformStatus.Pass;
+                    if (tx)
+                        res.TransformedExtents = ExtentsToString(e1);
+                }
+                else
+                {
+                    res.Status = TransformStatus.Fail;
+                    res.Messages = string.Format(Properties.Resources.ExtentsTransformationFailed, layer.ResourceID);
+                }
+
+                processed++;
+                bgCalculation.ReportProgress(processed, res);
+            }
+        }
+
+        private string ExtentsToString(IEnvelope env)
+        {
+            Check.NotNull(env, "env");
+            return string.Format("[{0} {1}] [{2} {3}]", env.MinX, env.MinY, env.MaxX, env.MaxY);
+        }
+
+        private void bgCalculation_ProgressChanged(object sender, ProgressChangedEventArgs e)
+        {
+            prgCalculations.Value = e.ProgressPercentage;
+            var res = (CalculationResult)e.UserState;
+
+            var env = this.Extents;
+            if (env == null)
+            {
+                if (res.Status == TransformStatus.Pass && res.TransformedResult != null)
+                {
+                    txtLowerX.Text = res.TransformedResult.MinX.ToString();
+                    txtLowerY.Text = res.TransformedResult.MinY.ToString();
+                    txtUpperX.Text = res.TransformedResult.MaxX.ToString();
+                    txtUpperY.Text = res.TransformedResult.MaxY.ToString();
+                }
+            }
+            else
+            {
+                if (res.Status == TransformStatus.Pass && res.TransformedResult != null)
+                {
+                    env.ExpandToInclude(res.TransformedResult);
+
+                    txtLowerX.Text = env.MinX.ToString();
+                    txtLowerY.Text = env.MinY.ToString();
+                    txtUpperX.Text = env.MaxX.ToString();
+                    txtUpperY.Text = env.MaxY.ToString();
+                }
+            }
+
+            _results.Add(res);
+        }
+
+        private void bgCalculation_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+        {
+            lblMessage.Text = Properties.Resources.ExtentsCalculationCompleted;
+            btnAccept.Enabled = btnClose.Enabled = true;
+        }
+    }
+}

Added: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.resx	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/ExtentCalculationDialog.resx	2011-08-14 12:59:13 UTC (rev 6063)
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="bgCalculation.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+</root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapSettingsSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapSettingsSectionCtrl.cs	2011-08-13 08:06:08 UTC (rev 6062)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapSettingsSectionCtrl.cs	2011-08-14 12:59:13 UTC (rev 6063)
@@ -223,85 +223,20 @@
 
         private void btnSetZoom_Click(object sender, EventArgs e)
         {
-            using (new WaitCursor(this))
+            var diag = new ExtentCalculationDialog(_map);
+            if (diag.ShowDialog() == DialogResult.OK)
             {
-                List<ILayerDefinition> layers = new List<ILayerDefinition>();
-                foreach (var lyr in _map.MapLayer)
-                {
-                    layers.Add((ILayerDefinition)_service.ResourceService.GetResource(lyr.ResourceId));
-                }
-                if (_map.BaseMap != null)
-                {
-                    foreach (var group in _map.BaseMap.BaseMapLayerGroup)
-                    {
-                        foreach (var layer in group.BaseMapLayer)
-                        {
-                            layers.Add((ILayerDefinition)_service.ResourceService.GetResource(layer.ResourceId));
-                        }
-                    }
-                }
-
-                bool hasFailures = false;
-                var env = Util.GetCombinedExtents(_map, layers, out hasFailures);
+                var env = diag.Extents;
                 if (env != null)
                 {
                     _map.SetExtents(env.MinX, env.MinY, env.MaxX, env.MaxY);
-                    if (hasFailures)
-                        MessageBox.Show(Properties.Resources.WarningMapExtentCalculation, Properties.Resources.TitleWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
                 else
                 {
                     MessageBox.Show(Properties.Resources.ErrorMapExtentCalculationFailed, Properties.Resources.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
-        }
 
-        internal class Util
-        {
-            public static IEnvelope GetCombinedExtents(IMapDefinition mapDef, IEnumerable<ILayerDefinition> layers, out bool hasFailures)
-            {
-                hasFailures = false;
-                Check.NotNull(layers, "layers");
-                IEnvelope env = null;
-                foreach (var layer in layers)
-                {
-                    string wkt;
-                    var e1 = layer.GetSpatialExtent(true, out wkt);
-                    if (wkt != mapDef.CoordinateSystem)
-                    {
-                        //Transform if not the same, otherwise assume either arbitrary or same as the map
-                        if (!string.IsNullOrEmpty(wkt))
-                            e1 = Utility.TransformEnvelope(e1, wkt, mapDef.CoordinateSystem);
-                    }
-
-                    if (e1 != null)
-                    {
-                        if (env == null)
-                        {
-                            env = e1;
-                        }
-                        else
-                        {
-                            if (e1.MinX < env.MinX)
-                                env.MinX = e1.MinX;
-                            if (e1.MinY < env.MinY)
-                                env.MinY = e1.MinY;
-                            if (e1.MaxX > env.MaxX)
-                                env.MaxX = e1.MaxX;
-                            if (e1.MaxY > env.MaxY)
-                                env.MaxY = e1.MaxY;
-                        }
-                    }
-                    else
-                    {
-                        hasFailures = true;
-                        System.Diagnostics.Trace.TraceWarning("Could not transform extent of layer " + layer.ResourceID + " to the map definition's coordinate system. Extents ignored");
-                    }
-                }
-                return env;
-            }
-
-            
         }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-08-13 08:06:08 UTC (rev 6062)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.Designer.cs	2011-08-14 12:59:13 UTC (rev 6063)
@@ -623,6 +623,24 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Map extents calculation completed. Click Accept to use the calculated extents..
+        /// </summary>
+        internal static string ExtentsCalculationCompleted {
+            get {
+                return ResourceManager.GetString("ExtentsCalculationCompleted", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Could not transform extent of layer {0} to the map definition&apos;s coordinate system. Extents ignored.
+        /// </summary>
+        internal static string ExtentsTransformationFailed {
+            get {
+                return ResourceManager.GetString("ExtentsTransformationFailed", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Failed to enumerate data stores. Reason: {0}.
         /// </summary>
         internal static string FailEnumDataStores {
@@ -2049,6 +2067,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to No transformation required.
+        /// </summary>
+        internal static string NoTransformationRequired {
+            get {
+                return ResourceManager.GetString("NoTransformationRequired", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Resource ID must not be session based.
         /// </summary>
         internal static string NotSessionBasedId {

Modified: trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-08-13 08:06:08 UTC (rev 6062)
+++ trunk/Tools/Maestro/Maestro.Editors/Properties/Resources.resx	2011-08-14 12:59:13 UTC (rev 6063)
@@ -1250,4 +1250,13 @@
   <data name="NotSessionBasedId" xml:space="preserve">
     <value>Resource ID must not be session based</value>
   </data>
+  <data name="ExtentsCalculationCompleted" xml:space="preserve">
+    <value>Map extents calculation completed. Click Accept to use the calculated extents.</value>
+  </data>
+  <data name="ExtentsTransformationFailed" xml:space="preserve">
+    <value>Could not transform extent of layer {0} to the map definition's coordinate system. Extents ignored</value>
+  </data>
+  <data name="NoTransformationRequired" xml:space="preserve">
+    <value>No transformation required</value>
+  </data>
 </root>
\ No newline at end of file



More information about the mapguide-commits mailing list