예제 #1
0
        public PhysicsPainterMainForm()
        {
            InitializeComponent();

            // Setup the map
            _map.CollisionHandler = new CollisionHandler();
            _map.CollisionHandler.PenetrationThresholdPercent = PENETRATIONTHRESHOLDPERCENT;
            _map.TimerPullApartType = PullApartType.Force;
            _map.CollisionHandler.PullApartSpringVelocity = 15d;

            // Setup the viewer
            pictureBox1.SetBorder(_boundryLower, _boundryUpper);
            pictureBox1.ShowBorder(Color.GhostWhite, 3);
            pictureBox1.ShowCheckerBackground(UtilityGDI.AlphaBlend(Color.DarkGray, pictureBox1.BackColor, .15d), 10);
            pictureBox1.ZoomFit();
            //pictureBox1.KeyDown += new KeyEventHandler(PhysicsPainter_KeyDown);
            //pictureBox1.KeyUp += new KeyEventHandler(PhysicsPainter_KeyUp);

            // Setup the renderer
            _renderer = new ObjectRenderer(pictureBox1);
            btnShowStats_Click(this, new EventArgs());

            _ignoreTokens = new List <long>();

            // Setup the adders/selecter
            _selector       = new Selector(pictureBox1, _map, _renderer, _ignoreTokens);
            _ballAdder      = new BallAdder(pictureBox1, _renderer, ballProps1.ExposedProps, _map, _boundryLower, _boundryUpper, _tempObjects);
            _gravMouse      = new GravMouse(pictureBox1, _map, _boundryLower, _boundryUpper);
            _shipController = new ShipController(pictureBox1, _map, _boundryLower, _boundryUpper);
            _gravController = new GravityController(_map);

            _ignoreTokens.Add(_gravMouse.CursorToken);
            _ignoreTokens.Add(_shipController.ShipToken);

            // Setup Panels
            scenes1.SetPointers(_map, _renderer, _ignoreTokens);
            shipProps1.SetPointers(pictureBox1, _shipController, _map);
            gravityProps1.SetPointers(_gravController);
            mapShape1.SetPointers(_boundryLower, _boundryUpper);
            generalProps1.SetPointers();

            // Put all the checkable toolbuttons into an array
            _checkButtons     = new ToolStripButton[16];
            _checkButtons[0]  = btnArrow;
            _checkButtons[1]  = btnPan;
            _checkButtons[2]  = btnGravityArrow;
            _checkButtons[3]  = btnVectorFieldArrow;
            _checkButtons[4]  = btnNewBall;
            _checkButtons[5]  = btnNewSolidBall;
            _checkButtons[6]  = btnNewRigidBody;
            _checkButtons[7]  = btnNewPolygon;
            _checkButtons[8]  = btnNewVectorField;
            _checkButtons[9]  = btnGravityProps;
            _checkButtons[10] = btnCollisionProps;
            _checkButtons[11] = btnGeneralProps;
            _checkButtons[12] = btnMapShape;
            _checkButtons[13] = btnScenes;
            _checkButtons[14] = btnShip;
            _checkButtons[15] = btnMenuTester;

            // Put all the pie panels into an array
            _piePanels    = new PiePanel[8];
            _piePanels[0] = ballProps1;
            _piePanels[1] = solidBallProps1;
            _piePanels[2] = scenes1;
            _piePanels[3] = shipProps1;
            _piePanels[4] = pieMenuTester1;
            _piePanels[5] = gravityProps1;
            _piePanels[6] = mapShape1;
            _piePanels[7] = generalProps1;

            // Position all the pie controls (their anchor is already set)
            foreach (PiePanel piePanel in _piePanels)
            {
                piePanel.Anchor = ((AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Left));

                piePanel.Top  = this.DisplayRectangle.Height - piePanel.Height;
                piePanel.Left = 0;
                piePanel.SetDefaultBackColor();
            }

            // Start with the ball (I've watched several people just stare at this form when they see if for the first time, and
            // they don't know what to do.  Hopefully with the ball brush selected, they'll catch on faster)
            btnNewBall.Checked = true;
            btnNewBall_Click(this, new EventArgs());

            // Get the world started
            //TODO:  Don't use the timer to do drawing, only physics
            timer1.Enabled = true;              // this always stays enabled, because I need to keep drawing the world.
        }
        public PhysicsPainterMainForm()
        {
            InitializeComponent();

            // Setup the map
            _map.CollisionHandler = new CollisionHandler();
            _map.CollisionHandler.PenetrationThresholdPercent = PENETRATIONTHRESHOLDPERCENT;
            _map.TimerPullApartType = PullApartType.Force;
            _map.CollisionHandler.PullApartSpringVelocity = 15d;

            // Setup the viewer
            pictureBox1.SetBorder(_boundryLower, _boundryUpper);
            pictureBox1.ShowBorder(Color.GhostWhite, 3);
            pictureBox1.ShowCheckerBackground(UtilityGDI.AlphaBlend(Color.DarkGray, pictureBox1.BackColor, .15d), 10);
            pictureBox1.ZoomFit();
            //pictureBox1.KeyDown += new KeyEventHandler(PhysicsPainter_KeyDown);
            //pictureBox1.KeyUp += new KeyEventHandler(PhysicsPainter_KeyUp);

            // Setup the renderer
            _renderer = new ObjectRenderer(pictureBox1);
            btnShowStats_Click(this, new EventArgs());

            _ignoreTokens = new List<long>();

            // Setup the adders/selecter
            _selector = new Selector(pictureBox1, _map, _renderer, _ignoreTokens);
            _ballAdder = new BallAdder(pictureBox1, _renderer, ballProps1.ExposedProps, _map, _boundryLower, _boundryUpper, _tempObjects);
            _gravMouse = new GravMouse(pictureBox1, _map, _boundryLower, _boundryUpper);
            _shipController = new ShipController(pictureBox1, _map, _boundryLower, _boundryUpper);
            _gravController = new GravityController(_map);

            _ignoreTokens.Add(_gravMouse.CursorToken);
            _ignoreTokens.Add(_shipController.ShipToken);

            // Setup Panels
            scenes1.SetPointers(_map, _renderer, _ignoreTokens);
            shipProps1.SetPointers(pictureBox1, _shipController, _map);
            gravityProps1.SetPointers(_gravController);
            mapShape1.SetPointers(_boundryLower, _boundryUpper);
            generalProps1.SetPointers();

            // Put all the checkable toolbuttons into an array
            _checkButtons = new ToolStripButton[16];
            _checkButtons[0] = btnArrow;
            _checkButtons[1] = btnPan;
            _checkButtons[2] = btnGravityArrow;
            _checkButtons[3] = btnVectorFieldArrow;
            _checkButtons[4] = btnNewBall;
            _checkButtons[5] = btnNewSolidBall;
            _checkButtons[6] = btnNewRigidBody;
            _checkButtons[7] = btnNewPolygon;
            _checkButtons[8] = btnNewVectorField;
            _checkButtons[9] = btnGravityProps;
            _checkButtons[10] = btnCollisionProps;
            _checkButtons[11] = btnGeneralProps;
            _checkButtons[12] = btnMapShape;
            _checkButtons[13] = btnScenes;
            _checkButtons[14] = btnShip;
            _checkButtons[15] = btnMenuTester;

            // Put all the pie panels into an array
            _piePanels = new PiePanel[8];
            _piePanels[0] = ballProps1;
            _piePanels[1] = solidBallProps1;
            _piePanels[2] = scenes1;
            _piePanels[3] = shipProps1;
            _piePanels[4] = pieMenuTester1;
            _piePanels[5] = gravityProps1;
            _piePanels[6] = mapShape1;
            _piePanels[7] = generalProps1;

            // Position all the pie controls (their anchor is already set)
            foreach (PiePanel piePanel in _piePanels)
            {
                piePanel.Anchor = ((AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Left));

                piePanel.Top = this.DisplayRectangle.Height - piePanel.Height;
                piePanel.Left = 0;
                piePanel.SetDefaultBackColor();
            }

            // Start with the ball (I've watched several people just stare at this form when they see if for the first time, and
            // they don't know what to do.  Hopefully with the ball brush selected, they'll catch on faster)
            btnNewBall.Checked = true;
            btnNewBall_Click(this, new EventArgs());

            // Get the world started
            //TODO:  Don't use the timer to do drawing, only physics
            timer1.Enabled = true;		// this always stays enabled, because I need to keep drawing the world.
        }