示例#1
0
        private void parseButtonElement(String currentActivityName)
        {
            ButtonElement buttonElement = new ButtonElement();

            while (!reader.TokenType.ToString().Equals("EndObject"))
            {
                reader.Read();
                object value = reader.Value;
                if (value != null)
                {
                    if (reader.TokenType.ToString().Equals("PropertyName"))
                    {
                        if (value.Equals("id"))
                        {
                            reader.Read();
                            String id = reader.Value.ToString();
                            buttonElement.setId(id);
                            string target = "";
                            if (linksDictionary.TryGetValue(id, out target))
                            {
                                JObject targetObj = targetsDictionary[target];
                                switch (targetObj.GetValue("type").ToString())
                                {
                                    case "NavigationService":
                                        buttonElement.addOnClickTransition(currentActivityName,
                                            targetObj.GetValue("activity").ToString());
                                        break;
                                    case "GeolocationService":
                                        string map = "";
                                        if (linksDictionary.TryGetValue(target, out map))
                                        {
                                            buttonElement.addOnClickActions(
                                                String.Format("getLocation{0}();", map));
                                        }
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                        if (value.Equals("text"))
                        {
                            reader.Read();
                            buttonElement.addXmlAttr("text", reader.Value.ToString());
                        }
                        if (value.Equals("inline"))
                        {
                            reader.Read();
                            if (!(Boolean)reader.Value)
                            {
                                if (isNowInline)
                                {
                                    writeAndClearInline();
                                }
                                buttonElement.addXmlAttr("layout_width", "match_parent");
                            }
                            else
                            {
                                if (!isNowInline)
                                {
                                    inlineLayout = new InlineLayoutElement();
                                    isNowInline = true;
                                }
                                buttonElement.addXmlAttr("layout_width", "wrap_content");
                                buttonElement.addXmlAttr("layout_marginLeft", "2dp");
                                buttonElement.addXmlAttr("layout_marginRight", "2dp");
                            }
                        }
                        if (value.Equals("corners"))
                        {
                            reader.Read();
                            buttonElement.setRoundValue((Boolean)reader.Value);
                        }
                        if (value.Equals("mini"))
                        {
                            reader.Read();
                            if (!(Boolean)reader.Value)
                            {
                                buttonElement.addXmlAttr("layout_height", "wrap_content");
                            }
                            else
                            {
                                buttonElement.addXmlAttr("layout_height", "28dp");
                                buttonElement.addXmlAttr("textSize", "11sp");
                            }
                        }
                        if (value.Equals("theme"))
                        {
                            reader.Read();
                            buttonElement.setTheme(reader.Value.ToString());
                        }
                    }
                }
            }

            if (isNowInline)
            {
                inlineLayout.addElement(buttonElement.getXml());
            }
            else
            {
                layoutBuilder.addElementToBody(buttonElement.getXml());
            }
            activityBuider.addActionsToOnCreate(buttonElement.getOnCreateActions());
            activityBuider.addImports(buttonElement.getImports());
            activityBuider.addMethods(buttonElement.getOnClickSrc());
        }
示例#2
0
        private void parseButtonElement(String currentActivityName)
        {
            ButtonElement buttonElement = new ButtonElement();

            while (!reader.TokenType.ToString().Equals("EndObject"))
            {
                reader.Read();
                object value = reader.Value;
                if (value != null)
                {
                    if (reader.TokenType.ToString().Equals("PropertyName"))
                    {
                        if (value.Equals("id"))
                        {
                            reader.Read();
                            String id = reader.Value.ToString();
                            buttonElement.setId(id);
                            string target = "";
                            if (linksDictionary.TryGetValue(id, out target))
                            {
                                JObject targetObj = targetsDictionary[target];
                                switch (targetObj.GetValue("type").ToString())
                                {
                                case "NavigationService":
                                    buttonElement.addOnClickTransition(currentActivityName,
                                                                       targetObj.GetValue("activity").ToString());
                                    break;

                                case "GeolocationService":
                                    string map = "";
                                    if (linksDictionary.TryGetValue(target, out map))
                                    {
                                        buttonElement.addOnClickActions(
                                            String.Format("getLocation{0}();", map));
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                        if (value.Equals("text"))
                        {
                            reader.Read();
                            buttonElement.addXmlAttr("text", reader.Value.ToString());
                        }
                        if (value.Equals("inline"))
                        {
                            reader.Read();
                            if (!(Boolean)reader.Value)
                            {
                                if (isNowInline)
                                {
                                    writeAndClearInline();
                                }
                                buttonElement.addXmlAttr("layout_width", "match_parent");
                            }
                            else
                            {
                                if (!isNowInline)
                                {
                                    inlineLayout = new InlineLayoutElement();
                                    isNowInline  = true;
                                }
                                buttonElement.addXmlAttr("layout_width", "wrap_content");
                                buttonElement.addXmlAttr("layout_marginLeft", "2dp");
                                buttonElement.addXmlAttr("layout_marginRight", "2dp");
                            }
                        }
                        if (value.Equals("corners"))
                        {
                            reader.Read();
                            buttonElement.setRoundValue((Boolean)reader.Value);
                        }
                        if (value.Equals("mini"))
                        {
                            reader.Read();
                            if (!(Boolean)reader.Value)
                            {
                                buttonElement.addXmlAttr("layout_height", "wrap_content");
                            }
                            else
                            {
                                buttonElement.addXmlAttr("layout_height", "28dp");
                                buttonElement.addXmlAttr("textSize", "11sp");
                            }
                        }
                        if (value.Equals("theme"))
                        {
                            reader.Read();
                            buttonElement.setTheme(reader.Value.ToString());
                        }
                    }
                }
            }

            if (isNowInline)
            {
                inlineLayout.addElement(buttonElement.getXml());
            }
            else
            {
                layoutBuilder.addElementToBody(buttonElement.getXml());
            }
            activityBuider.addActionsToOnCreate(buttonElement.getOnCreateActions());
            activityBuider.addImports(buttonElement.getImports());
            activityBuider.addMethods(buttonElement.getOnClickSrc());
        }