// Remove all IndividualValueThemes from the World layer
        private void DoClearThemes()
        {
            // First obtain a reference to the layer
            FeatureLayer lyr = (FeatureLayer)mapControl1.Map.Layers[_layerName];

            if (lyr == null)
            {
                MessageBox.Show(
                    "Layer " + _layerName + " not found; no themes to remove.");
                return;
            }

            // Reference the layer's collection of themes and other modifiers
            FeatureStyleModifiers modifiers = lyr.Modifiers;

            // remove any IndividualValueTheme objects
            ArrayList aliases = new ArrayList();

            foreach (FeatureStyleModifier mod in modifiers)
            {
                IndividualValueTheme ivTheme = mod as IndividualValueTheme;
                if (ivTheme != null)
                {
                    // We found a modifier that is an IndividualValueTheme.
                    // Remember its name so we can remove it after this loop.
                    aliases.Add(ivTheme.Alias);
                }
            }
            foreach (string s in aliases)
            {
                modifiers.Remove(s);
            }
            MessageBox.Show("Removed " + aliases.Count
                            + " IndividualValueTheme(s) from layer: " + _layerName);
        }
        // Examine the layer's IndividualValueTheme, if there is one,
        // and display information about some of the theme's properties.
        private void DoThemeInfo()
        {
            // First obtain a reference to the layer
            FeatureLayer lyr = (FeatureLayer)mapControl1.Map.Layers[_layerName];

            if (lyr == null)
            {
                MessageBox.Show(
                    "Layer " + _layerName + " not found; no theme information to display.");
                return;
            }

            // Reference the layer's collection of themes and other modifiers
            FeatureStyleModifiers modifiers = lyr.Modifiers;

            // See if the collection contains any IndividualValueTheme objects
            IndividualValueTheme ivTheme = null;
            int counter = 0;

            foreach (FeatureStyleModifier mod in modifiers)
            {
                if (mod is IndividualValueTheme)
                {
                    // We did find an IndividualValueTheme in the collection
                    counter++;
                    if (ivTheme == null)
                    {
                        // Keep a reference to the top-most theme we find
                        ivTheme = mod as IndividualValueTheme;
                    }
                }
            }
            if (counter > 1)
            {
                MessageBox.Show("Found " + counter + " IndividualValueThemes on layer "
                                + _layerName + "; displaying information for topmost theme.");
            }
            if (ivTheme != null)
            {
                string str = "Individual Value Theme properties: ";
                str += "Theme name: '" + ivTheme.Name + "'. ";
                str += "Theme expression: '" + ivTheme.Expression + "'. ";
                str += "Theme has " + ivTheme.Bins.Count + " bins. ";
                if (ivTheme.Visible)
                {
                    str += " Theme is visible at the current zoom level. ";
                }
                else
                {
                    str += " Theme is not currently visible. ";
                }
                MessageBox.Show(str);
            }
            else
            {
                MessageBox.Show("No IndividualValueTheme objects found for layer " + _layerName);
            }
        }
        // Add an IndividualValueTheme to the specified layer.
        private void DoAddTheme(Map myMap, string layerToTheme, string expression)
        {
            // First obtain a reference to the layer that will own the theme
            FeatureLayer lyr = (FeatureLayer)myMap.Layers[layerToTheme];

            if (lyr == null)
            {
                MessageBox.Show("Layer " + layerToTheme + " not found; theme cannot be added.");
                return;
            }

            IndividualValueTheme ivTheme = null;

            try
            {
                // Create the theme.  Pass null for the theme's alias.
                ivTheme = new IndividualValueTheme(lyr, expression, null);
            }
            catch (System.NullReferenceException)
            {
                // This exception can occur if you specify an expression
                // that is not valid for this layer.
                MessageBox.Show("Unable to create theme; check expression syntax. "
                                + "Layer: " + layerToTheme + ", Expression: " + expression,
                                "Error");
                return;
            }

            // Set the theme's ApplyStylePart property to control which display
            // attributes are overridden by the theme. If you specify StylePart.All:
            //     ivTheme.ApplyStylePart = StylePart.All;
            // the theme will control each country's fill pattern and color.
            // If you specify StylePart.Color, the theme will control each country's
            // color, but will not alter each region's fill pattern.
            // If you have specified a fill pattern using a display style override,
            // and you do not want the individual value theme to interfere with that
            // fill pattern, set ApplyStylePart to StylePart.Color.
            ivTheme.ApplyStylePart = StylePart.Color;

            // Now add the theme to the layer's collection of style modifiers.
            // Insert it at the top of the list of modifiers, so that it will
            // definitely be visible.  (If the layer has other modifiers,
            // such as style overrides, and you append the theme to the
            // bottom of the list, the style overrides might override the theme.)
            lyr.Modifiers.Insert(0, ivTheme);
            MessageBox.Show("Added new IndividualValueTheme to layer " + _layerName
                            + " using expression: " + expression, "Theme Added");
        }
Ejemplo n.º 4
0
        public override void Process()
        {
            MapControlModel model = MapControlModel.GetModelFromSession();

            model.SetMapSize(MapAlias, MapWidth, MapHeight);

            //get map object from map model
            MapInfo.Mapping.Map map  = model.GetMapObj(MapAlias);
            FeatureLayer        fLyr = map.Layers[ProjectConstants.ThemeLayerAlias] as FeatureLayer;

            fLyr.Modifiers.Clear();
            map.Legends.Clear();

            //create theme
            IndividualValueTheme iTheme = new IndividualValueTheme(fLyr, ProjectConstants.IndColumnName, ProjectConstants.ThemeAlias);

            fLyr.Modifiers.Insert(0, iTheme);

            //create legend based on the individual value theme
            Legend lg = map.Legends.CreateLegend(new Size(236, 282));

            //create legend frame
            ThemeLegendFrame lgFrame = LegendFrameFactory.CreateThemeLegendFrame(iTheme);

            lg.Frames.Append(lgFrame);

            //modify legend frame style
            lgFrame.BackgroundBrush = new SolidBrush(Color.AliceBlue);
            lgFrame.Title           = "World Country Legend";
            lgFrame.SubTitle        = " ";

            MapInfo.Styles.Font titleFont = new MapInfo.Styles.Font("Arial", 10);
            titleFont.ForeColor  = Color.DarkBlue;
            titleFont.FontWeight = FontWeight.Bold;

            lgFrame.TitleStyle = titleFont;

            MapInfo.Styles.Font rowTextStyle = new Font("Arial", 8);
            rowTextStyle.FontWeight = FontWeight.Bold;

            lgFrame.RowTextStyle = rowTextStyle;

            //stream map image back to client
            MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);

            StreamImageToClient(ms);
        }
Ejemplo n.º 5
0
        public override void Process()
        {
            MapControlModel model = MapControlModel.GetModelFromSession();
            model.SetMapSize(MapAlias, MapWidth, MapHeight);

            //get map object from map model
            MapInfo.Mapping.Map map = model.GetMapObj(MapAlias);
            FeatureLayer fLyr = map.Layers[ProjectConstants.ThemeLayerAlias] as FeatureLayer;

            fLyr.Modifiers.Clear();
            map.Legends.Clear();

            //create theme
            IndividualValueTheme iTheme = new IndividualValueTheme(fLyr, ProjectConstants.IndColumnName, ProjectConstants.ThemeAlias);
            fLyr.Modifiers.Insert(0, iTheme);

            //create legend based on the individual value theme
            Legend lg = map.Legends.CreateLegend(new Size(236, 282));

            //create legend frame
            ThemeLegendFrame lgFrame = LegendFrameFactory.CreateThemeLegendFrame(iTheme);
            lg.Frames.Append(lgFrame);

            //modify legend frame style
            lgFrame.BackgroundBrush = new SolidBrush(Color.AliceBlue);
            lgFrame.Title = "World Country Legend";
            lgFrame.SubTitle = " ";

            MapInfo.Styles.Font titleFont = new MapInfo.Styles.Font("Arial", 10);
            titleFont.ForeColor = Color.DarkBlue;
            titleFont.FontWeight = FontWeight.Bold;

            lgFrame.TitleStyle = titleFont;

            MapInfo.Styles.Font rowTextStyle = new Font("Arial", 8);
            rowTextStyle.FontWeight = FontWeight.Bold;

            lgFrame.RowTextStyle = rowTextStyle;

            //stream map image back to client
            MemoryStream ms = model.GetMap(MapAlias, MapWidth, MapHeight, ExportFormat);
            StreamImageToClient(ms);
        }
Ejemplo n.º 6
0
 private void ModifyTheme()
 {
     try
     {
         // Bring up the modify theme dialog for modifier themes
         if (_themedFeatureLayer != null)
         {
             FeatureStyleModifier modifier = _themedFeatureLayer.Modifiers["theme1"];
             if (modifier != null)
             {
                 if (modifier is DotDensityTheme)
                 {
                     DotDensityTheme          thm = modifier as DotDensityTheme;
                     ModifyDotDensityThemeDlg dlg = new ModifyDotDensityThemeDlg(mapControl1.Map, thm);
                     dlg.ShowDialog();
                 }
                 else if (modifier is RangedTheme)
                 {
                     RangedTheme          thm = modifier as RangedTheme;
                     ModifyRangedThemeDlg dlg = new ModifyRangedThemeDlg(mapControl1.Map, thm);
                     dlg.ShowDialog();
                 }
                 else if (modifier is IndividualValueTheme)
                 {
                     IndividualValueTheme   thm = modifier as IndividualValueTheme;
                     ModifyIndValueThemeDlg dlg = new ModifyIndValueThemeDlg(mapControl1.Map, thm);
                     dlg.ShowDialog();
                 }
                 _themedFeatureLayer.Invalidate();
             }
         }
         // Bring up the modify theme dialog for object themes
         ObjectThemeLayer thmLayer = mapControl1.Map.Layers["theme1"] as ObjectThemeLayer;
         if (thmLayer != null)
         {
             if (thmLayer.Theme is GraduatedSymbolTheme)
             {
                 GraduatedSymbolTheme     thm = thmLayer.Theme as GraduatedSymbolTheme;
                 ModifyGradSymbolThemeDlg dlg = new ModifyGradSymbolThemeDlg(mapControl1.Map, thm);
                 dlg.ShowDialog();
             }
             else if (thmLayer.Theme is BarTheme)
             {
                 BarTheme          thm = thmLayer.Theme as BarTheme;
                 ModifyBarThemeDlg dlg = new ModifyBarThemeDlg(mapControl1.Map, thm);
                 dlg.ShowDialog();
             }
             else if (thmLayer.Theme is PieTheme)
             {
                 PieTheme          thm = thmLayer.Theme as PieTheme;
                 ModifyPieThemeDlg dlg = new ModifyPieThemeDlg(mapControl1.Map, thm);
                 dlg.ShowDialog();
             }
             thmLayer.RebuildTheme();
         }
         if (_themedLabelLayer != null)
         {
             LabelModifier labelModifier = _themedLabelLayer.Sources[0].Modifiers["theme1"];
             if (labelModifier != null)
             {
                 if (labelModifier is RangedLabelTheme)
                 {
                     RangedLabelTheme     thm = labelModifier as RangedLabelTheme;
                     ModifyRangedThemeDlg dlg = new ModifyRangedThemeDlg(mapControl1.Map, thm);
                     dlg.ShowDialog();
                 }
                 else if (labelModifier is IndividualValueLabelTheme)
                 {
                     IndividualValueLabelTheme thm = labelModifier as IndividualValueLabelTheme;
                     ModifyIndValueThemeDlg    dlg = new ModifyIndValueThemeDlg(mapControl1.Map, thm);
                     dlg.ShowDialog();
                 }
                 _themedLabelLayer.Invalidate();
             }
         }
     }
     catch (MapException)
     {
     }
 }
Ejemplo n.º 7
0
        // Disable other LabelLayers if we demo a new LabelLayer with theme or modifier sample.
        // so User could see theme/modifier label layer clearly.
//		public static void HandleLabelLayerVisibleStatus(Map map)
//		{
//			if(map == null) return;
//			for(int index=0; index < map.Layers.Count; index++)
//			{
//				IMapLayer lyr = map.Layers[index];
//				if(lyr is LabelLayer)
//				{
//					LabelLayer ll = lyr as LabelLayer;
//					if(map.Layers[SampleConstants.NewLabelLayerAlias] != null
//						&& ll.Alias != SampleConstants.NewLabelLayerAlias)
//					{
//						ll.Enabled = false;
//					}
//					else
//					{
//						ll.Enabled = true;
//					}
//				}
//			}
//		}

        // Create all MapXtreme.Net themes and modifiers for the bound data
        // and add them into the corresponding Map object.
        private void CreateThemeOrModifier(string themeName)
        {
            Map myMap = GetMapObj();

            if (myMap == null)
            {
                return;
            }
            // Clean up all temp themes or modifiers from the Map object.
            this.CleanUp(myMap);

            FeatureLayer          fLyr      = myMap.Layers[SampleConstants.ThemeLayerAlias] as FeatureLayer;
            ThemeAndModifierTypes themeType = ThemesAndModifiers.GetThemeAndModifierTypesByName(themeName);

            string alias = ConstructThemeAlias(themeType);

            switch (themeType)
            {
            case ThemeAndModifierTypes.RangedTheme:
                RangedTheme rt = new RangedTheme(fLyr, GetThemeOrModifierExpression(), alias, 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);
                fLyr.Modifiers.Append(rt);
                break;

            case ThemeAndModifierTypes.DotDensityTheme:
                DotDensityTheme ddt = new DotDensityTheme(fLyr, GetThemeOrModifierExpression(), alias, Color.Purple, DotDensitySize.Large);
                ddt.ValuePerDot = 2000000d;
                fLyr.Modifiers.Append(ddt);
                break;

            case ThemeAndModifierTypes.IndividualValueTheme:
                IndividualValueTheme ivt = new IndividualValueTheme(fLyr, GetThemeOrModifierExpression(), alias);
                fLyr.Modifiers.Append(ivt);
                break;

            case ThemeAndModifierTypes.PieTheme:
                PieTheme         pt    = new PieTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                ObjectThemeLayer otlPt = new ObjectThemeLayer("PieTheme", alias, pt);
                GetTheGroupLayer().Insert(0, otlPt);
                break;

            case ThemeAndModifierTypes.BarTheme:
                BarTheme bt = new BarTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                bt.DataValueAtSize = 10000000;
                bt.Size            = new MapInfo.Engine.PaperSize(0.1, 0.1, MapInfo.Geometry.PaperUnit.Inch);
                bt.Width           = new MapInfo.Engine.PaperSize(0.1, MapInfo.Geometry.PaperUnit.Inch);
                ObjectThemeLayer otlBt = new ObjectThemeLayer("BarTheme", alias, bt);

                GetTheGroupLayer().Insert(0, otlBt);
                break;

            case ThemeAndModifierTypes.GraduatedSymbolTheme:
                GraduatedSymbolTheme gst    = new GraduatedSymbolTheme(fLyr.Table, GetThemeOrModifierExpression());
                ObjectThemeLayer     otlGst = new ObjectThemeLayer("GraduatedSymbolTheme", alias, gst);
                GetTheGroupLayer().Insert(0, otlGst);
                break;

            case ThemeAndModifierTypes.FeatureOverrideStyleModifier:
                FeatureOverrideStyleModifier fosm = new FeatureOverrideStyleModifier("OverrideTheme", alias);

                SimpleInterior fs = new SimpleInterior((SimpleInterior.MaxFillPattern - SimpleInterior.MinFillPattern) / 2, Color.FromArgb(10, 23, 90), Color.FromArgb(33, 35, 35), false);
                fs.SetApplyAll();
                SimpleLineStyle lineStyle = new SimpleLineStyle(new LineWidth(2, LineWidthUnit.Point), (SimpleLineStyle.MaxLinePattern - SimpleLineStyle.MinLinePattern) / 2);
                lineStyle.Color       = Color.FromArgb(111, 150, 230);
                lineStyle.Interleaved = false;
                lineStyle.SetApplyAll();

                fosm.Style.AreaStyle = new AreaStyle(lineStyle, fs);
                fLyr.Modifiers.Append(fosm);
                break;

            case ThemeAndModifierTypes.Label_IndividualValueLabelTheme:
                IndividualValueLabelTheme ivlt = new IndividualValueLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias);
                CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(ivlt);
                break;

            case ThemeAndModifierTypes.Label_RangedLabelTheme:
                RangedLabelTheme rlt = new RangedLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias, 5, DistributionMethod.EqualCountPerRange);
                CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(rlt);
                break;

            case ThemeAndModifierTypes.Label_OverrideLabelModifier:
                OverrideLabelModifier olm  = new OverrideLabelModifier(alias, "OverrideLabelModifier");
                MapInfo.Styles.Font   font = new MapInfo.Styles.Font("Arial", 24, Color.Red, Color.Yellow, FontFaceStyle.Italic,
                                                                     FontWeight.Bold, TextEffect.Halo, TextDecoration.All, TextCase.AllCaps, true, true);

                font.Attributes = StyleAttributes.FontAttributes.All;

                olm.Properties.Style   = new TextStyle(font);
                olm.Properties.Caption = GetThemeOrModifierExpression();
                CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(olm);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 8
0
        // Create all MapXtreme.Net themes and modifiers for the bound data
        // and add them into the corresponding Map object.
        private void CreateThemeOrModifier(string themeName)
        {
            Map myMap = GetMapObj();
            if(myMap == null)return;
            // Clean up all temp themes or modifiers from the Map object.
            this.CleanUp(myMap);

            FeatureLayer fLyr = myMap.Layers[SampleConstants.ThemeLayerAlias] as FeatureLayer;
            ThemeAndModifierTypes themeType = ThemesAndModifiers.GetThemeAndModifierTypesByName(themeName);

            string alias = ConstructThemeAlias(themeType);
            switch(themeType)
            {
                case ThemeAndModifierTypes.RangedTheme:
                    RangedTheme rt = new RangedTheme(fLyr, GetThemeOrModifierExpression(), alias, 5, MapInfo.Mapping.Thematics.DistributionMethod.EqualCountPerRange);
                    fLyr.Modifiers.Append(rt);
                    break;
                case ThemeAndModifierTypes.DotDensityTheme:
                    DotDensityTheme ddt = new DotDensityTheme(fLyr, GetThemeOrModifierExpression(), alias, Color.Purple, DotDensitySize.Large);
                    ddt.ValuePerDot = 2000000d;
                    fLyr.Modifiers.Append(ddt);
                    break;
                case ThemeAndModifierTypes.IndividualValueTheme:
                    IndividualValueTheme ivt = new IndividualValueTheme(fLyr, GetThemeOrModifierExpression(), alias);
                    fLyr.Modifiers.Append(ivt);
                    break;
                case ThemeAndModifierTypes.PieTheme:
                    PieTheme pt = new PieTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                    ObjectThemeLayer otlPt = new ObjectThemeLayer("PieTheme", alias, pt);
                    GetTheGroupLayer().Insert(0, otlPt);
                    break;
                case ThemeAndModifierTypes.BarTheme:
                    BarTheme bt = new BarTheme(myMap, fLyr.Table, GetThemeOrModifierExpressions());
                    bt.DataValueAtSize = 10000000;
                    bt.Size = new MapInfo.Engine.PaperSize(0.1, 0.1, MapInfo.Geometry.PaperUnit.Inch);
                    bt.Width = new MapInfo.Engine.PaperSize(0.1, MapInfo.Geometry.PaperUnit.Inch);
                    ObjectThemeLayer otlBt = new ObjectThemeLayer("BarTheme", alias, bt);
                    GetTheGroupLayer().Insert(0, otlBt);
                    break;
                case ThemeAndModifierTypes.GraduatedSymbolTheme:
                    GraduatedSymbolTheme gst = new GraduatedSymbolTheme(fLyr.Table, GetThemeOrModifierExpression());
                    ObjectThemeLayer otlGst = new ObjectThemeLayer("GraduatedSymbolTheme", alias, gst);
                    GetTheGroupLayer().Insert(0, otlGst);
                    break;
                case ThemeAndModifierTypes.FeatureOverrideStyleModifier:
                    FeatureOverrideStyleModifier fosm = new FeatureOverrideStyleModifier("OverrideTheme", alias);

                    SimpleInterior fs = new SimpleInterior((SimpleInterior.MaxFillPattern - SimpleInterior.MinFillPattern) / 2, Color.FromArgb(10, 23, 90), Color.FromArgb(33, 35, 35), false);
                    fs.SetApplyAll();
                    SimpleLineStyle lineStyle = new SimpleLineStyle(new LineWidth(2, LineWidthUnit.Point), (SimpleLineStyle.MaxLinePattern - SimpleLineStyle.MinLinePattern) /2);
                    lineStyle.Color = Color.FromArgb(111, 150, 230);
                    lineStyle.Interleaved = false;
                    lineStyle.SetApplyAll();

                    fosm.Style.AreaStyle = new AreaStyle(lineStyle, fs);
                    fLyr.Modifiers.Append(fosm);
                    break;
                case ThemeAndModifierTypes.Label_IndividualValueLabelTheme:
                    IndividualValueLabelTheme ivlt = new IndividualValueLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias);
                    CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(ivlt);
                    break;
                case ThemeAndModifierTypes.Label_RangedLabelTheme:
                    RangedLabelTheme rlt = new RangedLabelTheme(fLyr.Table, GetThemeOrModifierExpression(), alias, 5, DistributionMethod.EqualCountPerRange);
                    CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(rlt);
                    break;
                case ThemeAndModifierTypes.Label_OverrideLabelModifier:
                    OverrideLabelModifier olm = new OverrideLabelModifier(alias, "OverrideLabelModifier");
                    MapInfo.Styles.Font font = new MapInfo.Styles.Font("Arial", 24, Color.Red, Color.Yellow, FontFaceStyle.Italic,
                        FontWeight.Bold, TextEffect.Halo, TextDecoration.All, TextCase.AllCaps, true, true);

                    font.Attributes = StyleAttributes.FontAttributes.All;

                    olm.Properties.Style = new TextStyle(font);
                    olm.Properties.Caption = GetThemeOrModifierExpression();
                    CreateLabelLayer(myMap, fLyr.Table, GetThemeOrModifierExpression()).Sources[0].Modifiers.Append(olm);
                    break;
                default:
                    break;
            }
        }
        // Add an IndividualValueTheme to the specified layer.
        private void DoAddTheme(Map myMap, string layerToTheme, string expression)
        {
            // First obtain a reference to the layer that will own the theme
            FeatureLayer lyr = (FeatureLayer)myMap.Layers[layerToTheme];
            if (lyr == null)
            {
                MessageBox.Show("Layer " + layerToTheme + " not found; theme cannot be added.");
                return;
            }

            IndividualValueTheme ivTheme = null;
            try
            {
                // Create the theme.  Pass null for the theme's alias.
                ivTheme = new IndividualValueTheme(lyr, expression, null);
            }
            catch (System.NullReferenceException)
            {
                // This exception can occur if you specify an expression
                // that is not valid for this layer.
                MessageBox.Show("Unable to create theme; check expression syntax. "
                    + "Layer: " + layerToTheme + ", Expression: " + expression,
                    "Error");
                return;
            }

            // Set the theme's ApplyStylePart property to control which display
            // attributes are overridden by the theme. If you specify StylePart.All:
            //     ivTheme.ApplyStylePart = StylePart.All;
            // the theme will control each country's fill pattern and color.
            // If you specify StylePart.Color, the theme will control each country's
            // color, but will not alter each region's fill pattern.
            // If you have specified a fill pattern using a display style override,
            // and you do not want the individual value theme to interfere with that
            // fill pattern, set ApplyStylePart to StylePart.Color.
            ivTheme.ApplyStylePart = StylePart.Color;

            // Now add the theme to the layer's collection of style modifiers.
            // Insert it at the top of the list of modifiers, so that it will
            // definitely be visible.  (If the layer has other modifiers,
            // such as style overrides, and you append the theme to the
            // bottom of the list, the style overrides might override the theme.)
            lyr.Modifiers.Insert(0, ivTheme);
            MessageBox.Show("Added new IndividualValueTheme to layer " + _layerName
                + " using expression: " + expression,  "Theme Added");
        }