/// <summary> /// Gets the back referenced cells. /// </summary> /// <param name="srcCell">The SRC cell.</param> /// <param name="refCellList">The ref cell list.</param> private void GetBackReferencedCells(Cell srcCell, ArrayList refCellList) { ArrayList foundList = new ArrayList(); //ExpressionInfo exInfo = ExpressionInfo.Parse(srcCell.Expression); ExpressionInfo exInfo = srcCell.GetExpressionInfo(); foreach (string strParam in exInfo.Params) { string[] strPrmSplit = strParam.Split(':'); // if(strPrmSplit[0].StartsWith("-")) // { // strPrmSplit[0] = strPrmSplit[0].Substring(1); // } Cell cell = this.GetCell(strPrmSplit[0], strPrmSplit[1]); if (cell != null) { foundList.Add(cell); } } refCellList.AddRange(foundList); foreach (Cell chSrcCell in foundList) { GetBackReferencedCells(chSrcCell, refCellList); } }
/// <summary> /// Gets the referenced cells. /// </summary> /// <param name="srcCell">The SRC cell.</param> /// <param name="refCellList">The ref cell list.</param> private void GetReferencedCells(Cell srcCell, ArrayList refCellList) { ArrayList foundList = new ArrayList(); for (int colIndex = 0; colIndex < this.Columns.Length; colIndex++) { for (int rowIndex = 0; rowIndex < this.Rows.Length; rowIndex++) { Cell cell = this.GetCell(colIndex, rowIndex); if (cell != null && cell.Type == CellType.AutoCalc) { //ExpressionInfo expInfo = ExpressionInfo.Parse(cell.Expression); ExpressionInfo expInfo = cell.GetExpressionInfo(); if (expInfo.ContainsParam(srcCell.Uid)) { foundList.Add(cell); } } } } refCellList.AddRange(foundList); foreach (Cell chSrcCell in foundList) { GetReferencedCells(chSrcCell, refCellList); } }
/// <summary> /// Recalculates the related cells. /// </summary> /// <param name="srcCell">The SRC cell.</param> private void RecalculateRelatedCells(Cell srcCell) { RaiseCellValueChanged(srcCell); ArrayList changedCells = new ArrayList(); for (int colIndex = 0; colIndex < this.Columns.Length; colIndex++) { for (int rowIndex = 0; rowIndex < this.Rows.Length; rowIndex++) { Cell cell = this.GetCell(colIndex, rowIndex); if (cell != null && cell.Type == CellType.AutoCalc) { //ExpressionInfo expInfo = ExpressionInfo.Parse(cell.Expression); ExpressionInfo expInfo = cell.GetExpressionInfo(); if (expInfo.ContainsParam(srcCell.Uid)) { double oldValue = cell.Value; EvaluateAutoValue(cell); changedCells.Add(cell); } // // int index = cell.Expression.IndexOf(srcCell.Uid); // if(index!=-1) // { // char endChar = cell.Expression[index+srcCell.Uid.Length]; // if(endChar==',' || endChar==')' ) // { // double oldValue = cell.Value; // EvaluateAutoValue(cell); // // //if(oldValue!=cell.Value) // changedCells.Add(cell); // } // } } } } foreach (Cell chCell in changedCells) { RecalculateRelatedCells(chCell); } }
/// <summary> /// Gets the back referenced cells. /// </summary> /// <param name="srcCell">The SRC cell.</param> /// <param name="refCellList">The ref cell list.</param> private void GetBackReferencedCells(Cell srcCell, ArrayList refCellList) { ArrayList foundList = new ArrayList(); //ExpressionInfo exInfo = ExpressionInfo.Parse(srcCell.Expression); ExpressionInfo exInfo = srcCell.GetExpressionInfo(); foreach(string strParam in exInfo.Params) { string[] strPrmSplit = strParam.Split(':'); // if(strPrmSplit[0].StartsWith("-")) // { // strPrmSplit[0] = strPrmSplit[0].Substring(1); // } Cell cell = this.GetCell(strPrmSplit[0], strPrmSplit[1]); if(cell!=null) { foundList.Add(cell); } } refCellList.AddRange(foundList); foreach(Cell chSrcCell in foundList) { GetBackReferencedCells(chSrcCell, refCellList); } }