Example #1
0
 public CGridFeeSheet(FormFeeSheet pParentFormSheet, DataGridView pTheDataGrid)
 {
     _parentFormSheet = pParentFormSheet;
     _fileName        = pParentFormSheet._fileName;
     _theDataGrid     = pTheDataGrid;
     _theMatrix       = new CCellMatrix();
 }
Example #2
0
        // Event relay - double click on a cell
        public void CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                var val = _theDataGrid.Rows[e.RowIndex].Cells[e.ColumnIndex];
                var tag = _theDataGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag;

                if (tag is CCell)
                {
                    CCellMatrix theMatrix = BuildMatrixFromGrid();

                    CCell theCurrentCell = (CCell)tag;

                    using (var modal = new FormDialogCCel(theCurrentCell, theMatrix))
                    {
                        modal.ShowDialog();
                        if (modal.DialogResult == DialogResult.OK)
                        {
                            // refresh grid
                            ClearGrid();
                            AddHeaderToGrid();
                            AddDataToGrid();
                        }
                    }
                }
            }
        }
Example #3
0
        private void dataGridViewDyn_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
            {
                var val = dataGridViewDyn.Rows[e.RowIndex].Cells[e.ColumnIndex];
                var tag = dataGridViewDyn.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag;

                if (tag is CCell)
                {
                    // CCellHeader tCellHeader = new CCellHeader();

                    CCellMatrix theMatrix = BuildMatrixFromGrid(dataGridViewDyn);


                    using (var modal = new FormDialogCCel((CCell)tag, theMatrix))
                    {
                        modal.ShowDialog();
                        if (modal.DialogResult == DialogResult.OK)
                        {
                            // _cellHeaderVector.AddCellHeader(tCellHeader);

                            // AddCellToGrid(dataGridViewDyn, _cellHeaderVector);

                            // refresh grid
                            this.dataGridViewDyn.Columns.Clear();
                            AddCellToGrid(this.dataGridViewDyn, _theMatrix._cellHeaderVector);
                            AddDataToGrid(this.dataGridViewDyn, _theMatrix);
                        }
                        else if (modal.DialogResult == DialogResult.Cancel)
                        {
                        }
                    }
                }
            }
        }
Example #4
0
        private void AddDataToGrid(DataGridView pGrid, CCellMatrix pTheMatrix)
        {
            int t_row = 0;

            pGrid.Rows.Clear();
            pGrid.Columns.Clear();

            AddCellToGrid(pGrid, pTheMatrix._cellHeaderVector);


            foreach (var kv_vector in pTheMatrix._Vectors)
            {
                var kv_vector_key   = kv_vector.Key;
                var kv_vector_value = kv_vector.Value;

                int index = pGrid.Rows.Add();

                int t_col = 0;
                foreach (var kv_cell in kv_vector_value._Cells)
                {
                    CCell theCell = kv_cell.Value;

                    pGrid.Rows[t_row].Cells[t_col].Value = theCell._value;
                    pGrid.Rows[t_row].Cells[t_col].Tag   = theCell;

                    t_col++;
                }

                t_row++;
            }
        }
Example #5
0
 public FormDialogCCel(CCell pCell, CCellMatrix pCellMatrix)
 {
     InitializeComponent();
     _cell       = pCell;
     _cellMatrix = pCellMatrix;
     InitGui();
     _lastFeedback = _cell._calculationFeedback;
 }
Example #6
0
        private CCellMatrix BuildMatrixFromGrid(DataGridView pDataGrid)
        {
            CCellMatrix theMatrix = new CCellMatrix();
            CCellVector theCellVector;

            int i_row = 0;
            int i_col = 0;

            foreach (DataGridViewRow row in pDataGrid.Rows)
            {
                theCellVector = new CCellVector();
                //theMatrix.AddVector(i_row, theCellVector);

                i_col = 0;

                bool last_empty_line = true;

                foreach (DataGridViewCell cell in row.Cells)
                {
                    string colName = _theMatrix._cellHeaderVector._cellHeaders[i_col]._name;

                    // check if the last row is completely empty in order to insert the vector
                    if (!(cell.Value is null))
                    {
                        last_empty_line = false;
                    }

                    double cell_value = Convert.ToDouble(cell.Value);

                    //CCell cellToInsert = new CCell(0, cell_value);
                    CCell cellToInsert = new CCell(cell_value.ToString(), i_row);

                    var x = _theMatrix._cellHeaderVector._cellHeaders[i_col];
                    cellToInsert._cellHeader = _theMatrix._cellHeaderVector._cellHeaders[i_col];

                    theCellVector.Add(colName, cellToInsert);

                    i_col++;
                }

                if (!last_empty_line)
                {
                    theMatrix.AddVector(i_row, theCellVector);
                }


                i_row++;
            }

            return(theMatrix);
        }
Example #7
0
        private void SaveDatagrid_Data(DataGridView pDataGrid, string pFileName)
        {
            CCellMatrix       theMatrix         = BuildMatrixFromGrid(pDataGrid);
            CCellHeaderVector tCellHeaderVector = _theMatrix._cellHeaderVector;

            _theMatrix = theMatrix;
            _theMatrix._cellHeaderVector = tCellHeaderVector;


            CCellMatrixIO matrixIO = new CCellMatrixIO();

            matrixIO.BuildMatrixIO(_theMatrix);
            matrixIO.Save(pFileName);
        }
Example #8
0
 public bool RunPrecompiledScript(CCellMatrix pTheMatrix)
 {
     if (_precompileReady)
     {
         try
         {
             string sInfo = (string)_main.Invoke(null, new object[] { pTheMatrix });
             _runOutput = sInfo.ToString();
         }
         catch (System.Reflection.TargetInvocationException)      //SharedObjects.InvalidFieldException e)
         {
         }
     }
     return(true);
 }
Example #9
0
        // Load XML matrice xxxIo file and build a new matrix
        public void LoadDatagrid_Data()
        {
            // xxxIO allow to easily serialise/deserialise to xml, because no dictionary
            CCellMatrixIO matrixIO = CCellMatrixIO.Load(_fileName);

            // Create the new matrix
            _theMatrix = new CCellMatrix();

            // take back from xxxIO the Cell Columns header
            _theMatrix._cellHeaderVector = matrixIO._cellHeaderVector;

            // loop thru IO
            foreach (CCellMatrixElementIO v in matrixIO._matrixIO)
            {
                int    t_keyID   = v._keyID;
                string t_keyName = v._keyName;
                CCell  t_cell    = v._cell;

                CCellVector currentCellVector;

                // 1. determine wether the key is in the dico or not
                if (_theMatrix._Vectors.ContainsKey(t_keyID))
                {
                    // key is in: retrieve the pointe cellvector pointé par la clé
                    currentCellVector = _theMatrix._Vectors[t_keyID];
                }
                else
                {
                    // key not in, create a new cellvector and add it to the dico
                    currentCellVector = new CCellVector();
                    _theMatrix._Vectors.Add(t_keyID, currentCellVector);
                }

                // add the key and the cell to the cell vector
                currentCellVector.Add(t_keyName, t_cell);
            }

            AddDataToGrid();
        }
Example #10
0
        private void DoEval()
        {
            CCompiler tCompiler = new CCompiler();

            // Apply Cycée counter to the cell evaluated
            _cell.CycleInc();
            DisplayCellCycle();


            // Look for primitive properties in the settings
            CApplicationSettings settings = new CApplicationSettings();

            settings.Load("aurora_stettings.xml");

            // Really need another pointer ???
            CCellMatrix theMatrix = _cellMatrix;

            // Call the compiler and run the code;

            tCompiler._injection_definition  = settings._compPrimitiveInit;
            tCompiler._injection_constructor = settings._compPrimitiveConstructor;
            tCompiler._injection_primitives  = settings._compPrimitiveFunctions;

            string tScriptToTest = @richTextBoxScript.Text; // Main script to compile

            tCompiler.PreCompileScript(tScriptToTest);
            tCompiler.RunPrecompiledScript(theMatrix);


            // Get the feedback of the compilation/run;
            richTextBoxFeedBack.Text  = tCompiler._compilerOutput;
            richTextBoxFeedBack.Text += tCompiler._runOutput;
            textBoxPrevCellValue.Text = _cellMatrix._lastEvaluatedValue; //.ToString();

            _lastFeedback = tCompiler._runOutput;

            DisplayCellMainStatus(_cellMatrix._lastCellStatus);
        }
Example #11
0
        public void RebuildMatrix()
        {
            // back the headerVector
            CCellHeaderVector tCellHeaderVector = _theMatrix._cellHeaderVector;

            // back the matrix description
            string _matrixPhysicalName          = _theMatrix._matrixPhysicalName;
            string _matrixInheritedPhysicalName = _theMatrix._matrixInheritedPhysicalName;
            string _matrixDescription           = _theMatrix._matrixDescription;
            bool   _isInherited = _theMatrix._isInherited;

            // Build the new matrix from the grid
            _theMatrix = BuildMatrixFromGrid();

            // set back the headerVector
            _theMatrix._cellHeaderVector = tCellHeaderVector;

            // set back the matrix description
            _theMatrix._matrixPhysicalName          = _matrixPhysicalName;
            _theMatrix._matrixInheritedPhysicalName = _matrixInheritedPhysicalName;
            _theMatrix._matrixDescription           = _matrixDescription;
            _theMatrix._isInherited = _isInherited;
        }
Example #12
0
        private void LoadDatagrid_Data(DataGridView pDataGrid, string pFileName)
        {
            CCellMatrixIO matrixIO = CCellMatrixIO.Load(pFileName);

            //CCellMatrix theMatrix = new CCellMatrix();

            this._theMatrix = new CCellMatrix();

            _theMatrix._cellHeaderVector = matrixIO._cellHeaderVector;

            foreach (CCellMatrixElementIO v in matrixIO._matrixIO)
            {
                int    t_keyID   = v._keyID;
                string t_keyName = v._keyName;
                CCell  t_cell    = v._cell;

                CCellVector currentCellVector;

                // 1. recherche si la key n'est pas déja présente dans le dico
                if (_theMatrix._Vectors.ContainsKey(t_keyID))
                {
                    // si présente, on prend comme référence  le cellvector pointé par la clé
                    currentCellVector = _theMatrix._Vectors[t_keyID];
                }
                else
                {
                    //    sinon on crée ce cellvector et on l'ajoute au dico
                    currentCellVector = new CCellVector();
                    _theMatrix._Vectors.Add(t_keyID, currentCellVector);
                }

                // add the key and the cell to the cell vector
                currentCellVector.Add(t_keyName, t_cell);
            }

            AddDataToGrid(pDataGrid, _theMatrix);
        }
Example #13
0
        public CCellMatrix BuildMatrixFromGrid()
        {
            // back the headerVector
            CCellHeaderVector tCellHeaderVector = _theMatrix._cellHeaderVector;

            // back the new matrix
            CCellMatrix theMatrix = new CCellMatrix();

            // back the headerVector
            theMatrix._cellHeaderVector = tCellHeaderVector;

            CCellVector theCellVector;


            int i_row = 0;
            int i_col = 0;

            foreach (DataGridViewRow row in _theDataGrid.Rows)
            {
                theCellVector = new CCellVector();

                i_col = 0;

                bool last_empty_line = true;

                foreach (DataGridViewCell gridCell in row.Cells)
                {
                    string colName = _theMatrix.ColumnsHeader[i_col]._name;

                    // check if the last row is completely empty in order to insert the vector
                    // see also comment after the foreach loop
                    if (!(gridCell.Value is null))
                    {
                        last_empty_line = false;
                    }

                    CCell cellToInsert;

                    if (gridCell.Tag is null)
                    {
                        string cell_value = (string)gridCell.Value;
                        cellToInsert = new CCell(cell_value, i_row);

                        cellToInsert._cellHeader = _theMatrix.ColumnsHeader[i_col];
                    }
                    else
                    {
                        cellToInsert = (CCell)gridCell.Tag;
                    }

                    theCellVector.Add(colName, cellToInsert);

                    i_col++;
                }

                // in the row is not empty it is added
                if (!last_empty_line)
                {
                    theMatrix.AddVector(i_row, theCellVector);
                }


                i_row++;
            }

            return(theMatrix);
        }
Example #14
0
 public Form1()
 {
     InitializeComponent();
     _theMatrix = new CCellMatrix();
     //_cellHeaderVector = new CCellHeaderVector();
 }