Ejemplo n.º 1
0
        private void piePanelMenu1_DrawButton(object sender, PieMenuDrawButtonArgs e)
        {
            switch (e.Name)
            {
                case BUTTON_DENSITY:
                    e.Graphics.DrawString("Density", new Font("Arial", 8), Brushes.Black, 0, e.ButtonSize - 13);
                    break;

                default:
                    MessageBox.Show("Unknown Button: " + e.Name, "General Props - Draw Button", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
            }
        }
Ejemplo n.º 2
0
        private void piePanelMenuTop1_DrawButton(object sender, PieMenuDrawButtonArgs e)
        {
            switch (e.Name)
            {
                case BUTTON_SIZE:
                    DrawSize(e);
                    break;

                case BUTTON_VELOCITY:
                    DrawVelocity(e);
                    break;

                default:
                    MessageBox.Show("Unknown Button: " + e.Name, "SolidBallProps Button Clicked", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
            }
        }
Ejemplo n.º 3
0
        private void piePanelMenu1_DrawButton(object sender, PieMenuDrawButtonArgs e)
        {
            switch (e.Name)
            {
                case BUTTON_MAIN:
                    e.Graphics.DrawString("Main", new Font("Arial", 8), Brushes.Black, 0, e.ButtonSize - 13);
                    break;

                case BUTTON_TRACTOR:
                    e.Graphics.DrawString("Tractor", new Font("Arial", 8), Brushes.Black, 0, e.ButtonSize - 13);
                    break;

                case BUTTON_GUN:
                    e.Graphics.DrawString("Gun", new Font("Arial", 8), Brushes.Black, 0, e.ButtonSize - 13);
                    break;

                default:
                    MessageBox.Show("Unknown Button: " + e.Name, "Ship Props - Draw Button", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
            }
        }
Ejemplo n.º 4
0
 private void piePanelMenuTop1_DrawButton(object sender, PieMenuDrawButtonArgs e)
 {
     e.Graphics.Clear(_buttonColors[e.Index]);
 }
Ejemplo n.º 5
0
 private void piePanelMenuTop1_DrawButton(object sender, PieMenuDrawButtonArgs e)
 {
     e.Graphics.Clear(_buttonColors[e.Index]);
 }
Ejemplo n.º 6
0
        private void DrawVelocity(PieMenuDrawButtonArgs e)
        {
            const double MINLENGTHPERCENT = 0d;
            const double MAXLENGTHPERCENT = 1d;
            const double MINTARGET = 10d;
            const double MAXTARGET = 250d;

            #region Figure out the length

            // Figure out how long the real velocity will be
            double realVelocity = 0d;

            if (this.ExposedProps.RandomVelocity)
            {
                realVelocity = this.ExposedProps.MaxVelocity * .75d;
            }
            else
            {
                if (this.ExposedProps.Velocity != null && !this.ExposedProps.Velocity.IsZero)
                {
                    realVelocity = this.ExposedProps.Velocity.GetMagnitude();
                }
            }

            // Figure out the velocity to draw
            double velocityPercent = 0d;
            if (realVelocity >= MINLENGTHPERCENT)
            {
                velocityPercent = UtilityCore.GetScaledValue_Capped(MINLENGTHPERCENT, MAXLENGTHPERCENT, MINTARGET, MAXTARGET, realVelocity);
            }

            #endregion

            // Figure out the color
            Color velocityColor = GetGreenRedColor(MINTARGET, MAXTARGET, realVelocity, velocityPercent);

            float halfSize = e.ButtonSize * .5f;

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            if (velocityPercent > 0d)
            {
                #region Draw Vector

                double drawLength = (e.ButtonSize / 2d) * velocityPercent;

                // Draw Vector
                using (Pen vectorPen = new Pen(velocityColor, 2f))
                {
                    vectorPen.StartCap = LineCap.Round;	// LineCap.RoundAnchor;
                    vectorPen.EndCap = LineCap.ArrowAnchor;

                    MyVector vectorLine;
                    if (this.ExposedProps.RandomVelocity)
                    {
                        // Draw a circle underneath
                        using (Pen circlePen = new Pen(SystemColors.ControlDark, 1f))
                        {
                            e.Graphics.DrawEllipse(circlePen, Convert.ToSingle(halfSize - drawLength), Convert.ToSingle(halfSize - drawLength), Convert.ToSingle(drawLength * 2d), Convert.ToSingle(drawLength * 2d));
                        }

                        vectorLine = new MyVector(drawLength, 0, 0);

                        vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-60d));
                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                        vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-85d));
                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                        vectorLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-150d));
                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));

                    }
                    else
                    {
                        vectorLine = this.ExposedProps.Velocity.Clone();
                        vectorLine.BecomeUnitVector();
                        vectorLine.Multiply(drawLength);

                        e.Graphics.DrawLine(vectorPen, halfSize, halfSize, Convert.ToSingle(halfSize + vectorLine.X), Convert.ToSingle(halfSize + vectorLine.Y));
                    }
                }

                #endregion
            }
            else
            {
                e.Graphics.DrawString("Velocity", new Font("Arial", 8), Brushes.Black, 0, e.ButtonSize - 13);
            }

        }
Ejemplo n.º 7
0
        private void DrawSize(PieMenuDrawButtonArgs e)
        {
            const double MINRADIUSPERCENT = .15d;
            const double MAXRADIUSPERCENT = 1d;
            const double MINTARGET = 20d;
            const double MAXTARGET = 1000d;

            #region Figure out the radius

            // Figure out how big the real ball will be
            double ballRadius = 0;

            switch (this.ExposedProps.SizeMode)
            {
                case BallProps.SizeModes.Draw:
                    //TODO:  Use a different line color
                    ballRadius = UtilityCore.GetScaledValue(MINTARGET, MAXTARGET, 0d, 1d, .75d);
                    break;

                case BallProps.SizeModes.Fixed:
                    ballRadius = this.ExposedProps.SizeIfFixed;
                    break;

                case BallProps.SizeModes.Random:
                    ballRadius = (this.ExposedProps.MinRandSize + this.ExposedProps.MaxRandSize) / 2d;
                    break;

                default:
                    throw new ApplicationException("Unknown BallProps.SizeModes: " + this.ExposedProps.SizeMode.ToString());
            }

            // Figure out the radius to draw
            double radiusPercent = UtilityCore.GetScaledValue_Capped(MINRADIUSPERCENT, MAXRADIUSPERCENT, MINTARGET, MAXTARGET, ballRadius);

            #endregion

            // Figure out the color
            Color radiusColor = GetGreenRedColor(MINTARGET, MAXTARGET, ballRadius, radiusPercent);

            float drawWidth = Convert.ToSingle((e.ButtonSize - 2) * radiusPercent);
            float halfDrawWidth = drawWidth * .5f;
            float halfSize = (e.ButtonSize - 2) * .5f;

            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            // Draw Radius
            using (Pen radiusPen = new Pen(radiusColor, 2f))
            {
                MyVector radiusLine = new MyVector(halfDrawWidth, 0, 0);
                radiusLine.RotateAroundAxis(new MyVector(0, 0, 1), Utility3D.GetDegreesToRadians(-30d));

                e.Graphics.DrawLine(radiusPen, halfSize, halfSize, Convert.ToSingle(halfSize + radiusLine.X), Convert.ToSingle(halfSize + radiusLine.Y));
            }

            // Draw Circle
            Color circleColor = Color.Black;
            if (this.ExposedProps.SizeMode == BallProps.SizeModes.Draw)
            {
                circleColor = SystemColors.ControlDark;
            }

            using (Pen circlePen = new Pen(circleColor, 2f))
            {
                e.Graphics.DrawEllipse(circlePen, halfSize - halfDrawWidth, halfSize - halfDrawWidth, drawWidth, drawWidth);
            }
        }