Exemple #1
0
        private void ResetHotTrackPens()
        {
            // Clicked
            if (_clickedBrush != null)
            {
                _clickedBrush.Dispose();
                _clickedBrush = null;
            }
            if (_clickedPen != null)
            {
                _clickedPen.Dispose();
                _clickedPen = null;
            }

            _clickedBrush = new SolidBrush(SystemColors.Window);
            _clickedPen   = new Pen(UtilityGDI.AlphaBlend(SystemColors.HotTrack, this.BackColor, .33d));

            // HotTrack
            if (_hotTrackBrush != null)
            {
                _hotTrackBrush.Dispose();
                _hotTrackBrush = null;
            }
            if (_hotTrackPen != null)
            {
                _hotTrackPen.Dispose();
                _hotTrackPen = null;
            }

            _hotTrackBrush = new SolidBrush(UtilityGDI.AlphaBlend(SystemColors.HotTrack, this.BackColor, .05d));
            _hotTrackPen   = new Pen(UtilityGDI.AlphaBlend(SystemColors.HotTrack, this.BackColor, .33d));
        }
Exemple #2
0
        private void DrawShipRunning(Color massColor, Color massOutlineColor)
        {
            // Radius
            pictureBox1.DrawCircle(UtilityGDI.AlphaBlend(Color.DarkCyan, Color.Black, .5d), .5d, _ship.Position, _ship.Radius);

            // Point Masses
            SolidBrush massBrush = new SolidBrush(massColor);

            foreach (PointMass pointMass in _ship.PointMasses)
            {
                MyVector rotatedMass = _ship.Rotation.GetRotatedVector(pointMass.Position, true);

                pictureBox1.FillCircle(massBrush, _ship.Position + rotatedMass, pointMass.Mass);
                pictureBox1.DrawCircle(massOutlineColor, 1, _ship.Position + rotatedMass, pointMass.Mass);
            }

            massBrush.Dispose();

            // Orientation
            pictureBox1.DrawLine(Color.FromArgb(64, 64, 64), 1, _ship.Position, _ship.Position + (_ship.DirectionFacing.Standard * 100d));
            pictureBox1.DrawLine(Color.FromArgb(32, 32, 32), 1, _ship.Position, _ship.Position + (_ship.DirectionFacing.Orth * 100d));

            MyVector rotatedCenterMass = _ship.Rotation.GetRotatedVector(_ship.CenterOfMass, true);

            // Line from centerpoint to centermass
            pictureBox1.DrawLine(UtilityGDI.AlphaBlend(Color.DarkMagenta, Color.Black, .4d), 1, _ship.Position, _ship.Position + rotatedCenterMass);

            // Center Point
            pictureBox1.FillCircle(Color.DarkMagenta, _ship.Position, 2);

            // Center Mass
            pictureBox1.FillCircle(Color.HotPink, _ship.Position + rotatedCenterMass, 2);
        }
Exemple #3
0
        private void ColorArrowKeysSprtSinglePictureBox(PictureBox pctBox, bool isPressed, ThrusterKey key)
        {
            Color  pressedColor;
            double alpha;

            if (isPressed)
            {
                pressedColor = SystemColors.ControlDark;
                alpha        = .5d;
            }
            else
            {
                pressedColor = SystemColors.Control;
                alpha        = .25d;
            }

            if (_thrustersCustom.ContainsKey(key))
            {
                pctBox.BackColor = UtilityGDI.AlphaBlend(_thrusterColors[key], pressedColor, alpha);
            }
            else
            {
                pctBox.BackColor = SystemColors.Control;
            }
        }
Exemple #4
0
        public SolidBallPropsMenu()
        {
            InitializeComponent();

            _hotTrackBrush = new SolidBrush(UtilityGDI.AlphaBlend(SystemColors.HotTrack, this.BackColor, .05d));
            _hotTrackPen   = new Pen(UtilityGDI.AlphaBlend(SystemColors.HotTrack, this.BackColor, .33d));
        }
Exemple #5
0
        public void SetDefaultBackColor()
        {
            // I tried to match the backcolor of the tab control
            //this.BackColor = UtilityHelper.AlphaBlend(UtilityHelper.AlphaBlend(SystemColors.Control, SystemColors.Window, .4d), Color.GhostWhite, .85d);

            this.BackColor = UtilityGDI.AlphaBlend(SystemColors.Window, SystemColors.Control, .65d);            // that gray was UGLY

            // Repaint the background
            RebuildRegion();
        }
Exemple #6
0
        private Color GetGreenRedColor(double minTarget, double maxTarget, double actualValue, double sizePercent)
        {
            if (sizePercent < .9d)
            {
                return(Color.OliveDrab);
            }
            else
            {
                double derivedMinTarget = UtilityCore.GetScaledValue(minTarget, maxTarget, 0d, 1d, .9d);
                double colorPercent     = UtilityCore.GetScaledValue_Capped(0d, 1d, derivedMinTarget, maxTarget * 3d, actualValue);

                return(UtilityGDI.AlphaBlend(Color.Firebrick, Color.OliveDrab, colorPercent));
            }
        }
Exemple #7
0
        private void trkYBoundry_Scroll(object sender, EventArgs e)
        {
            _boundryLower.Y = trkYBoundry.Value * trkBoundryScale.Value * -1;
            _boundryUpper.Y = trkYBoundry.Value * trkBoundryScale.Value;

            int numSquares = trkYBoundry.Value / 500;           // integer division

            if (numSquares > 0)
            {
                pictureBox1.ShowCheckerBackground(UtilityGDI.AlphaBlend(Color.DarkGray, pictureBox1.BackColor, .15d), numSquares);
            }
            else
            {
                pictureBox1.HideBackground();
            }
        }
Exemple #8
0
        private void DrawThrustDesign(Color fromColor, double alpha)
        {
            MyVector centerPoint = GetMiddlePoint();

            // Draw all the thrusters
            foreach (ThrusterKey thrusterKey in _thrustersCustom.Keys)
            {
                foreach (MyVector[] thruster in _thrustersCustom[thrusterKey])
                {
                    MyVector offset  = centerPoint + thruster[0];
                    MyVector toPoint = offset + thruster[1];

                    Color finalColor = UtilityGDI.AlphaBlend(_thrusterColors[thrusterKey], fromColor, alpha);

                    DrawDot(offset, 5, finalColor);
                    DrawVector(offset, toPoint, finalColor);
                }
            }
        }
Exemple #9
0
        private void DrawRigidBody(RigidBody body, Color massColor, Color massOutlineColor, bool drawRed)
        {
            // Radius
            if (drawRed)
            {
                pictureBox1.FillCircle(Color.FromArgb(160, Color.Tomato), body.Position, body.Radius);
            }
            else
            {
                pictureBox1.FillCircle(Color.FromArgb(32, Color.DarkTurquoise), body.Position, body.Radius);
            }
            pictureBox1.DrawCircle(UtilityGDI.AlphaBlend(Color.DarkTurquoise, Color.Black, .5d), .5d, body.Position, body.Radius);

            // Point Masses
            SolidBrush massBrush = new SolidBrush(massColor);

            foreach (PointMass pointMass in body.PointMasses)
            {
                MyVector rotatedMass = body.Rotation.GetRotatedVector(pointMass.Position, true);

                pictureBox1.FillCircle(massBrush, body.Position + rotatedMass, pointMass.Mass);
                pictureBox1.DrawCircle(massOutlineColor, 1, body.Position + rotatedMass, pointMass.Mass);
            }

            massBrush.Dispose();

            // Orientation
            //_viewer.DrawLine(Color.FromArgb(64, 64, 64), 1, body.Position, MyVector.AddVector(body.Position, MyVector.MultiplyConstant(body.DirectionFacing.Stanard, 100)));
            //_viewer.DrawLine(Color.FromArgb(32, 32, 32), 1, body.Position, MyVector.AddVector(body.Position, MyVector.MultiplyConstant(body.DirectionFacing.Orth, 100)));

            MyVector rotatedCenterMass = body.Rotation.GetRotatedVector(body.CenterOfMass, true);

            // Line from centerpoint to centermass
            pictureBox1.DrawLine(Color.DarkMagenta, 1, body.Position, body.Position + rotatedCenterMass);

            // Center Point
            pictureBox1.FillCircle(Color.DarkMagenta, body.Position, 10);

            // Center Mass
            pictureBox1.FillCircle(Color.HotPink, body.Position + rotatedCenterMass, 22);
        }
Exemple #10
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.
        }
Exemple #11
0
        private void RepositionButtons()
        {
            if (this.Width <= 2 || this.Height <= 2)
            {
                return;
            }

            if (_buttons.Count == 0)
            {
                return;
            }

            const int OUTERMARGIN = 4;
            const int INNERMARGIN = 2;

            // Figure out the max button size, and how they should be tiled
            List <int> buttonsPerRow = GetButtonArrangement(out _buttonSize, INNERMARGIN, OUTERMARGIN);

            if (_buttonSize == -1)
            {
                MessageBox.Show("Buttons don't fit in the space provided", "Pie Panel Menu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                _buttonSize = 1;
            }

            // Place and draw the buttons
            int buttonCntr = 0;

            for (int rowCntr = 0; rowCntr < buttonsPerRow.Count; rowCntr++)
            {
                // All buttons in this row will be at this y coord
                int y = this.Height - OUTERMARGIN - ((buttonsPerRow.Count - rowCntr) * _buttonSize) - ((buttonsPerRow.Count - rowCntr - 1) * INNERMARGIN);

                for (int colCntr = 0; colCntr < buttonsPerRow[rowCntr]; colCntr++)
                {
                    #region Place Button

                    // Figure out where this button will sit
                    _buttons[buttonCntr].Rectangle = new Rectangle(OUTERMARGIN + (colCntr * _buttonSize) + (colCntr * INNERMARGIN), y, _buttonSize, _buttonSize);

                    // Rebuild the graphics path
                    //TODO: Support slightly rounded corners
                    if (_buttons[buttonCntr].Outline != null)
                    {
                        _buttons[buttonCntr].Outline.Dispose();
                        _buttons[buttonCntr].Outline = null;
                    }

                    _buttons[buttonCntr].Outline = UtilityGDI.GetRoundedRectangle(_buttons[buttonCntr].Rectangle, _buttonSize / 3);

                    // Draw the button
                    DrawButton_Private(buttonCntr);

                    #endregion

                    // Point to the next button
                    buttonCntr++;
                }
            }

            // Any time the layout changes, I should probably redraw
            this.Invalidate();
        }