Exemplo n.º 1
0
        public LifeGrid()
            : base()
        {
            gridw = 0;
            gridh = 0;
            cellSize = 0;

            lastgx = 0;
            lastgy = 0;

            playing = false;
            speed = 0.05;
            lastUpdate = 0.0;

            currentBrush = null;
            selectMode = 0;
        }
Exemplo n.º 2
0
        // Event from LifeGrid
        void SaveBrush(object sender, LifeSelectEventArgs args)
        {
            // Save dialog
            SaveFileDialog savedialog = new SaveFileDialog();
            savedialog.CheckPathExists = true;
            savedialog.Filter = "Game of Life brush (*.lifebrush)|*.lifebrush";
            savedialog.FilterIndex = 0;

            DialogResult result = savedialog.ShowDialog();
            if (result != DialogResult.OK)
                return;

            // Create brush from selected grid
            Brush b = new Brush();
            b.Color = Color.RoyalBlue;
            b.SetGrid(args.grid);
            b.Width = 46;
            b.Height = 46;
            brushlist.Add(b);

            b.Save(savedialog.FileName);
        }
Exemplo n.º 3
0
        // OnClick from load
        void LoadBrush(object sender, EventArgs args)
        {
            // Open a select file dialog
            OpenFileDialog filedialog = new OpenFileDialog();
            filedialog.CheckPathExists = true;
            filedialog.CheckFileExists = true;
            filedialog.Multiselect = true;
            filedialog.Filter = "Game of life brush (*.lifebrush)|*.lifebrush";
            filedialog.FilterIndex = 0;

            DialogResult result = filedialog.ShowDialog();
            if (result != DialogResult.OK)
                return;

            // Loop through all files selected, create brushes and add them
            foreach (String file in filedialog.FileNames)
            {
                Brush b = new Brush();
                if (b.Load(file))
                {
                    b.Color = Color.RoyalBlue;
                    b.Width = 46;
                    b.Height = 46;
                    brushlist.Add(b);
                }
            }
        }