Beispiel #1
0
        /// <summary>
        /// Copy the data from the 'rows' passed in with the WAITFOREVENT
        /// into a copy of the program array
        ///
        /// We maintain a copy on this side for easier processing...
        /// </summary>
        /// <param name="rows"></param>
        public void setUpData(ROW[] rows)
        {
            DataGridViewCell c;
            DataGridViewCell orig_c;

            orig_c = inputArrayGrid.CurrentCell;
            //  Data.AcceptChanges();
            c = inputArrayGrid.CurrentCell;


            // row may be been deleted..
            // try selecting the same row anyway..
            if (c == null && orig_c != null)
            {
                try
                {
                    c = inputArrayGrid.Rows[orig_c.RowIndex].Cells[orig_c.ColumnIndex];
                }
                catch (Exception ex)
                {
                    // if c is still null - nothing lost...
                }
            }
            Data.BeginLoadData();


            try
            {
                for (int row = 0; row < rows.Length; row++)
                {
                    int subscript = Convert.ToInt32(rows[row].SUBSCRIPT) - 1;
                    while (subscript >= Data.Rows.Count)
                    {
                        string[] newData;
                        newData = new string[nCols + 1];
                        for (int cnt = 0; cnt <= nCols; cnt++)
                        {
                            newData[cnt] = null;
                        }
                        Data.Rows.Add(newData);
                    }
                }


                for (int row = 0; row < rows.Length; row++)
                {
                    int subscript = Convert.ToInt32(rows[row].SUBSCRIPT) - 1;

                    // We'll use the first column to store the index
                    // for the current row...


                    Data.Rows[subscript][0] = "XXX"; // First column was to hold the subscript - but its currently not used....
                    for (int col = 0; col < rows[row].VS.Length; col++)
                    {
                        object itm;
                        int    trimWidth = -1;
                        AubitDesktop.Xml.XMLForm.TableColumn tc = inputArrayGrid.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);
                        }


                        Data.Rows[subscript][col + 1] = (string)rows[row].VS[col].Text;
                        if (trimWidth > 0)
                        {
                            if (rows[row].VS[col].Text != null)
                            {
                                if (rows[row].VS[col].Text.Length > trimWidth)
                                {
                                    Data.Rows[subscript][col + 1] = (string)rows[row].VS[col].Text.Substring(0, trimWidth);
                                }
                            }
                        }
                    }
                    // as we've been passed these values in -
                    // it makes sense not to send them back straight away again
                    // so we call 'AcceptChanges' to mark the rows as 'unchanged' after we've just
                    // changed them ;-)
                    Data.Rows[subscript].AcceptChanges();
                }
            } catch {
            }

            inputArrayGrid.CurrentCell = c;
            Data.EndLoadData();
        }
Beispiel #2
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();
        }