Exemplo n.º 1
0
        //added to support visual studio forms designer
        public void setModel(CritterModel model)
        {
            myModel = model;
            // construct font and compute char width once in constructor
            // for efficiency
            myFont    = new Font(FontFamily.GenericMonospace, FONT_SIZE + 4, FontStyle.Bold);
            BackColor = Color.Cyan;

            Size = new Size(FONT_SIZE * model.getWidth() + 20, FONT_SIZE * model.getHeight() + 20);
        }
Exemplo n.º 2
0
        public CritterPanel(CritterModel model)
        {
            InitializeComponent();
            // this prevents someone from trying to create their own copy of
            // the GUI components
            if (created)
            {
                throw new SystemException("Only one world allowed");
            }
            created = true;

            myModel = model;
            // construct font and compute char width once in constructor
            // for efficiency
            myFont    = new Font(FontFamily.GenericMonospace, FONT_SIZE + 4, FontStyle.Bold);
            BackColor = Color.Cyan;

            Size = new Size(FONT_SIZE * model.getWidth() + 20, FONT_SIZE * model.getHeight() + 20);
        }
Exemplo n.º 3
0
        public CritterFrame(int width, int height)
        {
            InitializeComponent();
            // this prevents someone from trying to create their own copy of
            // the GUI components
            if (created)
            {
                throw new SystemException("Only one world allowed");
            }
            created = true;

            // create model
            myModel = new CritterModel(width, height);

            // set up critter picture panel
            //   myPicture = new CritterPanel(myModel);
            myPicture.setModel(myModel);

            // initially it has not started
            started = false;
        }