[mapguide-commits] r5660 - in trunk/Tools/Maestro: Maestro.Base/Commands Maestro.Editors/LayerDefinition/Vector/StyleEditors OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Mar 24 06:47:22 EDT 2011


Author: jng
Date: 2011-03-24 03:47:22 -0700 (Thu, 24 Mar 2011)
New Revision: 5660

Modified:
   trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs
Log:
Fix #1639: I messed up the interfaces for point styles. For the longest time I couldn't figure out why size/rotation/etc were strings and not doubles, so I had them defined as nullable double properties. I now know why they're strings (and why the original 2.x implementation of the editors were correct). Strings are legit values because FDO expressions are allowed here! This submission should hopefully undo all the damage I've done to these editors since the 2.x version.

Also add a reminder note for #1505

Modified: trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs	2011-03-23 11:59:26 UTC (rev 5659)
+++ trunk/Tools/Maestro/Maestro.Base/Commands/LoginCommand.cs	2011-03-24 10:47:22 UTC (rev 5660)
@@ -40,6 +40,11 @@
             {
                 var conn = login.Connection;
 
+                //TODO: Determine if this is a http connection. If not,
+                //wrap it in an IServerConnection decorator that will do all the
+                //request dispatch broadcasting. This will solve trac #1505 and will
+                //work for any future non-http implementations
+
                 var mgr = ServiceRegistry.GetService<ServerConnectionManager>();
                 Debug.Assert(mgr != null);
 

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs	2011-03-23 11:59:26 UTC (rev 5659)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs	2011-03-24 10:47:22 UTC (rev 5660)
@@ -184,7 +184,7 @@
                 backgroundColor.CurrentColor = Utility.ParseHTMLColor(m_item.BackgroundColor);
 				backgroundTypeCombo.SelectedValue = m_item.BackgroundStyle.ToString();
                 rotationCombo.SelectedIndex = -1;
-                rotationCombo.Text = m_item.Rotation.HasValue ? m_item.Rotation.ToString() : "";
+                rotationCombo.Text = m_item.Rotation;
                 if (m_item.HorizontalAlignment != null)
                 {
                     horizontalCombo.SelectedValue = m_item.HorizontalAlignment;
@@ -781,7 +781,7 @@
 		{
             if (sizeCombo.SelectedIndex == sizeCombo.Items.Count - 1)
             {
-                string current = m_item.SizeX.HasValue ? m_item.SizeX.ToString() : string.Empty;
+                string current = m_item.SizeX;
                 string expr = m_editor.EditExpression(current, m_schema, m_providername, m_featureSource);
                 if (!string.IsNullOrEmpty(expr))
                     current = expr;
@@ -900,7 +900,7 @@
 		{
             if (rotationCombo.SelectedIndex == rotationCombo.Items.Count - 1)
             {
-                string current = m_item.Rotation.HasValue ? m_item.Rotation.Value.ToString() : string.Empty;
+                string current = m_item.Rotation;
                 string expr = m_editor.EditExpression(current, m_schema, m_providername, m_featureSource);
                 if (!string.IsNullOrEmpty(expr))
                     current = expr;
@@ -910,7 +910,7 @@
             }
             else if (rotationCombo.SelectedIndex != -1)
             {
-                m_item.Rotation = StringToDouble((string)rotationCombo.SelectedValue);
+                m_item.Rotation = (string)rotationCombo.SelectedValue;
             }
         }
 
@@ -983,7 +983,7 @@
                 return;
 
             //TODO: Validate
-            m_item.SizeX = m_item.SizeY = StringToDouble(sizeCombo.Text);
+            m_item.SizeX = m_item.SizeY = sizeCombo.Text;
             previewPicture.Refresh();
 
             if (Changed != null)
@@ -1049,7 +1049,7 @@
                 return;
 
             //TODO: Validate
-            m_item.Rotation = StringToDouble(rotationCombo.Text);
+            m_item.Rotation = rotationCombo.Text;
             previewPicture.Refresh();
 
             if (Changed != null)

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs	2011-03-23 11:59:26 UTC (rev 5659)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs	2011-03-24 10:47:22 UTC (rev 5660)
@@ -68,7 +68,7 @@
 		/// Required designer variable.
 		/// </summary>
 		private System.ComponentModel.Container components = null;
-		private System.Windows.Forms.ComboBox HeigthText;
+		private System.Windows.Forms.ComboBox HeightText;
 		private System.Windows.Forms.ComboBox WidthText;
 		private System.Windows.Forms.ComboBox SizeUnits;
 		private System.Windows.Forms.ComboBox SizeContext;
@@ -188,10 +188,10 @@
                     m_item.Symbol = _factory.CreateDefaultMarkSymbol();
 
 				// shared values
-                WidthText.Text = DoubleToString(m_item.Symbol.SizeX);
-                HeigthText.Text = DoubleToString(m_item.Symbol.SizeY);
+                WidthText.Text = m_item.Symbol.SizeX;
+                HeightText.Text = m_item.Symbol.SizeY;
                 RotationBox.SelectedIndex = -1;
-                RotationBox.Text = DoubleToString(m_item.Symbol.Rotation);
+                RotationBox.Text = m_item.Symbol.Rotation;
 
                 SizeUnits.SelectedValue = m_item.Symbol.Unit;
                 SizeContext.SelectedValue = m_item.Symbol.SizeContext.ToString();
@@ -201,13 +201,15 @@
 				{
                     MaintainAspectRatio.Checked = m_item.Symbol.MaintainAspect;
 					double d;
-                    ReferenceX.Text = DoubleToString(m_item.Symbol.InsertionPointX);
+                    if (double.TryParse(m_item.Symbol.InsertionPointX, NumberStyles.Float, CultureInfo.InvariantCulture, out d))
+                        ReferenceX.Text = d.ToString(System.Threading.Thread.CurrentThread.CurrentUICulture);
+                    else
+                        ReferenceX.Text = m_item.Symbol.InsertionPointX;
 
-                    //if (double.TryParse(m_item.Item.InsertionPointY, NumberStyles.Float, CultureInfo.InvariantCulture, out d))
-                    //    ReferenceY.Text = d.ToString(System.Threading.Thread.CurrentThread.CurrentUICulture);
-                    //else
-                    //    ReferenceY.Text = m_item.Item.InsertionPointY;
-                    ReferenceY.Text = DoubleToString(m_item.Symbol.InsertionPointY);
+                    if (double.TryParse(m_item.Symbol.InsertionPointY, NumberStyles.Float, CultureInfo.InvariantCulture, out d))
+                        ReferenceY.Text = d.ToString(System.Threading.Thread.CurrentThread.CurrentUICulture);
+                    else
+                        ReferenceY.Text = m_item.Symbol.InsertionPointY;
 
                     IMarkSymbol t = (IMarkSymbol)m_item.Symbol;
 					Symbol.SelectedValue = t.Shape.ToString();
@@ -303,7 +305,7 @@
             this.dataColumn7 = new System.Data.DataColumn();
             this.dataColumn8 = new System.Data.DataColumn();
             this.label9 = new System.Windows.Forms.Label();
-            this.HeigthText = new System.Windows.Forms.ComboBox();
+            this.HeightText = new System.Windows.Forms.ComboBox();
             this.WidthText = new System.Windows.Forms.ComboBox();
             this.SizeUnits = new System.Windows.Forms.ComboBox();
             this.UnitsTable = new System.Data.DataTable();
@@ -371,7 +373,7 @@
             resources.ApplyResources(this.groupBox1, "groupBox1");
             this.groupBox1.Controls.Add(this.RotationBox);
             this.groupBox1.Controls.Add(this.label9);
-            this.groupBox1.Controls.Add(this.HeigthText);
+            this.groupBox1.Controls.Add(this.HeightText);
             this.groupBox1.Controls.Add(this.WidthText);
             this.groupBox1.Controls.Add(this.SizeUnits);
             this.groupBox1.Controls.Add(this.SizeContext);
@@ -418,12 +420,12 @@
             // 
             // HeigthText
             // 
-            resources.ApplyResources(this.HeigthText, "HeigthText");
-            this.HeigthText.Items.AddRange(new object[] {
+            resources.ApplyResources(this.HeightText, "HeigthText");
+            this.HeightText.Items.AddRange(new object[] {
             resources.GetString("HeigthText.Items")});
-            this.HeigthText.Name = "HeigthText";
-            this.HeigthText.SelectedIndexChanged += new System.EventHandler(this.HeigthText_SelectedIndexChanged);
-            this.HeigthText.TextChanged += new System.EventHandler(this.HeigthText_TextChanged);
+            this.HeightText.Name = "HeigthText";
+            this.HeightText.SelectedIndexChanged += new System.EventHandler(this.HeigthText_SelectedIndexChanged);
+            this.HeightText.TextChanged += new System.EventHandler(this.HeightText_TextChanged);
             // 
             // WidthText
             // 
@@ -839,9 +841,9 @@
                 {
                     m_lastFont = _factory.CreateDefaultFontSymbol();
                     m_lastFont.SizeContext = SizeContextType.DeviceUnits;
-                    m_lastFont.Rotation = 0.0;
-                    m_lastFont.SizeX = 10;
-                    m_lastFont.SizeY = 10;
+                    m_lastFont.Rotation = "0";
+                    m_lastFont.SizeX = "10";
+                    m_lastFont.SizeY = "10";
                     m_lastFont.Unit = LengthUnitType.Points;
                 }
 
@@ -919,7 +921,7 @@
             {
                 string current = null;
                 if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
-                    current = DoubleToString(m_item.Symbol.SizeX);
+                    current = m_item.Symbol.SizeX;
 
                 string expr = null;
                 if (current != null)
@@ -939,11 +941,11 @@
 			if (m_inUpdate)
 				return;
 
-            if (HeigthText.SelectedIndex == HeigthText.Items.Count - 1)
+            if (HeightText.SelectedIndex == HeightText.Items.Count - 1)
             {
                 string current = null;
                 if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
-                    current = DoubleToString(m_item.Symbol.SizeY);
+                    current = m_item.Symbol.SizeY;
 
                 string expr = null;
                 if (current != null)
@@ -954,7 +956,7 @@
                 }
 
                 //This is required as we cannot update the text from within the SelectedIndexChanged event :(
-                BeginInvoke(new UpdateComboTextFromSelectChangedDelegate(UpdateComboTextFromSelectChanged), HeigthText, current, expr != null);
+                BeginInvoke(new UpdateComboTextFromSelectChangedDelegate(UpdateComboTextFromSelectChanged), HeightText, current, expr != null);
             }
 		}
 
@@ -967,11 +969,11 @@
             {
                 double d;
                 if (ReferenceX.Text.Trim().Length == 0)
-                    m_item.Symbol.InsertionPointY = 0.5;
+                    m_item.Symbol.InsertionPointY = "0.5";
                 else if (double.TryParse(ReferenceX.Text, System.Globalization.NumberStyles.Float, System.Threading.Thread.CurrentThread.CurrentUICulture, out d) || double.TryParse(ReferenceX.Text, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
-                    m_item.Symbol.InsertionPointX = StringToDouble(Math.Min(Math.Max(0.0, d), 1.0).ToString(System.Globalization.CultureInfo.InvariantCulture));
+                    m_item.Symbol.InsertionPointX = Math.Min(Math.Max(0.0, d), 1.0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                 else
-                    m_item.Symbol.InsertionPointX = StringToDouble(ReferenceX.Text);
+                    m_item.Symbol.InsertionPointX = ReferenceX.Text;
             }
 			previewPicture.Refresh();		
 			if (Changed != null)
@@ -987,9 +989,9 @@
             {
                 double d;
                 if (double.TryParse(ReferenceY.Text, System.Globalization.NumberStyles.Float, System.Threading.Thread.CurrentThread.CurrentUICulture, out d) || double.TryParse(ReferenceY.Text, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
-                    m_item.Symbol.InsertionPointY = Math.Min(Math.Max(0.0, d), 1.0);
+                    m_item.Symbol.InsertionPointY = Math.Min(Math.Max(0.0, d), 1.0).ToString(System.Globalization.CultureInfo.InvariantCulture);
                 else
-                    m_item.Symbol.InsertionPointY = 0.5;
+                    m_item.Symbol.InsertionPointY = "0.5";
             }
 			previewPicture.Refresh();		
 			if (Changed != null)
@@ -1005,7 +1007,7 @@
             {
                 string current = null;
                 if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
-                    current = DoubleToString(m_item.Symbol.Rotation);
+                    current = m_item.Symbol.Rotation;
 
                 string expr = null;
                 if (current != null)
@@ -1021,7 +1023,7 @@
             else if (RotationBox.SelectedIndex != -1)
             {
                 if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
-                    m_item.Symbol.Rotation = StringToDouble((string)RotationBox.SelectedValue);
+                    m_item.Symbol.Rotation = (string)RotationBox.SelectedValue;
 
                 //RotationBox.SelectedIndex = -1;
             }
@@ -1279,22 +1281,22 @@
 
             //TODO: Validate
             if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
-                m_item.Symbol.SizeX = StringToDouble(WidthText.Text);
+                m_item.Symbol.SizeX = WidthText.Text;
             previewPicture.Refresh();
             if (Changed != null)
                 Changed(this, new EventArgs());
         }
 
-        private void HeigthText_TextChanged(object sender, EventArgs e)
+        private void HeightText_TextChanged(object sender, EventArgs e)
         {
-            if (m_inUpdate || HeigthText.SelectedIndex != -1)
+            if (m_inUpdate || HeightText.SelectedIndex != -1)
                 return;
 
             //TODO: Validate
             if (m_item.Symbol.Type == PointSymbolType.Mark)
-                m_item.Symbol.SizeY = StringToDouble(HeigthText.Text);
+                m_item.Symbol.SizeY = HeightText.Text;
             else if (m_item.Symbol.Type == PointSymbolType.Font)
-                m_item.Symbol.SizeY = StringToDouble(HeigthText.Text);
+                m_item.Symbol.SizeY = HeightText.Text;
             previewPicture.Refresh();
             if (Changed != null)
                 Changed(this, new EventArgs());
@@ -1307,9 +1309,9 @@
 
             //TODO: Validate
             if (m_item.Symbol.Type == PointSymbolType.Mark)
-                m_item.Symbol.Rotation = StringToDouble(RotationBox.Text);
+                m_item.Symbol.Rotation = RotationBox.Text;
             else if (m_item.Symbol.Type == PointSymbolType.Font)
-                m_item.Symbol.Rotation = StringToDouble(RotationBox.Text);
+                m_item.Symbol.Rotation = RotationBox.Text;
             previewPicture.Refresh();
             if (Changed != null)
                 Changed(this, new EventArgs());
@@ -1317,10 +1319,10 @@
 		
 		private void ReferenceY_Leave(object sender, EventArgs e)
         {
-            //double d;
-            //if (m_item.Item is IMarkSymbol)
-            //    if (!double.TryParse(((IMarkSymbol)m_item.Item).InsertionPointY, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
-            //        MessageBox.Show(this, Properties.Resources.InsertionPointYError, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
+            double d;
+            if (m_item.Symbol is IMarkSymbol)
+                if (!double.TryParse(((IMarkSymbol)m_item.Symbol).InsertionPointY, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
+                    MessageBox.Show(this, Properties.Resources.InsertionPointYError, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
 
         private void FontBoldButton_Click(object sender, EventArgs e)

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs	2011-03-23 11:59:26 UTC (rev 5659)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs	2011-03-24 10:47:22 UTC (rev 5660)
@@ -879,17 +879,17 @@
         /// <summary>
         /// Gets or sets the width of the symbol. This is a double FDO expression. Does not apply to font symbols
         /// </summary>
-        double? SizeX { get; set; }
+        string SizeX { get; set; }
 
         /// <summary>
         /// Gets or sets the height of the symbol. This is a double FDO expression.
         /// </summary>
-        double? SizeY { get; set; }
+        string SizeY { get; set; }
 
         /// <summary>
         /// Gets or sets the amount to rotate the symbol in degrees. This is a double FDO expression. Does not apply to line labels
         /// </summary>
-        double? Rotation { get; set; }
+        string Rotation { get; set; }
 
         /// <summary>
         /// Hint for the UI only. When the user enters a constant size for the width or height, the other dimension should be adjusted accordingly.  Does not apply to font symbols or labels.
@@ -897,14 +897,14 @@
         bool MaintainAspect { get; set; }
 
         /// <summary>
-        /// Gets or sets the X offset for the symbol specified in symbol space.  Does not apply to labels.
+        /// Gets or sets the X offset for the symbol specified in symbol space. This is a double FDO expression. Does not apply to labels.
         /// </summary>
-        double? InsertionPointX { get; set; }
+        string InsertionPointX { get; set; }
 
         /// <summary>
-        /// Gets or sets the Y offset for the symbol specified in symbol space.  Does not apply to labels.
+        /// Gets or sets the Y offset for the symbol specified in symbol space. This is a double FDO expression. Does not apply to labels.
         /// </summary>
-        double? InsertionPointY { get; set; }
+        string InsertionPointY { get; set; }
     }
 
     /// <summary>

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs	2011-03-23 11:59:26 UTC (rev 5659)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs	2011-03-24 10:47:22 UTC (rev 5660)
@@ -814,75 +814,6 @@
         }
 
         [XmlIgnore]
-        double? ISymbol.SizeX
-        {
-            get
-            {
-                if (string.IsNullOrEmpty(this.SizeX))
-                    return null;
-
-                double d;
-                if (double.TryParse(this.SizeX, out d))
-                    return d;
-
-                return null;
-            }
-            set
-            {
-                if (!value.HasValue)
-                    this.SizeX = null;
-                else
-                    this.SizeX = value.Value.ToString(CultureInfo.InvariantCulture);
-            }
-        }
-
-        [XmlIgnore]
-        double? ISymbol.SizeY
-        {
-            get
-            {
-                if (string.IsNullOrEmpty(this.SizeY))
-                    return null;
-
-                double d;
-                if (double.TryParse(this.SizeY, out d))
-                    return d;
-
-                return null;
-            }
-            set
-            {
-                if (!value.HasValue)
-                    this.SizeY = null;
-                else
-                    this.SizeY = value.Value.ToString(CultureInfo.InvariantCulture);
-            }
-        }
-
-        [XmlIgnore]
-        double? ISymbol.Rotation
-        {
-            get
-            {
-                if (string.IsNullOrEmpty(this.Rotation))
-                    return null;
-
-                double d;
-                if (double.TryParse(this.Rotation, out d))
-                    return d;
-
-                return null;
-            }
-            set
-            {
-                if (!value.HasValue)
-                    this.Rotation = null;
-                else
-                    this.Rotation = value.Value.ToString(CultureInfo.InvariantCulture);
-            }
-        }
-
-        [XmlIgnore]
         bool ISymbol.MaintainAspect
         {
             get
@@ -896,53 +827,20 @@
         }
 
         [XmlIgnore]
-        double? ISymbol.InsertionPointX
-        {
-            get
-            {
-                if (string.IsNullOrEmpty(this.InsertionPointX))
-                    return null;
+        public abstract PointSymbolType Type { get; }
 
-                double d;
-                if (double.TryParse(this.InsertionPointX, out d))
-                    return d;
-                else
-                    return null;
-            }
-            set
-            {
-                if (value.HasValue)
-                    this.InsertionPointX = value.Value.ToString(CultureInfo.InvariantCulture);
-                else
-                    this.InsertionPointX = null;
-            }
-        }
-
         [XmlIgnore]
-        double? ISymbol.InsertionPointY
+        string ISymbol.InsertionPointY
         {
             get
             {
-                if (string.IsNullOrEmpty(this.InsertionPointX))
-                    return null;
-
-                double d;
-                if (double.TryParse(this.InsertionPointX, out d))
-                    return d;
-                else
-                    return null;
+                return this.InsertionPointY.ToString();
             }
             set
             {
-                if (value.HasValue)
-                    this.InsertionPointY = value.Value;
-
-                //TODO: throw exception?
+                this.InsertionPointY = Convert.ToDouble(value);
             }
         }
-
-        [XmlIgnore]
-        public abstract PointSymbolType Type { get; }
     }
 
     partial class FontSymbolType : IFontSymbol



More information about the mapguide-commits mailing list