protected override void OnPreRender(EventArgs e) { if (!IsPostBack) { string[] colAlias = SampleConstants.BoundDataColumns; ArrayList ThemeList = new ArrayList(); ThemesAndModifiers.FillThemeNames(ThemeList); DropDownList1.Items.Clear(); DropDownList1.DataSource = ThemeList; DropDownList1.DataBind(); // Prepare CheckBoxes, RadioButtons and note label contents. CheckBoxList1.DataSource = colAlias; CheckBoxList1.DataBind(); CheckBoxList1.Visible = this.IsCheckBoxListVisible(ThemeList[0] as string); RadioButtonList1.DataSource = colAlias; RadioButtonList1.DataBind(); RadioButtonList1.Visible = this.IsRadioButtonListVisible(ThemeList[0] as string); Label2.Visible = this.IsNoteLabelVisible(ThemeList[0] as string); Label2.Text = "Please select two columns from below checkboxes."; DropDownList1.Items.Clear(); DropDownList1.DataSource = ThemeList; DropDownList1.DataBind(); } }
// Decide if the note message should be displayed or not. private bool IsNoteLabelVisible(string themeName) { ThemeAndModifierTypes themeType = ThemesAndModifiers.GetThemeAndModifierTypesByName(themeName); switch (themeType) { case ThemeAndModifierTypes.BarTheme: case ThemeAndModifierTypes.PieTheme: return(true); } return(false); }
// Decide if the RadioButtonListVisible should be visible or not. private bool IsRadioButtonListVisible(string themeName) { ThemeAndModifierTypes themeType = ThemesAndModifiers.GetThemeAndModifierTypesByName(themeName); switch (themeType) { case ThemeAndModifierTypes.RangedTheme: case ThemeAndModifierTypes.IndividualValueTheme: case ThemeAndModifierTypes.DotDensityTheme: case ThemeAndModifierTypes.GraduatedSymbolTheme: case ThemeAndModifierTypes.Label_IndividualValueLabelTheme: case ThemeAndModifierTypes.Label_RangedLabelTheme: case ThemeAndModifierTypes.Label_OverrideLabelModifier: return(true); } return(false); }
// Validate user's inputs. private bool ValidateThemeAndModifierParams(string themeName) { ThemeAndModifierTypes themeType = ThemesAndModifiers.GetThemeAndModifierTypesByName(themeName); switch (themeType) { case ThemeAndModifierTypes.RangedTheme: case ThemeAndModifierTypes.IndividualValueTheme: case ThemeAndModifierTypes.DotDensityTheme: case ThemeAndModifierTypes.GraduatedSymbolTheme: case ThemeAndModifierTypes.Label_IndividualValueLabelTheme: case ThemeAndModifierTypes.Label_RangedLabelTheme: case ThemeAndModifierTypes.Label_OverrideLabelModifier: // Need to select one column, otherwise we can not proceed it. if (RadioButtonList1.SelectedItem == null) { return(false); } return(true); case ThemeAndModifierTypes.BarTheme: case ThemeAndModifierTypes.PieTheme: // Need to select two columns. int selectedItemsSum = 0; // this is required to customer to select 2 cols. for (int index = 0; index < CheckBoxList1.Items.Count; index++) { if (CheckBoxList1.Items[index].Selected) { selectedItemsSum++; } } if (selectedItemsSum != 2) { return(false); } return(true); case ThemeAndModifierTypes.FeatureOverrideStyleModifier: return(true); } return(false); }
// 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; } }