示例#1
0
            public static bool TryParse(MslDialog dialog, string s, out MslEdit control)
            {
                var match = MslControl.ParseRegex.Match(s);

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

                control = new MslEdit(dialog, int.Parse(match.Groups[4].Value), int.Parse(match.Groups[5].Value), int.Parse(match.Groups[6].Value), int.Parse(match.Groups[7].Value), match.Groups[2].Value, match.Groups[8].Value)
                {
                    ID = int.Parse(match.Groups[3].Value)
                };
                return(true);
            }
示例#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);
        }
示例#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 + ".");
        }