Esempio n. 1
0
 /*******************************************************************************************************************
 *******************************************************************************************************************/
 internal void AddNewPattern(CellWorld pattern)
 {
     pattern.Name = GetNameFromUser();
     pattern.NormalizeWorld();
     Patterns.Add(new CellWorld(pattern));
     pattern.Cells.Clear();
     UpdatePatternList();
 }
Esempio n. 2
0
        /*******************************************************************************************************************
        *******************************************************************************************************************/
        private void LoadPatternFromDisk(string fileName)
        {
            var name = Path.GetFileNameWithoutExtension(fileName);
            var cw   = new CellWorld(Color.AliceBlue)
            {
                Name = name
            };

            cw.LoadWorld(fileName);
            Patterns.Add(cw);
        }
        /*******************************************************************************************************************
        *******************************************************************************************************************/
        private void ToggleAtPosition(int x, int y, CellWorld world)
        {
            var pos = world.Cells.FindIndex(c => c.x == x && c.y == y);

            if (pos < 0)
            {
                world.Cells.Add(new Cell(x, y, world.CellColor));
            }
            else
            {
                world.Cells.RemoveAt(pos);
            }
            Draw();
        }
Esempio n. 4
0
        /*******************************************************************************************************************
        *******************************************************************************************************************/
        private void SavePatternBackToDisk(CellWorld p)
        {
            var name = Path.ChangeExtension(p.Name, patternFileExtension);

            p.SaveWorld(name);
        }
 /*******************************************************************************************************************
 *******************************************************************************************************************/
 public GameOfLifeWorld(Canvas world) : base(Color.DeepSkyBlue)
 {
     theWorld   = world;
     NewPattern = new CellWorld(Color.Violet);
 }
Esempio n. 6
0
 /*******************************************************************************************************************
 *******************************************************************************************************************/
 public CellWorld(CellWorld cpy)
 {
     CellColor = cpy.CellColor;
     Cells     = new List <Cell>(cpy.Cells);
     Name      = cpy.Name;
 }