[mapguide-commits] r7183 - in trunk/Tools/Maestro: Maestro.Base Maestro.Base/Editor Maestro.Base/Events Maestro.Base/Services Maestro.Base/UI Maestro.Base/UI/Preferences Maestro.Editors/Common Maestro.MapViewer

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Nov 2 04:16:16 PDT 2012


Author: jng
Date: 2012-11-02 04:16:16 -0700 (Fri, 02 Nov 2012)
New Revision: 7183

Added:
   trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs
   trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.cs
   trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.resx
Modified:
   trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
   trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs
   trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
   trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj
   trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs
   trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs
   trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs
   trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/Common/RepositoryTreeModel.cs
   trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs
   trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
Log:
#2167: Implement MapViewer-driven previews for resources that it can be applicable to (Layer Definitions, Watermarks, Map Definitions). The choice to use MapViewer previews is controlled by a new UseLocalPreview configuration property, configurable via Tools - Options.

Modified: trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/Editor/EditorContentBase.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -285,11 +285,7 @@
                 if (res != null)
                 {
                     var type = res.CurrentConnection.ProviderName;
-                    var previewer = ResourcePreviewerFactory.GetPreviewer(type);
-                    if (previewer != null)
-                    {
-                        return previewer.IsPreviewable(res);
-                    }
+                    return ResourcePreviewerFactory.IsPreviewable(type, res);
                 }
                 return false;
             }

Modified: trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/Editor/ResourcePreviewEngine.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -73,28 +73,18 @@
             var sessionId = _edSvc.SessionID;
             var conn = res.CurrentConnection;
 
-            //Create temp map definition to house our current layer
-            var mdfId = "Session:" + sessionId + "//" + Guid.NewGuid() + ".MapDefinition"; //NOXLATE
-            string csWkt;
-            var extent = ldf.GetSpatialExtent(true, out csWkt);
-
-            //TODO: Based on the visible scales in this layer, size this extents accordingly
-            var mdf = ObjectFactory.CreateMapDefinition(conn, Strings.PreviewMap, csWkt, extent);
-
-            var layer = mdf.AddLayer(null, ResourceIdentifier.GetName(_edSvc.ResourceID), ldf.ResourceID);
-
+            string layerName = string.Empty;
             //Use feature source as name/label if new and unsaved
             if (_edSvc.IsNew)
-                layer.Name = layer.LegendLabel = ResourceIdentifier.GetName(ldf.SubLayer.ResourceId);
+                layerName = ResourceIdentifier.GetName(ldf.SubLayer.ResourceId);
             else
-                layer.Name = layer.LegendLabel = ResourceIdentifier.GetName(_edSvc.ResourceID);
+                layerName = ResourceIdentifier.GetName(_edSvc.ResourceID);
 
-            conn.ResourceService.SaveResourceAs(mdf, mdfId);
-
+            var mdf = CreateLayerPreviewMapDefinition(ldf, sessionId, layerName, conn);
             if (PropertyService.Get(ConfigProperties.PreviewViewerType, "AJAX").Equals("AJAX")) //NOXLATE
             {
                 //Create temp web layout to house this map
-                var wl = ObjectFactory.CreateWebLayout(_edSvc.GetEditedResource().CurrentConnection, new Version(1, 0, 0), mdfId);
+                var wl = ObjectFactory.CreateWebLayout(_edSvc.GetEditedResource().CurrentConnection, new Version(1, 0, 0), mdf.ResourceID);
 
                 //Add a custom zoom command (to assist previews of layers that aren't [0, infinity] scale)
                 AttachPreviewCommands(wl);
@@ -119,6 +109,22 @@
             return url;
         }
 
+        internal static IMapDefinition CreateLayerPreviewMapDefinition(ILayerDefinition ldf, string sessionId, string layerName, IServerConnection conn)
+        {
+            //Create temp map definition to house our current layer
+            var mdfId = "Session:" + sessionId + "//" + Guid.NewGuid() + ".MapDefinition"; //NOXLATE
+            string csWkt;
+            var extent = ldf.GetSpatialExtent(true, out csWkt);
+
+            //TODO: Based on the visible scales in this layer, size this extents accordingly
+            var mdf = ObjectFactory.CreateMapDefinition(conn, Strings.PreviewMap, csWkt, extent);
+
+            var layer = mdf.AddLayer(null, layerName, ldf.ResourceID);
+            conn.ResourceService.SaveResourceAs(mdf, mdfId);
+            mdf.ResourceID = mdfId;
+            return mdf;
+        }
+
         private static void AttachPreviewCommands(IWebLayout wl)
         {
             var cmd = wl.CreateInvokeScriptCommand();
@@ -185,11 +191,17 @@
             if (wmd.CurrentConnection.SiteVersion < new Version(2, 3))
                 throw new InvalidOperationException(Strings.SiteVersionDoesntSupportWatermarks);
 
+            IMapDefinition2 map = CreateWatermarkPreviewMapDefinition(wmd);
+            return GenerateMapPreviewUrl(map, locale);
+        }
+
+        internal static IMapDefinition2 CreateWatermarkPreviewMapDefinition(IWatermarkDefinition wmd)
+        {
             IMapDefinition2 map = (IMapDefinition2)ObjectFactory.CreateMapDefinition(wmd.CurrentConnection, wmd.SupportedMapDefinitionVersion, "Watermark Definition Preview"); //NOXLATE
             map.CoordinateSystem = @"LOCAL_CS[""*XY-M*"", LOCAL_DATUM[""*X-Y*"", 10000], UNIT[""Meter"", 1], AXIS[""X"", EAST], AXIS[""Y"", NORTH]]"; //NOXLATE
             map.Extents = ObjectFactory.CreateEnvelope(-1000000, -1000000, 1000000, 1000000);
             map.AddWatermark(wmd);
-            return GenerateMapPreviewUrl(map, locale);
+            return map;
         }
 
         private string GenerateMapPreviewUrl(IResource res, string locale)

Modified: trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/Events/EventWatcher.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -28,6 +28,7 @@
 using ICSharpCode.Core;
 using System.Windows.Forms;
 using Maestro.Shared.UI;
+using Maestro.Base.UI.Preferences;
 
 namespace Maestro.Base.Events
 {

Modified: trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/Maestro.Base.csproj	2012-11-02 11:16:16 UTC (rev 7183)
@@ -318,6 +318,12 @@
     <Compile Include="UI\LabelLocalizationDialog.Designer.cs">
       <DependentUpon>LabelLocalizationDialog.cs</DependentUpon>
     </Compile>
+    <Compile Include="UI\MapPreviewDialog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="UI\MapPreviewDialog.Designer.cs">
+      <DependentUpon>MapPreviewDialog.cs</DependentUpon>
+    </Compile>
     <Compile Include="UI\MessageViewer.cs">
       <SubType>UserControl</SubType>
     </Compile>
@@ -591,6 +597,9 @@
     <EmbeddedResource Include="UI\LabelLocalizationDialog.resx">
       <DependentUpon>LabelLocalizationDialog.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="UI\MapPreviewDialog.resx">
+      <DependentUpon>MapPreviewDialog.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="UI\MessageViewer.resx">
       <DependentUpon>MessageViewer.cs</DependentUpon>
       <SubType>Designer</SubType>
@@ -662,6 +671,10 @@
       <Project>{07588440-5F9F-4C30-AA06-9CF30BA6DDE6}</Project>
       <Name>Maestro.Login</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Maestro.MapViewer\Maestro.MapViewer.csproj">
+      <Project>{4F9658DE-D16F-4B40-B830-BB1E0136DBD7}</Project>
+      <Name>Maestro.MapViewer</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Maestro.Packaging\Maestro.Packaging.csproj">
       <Project>{0EA33E36-9C33-4D60-B378-B87FADAA0F40}</Project>
       <Name>Maestro.Packaging</Name>

Modified: trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/Services/ResourcePreviewerFactory.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -30,6 +30,12 @@
 using OSGeo.MapGuide.ObjectModels;
 using OSGeo.MapGuide.MaestroAPI.Services;
 using Maestro.Editors.SymbolDefinition;
+using ICSharpCode.Core;
+using Maestro.Base.UI.Preferences;
+using OSGeo.MapGuide.ObjectModels.MapDefinition;
+using OSGeo.MapGuide.ObjectModels.WatermarkDefinition;
+using Maestro.Base.UI;
+using OSGeo.MapGuide.MaestroAPI.Mapping;
 
 namespace Maestro.Base.Services
 {
@@ -65,6 +71,106 @@
         void Preview(IResource res, IEditorService edSvc, string locale);
     }
 
+    public class LocalMapPreviewer : IResourcePreviewer
+    {
+        private IResourcePreviewer _inner;
+
+        public LocalMapPreviewer(IResourcePreviewer inner)
+        {
+            _inner = inner;
+        }
+
+        public bool UseLocal
+        {
+            get { return PropertyService.Get(ConfigProperties.UseLocalPreview, ConfigProperties.DefaultUseLocalPreview); }
+        }
+
+        public bool IsPreviewable(IResource res)
+        {
+            if (this.UseLocal)
+            {
+                if (IsLocalPreviewableType(res))
+                {
+                    return true;
+                }
+            }
+            return _inner.IsPreviewable(res);
+        }
+
+        private static bool IsLocalPreviewableType(IResource res)
+        {
+            return res.ResourceType == ResourceTypes.LayerDefinition ||
+                   res.ResourceType == ResourceTypes.MapDefinition ||
+                   res.ResourceType == ResourceTypes.WatermarkDefinition;
+        }
+
+        public void Preview(IResource res, IEditorService edSvc)
+        {
+            Preview(res, edSvc, null);
+        }
+
+        static bool SupportsMappingService(IServerConnection conn)
+        {
+            return Array.IndexOf(conn.Capabilities.SupportedServices, (int)ServiceType.Mapping) >= 0;
+        }
+
+        public void Preview(IResource res, IEditorService edSvc, string locale)
+        {
+            IServerConnection conn = res.CurrentConnection;
+            if (this.UseLocal && IsLocalPreviewableType(res) && SupportsMappingService(conn))
+            {
+                BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, () => { 
+                    IMappingService mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+                    IMapDefinition previewMdf = null;
+                    switch (res.ResourceType)
+                    { 
+                        case ResourceTypes.LayerDefinition:
+                            {
+                                ILayerDefinition ldf = (ILayerDefinition)res;
+                                string layerName = string.Empty;
+                                if (edSvc.IsNew)
+                                    layerName = ResourceIdentifier.GetName(ldf.SubLayer.ResourceId);
+                                else
+                                    layerName = ResourceIdentifier.GetName(edSvc.ResourceID);
+                                previewMdf = ResourcePreviewEngine.CreateLayerPreviewMapDefinition(ldf, edSvc.SessionID, layerName, conn);
+                            }
+                            break;
+                        case ResourceTypes.WatermarkDefinition:
+                            {
+                                previewMdf = ResourcePreviewEngine.CreateWatermarkPreviewMapDefinition((IWatermarkDefinition)res);
+                            }
+                            break;
+                        case ResourceTypes.MapDefinition:
+                            {
+                                previewMdf = (IMapDefinition)res;
+                            }
+                            break;
+                    }
+                    if (previewMdf != null)
+                        return mapSvc.CreateMap(previewMdf);
+                    else
+                        return null;
+                }, (obj) => {
+                    if (obj != null)
+                    {
+                        var rtMap = (RuntimeMap)obj;
+                        var launcher = ServiceRegistry.GetService<UrlLauncherService>();
+                        var diag = new MapPreviewDialog(rtMap, launcher, (edSvc.IsNew) ? null : edSvc.ResourceID);
+                        diag.Show(null);
+                    }
+                    else //Fallback, shouldn't happen
+                    {
+                        _inner.Preview(res, edSvc, locale);
+                    }
+                });
+            }
+            else
+            {
+                _inner.Preview(res, edSvc, locale);
+            }
+        }
+    }
+
     /// <summary>
     /// The default resource previewer implementation
     /// </summary>
@@ -211,7 +317,7 @@
         /// <param name="previewer">The previewer implementation</param>
         public static void RegisterPreviewer(string provider, IResourcePreviewer previewer)
         {
-            _previewers[provider.ToUpper()] = previewer;
+            _previewers[provider.ToUpper()] = new LocalMapPreviewer(previewer);
         }
 
         /// <summary>
@@ -223,7 +329,22 @@
         {
             return _previewers.ContainsKey(provider.ToUpper());
         }
+        
+        /// <summary>
+        /// Gets whether the given resource type is previewable for the given connection provider
+        /// </summary>
+        /// <param name="provider"></param>
+        /// <param name="resource"></param>
+        /// <returns></returns>
+        public static bool IsPreviewable(string provider, IResource resource)
+        {
+            var preview = GetPreviewer(provider);
+            if (preview != null)
+                return preview.IsPreviewable(resource);
 
+            return false;
+        }
+
         /// <summary>
         /// Gets the registered previewer for the specified connection provider
         /// </summary>

Added: trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.Designer.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -0,0 +1,401 @@
+namespace Maestro.Base.UI
+{
+    partial class MapPreviewDialog
+    {
+        /// <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.defaultToolbar = new Maestro.MapViewer.DefaultToolbar();
+            this.mapViewer = new Maestro.MapViewer.MapViewer();
+            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+            this.lblCoordinates = new System.Windows.Forms.ToolStripStatusLabel();
+            this.lblSelected = new System.Windows.Forms.ToolStripStatusLabel();
+            this.lblScale = new System.Windows.Forms.ToolStripStatusLabel();
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+            this.legend = new Maestro.MapViewer.Legend();
+            this.mapStatusTracker = new Maestro.MapViewer.MapStatusTracker();
+            this.splitContainer2 = new System.Windows.Forms.SplitContainer();
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.grpOtherTools = new System.Windows.Forms.GroupBox();
+            this.btnGetMapKml = new System.Windows.Forms.Button();
+            this.lnkZoomToScale = new System.Windows.Forms.LinkLabel();
+            this.numZoomToScale = new System.Windows.Forms.NumericUpDown();
+            this.label5 = new System.Windows.Forms.Label();
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.txtMaxY = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.txtMaxX = new System.Windows.Forms.TextBox();
+            this.label3 = new System.Windows.Forms.Label();
+            this.txtMinY = new System.Windows.Forms.TextBox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.txtMinX = new System.Windows.Forms.TextBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.statusStrip1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
+            this.splitContainer1.Panel1.SuspendLayout();
+            this.splitContainer1.Panel2.SuspendLayout();
+            this.splitContainer1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
+            this.splitContainer2.Panel1.SuspendLayout();
+            this.splitContainer2.Panel2.SuspendLayout();
+            this.splitContainer2.SuspendLayout();
+            this.panel1.SuspendLayout();
+            this.grpOtherTools.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.numZoomToScale)).BeginInit();
+            this.groupBox1.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // defaultToolbar
+            // 
+            this.defaultToolbar.Location = new System.Drawing.Point(0, 0);
+            this.defaultToolbar.Name = "defaultToolbar";
+            this.defaultToolbar.Size = new System.Drawing.Size(784, 25);
+            this.defaultToolbar.TabIndex = 0;
+            this.defaultToolbar.Viewer = this.mapViewer;
+            // 
+            // mapViewer
+            // 
+            this.mapViewer.Cursor = System.Windows.Forms.Cursors.Default;
+            this.mapViewer.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.mapViewer.Location = new System.Drawing.Point(0, 0);
+            this.mapViewer.MaxScale = 1000000000;
+            this.mapViewer.MinScale = 10;
+            this.mapViewer.MouseWheelDelayRenderInterval = 800;
+            this.mapViewer.Name = "mapViewer";
+            this.mapViewer.PointPixelBuffer = 2;
+            this.mapViewer.SelectionColor = System.Drawing.Color.Blue;
+            this.mapViewer.Size = new System.Drawing.Size(381, 515);
+            this.mapViewer.TabIndex = 0;
+            this.mapViewer.Text = "mapViewer1";
+            this.mapViewer.TooltipDelayInterval = 1000;
+            this.mapViewer.ZoomInFactor = 0.5D;
+            this.mapViewer.ZoomOutFactor = 2D;
+            this.mapViewer.MapScaleChanged += new System.EventHandler(this.mapViewer_MapScaleChanged);
+            this.mapViewer.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(this.mapViewer_PropertyChanged);
+            // 
+            // statusStrip1
+            // 
+            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.lblCoordinates,
+            this.lblSelected,
+            this.lblScale});
+            this.statusStrip1.Location = new System.Drawing.Point(0, 540);
+            this.statusStrip1.Name = "statusStrip1";
+            this.statusStrip1.Size = new System.Drawing.Size(784, 22);
+            this.statusStrip1.TabIndex = 1;
+            this.statusStrip1.Text = "statusStrip1";
+            // 
+            // lblCoordinates
+            // 
+            this.lblCoordinates.Name = "lblCoordinates";
+            this.lblCoordinates.Size = new System.Drawing.Size(0, 17);
+            // 
+            // lblSelected
+            // 
+            this.lblSelected.Name = "lblSelected";
+            this.lblSelected.Size = new System.Drawing.Size(769, 17);
+            this.lblSelected.Spring = true;
+            this.lblSelected.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+            // 
+            // lblScale
+            // 
+            this.lblScale.Name = "lblScale";
+            this.lblScale.Size = new System.Drawing.Size(0, 17);
+            // 
+            // splitContainer1
+            // 
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
+            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer1.Name = "splitContainer1";
+            // 
+            // splitContainer1.Panel1
+            // 
+            this.splitContainer1.Panel1.Controls.Add(this.legend);
+            // 
+            // splitContainer1.Panel2
+            // 
+            this.splitContainer1.Panel2.Controls.Add(this.mapViewer);
+            this.splitContainer1.Size = new System.Drawing.Size(584, 515);
+            this.splitContainer1.SplitterDistance = 199;
+            this.splitContainer1.TabIndex = 2;
+            // 
+            // legend
+            // 
+            this.legend.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.legend.GroupContextMenu = null;
+            this.legend.LayerContextMenu = null;
+            this.legend.Location = new System.Drawing.Point(0, 0);
+            this.legend.Name = "legend";
+            this.legend.SelectOnRightClick = false;
+            this.legend.ShowAllLayersAndGroups = false;
+            this.legend.ShowTooltips = true;
+            this.legend.Size = new System.Drawing.Size(199, 515);
+            this.legend.TabIndex = 0;
+            this.legend.ThemeCompressionLimit = 25;
+            this.legend.Viewer = this.mapViewer;
+            // 
+            // mapStatusTracker
+            // 
+            this.mapStatusTracker.CoordinatesLabel = this.lblCoordinates;
+            this.mapStatusTracker.ScaleLabel = this.lblScale;
+            this.mapStatusTracker.SelectedLabel = this.lblSelected;
+            this.mapStatusTracker.Viewer = this.mapViewer;
+            // 
+            // splitContainer2
+            // 
+            this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
+            this.splitContainer2.Location = new System.Drawing.Point(0, 25);
+            this.splitContainer2.Name = "splitContainer2";
+            // 
+            // splitContainer2.Panel1
+            // 
+            this.splitContainer2.Panel1.Controls.Add(this.splitContainer1);
+            // 
+            // splitContainer2.Panel2
+            // 
+            this.splitContainer2.Panel2.Controls.Add(this.panel1);
+            this.splitContainer2.Size = new System.Drawing.Size(784, 515);
+            this.splitContainer2.SplitterDistance = 584;
+            this.splitContainer2.TabIndex = 3;
+            // 
+            // panel1
+            // 
+            this.panel1.AutoScroll = true;
+            this.panel1.Controls.Add(this.grpOtherTools);
+            this.panel1.Controls.Add(this.groupBox1);
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.panel1.Location = new System.Drawing.Point(0, 0);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(196, 515);
+            this.panel1.TabIndex = 1;
+            // 
+            // grpOtherTools
+            // 
+            this.grpOtherTools.Controls.Add(this.btnGetMapKml);
+            this.grpOtherTools.Controls.Add(this.lnkZoomToScale);
+            this.grpOtherTools.Controls.Add(this.numZoomToScale);
+            this.grpOtherTools.Controls.Add(this.label5);
+            this.grpOtherTools.Location = new System.Drawing.Point(16, 222);
+            this.grpOtherTools.Name = "grpOtherTools";
+            this.grpOtherTools.Size = new System.Drawing.Size(165, 260);
+            this.grpOtherTools.TabIndex = 1;
+            this.grpOtherTools.TabStop = false;
+            this.grpOtherTools.Text = "Other Tools";
+            // 
+            // btnGetMapKml
+            // 
+            this.btnGetMapKml.Location = new System.Drawing.Point(10, 108);
+            this.btnGetMapKml.Name = "btnGetMapKml";
+            this.btnGetMapKml.Size = new System.Drawing.Size(94, 23);
+            this.btnGetMapKml.TabIndex = 4;
+            this.btnGetMapKml.Text = "Get Map KML";
+            this.btnGetMapKml.UseVisualStyleBackColor = true;
+            this.btnGetMapKml.Click += new System.EventHandler(this.btnGetMapKml_Click);
+            // 
+            // lnkZoomToScale
+            // 
+            this.lnkZoomToScale.AutoSize = true;
+            this.lnkZoomToScale.Location = new System.Drawing.Point(93, 32);
+            this.lnkZoomToScale.Name = "lnkZoomToScale";
+            this.lnkZoomToScale.Size = new System.Drawing.Size(40, 13);
+            this.lnkZoomToScale.TabIndex = 3;
+            this.lnkZoomToScale.TabStop = true;
+            this.lnkZoomToScale.Text = "(Zoom)";
+            this.lnkZoomToScale.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkZoomToScale_LinkClicked);
+            // 
+            // numZoomToScale
+            // 
+            this.numZoomToScale.Location = new System.Drawing.Point(10, 48);
+            this.numZoomToScale.Name = "numZoomToScale";
+            this.numZoomToScale.Size = new System.Drawing.Size(135, 20);
+            this.numZoomToScale.TabIndex = 2;
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(7, 32);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(80, 13);
+            this.label5.TabIndex = 1;
+            this.label5.Text = "Zoom To Scale";
+            // 
+            // groupBox1
+            // 
+            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.groupBox1.Controls.Add(this.txtMaxY);
+            this.groupBox1.Controls.Add(this.label4);
+            this.groupBox1.Controls.Add(this.txtMaxX);
+            this.groupBox1.Controls.Add(this.label3);
+            this.groupBox1.Controls.Add(this.txtMinY);
+            this.groupBox1.Controls.Add(this.label2);
+            this.groupBox1.Controls.Add(this.txtMinX);
+            this.groupBox1.Controls.Add(this.label1);
+            this.groupBox1.Location = new System.Drawing.Point(16, 10);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(165, 205);
+            this.groupBox1.TabIndex = 0;
+            this.groupBox1.TabStop = false;
+            this.groupBox1.Text = "Current Extents";
+            // 
+            // txtMaxY
+            // 
+            this.txtMaxY.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.txtMaxY.Location = new System.Drawing.Point(10, 167);
+            this.txtMaxY.Name = "txtMaxY";
+            this.txtMaxY.ReadOnly = true;
+            this.txtMaxY.Size = new System.Drawing.Size(135, 20);
+            this.txtMaxY.TabIndex = 7;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(7, 150);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(37, 13);
+            this.label4.TabIndex = 6;
+            this.label4.Text = "Max Y";
+            // 
+            // txtMaxX
+            // 
+            this.txtMaxX.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.txtMaxX.Location = new System.Drawing.Point(10, 129);
+            this.txtMaxX.Name = "txtMaxX";
+            this.txtMaxX.ReadOnly = true;
+            this.txtMaxX.Size = new System.Drawing.Size(135, 20);
+            this.txtMaxX.TabIndex = 5;
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(7, 112);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(37, 13);
+            this.label3.TabIndex = 4;
+            this.label3.Text = "Max X";
+            // 
+            // txtMinY
+            // 
+            this.txtMinY.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.txtMinY.Location = new System.Drawing.Point(10, 89);
+            this.txtMinY.Name = "txtMinY";
+            this.txtMinY.ReadOnly = true;
+            this.txtMinY.Size = new System.Drawing.Size(135, 20);
+            this.txtMinY.TabIndex = 3;
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(7, 72);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(34, 13);
+            this.label2.TabIndex = 2;
+            this.label2.Text = "Min Y";
+            // 
+            // txtMinX
+            // 
+            this.txtMinX.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.txtMinX.Location = new System.Drawing.Point(10, 49);
+            this.txtMinX.Name = "txtMinX";
+            this.txtMinX.ReadOnly = true;
+            this.txtMinX.Size = new System.Drawing.Size(135, 20);
+            this.txtMinX.TabIndex = 1;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(7, 32);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(34, 13);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "Min X";
+            // 
+            // MapPreviewDialog
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(784, 562);
+            this.Controls.Add(this.splitContainer2);
+            this.Controls.Add(this.statusStrip1);
+            this.Controls.Add(this.defaultToolbar);
+            this.Name = "MapPreviewDialog";
+            this.Text = "Map Preview";
+            this.statusStrip1.ResumeLayout(false);
+            this.statusStrip1.PerformLayout();
+            this.splitContainer1.Panel1.ResumeLayout(false);
+            this.splitContainer1.Panel2.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
+            this.splitContainer1.ResumeLayout(false);
+            this.splitContainer2.Panel1.ResumeLayout(false);
+            this.splitContainer2.Panel2.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
+            this.splitContainer2.ResumeLayout(false);
+            this.panel1.ResumeLayout(false);
+            this.grpOtherTools.ResumeLayout(false);
+            this.grpOtherTools.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.numZoomToScale)).EndInit();
+            this.groupBox1.ResumeLayout(false);
+            this.groupBox1.PerformLayout();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private MapViewer.DefaultToolbar defaultToolbar;
+        private System.Windows.Forms.StatusStrip statusStrip1;
+        private System.Windows.Forms.ToolStripStatusLabel lblCoordinates;
+        private System.Windows.Forms.ToolStripStatusLabel lblSelected;
+        private System.Windows.Forms.ToolStripStatusLabel lblScale;
+        private System.Windows.Forms.SplitContainer splitContainer1;
+        private MapViewer.Legend legend;
+        private MapViewer.MapViewer mapViewer;
+        private MapViewer.MapStatusTracker mapStatusTracker;
+        private System.Windows.Forms.SplitContainer splitContainer2;
+        private System.Windows.Forms.Panel panel1;
+        private System.Windows.Forms.GroupBox grpOtherTools;
+        private System.Windows.Forms.LinkLabel lnkZoomToScale;
+        private System.Windows.Forms.NumericUpDown numZoomToScale;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.GroupBox groupBox1;
+        private System.Windows.Forms.TextBox txtMaxY;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.TextBox txtMaxX;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.TextBox txtMinY;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.TextBox txtMinX;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Button btnGetMapKml;
+    }
+}
\ No newline at end of file

Added: trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.cs	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -0,0 +1,111 @@
+#region Disclaimer / License
+// Copyright (C) 2012, 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 Maestro.Base.Services;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Mapping;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Maestro.Base.UI
+{
+    internal partial class MapPreviewDialog : Form
+    {
+        private RuntimeMap _map;
+        private IUrlLauncherService _launcher;
+        private IServerConnection _conn;
+
+        public MapPreviewDialog(RuntimeMap map, IUrlLauncherService urlLauncher, string resourceId)
+        {
+            InitializeComponent();
+            _map = map;
+            if (!string.IsNullOrEmpty(resourceId))
+                this.Text += " - " + resourceId;
+
+            numZoomToScale.Minimum = 1;
+            numZoomToScale.Maximum = Int32.MaxValue;
+            _launcher = urlLauncher;
+            _conn = map.CurrentConnection;
+            btnGetMapKml.Enabled = (_conn.ProviderName.ToUpper() == "MAESTRO.HTTP"); //NOXLATE
+        }
+
+        protected override void OnLoad(EventArgs e)
+        {
+            base.OnLoad(e);
+            if (_map.Layers.Count == 1) //Single-layer preview
+            {
+                var maxScale = _map.Layers.Max(x => x.ScaleRanges.Max(y => y.MaxScale));
+                var initScale = Math.Floor(maxScale - 0.5);
+                var env = _map.MapExtent;
+                double mcsW = env.MaxX - env.MinX;
+                double mcsH = env.MaxY - env.MinY;
+                var bboxScale = Maestro.MapViewer.MapViewer.CalculateScale(_map, mcsW, mcsH, mapViewer.Width, mapViewer.Height);
+                double desiredScale = Math.Min(initScale, bboxScale);
+                mapViewer.LoadMap(_map, desiredScale);
+            }
+            else
+            {
+                mapViewer.LoadMap(_map);
+            }
+        }
+
+        private void mapViewer_MapScaleChanged(object sender, EventArgs e)
+        {
+            numZoomToScale.Value = Convert.ToDecimal(mapViewer.GetMap().ViewScale);
+        }
+
+        private void lnkZoomToScale_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+        {
+            mapViewer.ZoomToScale(Convert.ToDouble(numZoomToScale.Value));
+        }
+
+        private void mapViewer_PropertyChanged(object sender, PropertyChangedEventArgs e)
+        {
+            if (e.PropertyName == "IsBusy") //NOXLATE
+            {
+                grpOtherTools.Enabled = !mapViewer.IsBusy;
+
+                if (!mapViewer.IsBusy)
+                {
+                    double minx, miny, maxx, maxy;
+                    mapViewer.GetViewExtent(out minx, out miny, out maxx, out maxy);
+
+                    txtMinX.Text = minx.ToString(CultureInfo.InvariantCulture);
+                    txtMinY.Text = miny.ToString(CultureInfo.InvariantCulture);
+                    txtMaxX.Text = maxx.ToString(CultureInfo.InvariantCulture);
+                    txtMaxY.Text = maxy.ToString(CultureInfo.InvariantCulture);
+                }
+            }
+        }
+
+        private void btnGetMapKml_Click(object sender, EventArgs e)
+        {
+            var mapagent = _conn.GetCustomProperty("BaseUrl").ToString(); //NOXLATE
+            mapagent += "mapagent/mapagent.fcgi?SESSION=" + _conn.SessionID + "&VERSION=1.0.0&OPERATION=GETMAPKML&DPI=96&MAPDEFINITION=" + _map.MapDefinition + "&FORMAT=KML&CLIENTAGENT=Maestro Local Map Previewer"; //NOXLATE
+            _launcher.OpenUrl(mapagent);
+        }
+    }
+}

Added: trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.resx	                        (rev 0)
+++ trunk/Tools/Maestro/Maestro.Base/UI/MapPreviewDialog.resx	2012-11-02 11:16:16 UTC (rev 7183)
@@ -0,0 +1,129 @@
+<?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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="defaultToolbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>155, 17</value>
+  </metadata>
+  <metadata name="mapStatusTracker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>271, 17</value>
+  </metadata>
+</root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/ConfigProperties.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -93,6 +93,11 @@
         public const string XsdSchemaPath = "Editor.XsdSchemaPath"; //NOXLATE
 
         /// <summary>
+        /// Use the local preview using Maestro's Map Viewer component
+        /// </summary>
+        public const string UseLocalPreview = "Editor.UseLocalPreview"; //NOXLATE
+
+        /// <summary>
         /// Show the tip of the day on startup
         /// </summary>
         public const string ShowTipOfTheDay = "General.ShowTipOfTheDay"; //NOXLATE
@@ -113,6 +118,7 @@
             Props.Set(ConfigProperties.PreviewLocale, DefaultPreviewLocale);
             Props.Set(ConfigProperties.ValidateOnSave, DefaultValidateOnSave);
             Props.Set(ConfigProperties.XsdSchemaPath, DefaultXsdSchemaPath);
+            Props.Set(ConfigProperties.UseLocalPreview, DefaultUseLocalPreview);
         }
 
         internal static void ApplyGeneralDefaults()
@@ -158,6 +164,11 @@
         public static string DefaultLiveMapEditorPath { get { return Path.Combine(FileUtility.ApplicationRootPath, "Maestro.LiveMapEditor.exe"); } } //NOXLATE
 
         /// <summary>
+        /// Default setting for using local previews
+        /// </summary>
+        public static bool DefaultUseLocalPreview { get { return true; } }
+
+        /// <summary>
         /// Default color for open resources in the Site Explorer
         /// </summary>
         public static Color DefaultOpenColor { get { return Color.LightGreen; } }

Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.Designer.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -35,8 +35,9 @@
             this.label4 = new System.Windows.Forms.Label();
             this.txtXsdPath = new System.Windows.Forms.TextBox();
             this.groupBox2 = new System.Windows.Forms.GroupBox();
+            this.txtPreviewLocale = new System.Windows.Forms.TextBox();
             this.label1 = new System.Windows.Forms.Label();
-            this.txtPreviewLocale = new System.Windows.Forms.TextBox();
+            this.chkUseLocalPreview = new System.Windows.Forms.CheckBox();
             this.groupBox4.SuspendLayout();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
@@ -46,13 +47,14 @@
             // 
             this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
             | System.Windows.Forms.AnchorStyles.Right)));
+            this.groupBox4.Controls.Add(this.chkUseLocalPreview);
             this.groupBox4.Controls.Add(this.chkValidateOnSave);
             this.groupBox4.Location = new System.Drawing.Point(3, 3);
             this.groupBox4.Name = "groupBox4";
             this.groupBox4.Size = new System.Drawing.Size(399, 50);
             this.groupBox4.TabIndex = 10;
             this.groupBox4.TabStop = false;
-            this.groupBox4.Text = "Editing";
+            this.groupBox4.Text = "General";
             // 
             // chkValidateOnSave
             // 
@@ -60,9 +62,9 @@
             this.chkValidateOnSave.ImeMode = System.Windows.Forms.ImeMode.NoControl;
             this.chkValidateOnSave.Location = new System.Drawing.Point(19, 19);
             this.chkValidateOnSave.Name = "chkValidateOnSave";
-            this.chkValidateOnSave.Size = new System.Drawing.Size(163, 17);
+            this.chkValidateOnSave.Size = new System.Drawing.Size(109, 17);
             this.chkValidateOnSave.TabIndex = 2;
-            this.chkValidateOnSave.Text = "Validate Resources On Save";
+            this.chkValidateOnSave.Text = "Validate On Save";
             this.chkValidateOnSave.UseVisualStyleBackColor = true;
             // 
             // groupBox1
@@ -124,6 +126,13 @@
             this.groupBox2.TabStop = false;
             this.groupBox2.Text = "Localization";
             // 
+            // txtPreviewLocale
+            // 
+            this.txtPreviewLocale.Location = new System.Drawing.Point(187, 22);
+            this.txtPreviewLocale.Name = "txtPreviewLocale";
+            this.txtPreviewLocale.Size = new System.Drawing.Size(47, 20);
+            this.txtPreviewLocale.TabIndex = 1;
+            // 
             // label1
             // 
             this.label1.AutoSize = true;
@@ -133,12 +142,15 @@
             this.label1.TabIndex = 0;
             this.label1.Text = "Preview using the following locale";
             // 
-            // txtPreviewLocale
+            // chkUseLocalPreview
             // 
-            this.txtPreviewLocale.Location = new System.Drawing.Point(187, 22);
-            this.txtPreviewLocale.Name = "txtPreviewLocale";
-            this.txtPreviewLocale.Size = new System.Drawing.Size(47, 20);
-            this.txtPreviewLocale.TabIndex = 1;
+            this.chkUseLocalPreview.AutoSize = true;
+            this.chkUseLocalPreview.Location = new System.Drawing.Point(134, 19);
+            this.chkUseLocalPreview.Name = "chkUseLocalPreview";
+            this.chkUseLocalPreview.Size = new System.Drawing.Size(257, 17);
+            this.chkUseLocalPreview.TabIndex = 3;
+            this.chkUseLocalPreview.Text = "Preview with local map viewer (where applicable)";
+            this.chkUseLocalPreview.UseVisualStyleBackColor = true;
             // 
             // EditorPreferencesCtrl
             // 
@@ -170,5 +182,6 @@
         private System.Windows.Forms.GroupBox groupBox2;
         private System.Windows.Forms.TextBox txtPreviewLocale;
         private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.CheckBox chkUseLocalPreview;
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Base/UI/Preferences/EditorPreferencesCtrl.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -35,6 +35,9 @@
             var validate = Props.Get(ConfigProperties.ValidateOnSave, ConfigProperties.DefaultValidateOnSave);
             chkValidateOnSave.Checked = validate;
 
+            var useLocal = Props.Get(ConfigProperties.UseLocalPreview, ConfigProperties.DefaultUseLocalPreview);
+            chkUseLocalPreview.Checked = useLocal;
+
             var path = Props.Get(ConfigProperties.XsdSchemaPath, ConfigProperties.DefaultXsdSchemaPath);
             txtXsdPath.Text = path;
 
@@ -56,6 +59,7 @@
             bool restart = false;
 
             Apply(ConfigProperties.ValidateOnSave, chkValidateOnSave.Checked);
+            Apply(ConfigProperties.UseLocalPreview, chkUseLocalPreview.Checked);
             Apply(ConfigProperties.PreviewLocale, txtPreviewLocale.Text);
 
             //These changes require restart

Modified: trunk/Tools/Maestro/Maestro.Editors/Common/RepositoryTreeModel.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/RepositoryTreeModel.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/RepositoryTreeModel.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -1,21 +1,21 @@
-#region Disclaimer / License
-// Copyright (C) 2012, 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
-// 
+#region Disclaimer / License
+// Copyright (C) 2012, 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;

Modified: trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.MapViewer/Interfaces.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -362,6 +362,15 @@
         /// Gets the view history stack. The first item being the earliest and the last item being the most recent.
         /// </summary>
         ReadOnlyCollection<MapViewHistoryEntry> ViewHistory { get; }
+
+        /// <summary>
+        /// Gets the current view extent in the map's coordinates
+        /// </summary>
+        /// <param name="minX"></param>
+        /// <param name="minY"></param>
+        /// <param name="maxX"></param>
+        /// <param name="maxY"></param>
+        void GetViewExtent(out double minX, out double minY, out double maxX, out double maxY);
     }
 
     /// <summary>

Modified: trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs	2012-11-02 05:31:02 UTC (rev 7182)
+++ trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs	2012-11-02 11:16:16 UTC (rev 7183)
@@ -1133,12 +1133,22 @@
         /// <param name="map"></param>
         public void LoadMap(RuntimeMap map)
         {
+            LoadMap(map, null);
+        }
+
+        /// <summary>
+        /// Load the viewer with the given runtime map
+        /// </summary>
+        /// <param name="map"></param>
+        /// <param name="initialScale"></param>
+        public void LoadMap(RuntimeMap map, double? initialScale)
+        {
             _map = map;
             _map.StrictSelection = false;
-            InitViewerFromMap();
+            InitViewerFromMap(initialScale);
         }
 
-        private void InitViewerFromMap()
+        private void InitViewerFromMap(double? initialScale)
         {
             this.BackColor = _map.BackgroundColor;
             _map.DisplayWidth = this.Width;
@@ -1193,21 +1203,25 @@
             if (handler != null)
                 handler(this, EventArgs.Empty);
 
-            InitialMapView();
+            if (initialScale.HasValue)
+                ZoomToScale(initialScale.Value);
+            else
+                InitialMapView();
         }
 
-        internal double MetersPerUnit
+        /// <summary>
+        /// Utility method to calculate the zoom scale for the give map
+        /// </summary>
+        /// <param name="map"></param>
+        /// <param name="mcsW"></param>
+        /// <param name="mcsH"></param>
+        /// <param name="devW"></param>
+        /// <param name="devH"></param>
+        /// <returns></returns>
+        public static double CalculateScale(RuntimeMap map, double mcsW, double mcsH, int devW, int devH)
         {
-            get
-            {
-                return _map.MetersPerUnit;
-            }
-        }
-
-        private double CalculateScale(double mcsW, double mcsH, int devW, int devH)
-        {
-            var mpu = this.MetersPerUnit;
-            var mpp = GetMetersPerPixel(_map.DisplayDpi);
+            var mpu = map.MetersPerUnit;
+            var mpp = GetMetersPerPixel(map.DisplayDpi);
             if (devH * mcsW > devW * mcsH)
                 return mcsW * mpu / (devW * mpp); //width-limited
             else
@@ -1612,7 +1626,7 @@
         /// </summary>
         public void ZoomExtents()
         {
-            var scale = CalculateScale((_orgX2 - _orgX1), (_orgY1 - _orgY2), this.Width, this.Height);
+            var scale = CalculateScale(_map, (_orgX2 - _orgX1), (_orgY1 - _orgY2), this.Width, this.Height);
             ZoomToView(_orgX1 + ((_orgX2 - _orgX1) / 2), _orgY2 + ((_orgY1 - _orgY2) / 2), scale, true);
         }
 
@@ -1625,7 +1639,7 @@
         /// <param name="ury"></param>
         public void ZoomToExtents(double llx, double lly, double urx, double ury)
         {
-            var scale = CalculateScale((urx - llx), (ury - lly), this.Width, this.Height);
+            var scale = CalculateScale(_map, (urx - llx), (ury - lly), this.Width, this.Height);
             ZoomToView(llx + ((urx - llx) / 2), ury + ((lly - ury) / 2), scale, true);
         }
 
@@ -1658,7 +1672,7 @@
         private void UpdateExtents()
         {
             //Update current extents
-            double mpu = this.MetersPerUnit;
+            double mpu = _map.MetersPerUnit;
             double scale = _map.ViewScale;
             double mpp = GetMetersPerPixel(_map.DisplayDpi);
             var coord = _map.ViewCenter;
@@ -1671,6 +1685,14 @@
             _extX2 = coord.X + mcsWidth / 2;
             _extY2 = coord.Y - mcsHeight / 2;
         }
+        
+        public void GetViewExtent(out double minX, out double minY, out double maxX, out double maxY)
+        {
+            minX = _extX1;
+            minY = _extY1;
+            maxX = _extX2;
+            maxY = _extY2;
+        }
 
         private bool PruneHistoryEntriesFromCurrentView()
         {
@@ -1946,7 +1968,7 @@
 
         private void InitialMapView(bool refreshMap)
         {
-            var scale = CalculateScale((_orgX2 - _orgX1), (_orgY1 - _orgY2), this.Width, this.Height);
+            var scale = CalculateScale(_map, (_orgX2 - _orgX1), (_orgY1 - _orgY2), this.Width, this.Height);
             ZoomToView(_orgX1 + ((_orgX2 - _orgX1) / 2), _orgY2 + ((_orgY1 - _orgY2) / 2), scale, refreshMap);
         }
 
@@ -2321,9 +2343,9 @@
             double screenZoomCenterY = e.Y - (e.Y - this.Height / 2) / zoomChange;
             delayRenderViewCenter = ScreenToMapUnits(screenZoomCenterX, screenZoomCenterY);
 
-            var mpu = this.MetersPerUnit;
+            var mpu = _map.MetersPerUnit;
             var mpp = GetMetersPerPixel(_map.DisplayDpi);
-            var w = (_extX2 - _extX1) * this.MetersPerUnit / (delayRenderScale * mpp);
+            var w = (_extX2 - _extX1) * _map.MetersPerUnit / (delayRenderScale * mpp);
             if (w > 20000)
             {
                 w = 20000;



More information about the mapguide-commits mailing list