private void RedrawButton_Click(object sender, RoutedEventArgs e)
        {
            UpdateCAProperties();

            //canvas.Width = (boxSize + 1) * length + 5;
            //canvas.Height = (boxSize + 1) * time + 5;

            ca = new SimulationPhys2_5.LinearCellularAutomaton(currentProperty.Rule, currentProperty.Length, currentProperty.Density);

            using (var dc = drawingGroup.Open())
            {
                Draw(dc, ca, currentProperty.MaxTime);
            }
        }
        private void RedrawButton_Click(object sender, RoutedEventArgs e)
        {
            UpdateCAProperties();

            //canvas.Width = (boxSize + 1) * length + 5;
            //canvas.Height = (boxSize + 1) * time + 5;

            ca = new SimulationPhys2_5.LinearCellularAutomaton(currentProperty.Rule, currentProperty.Length, currentProperty.Density);

            using (var dc = drawingGroup.Open())
            {
                Draw(dc, ca, currentProperty.MaxTime);
            }
        }
        void Draw(DrawingContext dc, SimulationPhys2_5.LinearCellularAutomaton ca, int time)
        {
            ca.Reset();

            foreach (int i in Enumerable.Range(0, time))
            {
                var currentStatus = ca.CurrentState.ToArray();
                foreach (int j in Enumerable.Range(0, ca.Length))
                {
                    if (currentStatus[j])
                    {
                        dc.DrawRectangle(Brushes.Black, boxStroke, new Rect(boxSize * j, boxSize * i, boxSize, boxSize));
                    }
                    else
                    {
                        dc.DrawRectangle(Brushes.White, boxStroke, new Rect(boxSize * j, boxSize * i, boxSize, boxSize));
                    }
                }
                ca.Next();
            }
        }