Exemplo n.º 1
0
        static private string MakeEntry(string instr, out Entry entry, ref System.Drawing.Point lastpos)
        {
            entry = null;

            BaseUtils.StringParser sp = new BaseUtils.StringParser(instr);

            string name = sp.NextQuotedWordComma();

            if (name == null)
            {
                return("Missing name");
            }

            string type = sp.NextWordComma(lowercase: true);

            Type ctype = null;

            if (type == null)
            {
                return("Missing type");
            }
            else if (type.Equals("button"))
            {
                ctype = typeof(ExtendedControls.ButtonExt);
            }
            else if (type.Equals("textbox"))
            {
                ctype = typeof(ExtendedControls.TextBoxBorder);
            }
            else if (type.Equals("checkbox"))
            {
                ctype = typeof(ExtendedControls.CheckBoxCustom);
            }
            else if (type.Equals("label"))
            {
                ctype = typeof(System.Windows.Forms.Label);
            }
            else if (type.Equals("combobox"))
            {
                ctype = typeof(ExtendedControls.ComboBoxCustom);
            }
            else if (type.Equals("datetime"))
            {
                ctype = typeof(ExtendedControls.CustomDateTimePicker);
            }
            else if (type.Equals("numberboxlong"))
            {
                ctype = typeof(ExtendedControls.NumberBoxLong);
            }
            else if (type.Equals("numberboxdouble"))
            {
                ctype = typeof(ExtendedControls.NumberBoxDouble);
            }
            else
            {
                return("Unknown control type " + type);
            }

            string text = sp.NextQuotedWordComma();     // normally text..

            if (text == null)
            {
                return("Missing text");
            }

            int?x = sp.NextWordComma().InvariantParseIntNullOffset(lastpos.X);
            int?y = sp.NextWordComma().InvariantParseIntNullOffset(lastpos.Y);
            int?w = sp.NextWordComma().InvariantParseIntNull();
            int?h = sp.NextWordComma().InvariantParseIntNull();

            if (x == null || y == null || w == null || h == null)
            {
                return("Missing position/size");
            }

            string tip = sp.NextQuotedWordComma();      // tip can be null

            entry = new ConfigurableForm.Entry(name, ctype,
                                               text, new System.Drawing.Point(x.Value, y.Value), new System.Drawing.Size(w.Value, h.Value), tip);

            if (type.Contains("textbox") && tip != null)
            {
                int?v = sp.NextWordComma().InvariantParseIntNull();
                entry.textboxmultiline = v.HasValue && v.Value != 0;
            }

            if (type.Contains("checkbox") && tip != null)
            {
                int?v = sp.NextWordComma().InvariantParseIntNull();
                entry.checkboxchecked = v.HasValue && v.Value != 0;

                v = sp.NextWordComma().InvariantParseIntNull();
                entry.clearonfirstchar = v.HasValue && v.Value != 0;
            }

            if (type.Contains("combobox"))
            {
                entry.comboboxitems = sp.LineLeft.Trim();
                if (tip == null || entry.comboboxitems.Length == 0)
                {
                    return("Missing paramters for combobox");
                }
            }

            if (type.Contains("datetime"))
            {
                entry.customdateformat = sp.NextWord();
            }

            if (type.Contains("numberboxdouble"))
            {
                double?min = sp.NextWordComma().InvariantParseDoubleNull();
                double?max = sp.NextWordComma().InvariantParseDoubleNull();
                entry.numberboxdoubleminimum = min.HasValue ? min.Value : double.MinValue;
                entry.numberboxdoublemaximum = max.HasValue ? max.Value : double.MaxValue;
                entry.numberboxformat        = sp.NextWordComma();
            }

            if (type.Contains("numberboxlong"))
            {
                long?min = sp.NextWordComma().InvariantParseLongNull();
                long?max = sp.NextWordComma().InvariantParseLongNull();
                entry.numberboxlongminimum = min.HasValue ? min.Value : long.MinValue;
                entry.numberboxlongmaximum = max.HasValue ? max.Value : long.MaxValue;
                entry.numberboxformat      = sp.NextWordComma();
            }

            lastpos = new System.Drawing.Point(x.Value, y.Value);
            return(null);
        }
Exemplo n.º 2
0
        static public string MakeEntry(string instr, out Entry entry, ref System.Drawing.Point lastpos)
        {
            entry = null;

            BaseUtils.StringParser sp = new BaseUtils.StringParser(instr);

            string name = sp.NextQuotedWordComma();

            if (name == null)
            {
                return("Missing name");
            }

            string type = sp.NextWordComma(lowercase: true);

            Type ctype = null;

            if (type == null)
            {
                return("Missing type");
            }
            else if (type.Equals("button"))
            {
                ctype = typeof(ExtendedControls.ButtonExt);
            }
            else if (type.Equals("textbox"))
            {
                ctype = typeof(ExtendedControls.TextBoxBorder);
            }
            else if (type.Equals("checkbox"))
            {
                ctype = typeof(ExtendedControls.CheckBoxCustom);
            }
            else if (type.Equals("label"))
            {
                ctype = typeof(System.Windows.Forms.Label);
            }
            else if (type.Equals("combobox"))
            {
                ctype = typeof(ExtendedControls.ComboBoxCustom);
            }
            else
            {
                return("Unknown control type " + type);
            }

            string text = sp.NextQuotedWordComma();

            if (text == null)
            {
                return("Missing text");
            }

            int?x = sp.NextWordComma().InvariantParseIntNullOffset(lastpos.X);
            int?y = sp.NextWordComma().InvariantParseIntNullOffset(lastpos.Y);
            int?w = sp.NextWordComma().InvariantParseIntNull();
            int?h = sp.NextWordComma().InvariantParseIntNull();

            if (x == null || y == null || w == null || h == null)
            {
                return("Missing position/size");
            }

            string tip = sp.NextQuotedWordComma();      // tip can be null

            entry = new ConfigurableForm.Entry(name, ctype,
                                               text, new System.Drawing.Point(x.Value, y.Value), new System.Drawing.Size(w.Value, h.Value), tip);

            if (type.Contains("textbox") && tip != null)
            {
                int?v = sp.NextWordComma().InvariantParseIntNull();
                entry.textboxmultiline = v.HasValue && v.Value != 0;
            }

            if (type.Contains("checkbox") && tip != null)
            {
                int?v = sp.NextWordComma().InvariantParseIntNull();
                entry.checkboxchecked = v.HasValue && v.Value != 0;
            }

            if (type.Contains("combobox"))
            {
                entry.comboboxitems = sp.LineLeft.Trim();
                if (tip == null || entry.comboboxitems.Length == 0)
                {
                    return("Missing paramters for combobox");
                }
            }

            lastpos = new System.Drawing.Point(x.Value, y.Value);
            return(null);
        }