Ejemplo n.º 1
0
            public void Draw(LargeMapViewer2D viewer, Color backColor1, Color backColor2)
            {
                const int ALPHA = 64;
                const double AXISMULT = 1.5d;
                const double AXISWIDTH = 5;

                // Draw Axis
                viewer.DrawLine(Color.Red, AXISWIDTH, this.Position, this.Position + this.Rotation.GetRotatedVector(new MyVector(this.Radius * AXISMULT, 0, 0), true));
                viewer.DrawLine(Color.Green, AXISWIDTH, this.Position, this.Position + this.Rotation.GetRotatedVector(new MyVector(0, this.Radius * AXISMULT, 0), true));
                viewer.DrawLine(Color.Blue, AXISWIDTH, this.Position, this.Position + this.Rotation.GetRotatedVector(new MyVector(0, 0, this.Radius * AXISMULT), true));

                // Draw Polygon
                viewer.FillPolygon(backColor1, backColor2, this.Position, this);

                // Dot Colors
                Color colorRotateX = Color.Red;
                Color colorRotateY = Color.Green;
                Color colorRotateZ = Color.Blue;

                switch (_mouseDown)
                {
                    case MouseDownOnPolygon.Nothing:
                    case MouseDownOnPolygon.Ball:
                        break;

                    case MouseDownOnPolygon.RotateX:
                        colorRotateX = Color.HotPink;
                        break;

                    case MouseDownOnPolygon.RotateY:
                        colorRotateY = Color.Chartreuse;
                        break;

                    case MouseDownOnPolygon.RotateZ:
                        colorRotateZ = Color.LightBlue;
                        break;

                    default:
                        throw new ApplicationException("Unknown MouseDownOnTriangle: " + _mouseDown.ToString());
                }

                colorRotateX = Color.FromArgb(ALPHA, colorRotateX);
                colorRotateY = Color.FromArgb(ALPHA, colorRotateY);
                colorRotateZ = Color.FromArgb(ALPHA, colorRotateZ);
                Color circleColor = Color.FromArgb(ALPHA, Color.Black);

                // Draw Dots
                MyVector point = this.Position + this.RotateHandleX;
                viewer.FillCircle(colorRotateX, point, DOTRADIUS);
                viewer.DrawCircle(circleColor, .5d, point, DOTRADIUS);
                viewer.DrawString("X", _font, _fontBrush, point, ContentAlignment.MiddleCenter);

                point = this.Position + this.RotateHandleY;
                viewer.FillCircle(colorRotateY, point, DOTRADIUS);
                viewer.DrawCircle(circleColor, .5d, point, DOTRADIUS);
                viewer.DrawString("Y", _font, _fontBrush, point, ContentAlignment.MiddleCenter);

                point = this.Position + this.RotateHandleZ;
                viewer.FillCircle(colorRotateZ, point, DOTRADIUS);
                viewer.DrawCircle(circleColor, .5d, point, DOTRADIUS);
                viewer.DrawString("Z", _font, _fontBrush, point, ContentAlignment.MiddleCenter);
            }
Ejemplo n.º 2
0
            public void Draw(LargeMapViewer2D viewer, Color backColor)
            {
                const double DOTRADIUS = 35;
                const int ALPHA = 64;

                MyVector point1 = this.Position + this.Vertex1;
                MyVector point2 = this.Position + this.Vertex2;
                MyVector point3 = this.Position + this.Vertex3;

                // Draw Triangle
                viewer.FillTriangle(backColor, point1, point2, point3);
                viewer.DrawTriangle(Color.Black, 1, point1, point2, point3);

                // Dot Colors
                Color color1 = point1.Z < -1 ? Color.Black : point1.Z > 1 ? Color.White : Color.MediumPurple;
                Color color2 = point2.Z < -1 ? Color.Black : point2.Z > 1 ? Color.White : Color.MediumPurple;
                Color color3 = point3.Z < -1 ? Color.Black : point3.Z > 1 ? Color.White : Color.MediumPurple;
                Color colorRotate = Color.DarkSeaGreen;

                switch (_mouseDown)
                {
                    case MouseDownOnTriangle.Nothing:
                    case MouseDownOnTriangle.Ball:
                        break;

                    case MouseDownOnTriangle.Point1:
                        color1 = Color.Silver;
                        break;

                    case MouseDownOnTriangle.Point2:
                        color2 = Color.Silver;
                        break;

                    case MouseDownOnTriangle.Point3:
                        color3 = Color.Silver;
                        break;

                    case MouseDownOnTriangle.Rotate:
                        colorRotate = Color.Chartreuse;
                        break;

                    default:
                        throw new ApplicationException("Unknown MouseDownOnTriangle: " + _mouseDown.ToString());
                }

                color1 = Color.FromArgb(ALPHA, color1);
                color2 = Color.FromArgb(ALPHA, color2);
                color3 = Color.FromArgb(ALPHA, color3);
                colorRotate = Color.FromArgb(ALPHA, colorRotate);
                Color circleColor = Color.FromArgb(ALPHA, Color.Black);

                // Draw Dots
                viewer.FillCircle(color1, point1, DOTRADIUS);
                viewer.DrawCircle(circleColor, .5d, point1, DOTRADIUS);
                viewer.DrawString("1", _font, _fontBrush, point1, ContentAlignment.MiddleCenter);

                viewer.FillCircle(color2, point2, DOTRADIUS);
                viewer.DrawCircle(circleColor, .5d, point2, DOTRADIUS);
                viewer.DrawString("2", _font, _fontBrush, point2, ContentAlignment.MiddleCenter);

                viewer.FillCircle(color3, point3, DOTRADIUS);
                viewer.DrawCircle(circleColor, .5d, point3, DOTRADIUS);
                viewer.DrawString("3", _font, _fontBrush, point3, ContentAlignment.MiddleCenter);

                MyVector pointRotate = this.Position + this.Rotation.GetRotatedVector(_rotateHandle, true);

                viewer.FillCircle(colorRotate, pointRotate, DOTRADIUS);
                viewer.DrawCircle(circleColor, .5d, pointRotate, DOTRADIUS);
            }