${iServerJava6R_ThemeRange_Title}
${iServerJava6R_ThemeRange_Description}
internal static ThemeRange FromJson(JsonObject json) { if (json == null) return null; ThemeRange themeRange = new ThemeRange(); if (json["items"] != null && json["items"].Count > 0) { List<ThemeRangeItem> itemsList = new List<ThemeRangeItem>(); foreach (JsonObject item in (JsonArray)json["items"]) { itemsList.Add(ThemeRangeItem.FromJson(item)); } themeRange.Items = itemsList; } if (json["colorGradientType"] != null) { themeRange.ColorGradientType = (ColorGradientType)Enum.Parse(typeof(ColorGradientType), json["colorGradientType"], true); } else { //这里不处理为空时的情况 } themeRange.RangeExpression = json["rangeExpression"]; if (json["rangeMode"] != null) { themeRange.RangeMode = (RangeMode)Enum.Parse(typeof(RangeMode), json["rangeMode"], true); } else { //不处理Null的情况 } themeRange.RangeParameter = (double)json["rangeParameter"]; return themeRange; }
private void ThemeRangeButton_Click(object sender, RoutedEventArgs e) { List<ThemeRangeItem> themeRangeItems = new List<ThemeRangeItem> { new ThemeRangeItem { Visible=true, Start=0, End=3058, Caption="A", Style=new ServerStyle { FillForeColor=Colors.Brown } }, new ThemeRangeItem { Visible=true, Start=3058, End=6116, Caption="B", Style=new ServerStyle { FillForeColor=Colors.Green } }, new ThemeRangeItem { Visible=true, Start=6116, End=9175, Caption="C", Style=new ServerStyle { FillForeColor=Colors.Blue } } }; ThemeRange themeRange = new ThemeRange { RangeExpression = "SmPerimeter", RangeMode = RangeMode.EQUALINTERVAL, RangeParameter = 3, Items = themeRangeItems }; ThemeParameters themeRangeParams = new ThemeParameters { DatasetName = "Capitals", DataSourceName = "World", Themes = new List<Theme> { themeRange } }; themeRangeParams.JoinItems.Add(new JoinItem { ForeignTableName = "Countries", JoinFilter = "Capitals.Capital=Countries.Capital", JoinType = JoinType.LEFTJOIN }); ThemeService themeRangeServie = new ThemeService(url); themeRangeServie.ProcessAsync(themeRangeParams); themeRangeServie.Failed += new EventHandler<ServiceFailedEventArgs>(themeRangeServie_Failed); themeRangeServie.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeRangeServie_ProcessCompleted); }
//点击生成专题图触发事件 private void commit_Click(object sender, RoutedEventArgs e) { //设置专题图子项 List<ThemeRangeItem> themeRangeItems = new List<ThemeRangeItem> { new ThemeRangeItem { Start = 0.0, End = 59973, Visible = true, Style = new ServerStyle { FillForeColor = new Color {R=216,G=244,B=254}, LineWidth = 0.1, } }, new ThemeRangeItem { Start = 59973, End = 1097234, Visible = true , Style = new ServerStyle { FillForeColor = new Color {R=131,G=232,B=252}, LineWidth = 0.1 , } }, new ThemeRangeItem { Start = 1097234, End = 5245515, Visible = true , Style = new ServerStyle { FillForeColor = new Color {R=112,G=212,B=243}, LineWidth = 0.1, } }, new ThemeRangeItem { Start = 5245515, End = 17250390, Visible = true, Style = new ServerStyle { FillForeColor = new Color {R=23,G=198,B=238}, LineWidth = 0.1, } }, new ThemeRangeItem { Start = 17250390, End = 894608700, Visible = true, Style = new ServerStyle { FillForeColor = new Color {R=0,G=187,B=236}, LineWidth = 0.1 , } }, new ThemeRangeItem { Start = 894608700, End = 12E+8, Visible = true , Style = new ServerStyle { FillForeColor = new Color {R=0,G=133,B=236}, LineWidth = 0.1 , } } }; //设置范围分段专题图字段、分段模式、分段参数和子项数组 ThemeRange themeRange = new ThemeRange { RangeExpression = "Pop_1994", RangeMode = RangeMode.EQUALINTERVAL, RangeParameter = 6, Items = themeRangeItems }; //设置专题图参数 ThemeParameters themeRangeParams = new ThemeParameters { //数据集名称 DatasetName = "Countries", //数据源名称 DataSourceName = "World", Themes = new List<Theme> { themeRange } }; //与服务器交互 ThemeService themeRangeServie = new ThemeService(url); themeRangeServie.ProcessAsync(themeRangeParams); themeRangeServie.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeRangeServie_ProcessCompleted); themeRangeServie.Failed += new EventHandler<ServiceFailedEventArgs>(themeRangeServie_Failed); }
internal static string ToJson(ThemeRange themeRange) { string json = "{"; List<string> list = new List<string>(); if (themeRange.Items != null && themeRange.Items.Count >= 1) { List<string> tempTUI = new List<string>(); foreach (var item in themeRange.Items) { tempTUI.Add(ThemeRangeItem.ToJson(item)); } list.Add(string.Format("\"items\":[{0}]", String.Join(",", tempTUI.ToArray()))); } else { list.Add("\"items\":[]"); } list.Add(string.Format("\"rangeParameter\":\"{0}\"", themeRange.RangeParameter.ToString(System.Globalization.CultureInfo.InvariantCulture))); list.Add(string.Format("\"rangeMode\":\"{0}\"", themeRange.RangeMode)); list.Add(string.Format("\"colorGradientType\":\"{0}\"", themeRange.ColorGradientType.ToString())); if (!string.IsNullOrEmpty(themeRange.RangeExpression)) { list.Add(string.Format("\"rangeExpression\":\"{0}\"", themeRange.RangeExpression)); } else { list.Add("\"rangeExpression\":\"\""); } if (themeRange.MemoryData != null) { list.Add("\"memoryData\":" + themeRange.ToJson(themeRange.MemoryData)); } else { list.Add("\"memoryData\":null"); } list.Add("\"type\":\"RANGE\""); json += string.Join(",", list.ToArray()); json += "}"; return json; }