[mapguide-commits] r6812 - in trunk/Tools/Maestro: Maestro.Editors/SymbolDefinition Maestro.Editors/SymbolDefinition/GraphicsEditors Maestro.Editors/WatermarkDefinition OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Jun 25 09:23:01 PDT 2012


Author: jng
Date: 2012-06-25 09:23:00 -0700 (Mon, 25 Jun 2012)
New Revision: 6812

Modified:
   trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/GraphicsEditors/ImageDialog.cs
   trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolGraphicsCtrl.cs
   trunk/Tools/Maestro/Maestro.Editors/WatermarkDefinition/WatermarkContentCtrl.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs
Log:
This submission contains the following changes:
 - #2039: Fix the incorrect minimum content model for a Simple Symbol Definition with text. The text element *requires* a Content and FontName elements specified.
 - Fix NullReferenceExceptions in the ImageDialog in the context of being used from the Watermark Editor due to the Simple Symbol Definition instances being detached (as it is a child element of the Watermark Definition and not its own top-level element).

Modified: trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/GraphicsEditors/ImageDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/GraphicsEditors/ImageDialog.cs	2012-06-25 15:16:50 UTC (rev 6811)
+++ trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/GraphicsEditors/ImageDialog.cs	2012-06-25 16:23:00 UTC (rev 6812)
@@ -30,6 +30,8 @@
 using System.IO;
 using Maestro.Editors.Common;
 using Maestro.Editors.Generic;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Services;
 
 namespace Maestro.Editors.SymbolDefinition.GraphicsEditors
 {
@@ -40,15 +42,17 @@
         private IImageReference _imageRef;
         private IInlineImage _imageInline;
         private EditorBindableCollapsiblePanel _ed;
+        private IResourceService _resSvc;
 
         private bool _init = false;
 
-        public ImageDialog(EditorBindableCollapsiblePanel parent, ISimpleSymbolDefinition ssd, IImageGraphic image)
+        public ImageDialog(EditorBindableCollapsiblePanel parent, IResourceService resSvc, ISimpleSymbolDefinition ssd, IImageGraphic image)
         {
             InitializeComponent();
             _ed = parent;
             _ssd = ssd;
             _image = image;
+            _resSvc = resSvc;
             try
             {
                 _init = true;
@@ -131,7 +135,7 @@
 
         private void txtResourceId_TextChanged(object sender, EventArgs e)
         {
-            _imageRef.ResourceId = txtImageBase64.Text;
+            _imageRef.ResourceId = txtResourceId.Text;
         }
 
         private void txtResData_TextChanged(object sender, EventArgs e)
@@ -163,10 +167,21 @@
                         _image.Item = _imageInline;
                     txtImageBase64.Text = Convert.ToBase64String(content);
                     txtImageBase64.Tag = content;
+                    using (var ms = new MemoryStream(content))
+                    {
+                        Image img = Image.FromStream(ms);
+                        symSizeX.Content = "'" + PxToMM(img.Width, 96).ToString(System.Globalization.CultureInfo.InvariantCulture) + "'";
+                        symSizeY.Content = "'" + PxToMM(img.Height, 96).ToString(System.Globalization.CultureInfo.InvariantCulture) + "'";
+                    }
                 }
             }
         }
 
+        static double PxToMM(int px, int dpi)
+        {
+            return (px * 25.4) / dpi;
+        }
+
         private void lnkPreview_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
         {
             if (txtImageBase64.Tag != null)
@@ -189,7 +204,7 @@
 
         private void btnBrowse_Click(object sender, EventArgs e)
         {
-            using (var picker = new ResourcePicker(_ssd.CurrentConnection.ResourceService, ResourcePickerMode.OpenResource))
+            using (var picker = new ResourcePicker(_resSvc, ResourcePickerMode.OpenResource))
             {
                 if (picker.ShowDialog() == DialogResult.OK)
                 {
@@ -205,13 +220,13 @@
             if (string.IsNullOrEmpty(resourceId))
                 resourceId = _ssd.ResourceID;
 
-            if (!_ssd.CurrentConnection.ResourceService.ResourceExists(resourceId))
+            if (!_resSvc.ResourceExists(resourceId))
             {
                 MessageBox.Show(Properties.Resources.ResourceDoesntExist);
                 return;
             }
 
-            var resData = _ssd.CurrentConnection.ResourceService.EnumerateResourceData(resourceId);
+            var resData = _resSvc.EnumerateResourceData(resourceId);
             var items = new List<string>();
             foreach (var rd in resData.ResourceData)
             {

Modified: trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolGraphicsCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolGraphicsCtrl.cs	2012-06-25 15:16:50 UTC (rev 6811)
+++ trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolGraphicsCtrl.cs	2012-06-25 16:23:00 UTC (rev 6812)
@@ -100,7 +100,7 @@
             var img = _sym.CreateImageGraphics();
             AddGraphicsItem(img);
             _sym.AddGraphics(img);
-            new ImageDialog(this, _sym, img).ShowDialog();
+            new ImageDialog(this, _sym.CurrentConnection.ResourceService, _sym, img).ShowDialog();
         }
 
         private void lstGraphics_SelectedIndexChanged(object sender, EventArgs e)
@@ -129,7 +129,7 @@
                 }
                 else if (img != null)
                 {
-                    new ImageDialog(this, _sym, img).ShowDialog();
+                    new ImageDialog(this, _sym.CurrentConnection.ResourceService, _sym, img).ShowDialog();
                 }
             }
         }

Modified: trunk/Tools/Maestro/Maestro.Editors/WatermarkDefinition/WatermarkContentCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/WatermarkDefinition/WatermarkContentCtrl.cs	2012-06-25 15:16:50 UTC (rev 6811)
+++ trunk/Tools/Maestro/Maestro.Editors/WatermarkDefinition/WatermarkContentCtrl.cs	2012-06-25 16:23:00 UTC (rev 6812)
@@ -46,11 +46,13 @@
         private IImageGraphic _image;
 
         private bool _init = false;
+        private IEditorService _edSvc;
 
         public override void Bind(IEditorService service)
         {
             service.RegisterCustomNotifier(this);
             _init = true;
+            _edSvc = service;
             try
             {
                 _wmd = (IWatermarkDefinition)service.GetEditedResource();
@@ -128,7 +130,7 @@
 
         private void btnEditImage_Click(object sender, EventArgs e)
         {
-            var diag = new ImageDialog(this, _sym, _image);
+            var diag = new ImageDialog(this, _edSvc.ResourceService, _sym, _image);
             diag.ShowDialog(this);
             OnResourceChanged();
         }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs	2012-06-25 15:16:50 UTC (rev 6811)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/SymbolDefinition.cs	2012-06-25 16:23:00 UTC (rev 6812)
@@ -328,7 +328,7 @@
 
         public ITextGraphic CreateTextGraphics()
         {
-            return new Text() { };
+            return new Text() { Content = "", FontName = "'Arial'" }; //Required for minimum content
         }
 
         public IPathGraphic CreatePathGraphics()



More information about the mapguide-commits mailing list