public UIDisplayArrayContext(FGLApplicationPanel f, DISPLAYARRAY p)
        {
            bool haveDown      = false;
            bool haveUp        = false;
            bool havePgDn      = false;
            bool havePgUp      = false;
            bool haveAccept    = false;
            bool haveInterrupt = false;


            int cnt;

            nCols            = Convert.ToInt32(p.ARRVARIABLES);
            KeyList          = new List <ONKEY_EVENT>();
            mainWin          = f;
            this.arrLine     = 1;
            this.scrLine     = 1;
            this.nextMove    = 0;
            this.lastarrLine = -1;
            this.nRows       = Convert.ToInt32(p.ARRCOUNT);
            onActionList     = new List <ON_ACTION_EVENT>();
            Data             = p.ROWS;
            finishing        = false;

            beforeRow = null;
            afterRow  = null;


            foreach (object evt in p.EVENTS)
            {
                if (evt is ONKEY_EVENT)
                {
                    ONKEY_EVENT e;
                    e = (ONKEY_EVENT)evt;
                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("ACCEPT"))
                    {
                        haveAccept = true;
                    }

                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("INTERRUPT"))
                    {
                        haveInterrupt = true;
                    }
                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("DOWN"))
                    {
                        haveDown = true;
                    }

                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("UP"))
                    {
                        haveUp = true;
                    }

                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("PGUP"))
                    {
                        havePgUp = true;
                    }

                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("PGDN"))
                    {
                        havePgDn = true;
                    }

                    KeyList.Add(e);
                    continue;
                }

                if (evt is BEFORE_ROW_EVENT)
                {
                    BEFORE_ROW_EVENT e;
                    e         = (BEFORE_ROW_EVENT)evt;
                    beforeRow = e;
                    continue;
                }

                if (evt is AFTER_ROW_EVENT)
                {
                    AFTER_ROW_EVENT e;
                    e        = (AFTER_ROW_EVENT)evt;
                    afterRow = e;
                    continue;
                }

                if (evt is ON_ACTION_EVENT)
                {
                    ON_ACTION_EVENT e;
                    e = (ON_ACTION_EVENT)evt;
                    onActionList.Add(e);
                    continue;
                }
                if (evt is AFTER_INPUT_EVENT)
                {
                    afterInput = (AFTER_INPUT_EVENT)evt;
                    continue;
                }
                Program.Show("Unhandled Event for DISPLAY ARRAY");
            }

            if (!haveAccept)
            {
                KeyList.Add(new ONKEY_EVENT("ACCEPT"));
            }

            if (!haveInterrupt)
            {
                KeyList.Add(new ONKEY_EVENT("INTERRUPT"));
            }

            if (!haveDown)
            {
                KeyList.Add(new ONKEY_EVENT("DOWN"));
            }

            if (!haveUp)
            {
                KeyList.Add(new ONKEY_EVENT("UP"));
            }

            if (!havePgDn)
            {
                KeyList.Add(new ONKEY_EVENT("PGDN"));
            }

            if (!havePgUp)
            {
                KeyList.Add(new ONKEY_EVENT("PGUP"));
            }



            activeFields = f.FindFieldArray(p.FIELDLIST);
            scrRecLines  = activeFields.Count / nCols;
            cnt          = 0;
            screenRecord = new FGLFoundField[scrRecLines, nCols];

            for (int a = 0; a < scrRecLines; a++)
            {
                //screenRecord[a] = new FGLFoundField[nCols];
                for (int b = 0; b < nCols; b++)
                {
                    screenRecord[a, b] = activeFields[cnt++];
                }
            }
        }