Exemple #1
0
        public UIInputArrayInTableContext(FGLApplicationPanel f, INPUTARRAY p)
        {
            bool haveDown      = false;
            bool haveUp        = false;
            bool havePgDn      = false;
            bool havePgUp      = false;
            bool haveAccept    = false;
            bool haveInterrupt = false;
            bool haveDelete    = false;
            bool haveInsert    = false;


            KeyList = new List <ONKEY_EVENT>();
            mainWin = f;
            nCols   = p.ARRVARIABLES;
            maxRows = p.MAXARRSIZE;


            Data = new DataTable();          //new string[p.MAXARRSIZE, p.ARRVARIABLES];

            for (int a = 0; a <= nCols; a++) // One extra for the subscript....
            {
                if (a == 0)
                {
                    Data.Columns.Add("subscript");
                }
                else
                {
                    Data.Columns.Add("col" + a);
                }
            }



            //  rowWasAutoInserted = new bool[maxRows];
            //     rowDataChanged = new bool[maxRows];

            //  inputArrayGrid.maxRows = maxRows;


            PendingEvents = new List <s_pending>();

            lastRowData = new string[maxRows];
            for (int a = 0; a < maxRows; a++)
            {
                lastRowData[a] = "";
            }



            // Set up the 'blank' event IDs for before
            // and after fields for the Cell number
            // this will make it easier to check if we need to action
            // a before or after field event
            beforeFieldEventIds = new int[nCols];
            afterFieldEventIds  = new int[nCols];
            for (int a = 0; a < nCols; a++)
            {
                beforeFieldEventIds[a] = -1;
                afterFieldEventIds[a]  = -1;
            }


            onActionList = new List <ON_ACTION_EVENT>();


            beforeRow = null;
            afterRow  = null;

            inputArrayGrid = f.FindRecord(p.FIELDLIST);

            if (inputArrayGrid == null)
            {
                MessageBox.Show("Screen record " + p.FIELDLIST + " not found - fix your 4gl!");
                Application.Exit();
            }


            inputArrayGrid.DataSource = null;

            // Make sure the array is completely cleared down..
            inputArrayGrid.ClearSelection();
            inputArrayGrid.Rows.Clear();
            inputArrayGrid.init();
            inputArrayGrid.maxRows = maxRows;

            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;
                    }
                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("INSERT"))
                    {
                        haveInsert = true;
                    }

                    if (e.KEY == "" + FGLUtils.getKeyCodeFromKeyName("DELETE"))
                    {
                        haveDelete = 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 BEFORE_DELETE_EVENT)
                {
                    BEFORE_DELETE_EVENT e;
                    e            = (BEFORE_DELETE_EVENT)evt;
                    beforeDelete = e;
                    continue;
                }

                if (evt is BEFORE_INSERT_EVENT)
                {
                    BEFORE_INSERT_EVENT e;
                    e            = (BEFORE_INSERT_EVENT)evt;
                    beforeInsert = e;
                    continue;
                }


                if (evt is AFTER_DELETE_EVENT)
                {
                    AFTER_DELETE_EVENT e;
                    e           = (AFTER_DELETE_EVENT)evt;
                    afterDelete = e;
                    continue;
                }

                if (evt is AFTER_INPUT_EVENT)
                {
                    afterInput = (AFTER_INPUT_EVENT)evt;
                    continue;
                }

                if (evt is AFTER_INSERT_EVENT)
                {
                    AFTER_INSERT_EVENT e;
                    e           = (AFTER_INSERT_EVENT)evt;
                    afterInsert = 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 BEFORE_FIELD_EVENT)
                {
                    BEFORE_FIELD_EVENT e;
                    e = (BEFORE_FIELD_EVENT)evt;
                    int a = getCellNumberForField(e.FIELD);

                    if (a >= 0)
                    {
                        beforeFieldEventIds[a] = Convert.ToInt32(e.ID);
                    }
                    else
                    {
                        MessageBox.Show("BEFORE FIELD " + e.FIELD + " - field not found");
                    }
                    continue;
                }

                if (evt is AFTER_FIELD_EVENT)
                {
                    AFTER_FIELD_EVENT e;
                    e = (AFTER_FIELD_EVENT)evt;
                    int a = getCellNumberForField(e.FIELD);
                    if (a >= 0)
                    {
                        afterFieldEventIds[a] = Convert.ToInt32(e.ID);
                    }
                    else
                    {
                        MessageBox.Show("AFTER FIELD " + e.FIELD + " - field not found");
                    }

                    continue;
                }

                Program.Show("Unhandled Event for INPUT ARRAY");
            }



            if (p.NONEWLINES == 1 || p.ALLOWINSERT == 0)
            {
                allowInsert = false;
            }
            else
            {
                allowInsert = true;
            }

            if (p.ALLOWDELETE == 1)
            {
                allowDelete = true;
            }
            else
            {
                allowDelete = false;
            }

            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"));
            }

            if (!haveInsert && allowInsert)
            {
                KeyList.Add(new ONKEY_EVENT("INSERT"));
            }

            if (!haveDelete && allowDelete)
            {
                KeyList.Add(new ONKEY_EVENT("DELETE"));
            }
        }
        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++];
                }
            }
        }
        //  private List<FGLFoundField> activeFields;

        public UIConstructInTableContext(FGLApplicationPanel f, CONSTRUCT c, FormattedGridView pConstructGrid, List <DataGridViewCell> pRecordFields)
        {
            bool haveAccept    = false;
            bool haveInterrupt = false;

            KeyList = new List <ONKEY_EVENT>();
            KeyList.Clear();
            RecordFields    = pRecordFields;
            afterFieldList  = new List <AFTER_FIELD_EVENT>();
            beforeFieldList = new List <BEFORE_FIELD_EVENT>();
            onActionList    = new List <ON_ACTION_EVENT>();
            setCurrentField = null;
            CurrentField    = null;
            PendingEvents   = new List <string>();
            isBeforeInput   = true;

            // activeFields = f.FindFieldArray(c.FIELDLIST);

            foreach (object evt in c.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;
                    }
                    KeyList.Add(e);
                    continue;
                }

                if (evt is BEFORE_FIELD_EVENT)
                {
                    BEFORE_FIELD_EVENT e;
                    e = (BEFORE_FIELD_EVENT)evt;
                    beforeFieldList.Add(e);
                    continue;
                }

                if (evt is AFTER_FIELD_EVENT)
                {
                    AFTER_FIELD_EVENT e;
                    e = (AFTER_FIELD_EVENT)evt;
                    afterFieldList.Add(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 CONSTRUCT");
            }

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

            mainWin = f;


            constructGrid = pConstructGrid;

            if (constructGrid == null)
            {
                constructGrid = (FormattedGridView)pRecordFields[0].DataGridView;
            }

            constructGrid.init();
            constructGrid.DataSource = null;
            dt = new DataTable();
            dt.Columns.Add("subscript");


            // Add a column for each column in the grid
            for (int cols = 0; cols < constructGrid.Columns.Count; cols++)
            {
                DataColumn col = new DataColumn("col" + (cols));
                dt.Columns.Add(col);
            }

            constructColumnList = c.COLUMNS;

            constructGrid.allowInsertRow = false;


            DataGridViewRow r;

            string[] data;
            data = new string[constructGrid.Columns.Count];
            r    = new DataGridViewRow();


            for (int colno = 1; colno < constructGrid.Columns.Count; colno++)
            {
                data[colno] = "";
            }
            setActiveFields();
            dt.Rows.Add(data);

            constructGrid.Columns[0].Visible = false;
            constructGrid.DataSource         = dt;
            //   constructGrid.AutoResizeColumnHeadersHeight();
            //   constructGrid.AutoResizeRow(0);

            // for (int colno = 1; colno < constructGrid.Columns.Count; colno++)
            //  {
            //     constructGrid.AutoResizeColumn(colno);
            //  }

            constructGrid.Enabled = false;

            // WEBGUI displayArrayGrid.sizeGrid();
        }