${REST_ThemeFlow_Title}

${REST_ThemeFlow_Description}

コード例 #1
0
        internal static ThemeFlow FromJson(JsonObject json)
        {
            if (json == null) return null;
            ThemeFlow flow = new ThemeFlow();

            flow.FlowEnabled = json["flowEnabled"].GetBooleanEx();
            flow.LeaderLineDisplayed = json["leaderLineDisplayed"].GetBooleanEx();
            if (json["leaderLineStyle"] != null)
            {
                flow.LeaderLineStyle = ServerStyle.FromJson(json["leaderLineStyle"].GetObjectEx());
            }
            return flow;
        }
コード例 #2
0
        internal static string ToJson(ThemeFlow flowTheme)
        {
            string json = "";
            List<string> list = new List<string>();

            if (flowTheme.LeaderLineStyle != null)
            {
                list.Add(string.Format("\"leaderLineStyle\":{0}", ServerStyle.ToJson(flowTheme.LeaderLineStyle)));
            }
            else
            {
                list.Add(string.Format("\"leaderLineStyle\":{0}", ServerStyle.ToJson(new ServerStyle())));
            }

            list.Add(string.Format("\"flowEnabled\":{0}", flowTheme.FlowEnabled.ToString().ToLower()));
            list.Add(string.Format("\"leaderLineDisplayed\":{0}", flowTheme.LeaderLineDisplayed.ToString().ToLower()));

            json = string.Join(",", list.ToArray());
            return json;
        }
コード例 #3
0
        internal static ThemeLabel FromJson(JsonObject json)
        {
            if (json == null) return null;
            ThemeLabel themeLabel = new ThemeLabel();

            ThemeLabelAlongLine alongLine = new ThemeLabelAlongLine();
            if (json["alongLineDirection"] != null)
            {
                alongLine.AlongLineDirection = (AlongLineDirection)Enum.Parse(typeof(AlongLineDirection), json["alongLineDirection"].GetStringEx(), true);
            }
            else
            {
                //不处理null的情况
            }
            alongLine.AngleFixed = json["angleFixed"].GetBooleanEx();
            alongLine.IsAlongLine = json["alongLine"].GetBooleanEx();
            alongLine.LabelRepeatInterval = json["labelRepeatInterval"].GetNumberEx();
            alongLine.RepeatedLabelAvoided = json["repeatedLabelAvoided"].GetBooleanEx();
            alongLine.RepeatIntervalFixed = json["repeatIntervalFixed"].GetBooleanEx();
            themeLabel.AlongLine = alongLine;

            ThemeLabelBackSetting backSetting = new ThemeLabelBackSetting();
            if (json["backStyle"] != null)
            {
                backSetting.BackStyle = ServerStyle.FromJson(json["backStyle"].GetObjectEx());
            }
            if (json["labelBackShape"] != null)
            {
                backSetting.LabelBackShape = (LabelBackShape)Enum.Parse(typeof(LabelBackShape), json["labelBackShape"].GetStringEx(), true);
            }
            else
            {
                //不处理null的情况
            }

            themeLabel.BackSetting = backSetting;

            ThemeFlow flow = new ThemeFlow();
            flow.FlowEnabled = json["flowEnabled"].GetBooleanEx();
            flow.LeaderLineDisplayed = json["leaderLineDisplayed"].GetBooleanEx();
            if (json["leaderLineStyle"] != null)
            {
                flow.LeaderLineStyle = ServerStyle.FromJson(json["leaderLineStyle"].GetObjectEx());
            }
            themeLabel.Flow = flow;

            List<ThemeLabelItem> items = new List<ThemeLabelItem>();
            if (json["items"].ValueType != JsonValueType.Null && json["items"].GetArray().Count > 0)
            {
                for (int i = 0; i < json["items"].GetArray().Count; i++)
                {
                    items.Add(ThemeLabelItem.FromJson(json["items"].GetArray()[i].GetObjectEx()));
                }
            }
            themeLabel.Items = items;

            themeLabel.LabelExpression = json["labelExpression"].GetStringEx();
            if (json["labelOverLengthMode"].ValueType != JsonValueType.Null)
            {
                themeLabel.LabelOverLengthMode = (LabelOverLengthMode)Enum.Parse(typeof(LabelOverLengthMode), json["labelOverLengthMode"].GetStringEx(), true);
            }
            else
            {
                //不处理null的情况
            }

            //themeLabel.MatrixCells
            if (json["matrixCells"].ValueType != JsonValueType.Null)
            {
                int rowCount = (json["matrixCells"].GetArray()).Count;
                int columnCount = ((json["matrixCells"].GetArray())[0].GetArray()).Count;
                LabelMatrixCell[,] matrixCells = new LabelMatrixCell[columnCount, rowCount];

                for (int column = 0; column < (json["matrixCells"].GetArray()).Count; column++)
                {
                    JsonArray cells = (json["matrixCells"].GetArray())[column].GetArray();
                    for (int row = 0; row < cells.Count; row++)
                    {
                        if (cells[row].GetObjectEx().ContainsKey("height") && cells[row].GetObjectEx().ContainsKey("pathField") && cells[row].GetObjectEx().ContainsKey("rotation") && cells[row].GetObjectEx().ContainsKey("sizeFixed") && cells[row].GetObjectEx().ContainsKey("width"))
                        {
                            matrixCells[row, column] = (LabelImageCell.FromJson(cells[row].GetObjectEx()));
                        }
                        else if (cells[row].GetObjectEx().ContainsKey("style") && cells[row].GetObjectEx().ContainsKey("symbolIDField"))
                        {
                            matrixCells[row, column] = (LabelSymbolCell.FromJson(cells[row].GetObjectEx()));
                        }
                        else if (cells[row].GetObjectEx().ContainsKey("themeLabel"))
                        {
                            matrixCells[row, column] = (LabelThemeCell.FromJson(cells[row].GetObjectEx()["themeLabel"].GetObjectEx()));
                        }
                    }
                }

                themeLabel.MatrixCells = matrixCells;
            }
            themeLabel.MaxLabelLength = (int)json["maxLabelLength"].GetNumberEx();
            themeLabel.NumericPrecision = (int)json["numericPrecision"].GetNumberEx();
            themeLabel.Offset = ThemeOffset.FromJson(json);
            themeLabel.OverlapAvoided = json["overlapAvoided"].GetBooleanEx();
            themeLabel.RangeExpression = json["rangeExpression"].GetStringEx();
            themeLabel.SmallGeometryLabeled = json["smallGeometryLabeled"].GetBooleanEx();
            themeLabel.Text = ThemeLabelText.FromJson(json);
            return themeLabel;
        }