示例#1
0
 public MainWindow()
 {
     InitializeComponent();
     HelperFunctions.PositionWindow(ref MainWindowN);                       // Set Position of MainWindow
     Log.Logger = new LoggerConfiguration().WriteTo.Debug().CreateLogger(); // Create logging object
     TheMatrix  = new Matrix(ref LifeGrid, 8, 16);                          //Init Rectangles/Universes/Matrix
     TheMatrix.Generate();                                                  // Create Rectangles/Universes/Matrix
     LifeCycle = new Life(ref TheMatrix);                                   // Begin the circle of Life
     LifeCycle.Start();
 }
示例#2
0
        private void MainWindowN_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Space)
            {
                if (LifeCycle.InProcess)
                {
                    LifeCycle.End();
                    TheMatrix.Universes.All((x) => { x.MouseDown += Universe_MouseDown; return(true); });
                }
                else
                {
                    LifeCycle.Start();
                }
            }
            if (e.Key == System.Windows.Input.Key.C)
            {
                TheMatrix.Universes.All((x) => { x.Die(); return(true); });

                for (int i = 0; i < 32; i++)
                {
                    TheMatrix.Universes.Where((x) => { return(x.X == Convert.ToUInt64(i) && x.Y == Convert.ToUInt64(i)); }).First().Born();
                    TheMatrix.Universes.Where((x) => { return(x.X == Convert.ToUInt64(31 - i) && x.Y == Convert.ToUInt64(i)); }).First().Born();
                }
            }
            if (e.Key == System.Windows.Input.Key.S)
            {
                LifeCycle.LifeCycleSequence();
            }
            if (e.Key == System.Windows.Input.Key.O)
            {
                TheMatrix.Universes.All((x) => { x.Die(); return(true); });

                TheMatrix.Universes.Where((x) => { return(x.X == 15 && x.Y == 15); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 16 && x.Y == 15); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 15 && x.Y == 16); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 15 && x.Y == 17); }).First().Born();
            }
            if (e.Key == System.Windows.Input.Key.B)
            {
                TheMatrix.Universes.All((x) => { x.Die(); return(true); });

                TheMatrix.Universes.Where((x) => { return(x.X == 15 && x.Y == 15); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 15 && x.Y == 16); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 15 && x.Y == 17); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 16 && x.Y == 15); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 16 && x.Y == 16); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 16 && x.Y == 17); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 17 && x.Y == 15); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 17 && x.Y == 16); }).First().Born();
                TheMatrix.Universes.Where((x) => { return(x.X == 17 && x.Y == 17); }).First().Born();
            }
        }