internal static ThemeGraduatedSymbol FromJson(JsonObject json) { if (json == null) return null; ThemeGraduatedSymbol graduatedSymbol = new ThemeGraduatedSymbol(); graduatedSymbol.BaseValue = (double)json["baseValue"]; graduatedSymbol.Expression = (string)json["expression"]; graduatedSymbol.Flow = ThemeFlow.FromJson(json); if (json["graduatedMode"] != null) { graduatedSymbol.GraduatedMode = (GraduatedMode)Enum.Parse(typeof(GraduatedMode), json["graduatedMode"], true); } else { //这里不处理为空时的情况 } graduatedSymbol.Offset = ThemeOffset.FromJson(json); graduatedSymbol.Style = ThemeGraduatedSymbolStyle.FromJson((JsonObject)json); return graduatedSymbol; }
//点击生成专题图触发事件 private void commit_Click(object sender, RoutedEventArgs e) { ThemeGraduatedSymbol themeGraduatedSymbol = new ThemeGraduatedSymbol { BaseValue = 1128139680, GraduatedMode = GraduatedMode.SQUAREROOT, Flow = new ThemeFlow { FlowEnabled = true, }, Expression = "Pop_1994", Style = new ThemeGraduatedSymbolStyle { PositiveStyle = new ServerStyle { LineColor = Colors.White, MarkerSize = 20, MarkerSymbolID = 5 } } }; //专题图参数设置 ThemeParameters themeGraduatedSymbolParams = new ThemeParameters { //数据集名称 DatasetName = "Countries", //数据源名称 DataSourceName = "World", Themes = new List<Theme> { themeGraduatedSymbol } }; //与服务器交互 ThemeService themeGraduatedSymbolService = new ThemeService(url); themeGraduatedSymbolService.ProcessAsync(themeGraduatedSymbolParams); themeGraduatedSymbolService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeGraduatedSymbolService_ProcessCompleted); themeGraduatedSymbolService.Failed += new EventHandler<ServiceFailedEventArgs>(themeGraduatedSymbolService_Failed); }
private void ThemeGraduatedSymbolButton_Click(object sender, RoutedEventArgs e) { ThemeGraduatedSymbol themeGraduatedSymbol = new ThemeGraduatedSymbol { Style = new ThemeGraduatedSymbolStyle { NegativeDisplayed = false, ZeroDisplayed = false, PositiveStyle = new ServerStyle { LineColor = Colors.Red, MarkerSize = 50, MarkerSymbolID = 15 }, }, BaseValue = 1128139680, GraduatedMode = GraduatedMode.SQUAREROOT, Flow = new ThemeFlow { FlowEnabled = true, }, Expression = "Pop_1994", }; ThemeParameters themeGraduatedSymbolParams = new ThemeParameters { DatasetName = "World", DataSourceName = "World", Themes = new List<Theme> { themeGraduatedSymbol } }; ThemeService themeGraduatedSymbolService = new ThemeService(url); themeGraduatedSymbolService.ProcessAsync(themeGraduatedSymbolParams); themeGraduatedSymbolService.ProcessCompleted += new EventHandler<ThemeEventArgs>(themeGraduatedSymbolService_ProcessCompleted); themeGraduatedSymbolService.Failed += new EventHandler<ServiceFailedEventArgs>(themeGraduatedSymbolService_Failed); }
internal static string ToJson(ThemeGraduatedSymbol graduatedSymbolTheme) { string json = "{"; List<string> list = new List<string>(); list.Add(string.Format("\"baseValue\":{0}", graduatedSymbolTheme.BaseValue.ToString(System.Globalization.CultureInfo.InvariantCulture))); if (!string.IsNullOrEmpty(graduatedSymbolTheme.Expression)) { list.Add(string.Format("\"expression\":\"{0}\"", graduatedSymbolTheme.Expression)); } else { list.Add("\"expression\":\"\""); } list.Add(string.Format("\"graduatedMode\":\"{0}\"", graduatedSymbolTheme.GraduatedMode.ToString())); if (graduatedSymbolTheme.Offset != null) { list.Add(ThemeOffset.ToJson(graduatedSymbolTheme.Offset)); } else { list.Add("\"offsetX\":\"\""); list.Add("\"offsetY\":\"\""); } if (graduatedSymbolTheme.Style != null) { list.Add(ThemeGraduatedSymbolStyle.ToJson(graduatedSymbolTheme.Style)); } else { list.Add(string.Format("\"positiveStyle\":{0}", ServerStyle.ToJson(new ServerStyle()))); list.Add(string.Format("\"negativeStyle\":{0}", ServerStyle.ToJson(new ServerStyle()))); list.Add(string.Format("\"zeroStyle\":{0}", ServerStyle.ToJson(new ServerStyle()))); } if (graduatedSymbolTheme.Flow != null) { list.Add(ThemeFlow.ToJson(graduatedSymbolTheme.Flow)); } else { list.Add(string.Format("\"leaderLineStyle\":{0}", ServerStyle.ToJson(new ServerStyle()))); } if (graduatedSymbolTheme.MemoryData != null) { list.Add("\"memoryData\":" + graduatedSymbolTheme.ToJson(graduatedSymbolTheme.MemoryData)); } else { list.Add("\"memoryData\":null"); } list.Add("\"type\":\"GRADUATEDSYMBOL\""); json += string.Join(",", list.ToArray()); json += "}"; return json; }