Ejemplo n.º 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++];
                }
            }
        }
Ejemplo n.º 3
0
        public UIDisplayArrayInTableContext(FGLApplicationPanel f, DISPLAYARRAY p)
        {
            bool haveDown      = false;
            bool haveUp        = false;
            bool havePgDn      = false;
            bool havePgUp      = false;
            bool haveAccept    = false;
            bool haveInterrupt = false;

            //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;

            beforeRow  = null;
            afterRow   = null;
            initialRow = true;

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



            displayArrayGrid = f.FindRecord(p.FIELDLIST);
            displayArrayGrid.init();
            displayArrayGrid.DataSource = null;
            dt = new DataTable();

            dt.Columns.Add("subscript");
            for (int cols = 1; cols <= p.ROWS[0].VALUES.Length; cols++)
            {
                dt.Columns.Add("col" + (cols));
            }


            //displayArrayGrid.Rows.Clear();

            displayArrayGrid.allowInsertRow = false;

            for (int row = 0; row < p.ROWS.Length; row++)
            {
                DataGridViewRow r;
                string[]        data;
                data = new string[p.ROWS[row].VALUES.Length + 1];
                r    = new DataGridViewRow();

                // We'll use the first column to store the index
                // for the current row...
                data[0] = "" + (row + 1);

                for (int col = 0; col < p.ROWS[row].VALUES.Length; col++)
                {
                    object itm;
                    int    trimWidth = -1;
                    AubitDesktop.Xml.XMLForm.TableColumn tc = displayArrayGrid.table.TableColumn[col];
                    itm = tc.Item;


                    if (itm is AubitDesktop.Xml.XMLForm.Edit)
                    {
                        AubitDesktop.Xml.XMLForm.Edit e;
                        e         = (AubitDesktop.Xml.XMLForm.Edit)itm;
                        trimWidth = Convert.ToInt32(e.width);
                    }
                    if (itm is AubitDesktop.Xml.XMLForm.Widget)
                    {
                        AubitDesktop.Xml.XMLForm.Widget e;
                        e         = (AubitDesktop.Xml.XMLForm.Widget)itm;
                        trimWidth = Convert.ToInt32(e.width);
                    }

                    data[col + 1] = p.ROWS[row].VALUES[col].Text;

                    if (trimWidth > 0)
                    {
                        if (p.ROWS[row].VALUES[col].Text != null)
                        {
                            if (p.ROWS[row].VALUES[col].Text.Length > trimWidth)
                            {
                                data[col + 1] = p.ROWS[row].VALUES[col].Text.Substring(0, trimWidth);
                            }
                        }
                    }
                }
                dt.Rows.Add(data);
                //displayArrayGrid.Rows.Add(data);

                //displayArrayGrid.AutoResizeRow(row);
                //displayArrayGrid.AutoResizeColumnHeadersHeight();
            }


            displayArrayGrid.Columns[0].Visible = false;

            displayArrayGrid.DataSource = dt;

            displayArrayGrid.AutoResizeColumnHeadersHeight();
            for (int row = 0; row < dt.Rows.Count; row++)
            {
                displayArrayGrid.AutoResizeRow(row);

                for (int col = 0; col < p.ROWS[row].VALUES.Length; col++)
                {
                    displayArrayGrid.AutoResizeColumn(col);
                }
            }

            //  displayArrayGrid.RowCount = 5;
            displayArrayGrid.Enabled = false;
            displayArrayGrid.sizeGrid();
        }