[mapguide-commits] r6634 - in trunk/Tools/Maestro: Maestro.Editors/LayerDefinition/Raster OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed May 9 09:21:18 EDT 2012


Author: jng
Date: 2012-05-09 06:21:18 -0700 (Wed, 09 May 2012)
New Revision: 6634

Modified:
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerAdvancedSectionCtrl.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs
Log:
#1963: Fix raster layer advanced settings not saving. Note that default values are omitted from the final xml, which is still okay because MapGuide will still assume said defaults in the absence of these elements.

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerAdvancedSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerAdvancedSectionCtrl.cs	2012-05-09 12:39:10 UTC (rev 6633)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Raster/RasterLayerAdvancedSectionCtrl.cs	2012-05-09 13:21:18 UTC (rev 6634)
@@ -122,37 +122,35 @@
             if (chkAdvanced.Checked)
             {
                 txtBrightnessFactor.Enabled = txtContrastFactor.Enabled = cmbTransparencyColor.Enabled = true;
-                try
-                {
-                    _init = true;
-                    //Restore values from UI fields
-                    txtBrightnessFactor_TextChanged(this, EventArgs.Empty);
-                    txtContrastFactor_TextChanged(this, EventArgs.Empty);
-                    cmbTransparencyColor_SelectedIndexChanged(this, EventArgs.Empty);
-                    //Check if attached
-                    EnableSurface.Checked = (_activeRange.SurfaceStyle != null);
-                    EnableHillshade.Checked = (_colorStyle.HillShade != null);
-                }
-                finally { _init = false; }
+                //Restore values from UI fields, can't call the actual event handler methods
+                //because _init = true so they do nothing
+                double d;
+                if (double.TryParse(txtBrightnessFactor.Text, out d))
+                    _colorStyle.BrightnessFactor = d;
+                else
+                    _colorStyle.BrightnessFactor = null;
+                if (double.TryParse(txtContrastFactor.Text, out d))
+                    _colorStyle.ContrastFactor = d;
+                else
+                    _colorStyle.ContrastFactor = null;
+                _colorStyle.TransparencyColor = Utility.SerializeHTMLColor(cmbTransparencyColor.CurrentColor, false);
+                //Check if attached
+                EnableSurface.Checked = (_activeRange.SurfaceStyle != null);
+                EnableHillshade.Checked = (_colorStyle.HillShade != null);
             }
             else
             {
-                try
-                {
-                    _init = true;
-                    _colorStyle.BrightnessFactor = null;
-                    _colorStyle.ContrastFactor = null;
-                    _colorStyle.TransparencyColor = null;
+                _colorStyle.BrightnessFactor = null;
+                _colorStyle.ContrastFactor = null;
+                _colorStyle.TransparencyColor = null;
 
-                    txtBrightnessFactor.Enabled = txtContrastFactor.Enabled = cmbTransparencyColor.Enabled = false;
+                txtBrightnessFactor.Enabled = txtContrastFactor.Enabled = cmbTransparencyColor.Enabled = false;
 
-                    //Detach
-                    EnableSurface.Checked = false;
-                    EnableHillshade.Checked = false;
-                    _colorStyle.HillShade = null;
-                    _activeRange.SurfaceStyle = null;
-                }
-                catch { _init = false; }
+                //Detach
+                EnableSurface.Checked = false;
+                EnableHillshade.Checked = false;
+                _colorStyle.HillShade = null;
+                _activeRange.SurfaceStyle = null;
             }
         }
 

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs	2012-05-09 12:39:10 UTC (rev 6633)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs	2012-05-09 13:21:18 UTC (rev 6634)
@@ -506,30 +506,15 @@
         }
 
         [XmlIgnore]
-        public bool BrightnessFactorSpecified { get; set; }
-
-        [XmlIgnore]
-        public bool ContrastFactorSpecified { get; set; }
-
-        [XmlIgnore]
         double? IGridColorStyle.BrightnessFactor
         {
             get
             {
-                if (this.BrightnessFactorSpecified)
-                    return this.BrightnessFactor;
-                else
-                    return null;
+                return this.BrightnessFactor;
             }
             set
             {
-                if (value.HasValue)
-                {
-                    this.BrightnessFactor = value.Value;
-                    this.BrightnessFactorSpecified = true;
-                }
-                else
-                    this.BrightnessFactorSpecified = false;
+                this.BrightnessFactor = value.HasValue ? value.Value : default(double);
             }
         }
 
@@ -538,20 +523,11 @@
         {
             get
             {
-                if (this.ContrastFactorSpecified)
-                    return this.ContrastFactor;
-                else
-                    return null;
+                return this.ContrastFactor;
             }
             set
             {
-                if (value.HasValue)
-                {
-                    this.ContrastFactor = value.Value;
-                    this.ContrastFactorSpecified = true;
-                }
-                else
-                    this.ContrastFactorSpecified = false;
+                this.ContrastFactor = value.HasValue ? value.Value : default(double);
             }
         }
 



More information about the mapguide-commits mailing list