Ejemplo n.º 1
0
        public void Step()
        {
            var newGen = Stepper.GetNextGeneration(Data);

            Debug.Assert(newGen.GetLength(0) == Data.GetLength(0));
            Debug.Assert(newGen.GetLength(1) == Data.GetLength(1));

            bool changed = false;

            for (int row = 0; row < RowCount; row++)
            {
                for (int col = 0; col < ColCount; col++)
                {
                    if (Data[row, col] != newGen[row, col])
                    {
                        changed        = true;
                        Data[row, col] = newGen[row, col];
                    }
                }
            }

            if (changed)
            {
                var e = new ModelChangedEventArgs(EModelChangeType.Reset);
                ModelChanged?.Invoke(e);
            }
        }
Ejemplo n.º 2
0
 private void Model_ModelChanged(ModelChangedEventArgs e)
 {
     if (e.Type == EModelChangeType.Reset)
     {
         UpdateFromModel();
     }
     else
     {
         foreach (var point in e.ChangedCells)
         {
             var val = Model[point.Row, point.Col];
             Elements[point.Row, point.Col].Fill = val ? ElemVisibleFill : ElemHiddenFill;
         }
     }
 }
Ejemplo n.º 3
0
 public bool this[int row, int col]
 {
     get
     {
         return(Data[row, col]);
     }
     set
     {
         if (value != Data[row, col])
         {
             Data[row, col] = value;
             var e = new ModelChangedEventArgs(EModelChangeType.CellList);
             e.ChangedCells.Add(new IntPoint(row, col));
             ModelChanged?.Invoke(e);
         }
     }
 }
Ejemplo n.º 4
0
        public void Clear()
        {
            var changedCells = new List <IntPoint>();

            for (int row = 0; row < RowCount; row++)
            {
                for (int col = 0; col < ColCount; col++)
                {
                    if (Data[row, col] == true)
                    {
                        changedCells.Add(new IntPoint(row, col));
                        Data[row, col] = false;
                    }
                }
            }

            if (changedCells.Any())
            {
                var e = new ModelChangedEventArgs(EModelChangeType.CellList);
                e.ChangedCells.AddRange(changedCells);
                ModelChanged?.Invoke(e);
            }
        }