Ejemplo n.º 1
0
        public static MslControl Parse(MslDialog dialog, string s)
        {
            s = s.Trim();
            int space = s.IndexOf(' ');

            if (space == -1)
            {
                throw new FormatException("Invalid code: missing ID.");
            }
            string type = s.Substring(0, space);

            if (type.Equals("text", StringComparison.OrdinalIgnoreCase))
            {
                return(MslText.Parse(dialog, s));
            }
            if (type.Equals("edit", StringComparison.OrdinalIgnoreCase))
            {
                return(MslEdit.Parse(dialog, s));
            }
            if (type.Equals("button", StringComparison.OrdinalIgnoreCase))
            {
                return(MslButton.Parse(dialog, s));
            }
            if (type.Equals("check", StringComparison.OrdinalIgnoreCase))
            {
                return(MslCheck.Parse(dialog, s));
            }
            if (type.Equals("radio", StringComparison.OrdinalIgnoreCase))
            {
                return(MslRadio.Parse(dialog, s));
            }
            if (type.Equals("box", StringComparison.OrdinalIgnoreCase))
            {
                return(MslBox.Parse(dialog, s));
            }
            if (type.Equals("scroll", StringComparison.OrdinalIgnoreCase))
            {
                return(MslScroll.Parse(dialog, s));
            }
            if (type.Equals("list", StringComparison.OrdinalIgnoreCase))
            {
                return(MslList.Parse(dialog, s));
            }
            if (type.Equals("combo", StringComparison.OrdinalIgnoreCase))
            {
                return(MslCombo.Parse(dialog, s));
            }
            if (type.Equals("icon", StringComparison.OrdinalIgnoreCase))
            {
                return(MslIcon.Parse(dialog, s));
            }
            if (type.Equals("link", StringComparison.OrdinalIgnoreCase))
            {
                return(MslLink.Parse(dialog, s));
            }
            if (type.Equals("tab", StringComparison.OrdinalIgnoreCase))
            {
                return(MslTab.Parse(dialog, s));
            }
            if (type.Equals("menu", StringComparison.OrdinalIgnoreCase))
            {
                return(MslMenu.Parse(s));
            }
            if (type.Equals("item", StringComparison.OrdinalIgnoreCase))
            {
                return(MslMenu.MslItem.Parse(s));
            }

            throw new FormatException("Invalid code: no such control type as '" + type + ".");
        }