Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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;
            }
        }
Exemplo n.º 4
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;
            }
        }