Esempio n. 1
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string res;

            if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed)
            {
                BaseUtils.StringParser sp = new BaseUtils.StringParser(res);

                string nextcmd = sp.NextWordLCInvariant(" ");

                if (nextcmd == null)
                {
                    ap.ReportError("Missing command in ProgramWindow");
                }
                else if (nextcmd.Equals("tab") || nextcmd.Equals("opentab") || nextcmd.Equals("closetab"))
                {
                    string tabname = sp.NextQuotedWord(lowercase: System.Globalization.CultureInfo.InvariantCulture, replaceescape: true);

                    if (!(ap.ActionController as ActionController).DiscoveryForm.SelectTabPage(tabname, nextcmd.Equals("opentab"), nextcmd.Equals("closetab")))
                    {
                        ap.ReportError("Tab page name " + tabname + " not found");
                    }
                }
                else if (nextcmd.Equals("topmost"))
                {
                    (ap.ActionController as ActionController).DiscoveryForm.TopMost = true;
                }
                else if (nextcmd.Equals("normalz"))
                {
                    (ap.ActionController as ActionController).DiscoveryForm.TopMost = false;
                }
                else if (nextcmd.Equals("showintaskbar"))
                {
                    (ap.ActionController as ActionController).DiscoveryForm.ShowInTaskbar = true;
                }
                else if (nextcmd.Equals("notshowintaskbar"))
                {
                    (ap.ActionController as ActionController).DiscoveryForm.ShowInTaskbar = false;
                }
                else if (nextcmd.Equals("minimize"))
                {
                    (ap.ActionController as ActionController).DiscoveryForm.WindowState = FormWindowState.Minimized;
                }
                else if (nextcmd.Equals("normal"))
                {
                    (ap.ActionController as ActionController).DiscoveryForm.WindowState = FormWindowState.Normal;
                }
                else if (nextcmd.Equals("maximize"))
                {
                    (ap.ActionController as ActionController).DiscoveryForm.WindowState = FormWindowState.Maximized;
                }
                else if (nextcmd.Equals("location"))
                {
                    int?x = sp.NextWordComma().InvariantParseIntNull();
                    int?y = sp.NextWordComma().InvariantParseIntNull();
                    int?w = sp.NextWordComma().InvariantParseIntNull();
                    int?h = sp.NextWord().InvariantParseIntNull();

                    if (x.HasValue && y.HasValue && w.HasValue && h.HasValue)
                    {
                        (ap.ActionController as ActionController).DiscoveryForm.Location = new Point(x.Value, y.Value);
                        (ap.ActionController as ActionController).DiscoveryForm.Size     = new Size(w.Value, h.Value);
                    }
                    else
                    {
                        ap.ReportError("Location needs x,y,w,h in Popout");
                    }
                }
                else if (nextcmd.Equals("position"))
                {
                    int?x = sp.NextWordComma().InvariantParseIntNull();
                    int?y = sp.NextWord().InvariantParseIntNull();

                    if (x.HasValue && y.HasValue)
                    {
                        (ap.ActionController as ActionController).DiscoveryForm.Location = new Point(x.Value, y.Value);
                    }
                    else
                    {
                        ap.ReportError("Position needs x,y in Popout");
                    }
                }
                else if (nextcmd.Equals("size"))
                {
                    int?w = sp.NextWordComma().InvariantParseIntNull();
                    int?h = sp.NextWord().InvariantParseIntNull();

                    if (w.HasValue && h.HasValue)
                    {
                        (ap.ActionController as ActionController).DiscoveryForm.Size = new Size(w.Value, h.Value);
                    }
                    else
                    {
                        ap.ReportError("Size needs x,y,w,h in Popout");
                    }
                }
                else
                {
                    ap.ReportError("Unknown command " + nextcmd + " in Popout");
                }
            }
            else
            {
                ap.ReportError(res);
            }

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