Ejemplo n.º 1
0
        public ActionProgramRun(ActionFile af,                      // associated file
                                ActionProgram r,                    // the program
                                ConditionVariables iparas,          // input variables to the program only.. not globals
                                ActionRun runner,                   // who is running it..
                                ActionController ed) : base(r.Name) // allow a pause
        {
            actionfile           = af;
            actionrun            = runner;
            actioncontroller     = ed;
            execlevel            = 0;
            execstate[execlevel] = ExecState.On;
            nextstepnumber       = 0;

            System.Diagnostics.Debug.WriteLine("Run " + actionfile.name + "::" + r.Name);
            //ActionData.DumpVars(gvars, " Func Var:");

            inputvars = iparas;             // current vars is set up by ActionRun at the point of invokation to have the latests globals

            List <Action> psteps = new List <Action>();
            Action        ac;

            for (int i = 0; (ac = r.GetStep(i)) != null; i++)
            {
                psteps.Add(Action.CreateCopy(ac));
            }

            programsteps = psteps;
        }
Ejemplo n.º 2
0
        void LoadProgram(ActionProgram prog)
        {
            foreach (Group g in groups)
            {
                g.panel.Controls.Clear();
                panelVScroll.Controls.Remove(g.panel);
            }

            groups.Clear();

            curprog = new ActionProgram(prog.Name);

            initialprogname = textBoxBorderName.Text = prog.Name;

            SuspendLayout();
            panelVScroll.SuspendLayout();

            Action ac;
            int    step = 0;

            while ((ac = prog.GetStep(step)) != null)
            {
                Action ca = Action.CreateCopy(ac);// COPY it.. so we can modify without altering current
                curprog.Add(ca);
                CreateStep(-1, ca);
                step++;
            }

            RepositionGroups();
            panelVScroll.ResumeLayout();
            ResumeLayout();
        }
Ejemplo n.º 3
0
        string RepositionGroups(bool calcminsize = true)
        {
            SuspendLayout();
            panelVScroll.SuspendLayout();

            string errlist = curprog.CalculateLevels();

            int panelwidth = Math.Max(panelVScroll.Width - panelVScroll.ScrollBarWidth, 10);
            int voff       = panelheightmargin;
            int actstep    = 0;

            toolTip1.RemoveAll();

            foreach (Group g in groups)
            {
                int    indentlevel = 0;
                int    whitespace  = 0;
                int    lineno      = 0;
                Action act         = curprog.GetStep(actstep++);

                if (act != null)
                {
                    System.Diagnostics.Debug.Assert(Object.ReferenceEquals(g.checkit, act));
                    g.left.Enabled   = act.calcAllowLeft;
                    g.right.Enabled  = act.calcAllowRight;
                    indentlevel      = act.calcDisplayLevel;
                    whitespace       = act.Whitespace;
                    lineno           = act.LineNumber;
                    g.prog.Visible   = act.Type == Action.ActionType.Call & EditProgram != null;
                    g.config.Visible = act.ConfigurationMenuInUse;
                }
                else
                {
                    g.left.Enabled   = g.right.Enabled = false;
                    g.prog.Visible   = false;
                    g.config.Visible = false;
                }

                g.panel.SuspendLayout();

                g.panel.Location    = new Point(panelleftmargin, voff + panelVScroll.ScrollOffset);
                g.panel.Size        = new Size(panelwidth, panelheight + ((whitespace > 0) ? (panelheight / 2) : 0));
                g.stepname.Location = new Point(g.right.Right + 8 + 8 * indentlevel, panelheightmargin);
                g.stepname.Size     = new Size(140 - Math.Max((indentlevel - 4) * 8, 0), controlsize);
                g.value.Location    = new Point(g.right.Right + 140 + 8 + 8 * 4 + 8, panelheightmargin * 2);  // 8 spacing, allow 8*4 to indent
                int valuewidth = panelwidth - 350;
                g.value.Size      = new Size(valuewidth, controlsize);
                g.config.Location = new Point(g.value.Right + 4, panelheightmargin);      // 8 spacing, allow 8*4 to indent
                g.up.Location     = new Point(g.config.Right + 4, panelheightmargin);
                g.prog.Location   = new Point(g.up.Right + 4, panelheightmargin);
                g.up.Visible      = groups.IndexOf(g) > 0;

                g.panel.ResumeLayout();

                string tt1 = "Step " + actstep;
                if (indentlevel > 0)
                {
                    tt1 += " Lv " + indentlevel;
                }
                if (lineno > 0)
                {
                    tt1 += " Ln " + lineno;
                }
                if (act != null)
                {
                    tt1 += " SL " + act.calcStructLevel + " LU" + act.LevelUp;
                }

                toolTip1.SetToolTip(g.stepname, tt1);
                toolTip1.SetToolTip(g.stepname.GetInternalSystemControl, tt1);
                if (act != null && act.Comment.Length > 0)
                {
                    toolTip1.SetToolTip(g.value, "Comment: " + act.Comment);
                }

                //DEBUG Keep this useful for debugging structure levels
                //                if (g.programstep != null)
                //                  g.value.Enabled = false; g.value.Text = structlevel.ToString() + " ^ " + g.levelup + " UD: " + g.programstep.DisplayedUserData;g.value.Enabled = true;

                voff += g.panel.Height;
            }

            buttonMore.Location = new Point(panelleftmargin, voff + panelVScroll.ScrollOffset);
            buttonMore.Size     = new Size(controlsize, controlsize);

            Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle);
            int       titleHeight     = screenRectangle.Top - this.Top;

            // Beware Visible - it does not report back the set state, only the visible state.. hence use Enabled.
            voff += buttonMore.Height + titleHeight + panelName.Height + ((panelTop.Enabled) ? (panelTop.Height + statusStripCustom.Height) : 8) + 16 + panelOK.Height;

            if (calcminsize)
            {
                this.MinimumSize = new Size(600, voff);
                this.MaximumSize = new Size(Screen.FromControl(this).WorkingArea.Width - 100, Screen.FromControl(this).WorkingArea.Height - 100);

                if (Bottom > Screen.FromControl(this).WorkingArea.Height)
                {
                    Top = Screen.FromControl(this).WorkingArea.Height - Height - 50;
                }
            }

            panelVScroll.ResumeLayout();
            ResumeLayout();

            return(errlist);
        }