Esempio n. 1
0
        public static bool TryParse(string s, out MslMenu control)
        {
            var match = MslControl.ParseRegexItem.Match(s);

            if (!match.Success)
            {
                control = null; return(false);
            }

            control = new MslMenu(match.Groups[2].Value)
            {
                ID     = int.Parse(match.Groups[3].Value),
                Parent = match.Groups[4].Success ? int.Parse(match.Groups[4].Value) : 0
            };
            return(true);
        }
Esempio n. 2
0
        public static bool TryParse(MslDialog dialog, string s, out MslControl control)
        {
            bool result;

            s = s.Trim();
            int space = s.IndexOf(' ');

            if (space == -1)
            {
                control = null; return(false);
            }
            string type = s.Substring(0, space);

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

            return(result);
        }
Esempio n. 3
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 + ".");
        }