private void deleteCellsAtLastRow() { foreach (DataGridViewCell cell in DGVTable.Rows[DGVTable.RowCount - 1].Cells) { CellManager.DeleteCell(cell); } }
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); } }
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]); } }
private void ProccesInput(object sender, EventArgs e) { DataGridViewCell cell = DGVTable.CurrentCell; if (cell != null) { CellManager.ProccesExpression(cell, InputBox.Text); } }
private void deleteCellsAtLastColumn() { foreach (DataGridViewRow row in DGVTable.Rows) { DataGridViewCell cell = row.Cells[DGVTable.ColumnCount - 1]; if (cell != null) { CellManager.DeleteCell(cell); } } }
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))); }
private void InitializeCells() { foreach (DataGridViewRow row in DGVTable.Rows) { foreach (DataGridViewCell cell in row.Cells) { cell.Value = ""; cell.Tag = ""; CellManager.AddCell(cell); } } }
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(); }
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(); } } }
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); }