Esempio n. 1
0
 private void deleteCellsAtLastRow()
 {
     foreach (DataGridViewCell cell in DGVTable.Rows[DGVTable.RowCount - 1].Cells)
     {
         CellManager.DeleteCell(cell);
     }
 }
Esempio n. 2
0
 public static bool OpenDVG(DataGridView dgv, string file_path)
 {
     try
     {
         if (!isTxt(file_path))
         {
             throw new Exception();
         }
         StreamReader tr            = new StreamReader(file_path);
         int          rowCounter    = Convert.ToInt32(tr.ReadLine());
         int          columnCounter = Convert.ToInt32(tr.ReadLine());
         dgv.ColumnCount = columnCounter;
         dgv.RowCount    = rowCounter;
         foreach (DataGridViewRow row in dgv.Rows)
         {
             int      i         = 0;
             string   rowString = tr.ReadLine();
             string[] cells     = rowString.Split(SEPARATE_SYMBOL);
             foreach (DataGridViewCell cell in row.Cells)
             {
                 cell.Tag = cells[i++];
             }
         }
         CellManager.RefreshDGV(dgv);
         tr.Close();
         return(true);
     }
     catch (Exception)
     {
         MessageBox.Show("Помилка при відкритті файла, спробуйте ще раз");
         return(false);
     }
 }
Esempio n. 3
0
 private void AddColumn(object sender, EventArgs e)
 {
     DGVTable.Columns.Add(new DataGridViewColumn(DGVTable.Rows[0].Cells[0]));
     FillHeaders();
     foreach (DataGridViewRow row in DGVTable.Rows)
     {
         CellManager.AddCell(row.Cells[DGVTable.ColumnCount - 1]);
     }
 }
Esempio n. 4
0
        private void ProccesInput(object sender, EventArgs e)
        {
            DataGridViewCell cell = DGVTable.CurrentCell;

            if (cell != null)
            {
                CellManager.ProccesExpression(cell, InputBox.Text);
            }
        }
Esempio n. 5
0
 private void deleteCellsAtLastColumn()
 {
     foreach (DataGridViewRow row in DGVTable.Rows)
     {
         DataGridViewCell cell = row.Cells[DGVTable.ColumnCount - 1];
         if (cell != null)
         {
             CellManager.DeleteCell(cell);
         }
     }
 }
Esempio n. 6
0
        public override double VisitIdentifierExpr(MyExelParser.IdentifierExprContext context)
        {
            var result = context.GetText();

            parsedIdentifires.Add(result);
            if (CellManager.IdentifierToStringValue(result) == "null")
            {
                throw new NullCellException();
            }
            return(Convert.ToDouble(CellManager.IdentifierToBoolValue(result)));
        }
Esempio n. 7
0
 private void InitializeCells()
 {
     foreach (DataGridViewRow row in DGVTable.Rows)
     {
         foreach (DataGridViewCell cell in row.Cells)
         {
             cell.Value = "";
             cell.Tag   = "";
             CellManager.AddCell(cell);
         }
     }
 }
Esempio n. 8
0
        private void AddRow(object sender, EventArgs e)
        {
            DataGridViewRow addedRow = new DataGridViewRow();

            foreach (DataGridViewCell cell in addedRow.Cells)
            {
                cell.Value = "";
                cell.Tag   = "";
                CellManager.AddCell(cell);
            }
            DGVTable.Rows.Add(addedRow);
            FillHeaders();
        }
Esempio n. 9
0
 private bool isLastColumnHasDependence()
 {
     foreach (DataGridViewRow row in DGVTable.Rows)
     {
         DataGridViewCell cell = row.Cells[DGVTable.ColumnCount - 1];
         if (cell == null || CellManager.DGVCellToCell(cell) == null)
         {
             return(false);
         }
         if (CellManager.DGVCellToCell(cell).HasDependence())
         {
             return(true);
         }
     }
     return(false);
 }
        public void ProccesExpression(string expression)
        {
            bool        isRecursion = false;
            List <Cell> parsedCells = new List <Cell>();

            try
            {
                string res = Calculator.Evaluate(expression);
                parsedCells = CellManager.ListIdentifiersToListCells(Calculator.GetParsedIdentifiers());
                if (findCycle(parsedCells) == false)
                {
                    _value        = res;
                    _parent.Value = (stringToBool(_value)).ToString();
                }
                else
                {
                    MessageBox.Show("Ой, а вас рекурсія, будьте уважніші!");
                    //clearCell();
                    isRecursion = true;
                }
            }
            catch (NullCellException)
            {
                MessageBox.Show("Ой, а ви використовуете комірочку зі значенням null, будьте уважніші!");
                setNullValue();
            }
            catch (Exception)
            {
                MessageBox.Show("Ой, а у вас синтасична помилочка, будьте уважніші!");
                setNullValue();
            }
            finally
            {
                if (isRecursion == false)
                {
                    _expression = expression;
                    _parent.Tag = _expression;
                    updateDependency(parsedCells);
                    cellsIDependOn = parsedCells;
                    updateValue();
                }
            }
        }
Esempio n. 11
0
 private bool isLastRowHasDependence()
 {
     foreach (DataGridViewCell cell in DGVTable.Rows[DGVTable.Rows.Count - 1].Cells)
     {
         if (cell == null)
         {
             return(false);
         }
         Cell _cell = CellManager.DGVCellToCell(cell);
         if (_cell == null)
         {
             return(false);
         }
         if (_cell.HasDependence())
         {
             return(true);
         }
     }
     return(false);
 }