예제 #1
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;
            }
        }
예제 #2
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)
     {
     }
 }
예제 #3
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;
            }
        }