[mapguide-commits] r7999 - in trunk/Tools/Maestro: Maestro.Editors Maestro.Editors/LayerDefinition/Vector/GridEditor Maestro.Editors/LayerDefinition/Vector/Thematics OSGeo.MapGuide.MaestroAPI/ObjectModels

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sat Mar 29 10:50:27 PDT 2014


Author: jng
Date: 2014-03-29 10:50:27 -0700 (Sat, 29 Mar 2014)
New Revision: 7999

Modified:
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.resx
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.cs
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.resx
   trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
   trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs
   trunk/Tools/Maestro/Maestro.Editors/Strings.resx
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
Log:
This submission includes the following changes:
 - #2418: Add composite style support for the new grid-based style editor.
 - #2419: Add theme generation support for composite styles.

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.Designer.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.Designer.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -36,10 +36,9 @@
             this.btnCreateTheme = new System.Windows.Forms.ToolStripButton();
             this.btnExplodeTheme = new System.Windows.Forms.ToolStripButton();
             this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
-            this.btnShowInLegend = new System.Windows.Forms.ToolStripButton();
-            this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
             this.btnRefreshStylePreviews = new System.Windows.Forms.ToolStripButton();
             this.btnAutoRefresh = new System.Windows.Forms.ToolStripButton();
+            this.btnShowInLegend = new System.Windows.Forms.ToolStripButton();
             this.grdRules = new System.Windows.Forms.DataGridView();
             this.toolStrip1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.grdRules)).BeginInit();
@@ -54,10 +53,9 @@
             this.btnCreateTheme,
             this.btnExplodeTheme,
             this.toolStripSeparator1,
-            this.btnShowInLegend,
-            this.toolStripSeparator3,
             this.btnRefreshStylePreviews,
-            this.btnAutoRefresh});
+            this.btnAutoRefresh,
+            this.btnShowInLegend});
             this.toolStrip1.Location = new System.Drawing.Point(0, 0);
             this.toolStrip1.Name = "toolStrip1";
             this.toolStrip1.Size = new System.Drawing.Size(785, 25);
@@ -115,23 +113,6 @@
             this.toolStripSeparator1.Name = "toolStripSeparator1";
             this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
             // 
-            // btnShowInLegend
-            // 
-            this.btnShowInLegend.Checked = true;
-            this.btnShowInLegend.CheckOnClick = true;
-            this.btnShowInLegend.CheckState = System.Windows.Forms.CheckState.Checked;
-            this.btnShowInLegend.Image = global::Maestro.Editors.Properties.Resources.document_tree;
-            this.btnShowInLegend.ImageTransparentColor = System.Drawing.Color.Magenta;
-            this.btnShowInLegend.Name = "btnShowInLegend";
-            this.btnShowInLegend.Size = new System.Drawing.Size(111, 22);
-            this.btnShowInLegend.Text = "Show In Legend";
-            this.btnShowInLegend.ToolTipText = "These rules will be shown in the legend if checked";
-            // 
-            // toolStripSeparator3
-            // 
-            this.toolStripSeparator3.Name = "toolStripSeparator3";
-            this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25);
-            // 
             // btnRefreshStylePreviews
             // 
             this.btnRefreshStylePreviews.Image = global::Maestro.Editors.Properties.Resources.arrow_circle_135;
@@ -152,6 +133,19 @@
             this.btnAutoRefresh.ToolTipText = "Style previews for currently visible rules will be automatically updated as you s" +
     "croll the grid. Otherwise, you have to manually refresh these previews";
             // 
+            // btnShowInLegend
+            // 
+            this.btnShowInLegend.Checked = true;
+            this.btnShowInLegend.CheckOnClick = true;
+            this.btnShowInLegend.CheckState = System.Windows.Forms.CheckState.Checked;
+            this.btnShowInLegend.Image = global::Maestro.Editors.Properties.Resources.document_tree;
+            this.btnShowInLegend.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.btnShowInLegend.Name = "btnShowInLegend";
+            this.btnShowInLegend.Size = new System.Drawing.Size(111, 22);
+            this.btnShowInLegend.Text = "Show In Legend";
+            this.btnShowInLegend.ToolTipText = "These rules will be shown in the legend if checked";
+            this.btnShowInLegend.Click += new System.EventHandler(this.btnShowInLegend_Click);
+            // 
             // grdRules
             // 
             this.grdRules.AllowUserToAddRows = false;
@@ -193,7 +187,6 @@
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
         private System.Windows.Forms.ToolStripButton btnShowInLegend;
-        private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
         private System.Windows.Forms.ToolStripButton btnRefreshStylePreviews;
         private System.Windows.Forms.ToolStripButton btnAutoRefresh;
     }

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -45,6 +45,7 @@
         {
             _init = true;
             InitializeComponent();
+            this.ThemeIndexOffest = 0;
         }
 
         private void InitGrid(bool bComposite)
@@ -76,6 +77,11 @@
                 UpdateRulePreviewAsync(rule);
             }
 
+            CheckThemeExplodeStatus();
+        }
+
+        private void CheckThemeExplodeStatus()
+        {
             btnExplodeTheme.Enabled = (grdRules.Rows.Count > 1);
         }
 
@@ -109,6 +115,23 @@
                 _init = true;
                 _edSvc = edSvc;
                 _style = style;
+                var p2 = style as IPointVectorStyle2;
+                var l2 = style as ILineVectorStyle2;
+                var a2 = style as IAreaVectorStyle2;
+                var c2 = style as ICompositeTypeStyle2;
+                btnShowInLegend.Visible = !(p2 == null && l2 == null && a2 == null && c2 == null);
+                if (btnShowInLegend.Visible)
+                {
+                    if (p2 != null)
+                        btnShowInLegend.Checked = p2.ShowInLegend;
+                    else if (l2 != null)
+                        btnShowInLegend.Checked = l2.ShowInLegend;
+                    else if (a2 != null)
+                        btnShowInLegend.Checked = a2.ShowInLegend;
+                    else if (c2 != null)
+                        btnShowInLegend.Checked = c2.ShowInLegend;
+                }
+
                 InitGrid(style is ICompositeTypeStyle);
                 _editedLayer = (ILayerDefinition)_edSvc.GetEditedResource();
                 _parentScaleRange = parentRange;
@@ -154,6 +177,15 @@
                             }
                         }
                         break;
+                    case StyleType.Composite:
+                        {
+                            for (int i = 0; i < style.RuleCount; i++)
+                            {
+                                ICompositeRule cr = (ICompositeRule)style.GetRuleAt(i);
+                                _rules.Add(new CompositeRuleModel(cr, i));
+                            }
+                        }
+                        break;
                 }
             }
             else
@@ -165,12 +197,26 @@
         protected override void OnLoad(EventArgs e)
         {
             base.OnLoad(e);
-            if (_rules.Count > 0)
+            if (!this.DesignMode)
             {
-                GenerateStylePreviewsForVisibleRows(false);
+                if (_rules.Count > 0)
+                {
+                    GenerateStylePreviewsForVisibleRows(false);
+                }
             }
         }
 
+        /// <summary>
+        /// Gets or sets the theme index offset. Apply a theme offset if you have a layer with multiple styles and 
+        /// your are editing any style beyond the first one. The offset should be the total number of rules before
+        /// the style being edited
+        /// </summary>
+        public int ThemeIndexOffest
+        {
+            get;
+            set;
+        }
+
         private IEnumerable<DataGridViewRow> GetVisibleRuleRows()
         {
             var visRowCount = grdRules.DisplayedRowCount(true);
@@ -238,13 +284,14 @@
             var editedRes = _edSvc.GetEditedResource();
             var conn = editedRes.CurrentConnection;
             var mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping);
+            var themeOffset = this.ThemeIndexOffest;
 
             BusyWaitDialog.Run(Strings.UpdatingStylePreviews, () =>
             { //Background thread worker
                 var icons = new Dictionary<int, Image>();
                 foreach (var rule in visibleRules)
                 {
-                    var img = mapSvc.GetLegendImage(scale, layerId, rule.Index, styleType.Value, 50, 16, "PNG");
+                    var img = mapSvc.GetLegendImage(scale, layerId, themeOffset + rule.Index, styleType.Value, 50, 16, "PNG");
                     icons[rule.Index] = img;
                 }
                 return icons;
@@ -424,6 +471,7 @@
             PointRuleModel pr = rule as PointRuleModel;
             LineRuleModel lr = rule as LineRuleModel;
             AreaRuleModel ar = rule as AreaRuleModel;
+            CompositeRuleModel cr = rule as CompositeRuleModel;
 
             UserControl uc = null;
             /*
@@ -541,6 +589,14 @@
                 };
                 afse.SetEditCommit(editCommit);
             }
+            else if (cr != null)
+            {
+                var diag = new SymbolInstancesDialog(_edSvc, cr.GetSymbolizationStyle(), GetLayerClass(), GetLayerProvider(), vl.ResourceId, prev);
+                diag.ShowDialog();
+                //HACK: Assume edits made
+                _edSvc.HasChanged();
+                return;
+            }
 
             if (uc != null)
             {
@@ -732,6 +788,7 @@
                 {
                     _init = true;
                     ReSyncRules(_style);
+                    CheckThemeExplodeStatus();
                     _edSvc.SyncSessionCopy();
                     GenerateStylePreviewsForVisibleRows(false);
                 }
@@ -775,5 +832,21 @@
             Utility.ExplodeThemeIntoFilteredLayers(options, cb);
             return true;
         }
+
+        private void btnShowInLegend_Click(object sender, EventArgs e)
+        {
+            var p2 = _style as IPointVectorStyle2;
+            var l2 = _style as ILineVectorStyle2;
+            var a2 = _style as IAreaVectorStyle2;
+            var c2 = _style as ICompositeTypeStyle2;
+            if (p2 != null)
+                p2.ShowInLegend = btnShowInLegend.Checked;
+            else if (l2 != null)
+                l2.ShowInLegend = btnShowInLegend.Checked;
+            else if (a2 != null)
+                a2.ShowInLegend = btnShowInLegend.Checked;
+            else if (c2 != null)
+                c2.ShowInLegend = btnShowInLegend.Checked;
+        }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.resx	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/RuleGridView.resx	2014-03-29 17:50:27 UTC (rev 7999)
@@ -124,9 +124,9 @@
   <data name="btnCreateTheme.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
-        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABiSURBVDhPYxhGwNzWbZOFnft/YjFIPVQrBIAEv377TjQG
+        YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABiSURBVDhPYxhGwMzWbZOFnft/YjFIPVQrBIAEv377TjQG
         qYdqhQCQwKOnL4nGKAaQ6nwQnj1vMcIAkMD2PUcIYhRNyABkwNLVWwlikDqoFlRAjhdAeJDFBAhQnJiG
-        ImBgAAAeJVK8jX2h1gAAAABJRU5ErkJggg==
+        ImBgAAAQPlK13t4XgQAAAABJRU5ErkJggg==
 </value>
   </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.Designer.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.Designer.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -32,32 +32,32 @@
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VectorScaleRangeGrid));
             this.geomStyleIcons = new System.Windows.Forms.ImageList(this.components);
             this.TAB_LINES = new System.Windows.Forms.TabPage();
-            this.lineRuleGrid = new Maestro.Editors.LayerDefinition.Vector.GridEditor.RuleGridView();
             this.TAB_AREAS = new System.Windows.Forms.TabPage();
-            this.areaRuleGrid = new Maestro.Editors.LayerDefinition.Vector.GridEditor.RuleGridView();
             this.TAB_POINTS = new System.Windows.Forms.TabPage();
-            this.pointRuleGrid = new Maestro.Editors.LayerDefinition.Vector.GridEditor.RuleGridView();
             this.TAB_COMPOSITE = new System.Windows.Forms.TabPage();
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+            this.lstStyles = new System.Windows.Forms.ListBox();
+            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
+            this.btnAdd = new System.Windows.Forms.ToolStripButton();
+            this.btnDelete = new System.Windows.Forms.ToolStripButton();
             this.tabGeomStyles = new System.Windows.Forms.TabControl();
             this.label1 = new System.Windows.Forms.Label();
             this.chkComposite = new System.Windows.Forms.CheckBox();
             this.chkArea = new System.Windows.Forms.CheckBox();
             this.chkLine = new System.Windows.Forms.CheckBox();
             this.chkPoints = new System.Windows.Forms.CheckBox();
-            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
-            this.lstStyles = new System.Windows.Forms.ListBox();
-            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
-            this.btnAdd = new System.Windows.Forms.ToolStripButton();
-            this.btnDelete = new System.Windows.Forms.ToolStripButton();
+            this.pointRuleGrid = new Maestro.Editors.LayerDefinition.Vector.GridEditor.RuleGridView();
+            this.lineRuleGrid = new Maestro.Editors.LayerDefinition.Vector.GridEditor.RuleGridView();
+            this.areaRuleGrid = new Maestro.Editors.LayerDefinition.Vector.GridEditor.RuleGridView();
             this.TAB_LINES.SuspendLayout();
             this.TAB_AREAS.SuspendLayout();
             this.TAB_POINTS.SuspendLayout();
             this.TAB_COMPOSITE.SuspendLayout();
-            this.tabGeomStyles.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.SuspendLayout();
             this.toolStrip1.SuspendLayout();
+            this.tabGeomStyles.SuspendLayout();
             this.SuspendLayout();
             // 
             // geomStyleIcons
@@ -67,12 +67,13 @@
             this.geomStyleIcons.Images.SetKeyName(0, "layer-small.png");
             this.geomStyleIcons.Images.SetKeyName(1, "layer-shape-line.png");
             this.geomStyleIcons.Images.SetKeyName(2, "layer-shape-polygon.png");
-            this.geomStyleIcons.Images.SetKeyName(3, "images-stack.png");
+            this.geomStyleIcons.Images.SetKeyName(3, "layer-vector.png");
             // 
             // TAB_LINES
             // 
             this.TAB_LINES.AutoScroll = true;
             this.TAB_LINES.Controls.Add(this.lineRuleGrid);
+            this.TAB_LINES.ImageIndex = 1;
             this.TAB_LINES.Location = new System.Drawing.Point(4, 23);
             this.TAB_LINES.Name = "TAB_LINES";
             this.TAB_LINES.Padding = new System.Windows.Forms.Padding(3);
@@ -81,18 +82,11 @@
             this.TAB_LINES.Text = "Lines";
             this.TAB_LINES.UseVisualStyleBackColor = true;
             // 
-            // lineRuleGrid
-            // 
-            this.lineRuleGrid.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.lineRuleGrid.Location = new System.Drawing.Point(3, 3);
-            this.lineRuleGrid.Name = "lineRuleGrid";
-            this.lineRuleGrid.Size = new System.Drawing.Size(673, 384);
-            this.lineRuleGrid.TabIndex = 0;
-            // 
             // TAB_AREAS
             // 
             this.TAB_AREAS.AutoScroll = true;
             this.TAB_AREAS.Controls.Add(this.areaRuleGrid);
+            this.TAB_AREAS.ImageIndex = 2;
             this.TAB_AREAS.Location = new System.Drawing.Point(4, 23);
             this.TAB_AREAS.Name = "TAB_AREAS";
             this.TAB_AREAS.Padding = new System.Windows.Forms.Padding(3);
@@ -101,18 +95,11 @@
             this.TAB_AREAS.Text = "Areas";
             this.TAB_AREAS.UseVisualStyleBackColor = true;
             // 
-            // areaRuleGrid
-            // 
-            this.areaRuleGrid.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.areaRuleGrid.Location = new System.Drawing.Point(3, 3);
-            this.areaRuleGrid.Name = "areaRuleGrid";
-            this.areaRuleGrid.Size = new System.Drawing.Size(673, 384);
-            this.areaRuleGrid.TabIndex = 0;
-            // 
             // TAB_POINTS
             // 
             this.TAB_POINTS.AutoScroll = true;
             this.TAB_POINTS.Controls.Add(this.pointRuleGrid);
+            this.TAB_POINTS.ImageIndex = 0;
             this.TAB_POINTS.Location = new System.Drawing.Point(4, 23);
             this.TAB_POINTS.Name = "TAB_POINTS";
             this.TAB_POINTS.Padding = new System.Windows.Forms.Padding(3);
@@ -121,18 +108,11 @@
             this.TAB_POINTS.Text = "Points";
             this.TAB_POINTS.UseVisualStyleBackColor = true;
             // 
-            // pointRuleGrid
-            // 
-            this.pointRuleGrid.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.pointRuleGrid.Location = new System.Drawing.Point(3, 3);
-            this.pointRuleGrid.Name = "pointRuleGrid";
-            this.pointRuleGrid.Size = new System.Drawing.Size(673, 384);
-            this.pointRuleGrid.TabIndex = 0;
-            // 
             // TAB_COMPOSITE
             // 
             this.TAB_COMPOSITE.AutoScroll = true;
             this.TAB_COMPOSITE.Controls.Add(this.splitContainer1);
+            this.TAB_COMPOSITE.ImageIndex = 3;
             this.TAB_COMPOSITE.Location = new System.Drawing.Point(4, 23);
             this.TAB_COMPOSITE.Name = "TAB_COMPOSITE";
             this.TAB_COMPOSITE.Padding = new System.Windows.Forms.Padding(3);
@@ -141,6 +121,64 @@
             this.TAB_COMPOSITE.Text = "Composite";
             this.TAB_COMPOSITE.UseVisualStyleBackColor = true;
             // 
+            // splitContainer1
+            // 
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
+            this.splitContainer1.Location = new System.Drawing.Point(3, 3);
+            this.splitContainer1.Name = "splitContainer1";
+            // 
+            // splitContainer1.Panel1
+            // 
+            this.splitContainer1.Panel1.Controls.Add(this.lstStyles);
+            this.splitContainer1.Panel1.Controls.Add(this.toolStrip1);
+            this.splitContainer1.Size = new System.Drawing.Size(673, 384);
+            this.splitContainer1.SplitterDistance = 161;
+            this.splitContainer1.TabIndex = 0;
+            // 
+            // lstStyles
+            // 
+            this.lstStyles.DisplayMember = "DisplayString";
+            this.lstStyles.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lstStyles.FormattingEnabled = true;
+            this.lstStyles.Location = new System.Drawing.Point(0, 25);
+            this.lstStyles.Name = "lstStyles";
+            this.lstStyles.Size = new System.Drawing.Size(161, 359);
+            this.lstStyles.TabIndex = 3;
+            this.lstStyles.SelectedIndexChanged += new System.EventHandler(this.lstStyles_SelectedIndexChanged);
+            // 
+            // toolStrip1
+            // 
+            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.btnAdd,
+            this.btnDelete});
+            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
+            this.toolStrip1.Name = "toolStrip1";
+            this.toolStrip1.Size = new System.Drawing.Size(161, 25);
+            this.toolStrip1.TabIndex = 2;
+            this.toolStrip1.Text = "toolStrip1";
+            // 
+            // btnAdd
+            // 
+            this.btnAdd.Image = global::Maestro.Editors.Properties.Resources.plus_circle;
+            this.btnAdd.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.btnAdd.Name = "btnAdd";
+            this.btnAdd.Size = new System.Drawing.Size(49, 22);
+            this.btnAdd.Text = "Add";
+            this.btnAdd.ToolTipText = "Add a Composite Style";
+            this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
+            // 
+            // btnDelete
+            // 
+            this.btnDelete.Enabled = false;
+            this.btnDelete.Image = global::Maestro.Editors.Properties.Resources.cross_script;
+            this.btnDelete.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.btnDelete.Name = "btnDelete";
+            this.btnDelete.Size = new System.Drawing.Size(60, 22);
+            this.btnDelete.Text = "Delete";
+            this.btnDelete.ToolTipText = "Delete this Composite Style";
+            this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
+            // 
             // tabGeomStyles
             // 
             this.tabGeomStyles.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
@@ -215,60 +253,33 @@
             this.chkPoints.UseVisualStyleBackColor = true;
             this.chkPoints.CheckedChanged += new System.EventHandler(this.chkPoints_CheckedChanged);
             // 
-            // splitContainer1
+            // pointRuleGrid
             // 
-            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.splitContainer1.Location = new System.Drawing.Point(3, 3);
-            this.splitContainer1.Name = "splitContainer1";
+            this.pointRuleGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.pointRuleGrid.Location = new System.Drawing.Point(3, 3);
+            this.pointRuleGrid.Name = "pointRuleGrid";
+            this.pointRuleGrid.Size = new System.Drawing.Size(673, 384);
+            this.pointRuleGrid.TabIndex = 0;
+            this.pointRuleGrid.ThemeIndexOffest = 0;
             // 
-            // splitContainer1.Panel1
+            // lineRuleGrid
             // 
-            this.splitContainer1.Panel1.Controls.Add(this.lstStyles);
-            this.splitContainer1.Panel1.Controls.Add(this.toolStrip1);
-            this.splitContainer1.Size = new System.Drawing.Size(673, 384);
-            this.splitContainer1.SplitterDistance = 161;
-            this.splitContainer1.TabIndex = 0;
+            this.lineRuleGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.lineRuleGrid.Location = new System.Drawing.Point(3, 3);
+            this.lineRuleGrid.Name = "lineRuleGrid";
+            this.lineRuleGrid.Size = new System.Drawing.Size(673, 384);
+            this.lineRuleGrid.TabIndex = 0;
+            this.lineRuleGrid.ThemeIndexOffest = 0;
             // 
-            // lstStyles
+            // areaRuleGrid
             // 
-            this.lstStyles.DisplayMember = "DisplayString";
-            this.lstStyles.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.lstStyles.FormattingEnabled = true;
-            this.lstStyles.Location = new System.Drawing.Point(0, 25);
-            this.lstStyles.Name = "lstStyles";
-            this.lstStyles.Size = new System.Drawing.Size(161, 359);
-            this.lstStyles.TabIndex = 3;
+            this.areaRuleGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.areaRuleGrid.Location = new System.Drawing.Point(3, 3);
+            this.areaRuleGrid.Name = "areaRuleGrid";
+            this.areaRuleGrid.Size = new System.Drawing.Size(673, 384);
+            this.areaRuleGrid.TabIndex = 0;
+            this.areaRuleGrid.ThemeIndexOffest = 0;
             // 
-            // toolStrip1
-            // 
-            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.btnAdd,
-            this.btnDelete});
-            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
-            this.toolStrip1.Name = "toolStrip1";
-            this.toolStrip1.Size = new System.Drawing.Size(161, 25);
-            this.toolStrip1.TabIndex = 2;
-            this.toolStrip1.Text = "toolStrip1";
-            // 
-            // btnAdd
-            // 
-            this.btnAdd.Image = global::Maestro.Editors.Properties.Resources.plus_circle;
-            this.btnAdd.ImageTransparentColor = System.Drawing.Color.Magenta;
-            this.btnAdd.Name = "btnAdd";
-            this.btnAdd.Size = new System.Drawing.Size(49, 22);
-            this.btnAdd.Text = "Add";
-            this.btnAdd.ToolTipText = "Add a Composite Style";
-            // 
-            // btnDelete
-            // 
-            this.btnDelete.Enabled = false;
-            this.btnDelete.Image = global::Maestro.Editors.Properties.Resources.cross_script;
-            this.btnDelete.ImageTransparentColor = System.Drawing.Color.Magenta;
-            this.btnDelete.Name = "btnDelete";
-            this.btnDelete.Size = new System.Drawing.Size(60, 22);
-            this.btnDelete.Text = "Delete";
-            this.btnDelete.ToolTipText = "Delete this Composite Style";
-            // 
             // VectorScaleRangeGrid
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -285,13 +296,13 @@
             this.TAB_AREAS.ResumeLayout(false);
             this.TAB_POINTS.ResumeLayout(false);
             this.TAB_COMPOSITE.ResumeLayout(false);
-            this.tabGeomStyles.ResumeLayout(false);
             this.splitContainer1.Panel1.ResumeLayout(false);
             this.splitContainer1.Panel1.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
             this.splitContainer1.ResumeLayout(false);
             this.toolStrip1.ResumeLayout(false);
             this.toolStrip1.PerformLayout();
+            this.tabGeomStyles.ResumeLayout(false);
             this.ResumeLayout(false);
             this.PerformLayout();
 

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -26,6 +26,7 @@
 using System.Text;
 using System.Windows.Forms;
 using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using System.Diagnostics;
 
 namespace Maestro.Editors.LayerDefinition.Vector.GridEditor
 {
@@ -34,6 +35,7 @@
         private VectorScaleRangeGrid()
         {
             InitializeComponent();
+            _compositeRuleGrids = new Dictionary<ICompositeTypeStyle, RuleGridView>();
         }
 
         private bool _init = false;
@@ -42,7 +44,8 @@
         private IPointVectorStyle _pts;
         private ILineVectorStyle _lts;
         private IAreaVectorStyle _ats;
-        private List<ICompositeTypeStyle> _cts;
+        private BindingList<ICompositeTypeStyle> _cts;
+        private ILayerDefinition _editedLayer;
 
         public VectorScaleRangeGrid(IVectorScaleRange vsr, VectorLayerStyleSectionCtrl parent)
             : this()
@@ -51,6 +54,7 @@
             {
                 _init = true;
                 _parent = parent;
+                _editedLayer = (ILayerDefinition)_parent.EditorService.GetEditedResource();
                 _vsr = vsr;
                 _pts = _vsr.PointStyle;
                 _lts = _vsr.LineStyle;
@@ -59,11 +63,23 @@
                 chkPoints.Checked = (_pts != null);
                 chkLine.Checked = (_lts != null);
                 chkArea.Checked = (_ats != null);
+
                 var vsr2 = _vsr as IVectorScaleRange2;
                 if (vsr2 != null)
                 {
-                    _cts = new List<ICompositeTypeStyle>(vsr2.CompositeStyle);
-                    chkComposite.Checked = (vsr2.CompositeStyleCount > 0);
+                    _cts = new BindingList<ICompositeTypeStyle>();
+                    if (chkArea.Checked || chkLine.Checked || chkArea.Checked)
+                    {
+                        chkComposite.Checked = false;
+                    }
+                    else
+                    {
+                        foreach (var r in vsr2.CompositeStyle)
+                        {
+                            _cts.Add(r);
+                        }
+                        chkComposite.Checked = (vsr2.CompositeStyleCount > 0);
+                    }
                 }
                 else
                 {
@@ -152,6 +168,8 @@
         private void chkComposite_CheckedChanged(object sender, EventArgs e)
         {
             if (_init) return;
+
+            SetCompositeUI();
         }
 
         private void SetCompositeUI()
@@ -161,6 +179,8 @@
             SetCompositeTabVisibility(chkComposite.Checked);
             vsr2.CompositeStyle = (chkComposite.Checked) ? _cts : null;
 
+            lstStyles.DataSource = (chkComposite.Checked) ? _cts : null;
+
             if (!_init)
                 _parent.RaiseResourceChanged();
         }
@@ -209,5 +229,71 @@
                     tabGeomStyles.TabPages.RemoveAt(idx);
             }
         }
+
+        private void btnAdd_Click(object sender, EventArgs e)
+        {
+            var vsr2 = _vsr as IVectorScaleRange2;
+            if (vsr2 != null)
+            {
+                _cts.Add(_editedLayer.CreateDefaultCompositeStyle());
+                vsr2.CompositeStyle = _cts;
+                _parent.RaiseResourceChanged();
+            }
+        }
+
+        private void btnDelete_Click(object sender, EventArgs e)
+        {
+            var vsr2 = _vsr as IVectorScaleRange2;
+            if (vsr2 != null)
+            {
+                var style = lstStyles.SelectedItem as ICompositeTypeStyle;
+                if (style != null)
+                {
+                    _cts.Remove(style);
+                    vsr2.CompositeStyle = _cts;
+                    splitContainer1.Panel2.Controls.Clear();
+                    _parent.RaiseResourceChanged();
+                }
+            }
+        }
+
+        private Dictionary<ICompositeTypeStyle, RuleGridView> _compositeRuleGrids;
+
+        private void lstStyles_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            btnDelete.Enabled = false;
+            var style = lstStyles.SelectedItem as ICompositeTypeStyle;
+            if (style != null)
+            {
+                btnDelete.Enabled = true;
+                if (!_compositeRuleGrids.ContainsKey(style))
+                {
+                    var grid = new RuleGridView();
+
+                    if (lstStyles.SelectedIndex >= 0)
+                    {
+                        int offset = 0;
+                        for (int i = 0; i < lstStyles.SelectedIndex; i++)
+                        {
+                            offset += _cts[i].RuleCount;
+                        }
+                        grid.ThemeIndexOffest = offset;
+                    }
+
+                    grid.Init(_parent.EditorService, _vsr, style);
+                    _compositeRuleGrids[style] = grid;
+                }
+
+                SetActiveControl(_compositeRuleGrids[style]);
+            }
+        }
+
+        private void SetActiveControl(RuleGridView activeGrid)
+        {
+            Debug.WriteLine(string.Format("Set active composite rule grid to: {0}", activeGrid.GetHashCode()));
+            splitContainer1.Panel2.Controls.Clear();
+            activeGrid.Dock = DockStyle.Fill;
+            splitContainer1.Panel2.Controls.Add(activeGrid);
+        }
     }
 }

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.resx	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/GridEditor/VectorScaleRangeGrid.resx	2014-03-29 17:50:27 UTC (rev 7999)
@@ -124,8 +124,8 @@
     <value>
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
         LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
-        ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABY
-        CgAAAk1TRnQBSQFMAgEBBAEAAUgBAAFIAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+        ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAq
+        CgAAAk1TRnQBSQFMAgEBBAEAAWgBAAFoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
         AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
         AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
         AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -153,23 +153,22 @@
         AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
         AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
         AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
-        AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD//8A/wD/AP8ANQAM/xQA
-        DP8B8gG7AfMRAAG8CgcBvBQADP8BuwH/AbsBAAHzAbsB8gr/AfIBuwHzAbwB/wj0Af8BBwL/HQAB/wK8
-        AfMBAAEJAf8BCQrwAQkB/wEJAbwB9AQqATABNwEwASoB9AHsAQcBvAUAAfQB8AW8AfAB9A4AAf8B8AH/
-        AwAB9AG8AQkK8gEJAbwB9AG8AfQFMQFYATcBMQH0AfcB/wEHAv8DAAHxAfAF8gHwAfENAAH/AfAB/wUA
-        AfAK8gHwAfQCAAG8Af8BEQEVAUsBUQF5AaAB5QFYAf8BtAH0AewBBwG8AwAB8AfyAfAMAAH/AfEB/wYA
-        AfEI8gHzAfEB9AMAAfAB/wFEAUsCWAFZAeUBWQFYAf8BtAH0AfcB/wG8AwAB8QfyAfELAAH/AfEB/wcA
-        AfEB8wXyA/AB9AQAAfAB/wFSB1gB/wHvAf8BSgH0AbwDAAHxAfMG8gHxCgAB/wHxAf8HAAH0AvAB8wTy
-        AfAB/wHwBQAB8AH/CDEB/wEHAf8BUQH0AbwDAAHyBPMC8gHzAfIJAAH/AfEB/wgAAfAB/wHwBfMD8AH0
-        BAAB8Ar/AbsB/wFRAf8BvAMAAfIB9AXzAfQB8ggAAf8B8gH/CQAB9ALwAfQF8wL0AfIB9AMAAfMB8QHv
-        AbwCswG0AbMDtAG7Af8BUQH/AfADAAHzAfIF9AHyAfMHAAH/AfIB/wwAAfQB8gL0BfMB9AHyAfQEAAHw
-        Cv8BUQH/AfADAAH/AfMF8gHzAf8GAAH/AfIB/w4AAfQB8QLwBvQB8QHwAfQCAAHzAfEB7wG8CFEB/wHw
-        EAAB9AHwAfEB/xAAAfEB/wHxBvIB8QH/AfEEAAHwCv8B8BAAAfEB/wHxEQAB9AHxAfQGAAH0AfEB9AQA
-        AfMK8QHzEAAB9AHxAfQtAAFCAU0BPgcAAT4DAAEoAwABQAMAASADAAEBAQABAQYAAQEWAAP/gQAG/wEA
-        AQ8C/wEAAQEC/wEAAQ8C/wEAAQEDAAEDA/8B4QMAAQMB4AEPAf8BxwQAAeABDwH/AY8BgAEDAgAB4AEP
-        Af8BHwGAAQcCAAHgAQ8B/gE/AYABDwIAAeABDwH8AX8BAAEfAgAB4AEPAfgB/wEAAQ8CAAHgAQ8B8QH/
-        AQABBwIAAeABDwHjAf8BwAEDAcABAAHgAQ8BxwH/AeABAAHAAQAC/wEPAf8B8AEAAfABAAL/AR8B/wHx
-        AfgB8AEAAv8BHwX/Cw==
+        AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD//8A/wD/AP8AOAAD/wL0
+        AbwB9AP/EwAM/wHyAbsB8xQABP8C8gT/EwAM/wG7Af8BuwEAAfMBuwHyCv8B8gG7AfMGAAH/AfAB/yIA
+        Af8CvAHzAQABCQH/AQkK8AEJAf8BCQHdAc4B3QMAAfQB8gsAAfQB8AW8AfAB9A4AAf8B8AH/AwAB9AG8
+        AQkK8gEJAbwB9AGtAd0BrQMAAfIB9AsAAfEB8AXyAfAB8Q0AAf8B8AH/BQAB8AryAfAB9AIAAd0BrQHP
+        AfQCAAHxAf8LAAHwB/IB8AwAAf8B8QH/BgAB8QjyAfMB8QH0BQAB9AGtAfQBAAHxCAAB/wMAAfEH8gHx
+        CwAB/wHxAf8HAAHxAfMF8gPwAfQHAAH0Aa0B9AHyAf8FAAH/AfQB8gMAAfEB8wbyAfEKAAH/AfEB/wcA
+        AfQC8AHzBPIB8AH/AfAJAAH0Aa0BhgEJAf8BAAL/AfMB8gH0Af8DAAHyBPMC8gHzAfIJAAH/AfEB/wgA
+        AfAB/wHwBfMD8AH0CQABhgHdAYYD8gHzAfQB/wUAAfIB9AXzAfQB8ggAAf8B8gH/CQAB9ALwAfQF8wL0
+        AfIB9AgAAQkBpwGtAfQKAAHzAfIF9AHyAfMHAAH/AfIB/wwAAfQB8gL0BfMB9AHyAfQJAAH0Ac8B9AkA
+        Af8B8wXyAfMB/wYAAf8B8gH/DgAB9AHxAvAG9AHxAfAB9AgAAfQBzwH0FQAB9AHwAfEB/xAAAfEB/wHx
+        BvIB8QH/AfEJAAH0AbQBzwHdEwAB8QH/AfERAAH0AfEB9AYAAfQB8QH0CgABzwHdAc8TAAH0AfEB9CcA
+        Ad0B1QHdAwABQgFNAT4HAAE+AwABKAMAAUADAAEgAwABAQEAAQEGAAEBFgAD/4EABv8B4AEHAv8BAAEB
+        Av8B4AEHAv8BAAEBAgAB/AF/A/8B4QIAARwB/wHgAQ8B/wHHAgABHAH/AeABDwH/AY8BgAEDAQwB/wHg
+        AQ8B/wEfAYABBwHFAf4B4AEPAf4BPwGAAQ8B4AH4AeABDwH8AX8BAAEfAfABQAHgAQ8B+AH/AQABDwH4
+        AQMB4AEPAfEB/wEAAQcB+AF/AeABDwHjAf8BwAEDAf4BPwHgAQ8BxwH/AeABAAH/AR8C/wEPAf8B8AEA
+        Af8BhwL/AR8B/wHxAfgB/wHHAv8BHwT/AccL
 </value>
   </data>
   <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

Modified: trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -38,6 +38,9 @@
 using Maestro.Editors.Generic;
 using Maestro.Shared.UI;
 using OSGeo.MapGuide.ObjectModels.FeatureSource;
+using OSGeo.MapGuide.ObjectModels.SymbolDefinition;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using System.Diagnostics;
 
 namespace Maestro.Editors.LayerDefinition.Vector.Thematics
 {
@@ -90,7 +93,7 @@
             NUMERIC_TYPES = new Type[] { typeof(byte), typeof(int), typeof(float), typeof(double) };
         }
 
-        private ILayerElementFactory _factory;
+        private ILayerElementFactory2 _factory;
 
         public ThemeCreator(IEditorService editor, ILayerDefinition layer, ClassDefinition schema, object ruleCollection)
             : this()
@@ -100,7 +103,7 @@
             m_featureClass = schema;
             m_ruleCollection = ruleCollection;
 
-            _factory = (ILayerElementFactory)editor.GetEditedResource();
+            _factory = (ILayerElementFactory2)editor.GetEditedResource();
 
             ColorBrewerColorSet.SetCustomRender(new CustomCombo.RenderCustomItem(DrawColorSetPreview));
         }
@@ -834,6 +837,14 @@
             return arule;
         }
 
+        private ICompositeRule CreateCompositeRule(ICompositeRule template, ILayerElementFactory2 factory)
+        {
+            var crule = factory.CreateDefaultCompositeRule();
+            if (template.CompositeSymbolization != null)
+                crule.CompositeSymbolization = factory.CloneCompositeSymbolization(template.CompositeSymbolization);
+            return crule;
+        }
+
         private void OKBtn_Click(object sender, EventArgs e)
         {
             try
@@ -846,129 +857,363 @@
                         return;
                 }
 
-                if (m_ruleCollection is IPointVectorStyle)
+                IPointVectorStyle pts = m_ruleCollection as IPointVectorStyle;
+                ILineVectorStyle lts = m_ruleCollection as ILineVectorStyle;
+                IAreaVectorStyle ats = m_ruleCollection as IAreaVectorStyle;
+                ICompositeTypeStyle cts = m_ruleCollection as ICompositeTypeStyle;
+
+                if (pts != null)
                 {
-                    IPointVectorStyle col = m_ruleCollection as IPointVectorStyle;
+                    GeneratePointThemeRules(rules, pts);
+                }
+                else if (lts != null)
+                {
+                    GenerateLineThemeRules(rules, lts);
+                }
+                else if (ats != null)
+                {
+                    GenerateAreaThemeRules(rules, ats);
+                }
+                else if (cts != null)
+                {
+                    GenerateCompositeThemeRules(rules, cts);
+                }
 
-                    string fillAlpha = "";
-                    IPointRule template = null;
-                    if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
+                this.DialogResult = DialogResult.OK;
+                this.Close();
+            }
+            catch(Exception ex)
+            {
+                string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
+                //m_editor.SetLastException(ex);
+                MessageBox.Show(this, string.Format(Strings.GenericError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); 
+            }
+        }
+
+        private static ISymbolDefinitionBase GetSymbolFromReference(IResourceService resSvc, ISymbolInstanceReference symRef)
+        {
+            switch(symRef.Type)
+            {
+                case SymbolInstanceType.Inline:
+                    return ((ISymbolInstanceReferenceInline)symRef).SymbolDefinition;
+                case SymbolInstanceType.Reference:
+                    return (ISymbolDefinitionBase)resSvc.GetResource(((ISymbolInstanceReferenceLibrary)symRef).ResourceId);
+            }
+            return null;
+        }
+
+        enum FillColorSource
+        {
+            PathFillColor,
+            SymbolParameterDefaultValue,
+            SymbolParameterOverride
+        }
+
+        private void GenerateCompositeThemeRules(List<RuleItem> rules, ICompositeTypeStyle col)
+        {
+            if (!chkUseFirstRuleAsTemplate.Checked || col.RuleCount == 0)
+            {
+                MessageBox.Show(Strings.CompositeThemeRequiresFirstRuleAsTemplate);
+                return;
+            }
+
+            FillColorSource? source = null;
+            string fillAlpha = "";
+            ICompositeRule template = null;
+            if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
+            {
+                template = col.GetRuleAt(0);
+                if (template.CompositeSymbolization != null)
+                {
+                    foreach (ISymbolInstance symInst in template.CompositeSymbolization.SymbolInstance)
                     {
-                        template = col.GetRuleAt(0);
-                        var sym = template.PointSymbolization2D.Symbol;
-                        if (sym.Type == PointSymbolType.Mark)
+                        if (source.HasValue)
+                            break;
+
+                        var symRef = GetSymbolFromReference(m_editor.ResourceService, symInst.Reference);
+                        var simpleSym = symRef as ISimpleSymbolDefinition;
+                        if (simpleSym == null)
+                            throw new NotSupportedException(Strings.CannotCreateThemeFromCompoundSymbolInstance);
+
+                        var symName = simpleSym.Name;
+                        //Find the first path graphic with a fill color
+                        foreach (var graphic in simpleSym.Graphics)
                         {
-                            string htmlColor = ((IMarkSymbol)sym).Fill.ForegroundColor;
-                            if (htmlColor.Length == 8)
-                                fillAlpha = htmlColor.Substring(0, 2);
-                        }
-                        else if (sym.Type == PointSymbolType.Font)
-                        {
-                            string htmlColor = ((IFontSymbol)sym).ForegroundColor;
-                            if (htmlColor.Length == 8)
-                                fillAlpha = htmlColor.Substring(0, 2);
-                        }
-                    }
+                            if (source.HasValue)
+                                break;
 
-                    if (OverwriteRules.Checked)
-                        col.RemoveAllRules();
+                            if (graphic.Type == GraphicElementType.Path)
+                            {
+                                IPathGraphic path = (IPathGraphic)graphic;
+                                if (path.FillColor != null)
+                                {
+                                    var hexIdx = path.FillColor.IndexOf("0x");
+                                    if (hexIdx >= 0 && hexIdx + 4 < path.FillColor.Length)
+                                    {
+                                        fillAlpha = path.FillColor.Substring(hexIdx + 2, 2);
+                                        source = FillColorSource.PathFillColor;
+                                    }
+                                    else
+                                    {
+                                        string color = path.FillColor;
+                                        //Is this a parameter?
+                                        if (color.StartsWith("%") && color.EndsWith("%"))
+                                        {
+                                            string paramName = color.Substring(1, color.Length - 2);
+                                            if (simpleSym.ParameterDefinition != null)
+                                            {
+                                                foreach (var paramDef in simpleSym.ParameterDefinition.Parameter)
+                                                {
+                                                    if (source.HasValue)
+                                                        break;
 
-                    foreach (RuleItem entry in rules)
-                    {
-                        IPointRule r = (template != null) ? CreatePointRule(template, _factory) : _factory.CreateDefaultPointRule();
-                        r.Filter = entry.Filter;
-                        r.LegendLabel = entry.Label;
-                        var sym = r.PointSymbolization2D.Symbol;
-                        if (sym.Type == PointSymbolType.Mark)
-                        {
-                            ((IMarkSymbol)sym).Fill.ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
+                                                    if (paramDef.Name == paramName)
+                                                    {
+                                                        hexIdx = paramDef.DefaultValue.IndexOf("0x");
+                                                        if (hexIdx >= 0 && hexIdx + 4 < paramDef.DefaultValue.Length) 
+                                                        {
+                                                            fillAlpha = paramDef.DefaultValue.Substring(hexIdx + 2, 2);
+                                                            source = FillColorSource.SymbolParameterDefaultValue;
+                                                        }
+                                                        //But wait ... Is there an override for this too?
+
+                                                        var ov = symInst.ParameterOverrides;
+                                                        if (ov != null)
+                                                        {
+                                                            foreach (var pov in ov.Override)
+                                                            {
+                                                                if (pov.SymbolName == symName && pov.ParameterIdentifier == paramName)
+                                                                {
+                                                                    hexIdx = pov.ParameterValue.IndexOf("0x");
+                                                                    if (hexIdx >= 0 && hexIdx + 4 < pov.ParameterValue.Length)
+                                                                    {
+                                                                        fillAlpha = pov.ParameterValue.Substring(hexIdx + 2, 2);
+                                                                        source = FillColorSource.SymbolParameterOverride;
+                                                                        break;
+                                                                    }
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
                         }
-                        else if (sym.Type == PointSymbolType.Font)
-                        {
-                            ((IFontSymbol)sym).ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
-                        }
-                        col.AddRule(r);
                     }
                 }
-                else if (m_ruleCollection is ILineVectorStyle)
+            }
+
+            if (OverwriteRules.Checked)
+            {
+                col.RemoveAllRules();
+            }
+
+            foreach (RuleItem entry in rules)
+            {
+                var r = (template != null) ? CreateCompositeRule(template, _factory) : _factory.CreateDefaultCompositeRule();
+                r.Filter = entry.Filter;
+                r.LegendLabel = entry.Label;
+                if (r.CompositeSymbolization != null)
                 {
-                    ILineVectorStyle col = m_ruleCollection as ILineVectorStyle;
-
-                    string bordAlpha = "";
-                    ILineRule template = null;
-                    if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
+                    bool bSetFill = false;
+                    foreach (ISymbolInstance symInst in r.CompositeSymbolization.SymbolInstance)
                     {
-                        template = col.GetRuleAt(0);
+                        if (bSetFill)
+                            break;
 
-                        //TODO: Composite lines? Which "alpha" value wins there?
-                        foreach (var st in template.Strokes)
+                        var symRef = GetSymbolFromReference(m_editor.ResourceService, symInst.Reference);
+                        var simpleSym = symRef as ISimpleSymbolDefinition;
+                        if (simpleSym == null)
+                            throw new NotSupportedException(Strings.CannotCreateThemeFromCompoundSymbolInstance);
+
+                        var symName = simpleSym.Name;
+                        //Find the first path graphic with a fill color
+                        foreach (var graphic in simpleSym.Graphics)
                         {
-                            if (st.Color.Length == 8) 
+                            if (bSetFill)
+                                break;
+
+                            if (graphic.Type == GraphicElementType.Path)
                             {
-                                bordAlpha = st.Color.Substring(0, 2);
-                                break;
+                                IPathGraphic path = (IPathGraphic)graphic;
+                                if (path.FillColor != null)
+                                {
+                                    string color = path.FillColor;
+                                    if (source.Value == FillColorSource.PathFillColor)
+                                    {
+                                        path.FillColor = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
+                                        Debug.WriteLine(string.Format("Set fill color to {0} for symbol instance {1}", path.FillColor, symInst.GetHashCode()));
+                                        bSetFill = true;
+                                        break;
+                                    }
+                                    //Is this a parameter?
+                                    if (color.StartsWith("%") && color.EndsWith("%"))
+                                    {
+                                        string paramName = color.Substring(1, color.Length - 2);
+                                        if (simpleSym.ParameterDefinition != null)
+                                        {
+                                            foreach (var paramDef in simpleSym.ParameterDefinition.Parameter)
+                                            {
+                                                if (bSetFill)
+                                                    break;
+
+                                                if (paramDef.Name == paramName)
+                                                {
+                                                    if (source.Value == FillColorSource.SymbolParameterDefaultValue)
+                                                    {
+                                                        paramDef.DefaultValue = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
+                                                        Debug.WriteLine(string.Format("Set fill color default parameter value to {0} for symbol instance {1}", paramDef.DefaultValue, symInst.GetHashCode()));
+                                                        bSetFill = true;
+                                                        break;
+                                                    }
+
+                                                    //But wait ... Is there an override for this too?
+                                                    var ov = symInst.ParameterOverrides;
+                                                    if (ov != null)
+                                                    {
+                                                        foreach (var pov in ov.Override)
+                                                        {
+                                                            if (bSetFill)
+                                                                break;
+
+                                                            if (pov.SymbolName == symName && pov.ParameterIdentifier == paramName)
+                                                            {
+                                                                //fillAlpha = pov.ParameterValue;
+                                                                if (source == FillColorSource.SymbolParameterOverride)
+                                                                {
+                                                                    pov.ParameterValue = "0x" + fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
+                                                                    Debug.WriteLine(string.Format("Set fill color parameter override value to {0} for symbol instance {1}", pov.ParameterValue, symInst.GetHashCode()));
+                                                                    bSetFill = true;
+                                                                    break;
+                                                                }
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
                             }
                         }
                     }
+                }
 
-                    if (OverwriteRules.Checked)
-                        col.RemoveAllRules();
+                col.AddCompositeRule(r);
+            }
+        }
 
-                    foreach (RuleItem entry in rules)
-                    {
-                        var l = (template != null) ? CreateLineRule(template, _factory) : _factory.CreateDefaultLineRule();
-                        l.Filter = entry.Filter;
-                        l.LegendLabel = entry.Label;
-                        foreach (var st in l.Strokes)
-                        {
-                            st.Color = bordAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(bordAlpha));
-                        }
-                        col.AddRule(l);
-                    }
+        private void GeneratePointThemeRules(List<RuleItem> rules, IPointVectorStyle col)
+        {
+            string fillAlpha = "";
+            IPointRule template = null;
+            if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
+            {
+                template = col.GetRuleAt(0);
+                var sym = template.PointSymbolization2D.Symbol;
+                if (sym.Type == PointSymbolType.Mark)
+                {
+                    string htmlColor = ((IMarkSymbol)sym).Fill.ForegroundColor;
+                    if (htmlColor.Length == 8)
+                        fillAlpha = htmlColor.Substring(0, 2);
                 }
-                else if (m_ruleCollection is IAreaVectorStyle)
+                else if (sym.Type == PointSymbolType.Font)
                 {
-                    IAreaVectorStyle col = m_ruleCollection as IAreaVectorStyle;
+                    string htmlColor = ((IFontSymbol)sym).ForegroundColor;
+                    if (htmlColor.Length == 8)
+                        fillAlpha = htmlColor.Substring(0, 2);
+                }
+            }
 
-                    string fillAlpha = "";
-                    IAreaRule template = null;
-                    if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
-                    {
-                        template = col.GetRuleAt(0);
+            if (OverwriteRules.Checked)
+                col.RemoveAllRules();
 
-                        if (template.AreaSymbolization2D != null)
-                        {
-                            if (template.AreaSymbolization2D.Fill != null)
-                            {
-                                if (template.AreaSymbolization2D.Fill.ForegroundColor.Length == 8)
-                                    fillAlpha = template.AreaSymbolization2D.Fill.ForegroundColor.Substring(0, 2);
-                            }
-                        }
-                    }
+            foreach (RuleItem entry in rules)
+            {
+                IPointRule r = (template != null) ? CreatePointRule(template, _factory) : _factory.CreateDefaultPointRule();
+                r.Filter = entry.Filter;
+                r.LegendLabel = entry.Label;
+                var sym = r.PointSymbolization2D.Symbol;
+                if (sym.Type == PointSymbolType.Mark)
+                {
+                    ((IMarkSymbol)sym).Fill.ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
+                }
+                else if (sym.Type == PointSymbolType.Font)
+                {
+                    ((IFontSymbol)sym).ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
+                }
+                col.AddRule(r);
+            }
+        }
 
-                    if (OverwriteRules.Checked)
-                        col.RemoveAllRules();
+        private void GenerateLineThemeRules(List<RuleItem> rules, ILineVectorStyle col)
+        {
+            string bordAlpha = "";
+            ILineRule template = null;
+            if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
+            {
+                template = col.GetRuleAt(0);
 
-                    foreach (RuleItem entry in rules)
+                //TODO: Composite lines? Which "alpha" value wins there?
+                foreach (var st in template.Strokes)
+                {
+                    if (st.Color.Length == 8)
                     {
-                        var r = (template != null) ? CreateAreaRule(template, _factory) : _factory.CreateDefaultAreaRule();
-                        r.Filter = entry.Filter;
-                        r.LegendLabel = entry.Label;
-                        r.AreaSymbolization2D.Fill.ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
-
-                        col.AddRule(r);
+                        bordAlpha = st.Color.Substring(0, 2);
+                        break;
                     }
                 }
+            }
 
-                this.DialogResult = DialogResult.OK;
-                this.Close();
+            if (OverwriteRules.Checked)
+                col.RemoveAllRules();
+
+            foreach (RuleItem entry in rules)
+            {
+                var l = (template != null) ? CreateLineRule(template, _factory) : _factory.CreateDefaultLineRule();
+                l.Filter = entry.Filter;
+                l.LegendLabel = entry.Label;
+                foreach (var st in l.Strokes)
+                {
+                    st.Color = bordAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(bordAlpha));
+                }
+                col.AddRule(l);
             }
-            catch(Exception ex)
+        }
+
+        private void GenerateAreaThemeRules(List<RuleItem> rules, IAreaVectorStyle col)
+        {
+            string fillAlpha = "";
+            IAreaRule template = null;
+            if (chkUseFirstRuleAsTemplate.Checked && col.RuleCount > 0)
             {
-                string msg = NestedExceptionMessageProcessor.GetFullMessage(ex);
-                //m_editor.SetLastException(ex);
-                MessageBox.Show(this, string.Format(Strings.GenericError, msg), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); 
+                template = col.GetRuleAt(0);
+
+                if (template.AreaSymbolization2D != null)
+                {
+                    if (template.AreaSymbolization2D.Fill != null)
+                    {
+                        if (template.AreaSymbolization2D.Fill.ForegroundColor.Length == 8)
+                            fillAlpha = template.AreaSymbolization2D.Fill.ForegroundColor.Substring(0, 2);
+                    }
+                }
             }
+
+            if (OverwriteRules.Checked)
+                col.RemoveAllRules();
+
+            foreach (RuleItem entry in rules)
+            {
+                var r = (template != null) ? CreateAreaRule(template, _factory) : _factory.CreateDefaultAreaRule();
+                r.Filter = entry.Filter;
+                r.LegendLabel = entry.Label;
+                r.AreaSymbolization2D.Fill.ForegroundColor = fillAlpha + Utility.SerializeHTMLColor(entry.Color, string.IsNullOrEmpty(fillAlpha));
+
+                col.AddRule(r);
+            }
         }
 
         private void CancelBtn_Click(object sender, EventArgs e)

Modified: trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/Strings.Designer.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -124,6 +124,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Creating themes from a Composite Rule with a Compound Symbol is not supported.
+        /// </summary>
+        internal static string CannotCreateThemeFromCompoundSymbolInstance {
+            get {
+                return ResourceManager.GetString("CannotCreateThemeFromCompoundSymbolInstance", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Ensure the Geometry box is checked.
         /// </summary>
         internal static string CheckGeometryFirst {
@@ -331,6 +340,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Generating a theme for a composite style, requires a composite rule.
+        /// </summary>
+        internal static string CompositeThemeRequiresFirstRuleAsTemplate {
+            get {
+                return ResourceManager.GetString("CompositeThemeRequiresFirstRuleAsTemplate", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Computing Theme Parameters ....
         /// </summary>
         internal static string ComputingThemeParameters {

Modified: trunk/Tools/Maestro/Maestro.Editors/Strings.resx
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Strings.resx	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/Maestro.Editors/Strings.resx	2014-03-29 17:50:27 UTC (rev 7999)
@@ -1563,4 +1563,10 @@
   <data name="UpdatingStylePreviews" xml:space="preserve">
     <value>Updating Style Previews</value>
   </data>
+  <data name="CannotCreateThemeFromCompoundSymbolInstance" xml:space="preserve">
+    <value>Creating themes from a Composite Rule with a Compound Symbol is not supported</value>
+  </data>
+  <data name="CompositeThemeRequiresFirstRuleAsTemplate" xml:space="preserve">
+    <value>Generating a theme for a composite style, requires a composite rule</value>
+  </data>
 </root>
\ No newline at end of file

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -100,7 +100,7 @@
         }
     }
 
-    partial class LayerDefinition : ILayerElementFactory
+    partial class LayerDefinition : ILayerElementFactory, ILayerElementFactory2
     {
         public static ILayerDefinition CreateDefault(LayerType type)
         {
@@ -436,5 +436,15 @@
             throw new NotImplementedException();
 #endif
         }
+
+        public ICompositeSymbolization CloneCompositeSymbolization(ICompositeSymbolization sym)
+        {
+#if LDF_100
+            throw new NotImplementedException();
+#else
+            var csym = (CompositeSymbolization)sym;
+            return csym.Clone();
+#endif
+        }
     }
 }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -483,5 +483,23 @@
             Check.NotNull(style, "style"); //NOXLATE
             style.DefaultColor = Utility.SerializeHTMLColor(c, true);
         }
+
+        /// <summary>
+        /// Removes all rules from a composite style
+        /// </summary>
+        /// <param name="style"></param>
+        public static void RemoveAllRules(this ICompositeTypeStyle style)
+        {
+            Check.NotNull(style, "style"); //NOXLATE
+
+            var remove = new List<ICompositeRule>();
+            foreach (var r in style.CompositeRule)
+                remove.Add(r);
+
+            foreach (var r in remove)
+            {
+                style.RemoveCompositeRule(r);
+            }
+        }
     }
 }

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs	2014-03-29 14:08:54 UTC (rev 7998)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs	2014-03-29 17:50:27 UTC (rev 7999)
@@ -365,6 +365,20 @@
     }
 
     /// <summary>
+    /// Factory interface to assist in creating common layer definition elements. Supports additional cases
+    /// for Advanced Stylization
+    /// </summary>
+    public interface ILayerElementFactory2 : ILayerElementFactory
+    {
+        /// <summary>
+        /// Clones the given symbolization
+        /// </summary>
+        /// <param name="sym"></param>
+        /// <returns></returns>
+        ICompositeSymbolization CloneCompositeSymbolization(ICompositeSymbolization sym);
+    }
+
+    /// <summary>
     /// Top-level interface of the layer definition
     /// </summary>
     public interface ILayerDefinition : IResource, ILayerElementFactory
@@ -707,8 +721,8 @@
     }
 
     /// <summary>
-    /// The stylization to be applied to the vector features for a given scale range. Supports elevation
-    /// and extrusion settings.
+    /// The stylization to be applied to the vector features for a given scale range. Supports elevation, extrusion settings
+    /// and Advanced Stylization through composite styles
     /// 
     /// Supported by Layer Definition 1.1.0 and higher
     /// </summary>



More information about the mapguide-commits mailing list