예제 #1
0
 /// <summary>
 /// Invalidates the specified id.
 /// </summary>
 /// <param name="id">The data address.</param>
 /// <param name="autoCalculate">if set to <see langword="true" /> automatically calculate immediately.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="id" /> is <see langword="null" />.</exception>
 public void Invalidate(CalcLocalIdentity id, bool autoCalculate = true)
 {
     if (object.ReferenceEquals(id, null))
     {
         throw new ArgumentNullException("id");
     }
     if (!this.Graph.IsEmpty)
     {
         CalcNode objA = this.Graph.GetNode(id);
         if (!object.ReferenceEquals(objA, null))
         {
             objA.MarkAsDirty(this.Service, autoCalculate, true, true, true);
         }
         else if (objA == null)
         {
             CalcNode.CreateTempNode(this.Source, id).MarkAsDirty(this.Service, autoCalculate, true, true, true);
         }
         else
         {
             CalcCellIdentity identity = id as CalcCellIdentity;
             if (!object.ReferenceEquals(identity, null))
             {
                 foreach (CalcNode node2 in this.Graph.GetAllDependentRangeNodes(identity.RowIndex, identity.ColumnIndex, 1, 1))
                 {
                     node2.MarkAsDirty(this.Service, autoCalculate, false, true, true);
                 }
             }
             else
             {
                 CalcRangeIdentity identity2 = id as CalcRangeIdentity;
                 if (!object.ReferenceEquals(identity2, null))
                 {
                     if (identity2.IsFullColumn && identity2.IsFullRow)
                     {
                         this.InvalidateAllIdentity();
                         return;
                     }
                     if (!identity2.IsFullColumn && !identity2.IsFullRow)
                     {
                         foreach (CalcNode node3 in this.Graph.GetAllDependentRangeNodes(identity2.RowIndex, identity2.ColumnIndex, identity2.RowCount, identity2.ColumnCount))
                         {
                             node3.MarkAsDirty(this.Service, autoCalculate, true, true, true);
                         }
                         for (int i = 0; i < identity2.RowCount; i++)
                         {
                             for (int j = 0; j < identity2.ColumnCount; j++)
                             {
                                 CalcNode node = this.Graph.GetNode(new CalcCellIdentity(identity2.RowIndex + i, identity2.ColumnIndex + j));
                                 if (!object.ReferenceEquals(node, null))
                                 {
                                     node.MarkAsDirty(this.Service, autoCalculate, false, true, true);
                                 }
                             }
                         }
                     }
                     else
                     {
                         int columnIndex;
                         int columnCount;
                         if (identity2.IsFullColumn)
                         {
                             columnIndex = identity2.ColumnIndex;
                             columnCount = identity2.ColumnCount;
                         }
                         else
                         {
                             columnIndex = identity2.RowIndex;
                             columnCount = identity2.RowCount;
                         }
                         foreach (CalcNode node5 in this.Graph.GetBandDependentNodes(columnIndex, columnCount, identity2.IsFullRow))
                         {
                             node5.MarkAsDirty(this.Service, autoCalculate, true, true, true);
                         }
                         CalcReference reference = this.Evaluator.Evaluate(new CalcRangeExpression(columnIndex, columnCount, false, false, true), this.Source.GetEvaluatorContext(identity2)) as CalcReference;
                         if (!object.ReferenceEquals(reference, null) && (reference.RangeCount == 1))
                         {
                             for (int k = 0; k < reference.GetRowCount(0); k++)
                             {
                                 for (int m = 0; m < reference.GetColumnCount(0); m++)
                                 {
                                     CalcNode node6 = this.Graph.GetNode(new CalcCellIdentity(reference.GetRow(0) + k, reference.GetColumn(0) + m));
                                     if (!object.ReferenceEquals(node6, null))
                                     {
                                         node6.MarkAsDirty(this.Service, autoCalculate, false, true, true);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         foreach (CalcLocalIdentity identity3 in this.Graph.GetAllVolantedIdeneities())
         {
             this.Graph.EnsureNode(identity3, null).MarkAsDirty(this.Service, autoCalculate, true, true, true);
         }
         if (autoCalculate)
         {
             this.Service.Recalculate(0xc350, false);
         }
     }
 }