예제 #1
0
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            UpdateTimer();
            Update();

            // Clear to the default control background color.
            //Color backColor = new Color(BackColor.R, BackColor.G, BackColor.B);
            Color backColor = Color.CornflowerBlue;

            GraphicsDevice.Clear(backColor);

            if (SpriteFont != null && RoundLineManager != null && Effect != null)
            {
                Matrix viewProjMatrix = viewMatrix * projMatrix;

                roundLineManager.NumLinesDrawn = 0;

                float lineRadius = 4;
                roundLineManager.BlurThreshold = roundLineManager.ComputeBlurThreshold(lineRadius, viewProjMatrix,
                                                                                       GraphicsDevice.PresentationParameters.BackBufferWidth);

                float  time             = (float)gameTimer.TotalGameTime.TotalSeconds;
                string curTechniqueName = roundLineTechniqueNames[roundLineTechniqueIndex];

                roundLineManager.Draw(blueRoundLines, lineRadius, Color.Blue, viewProjMatrix, time, curTechniqueName);
                roundLineManager.Draw(greenRoundLines, lineRadius, Color.Green, viewProjMatrix, time, curTechniqueName);

                dude.Pos = new Vector2(cameraX, cameraY);
                roundLineManager.Draw(dude, 8, Color.Red, viewProjMatrix, time, "Tubular");

                Vector2 textPos = new Vector2(50, 50);
                spriteBatch.Begin();
                if (gameTimer.IsRunningSlowly)
                {
                    spriteBatch.DrawString(SpriteFont, "IsRunningSlowly", textPos, Color.Red);
                }
                else
                {
                    spriteBatch.DrawString(SpriteFont, "IsRunningNormally", textPos, Color.White);
                }

                textPos += new Vector2(0, 30);
                spriteBatch.DrawString(SpriteFont, string.Format("{0} Lines", roundLineManager.NumLinesDrawn), textPos, Color.White);

                textPos += new Vector2(0, 30);
                spriteBatch.DrawString(SpriteFont, string.Format("Technique (Press A): {0}", curTechniqueName), textPos, Color.White);

                spriteBatch.End();
            }
        }
예제 #2
0
        private void DrawGridsAndScale()
        {
            //var majorlinesPen = new Pen(System.Drawing.Color.Wheat, 1);
            //var minorlinesPen = new Pen(System.Drawing.Color.LightGray, 1);
            majorLines.Clear();
            minorLines.Clear();

            Xorigin = Yorigin = 0;
            ScaleX  = _width;
            ScaleY  = _height;

            _width  = (int)(SizePicture.X);
            _height = (int)(SizePicture.Y);

            var xMajorLines = (int)(_width / MajorIntervals / ScaleDraw.X);
            var yMajorLines = (int)(_height / MajorIntervals / ScaleDraw.Y);

            try
            {
                //draw X Axis major lines
                for (int i = 0; i <= xMajorLines; i++)
                {
                    float x = i * (_width / xMajorLines);
                    minorLines.Add(new RoundLine(x, 0.0f, x, _height));

                    //draw X Axis minor lines
                    for (int i1 = 1; i1 <= Xdivs; i1++)
                    {
                        float x1 = i1 * MajorIntervals / (Xdivs) * ScaleDraw.X;
                        majorLines.Add(new RoundLine(x + x1, 0, x + x1, _height));
                    }
                }

                //draw Y Axis major lines
                for (int i = 0; i <= yMajorLines; i++)
                {
                    //y = i * (Height / (yMajorLines));
                    float y = i * MajorIntervals * ScaleDraw.Y;
                    minorLines.Add(new RoundLine(0, y, _width, y));

                    //draw Y Axis minor lines
                    for (int i1 = 1; i1 <= Ydivs; i1++)
                    {
                        float y1 = i1 * MajorIntervals / (Ydivs) * ScaleDraw.Y;
                        majorLines.Add(new RoundLine(0, y + y1, _width, y + y1));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            roundLineManager.NumLinesDrawn = 0;

            float lineRadius = 1;

            roundLineManager.BlurThreshold = roundLineManager.ComputeBlurThreshold(lineRadius, viewProjMatrix,
                                                                                   GraphicsDevice.PresentationParameters.BackBufferWidth);



            if (RoundLineManager != null)
            {
                roundLineManager.Draw(minorLines, lineRadius, Color.LightGray, viewProjMatrix, time, curTechniqueName);
                roundLineManager.Draw(majorLines, lineRadius, Color.Wheat, viewProjMatrix, time, curTechniqueName);

                dude.Pos = new Vector2(camera.Pos.X, camera.Pos.Y);
                roundLineManager.Draw(dude, 8, Color.Red, viewProjMatrix, time, "Tubular");
            }
        }