[mapguide-commits] r7518 - in trunk/Tools/Maestro: Maestro.Editors/MapDefinition Maestro.LiveMapEditor Maestro.MapViewer

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri May 24 05:39:25 PDT 2013


Author: jng
Date: 2013-05-24 05:39:25 -0700 (Fri, 24 May 2013)
New Revision: 7518

Modified:
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.cs
   trunk/Tools/Maestro/Maestro.LiveMapEditor/MainForm.cs
   trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs
Log:
#2018: Live Map Definition editor improvements:
 - Support drag/drop reordering of layers in "Draw Order" view
 - Allow Layer Definition drops into the "Draw Order" view from the "Repository" view

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs	2013-05-24 10:26:57 UTC (rev 7517)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.Designer.cs	2013-05-24 12:39:25 UTC (rev 7518)
@@ -144,7 +144,7 @@
             resources.ApplyResources(this.drawOrderCtrl, "drawOrderCtrl");
             this.drawOrderCtrl.Name = "drawOrderCtrl";
             this.drawOrderCtrl.Viewer = this.viewer;
-            this.drawOrderCtrl.LayerChanged += new Maestro.Editors.MapDefinition.LayerEventHandler(this.drawOrderCtrl_LayerChanged);
+            this.drawOrderCtrl.LayerSelected += new Maestro.Editors.MapDefinition.LayerEventHandler(this.drawOrderCtrl_LayerSelected);
             this.drawOrderCtrl.LayerDeleted += new Maestro.Editors.MapDefinition.LayerEventHandler(this.drawOrderCtrl_LayerDeleted);
             // 
             // imageList1

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.cs	2013-05-24 10:26:57 UTC (rev 7517)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapDefinitionEditorCtrl.cs	2013-05-24 12:39:25 UTC (rev 7518)
@@ -129,9 +129,9 @@
                 propGrid.SelectedObject = node.Tag;
         }
 
-        private void drawOrderCtrl_LayerChanged(object sender, RuntimeMapLayer layer)
+        private void drawOrderCtrl_LayerSelected(object sender, RuntimeMapLayer layer)
         {
-            propGrid.SelectedObject = layer;
+            propGrid.SelectedObject = new LayerNodeMetadata(layer);
         }
 
         private void drawOrderCtrl_LayerDeleted(object sender, RuntimeMapLayer layer)

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.Designer.cs	2013-05-24 10:26:57 UTC (rev 7517)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.Designer.cs	2013-05-24 12:39:25 UTC (rev 7518)
@@ -91,6 +91,7 @@
             // 
             // lstDrawOrder
             // 
+            this.lstDrawOrder.AllowDrop = true;
             this.lstDrawOrder.DisplayMember = "DisplayString";
             this.lstDrawOrder.Dock = System.Windows.Forms.DockStyle.Fill;
             this.lstDrawOrder.FormattingEnabled = true;
@@ -102,6 +103,7 @@
             this.lstDrawOrder.DragDrop += new System.Windows.Forms.DragEventHandler(this.lstDrawOrder_DragDrop);
             this.lstDrawOrder.DragEnter += new System.Windows.Forms.DragEventHandler(this.lstDrawOrder_DragEnter);
             this.lstDrawOrder.DragOver += new System.Windows.Forms.DragEventHandler(this.lstDrawOrder_DragOver);
+            this.lstDrawOrder.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstDrawOrder_MouseDown);
             // 
             // LiveMapEditorDrawOrder
             // 

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.cs	2013-05-24 10:26:57 UTC (rev 7517)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/LiveMapEditorDrawOrder.cs	2013-05-24 12:39:25 UTC (rev 7518)
@@ -24,6 +24,11 @@
 using System.Windows.Forms;
 using Maestro.MapViewer;
 using OSGeo.MapGuide.MaestroAPI.Mapping;
+using Maestro.Editors.MapDefinition.Live;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
 
 namespace Maestro.Editors.MapDefinition
 {
@@ -129,16 +134,21 @@
             if (layer != null)
             {
                 btnUp.Enabled = btnDown.Enabled = btnDelete.Enabled = true;
-                var h = this.LayerChanged;
-                if (h != null)
-                    h(this, layer);
+                OnLayerSelected(layer);
             }
         }
 
+        private void OnLayerSelected(RuntimeMapLayer layer)
+        {
+            var h = this.LayerSelected;
+            if (h != null)
+                h(this, layer);
+        }
+
         /// <summary>
-        /// Raised when a layer's draw order has changed
+        /// Raised when a layer has been selected
         /// </summary>
-        public event LayerEventHandler LayerChanged;
+        public event LayerEventHandler LayerSelected;
 
         /// <summary>
         /// Raised when a layer has been removed from this view
@@ -159,6 +169,10 @@
                 else
                     return;
                 _map.Layers.SetNewIndex(idx, layer);
+                if (lstDrawOrder.SelectedIndex != idx)
+                    lstDrawOrder.SelectedIndex = idx;
+                else
+                    OnLayerSelected(layer);
                 this.Viewer.RefreshMap();
             }
         }
@@ -177,6 +191,10 @@
                 else
                     return;
                 _map.Layers.SetNewIndex(idx, layer);
+                if (lstDrawOrder.SelectedIndex != idx)
+                    lstDrawOrder.SelectedIndex = idx;
+                else
+                    OnLayerSelected(layer);
                 this.Viewer.RefreshMap();
             }
         }
@@ -193,7 +211,12 @@
 
         private void lstDrawOrder_DragOver(object sender, DragEventArgs e)
         {
-
+            var res = e.Data.GetData(typeof(ResourceDragMessage)) as ResourceDragMessage;
+            var layer = e.Data.GetData(typeof(RuntimeMapLayer)) as RuntimeMapLayer;
+            if (layer != null)
+                e.Effect = DragDropEffects.Move;
+            else if (res != null && ResourceIdentifier.GetResourceType(res.ResourceID) == ResourceTypes.LayerDefinition)
+                e.Effect = DragDropEffects.Copy;
         }
 
         private void lstDrawOrder_DragEnter(object sender, DragEventArgs e)
@@ -203,8 +226,42 @@
 
         private void lstDrawOrder_DragDrop(object sender, DragEventArgs e)
         {
+            var pt = lstDrawOrder.PointToClient(new Point(e.X, e.Y));
+            var index = lstDrawOrder.IndexFromPoint(pt);
+            if (index < 0)
+                index = lstDrawOrder.Items.Count - 1;
 
+            var res = e.Data.GetData(typeof(ResourceDragMessage)) as ResourceDragMessage;
+            var layer = e.Data.GetData(typeof(RuntimeMapLayer)) as RuntimeMapLayer;
+            if (layer != null)
+            {
+                _map.Layers.SetNewIndex(index, layer);
+                if (lstDrawOrder.SelectedIndex != index)
+                    lstDrawOrder.SelectedIndex = index;
+                else
+                    OnLayerSelected(layer);
+                this.Viewer.RefreshMap();
+            }
+            else if (res != null && ResourceIdentifier.GetResourceType(res.ResourceID) == ResourceTypes.LayerDefinition)
+            {
+                var conn = _map.CurrentConnection;
+                var mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+                layer = mapSvc.CreateMapLayer(_map, (ILayerDefinition)conn.ResourceService.GetResource(res.ResourceID));
+                _map.Layers.Insert(0, layer);
+                if (lstDrawOrder.SelectedIndex != 0)
+                    lstDrawOrder.SelectedIndex = 0;
+                else
+                    OnLayerSelected(layer);
+                this.Viewer.RefreshMap();
+            }
         }
+
+        private void lstDrawOrder_MouseDown(object sender, MouseEventArgs e)
+        {
+            var item = lstDrawOrder.SelectedItem as RuntimeMapLayer;
+            if (item != null)
+                lstDrawOrder.DoDragDrop(item, DragDropEffects.Move);
+        }
     }
 
     /// <summary>

Modified: trunk/Tools/Maestro/Maestro.LiveMapEditor/MainForm.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.LiveMapEditor/MainForm.cs	2013-05-24 10:26:57 UTC (rev 7517)
+++ trunk/Tools/Maestro/Maestro.LiveMapEditor/MainForm.cs	2013-05-24 12:39:25 UTC (rev 7518)
@@ -86,6 +86,9 @@
             var diag = new MapSettingsDialog(_conn, mdf);
             if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
+                //Start off in the session, so the editor service knows this is a new resource
+                mdf.ResourceID = "Session:" + _conn.SessionID + "//NewMap.MapDefinition";
+                _conn.ResourceService.SaveResource(mdf);
                 LoadMapDefinitionForEditing(mdf);
             }
             EvaluateCommandStates();
@@ -124,10 +127,17 @@
 
         private void DoSave()
         {
-            _mapEditor.SyncMap();                       //RuntimeMap to IMapDefinition
-            _mapEditor.EditorService.SyncSessionCopy(); //IMapDefinition to session-copy
-            _mapEditor.EditorService.Save();            //Session-copy to original resource
-            EvaluateCommandStates();
+            if (_mapEditor.EditorService.IsNew)
+            {
+                DoSaveAs();
+            }
+            else
+            {
+                _mapEditor.SyncMap();                       //RuntimeMap to IMapDefinition
+                _mapEditor.EditorService.SyncSessionCopy(); //IMapDefinition to session-copy
+                _mapEditor.EditorService.Save();            //Session-copy to original resource
+                EvaluateCommandStates();
+            }
         }
 
         private void DoSaveAs()

Modified: trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs	2013-05-24 10:26:57 UTC (rev 7517)
+++ trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs	2013-05-24 12:39:25 UTC (rev 7518)
@@ -978,6 +978,11 @@
         [DebuggerDisplay("Name = {Layer.Name}, Label = {Layer.LegendLabel}")]
         public class LayerNodeMetadata : LegendNodeMetadata
         {
+            public LayerNodeMetadata(RuntimeMapLayer layer)
+                : this(layer, layer.Selectable, layer.Type == RuntimeMapLayer.kBaseMap)
+            {
+            }
+
             internal LayerNodeMetadata(RuntimeMapLayer layer, bool bInitiallySelectable, bool bTiled)
             {
                 base.IsGroup = false;



More information about the mapguide-commits mailing list