예제 #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.White;

            GraphicsDevice.Clear(backColor);

            if (DrawingBatch != null && Texture != null && SpriteFont != null)
            {
                drawingContext.Begin();
                drawingContext.DrawLine(10, 20, 100, 20, Color.Red);
                drawingContext.DrawRectangle(120, 10, 100, 20, Color.Blue);
                drawingContext.DrawTriangle(240, 10, 240, 60, 200, 60, Color.Black);
                drawingContext.DrawEllipse(310, 10, 50, 50, Color.Green);
                drawingContext.DrawTexture(texture, new Vector2(10, 300), Color.White);
                drawingContext.DrawPolyline(new Vector2[] { new Vector2(410, 10), new Vector2(440, 10), new Vector2(420, 20), new Vector2(440, 40), new Vector2(410, 60) }, Color.Aqua);
                drawingContext.DrawFilledRectangle(120, 110, 50, 50, Color.Blue);
                drawingContext.DrawFilledTriangle(240, 110, 240, 160, 200, 160, Color.Brown);
                drawingContext.DrawFilledEllipse(310, 110, 80, 40, Color.Green);
                drawingContext.DrawText(SpriteFont, "Hello World!", new Vector2(120, 300), Color.Black);
                drawingContext.End();
            }
        }
예제 #2
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);
            Microsoft.Xna.Framework.Color backColor = Microsoft.Xna.Framework.Color.White;

            GraphicsDevice.Clear(backColor);

            if (DrawingContext != null && SpriteFont != null)
            {
                drawingContext.Begin();

                drawingContext.DrawText(SpriteFont, "X: " + MouseX.ToString(), new Vector2(1, 10), Microsoft.Xna.Framework.Color.Black);
                drawingContext.DrawText(SpriteFont, "Y: " + MouseY.ToString(), new Vector2(1, 30), Microsoft.Xna.Framework.Color.Black);
                drawingContext.DrawText(SpriteFont, "X: " + MyMouseX.ToString(), new Vector2(1, 50), Microsoft.Xna.Framework.Color.Black);
                drawingContext.DrawText(SpriteFont, "Y: " + MyMouseY.ToString(), new Vector2(1, 70), Microsoft.Xna.Framework.Color.Black);

                drawingContext.DrawText(SpriteFont, "Top: " + NetRectangle.Top.ToString() + " Right: " + NetRectangle.Right.ToString(), new Vector2(80, 10), Microsoft.Xna.Framework.Color.Black);
                drawingContext.DrawText(SpriteFont, "Left: " + NetRectangle.Left.ToString() + " Bottom: " + NetRectangle.Bottom.ToString(), new Vector2(80, 30), Microsoft.Xna.Framework.Color.Black);

                drawingContext.DrawText(SpriteFont, "X: " + myMouseRect.X.ToString() + " Width: " + myMouseRect.Width.ToString(), new Vector2(80, 70), Microsoft.Xna.Framework.Color.Black);
                drawingContext.DrawText(SpriteFont, "Y: " + myMouseRect.Y.ToString() + " Height: " + myMouseRect.Height.ToString(), new Vector2(80, 90), Microsoft.Xna.Framework.Color.Black);

                drawingContext.DrawText(SpriteFont, "X: " + this.Bounds.X.ToString() + " Width: " + this.Bounds.Width.ToString(), new Vector2(80, 120), Microsoft.Xna.Framework.Color.Black);
                drawingContext.DrawText(SpriteFont, "Y: " + this.Bounds.Y.ToString() + " Height: " + this.Bounds.Height.ToString(), new Vector2(80, 140), Microsoft.Xna.Framework.Color.Black);

                drawingContext.DrawText(SpriteFont, "X Adjust: " + XAdjust.ToString(), new Vector2(250, 70), Microsoft.Xna.Framework.Color.Black);
                drawingContext.DrawText(SpriteFont, "Y Adjust: " + YAdjust.ToString(), new Vector2(250, 90), Microsoft.Xna.Framework.Color.Black);

                drawingContext.DrawFilledRectangle(myMouseRect, Color.HotPink);

                drawingContext.DrawLine(myMouseRect.X - 5, myMouseRect.Y, myMouseRect.X + 5, myMouseRect.Y, Color.Black);
                drawingContext.DrawLine(myMouseRect.X, myMouseRect.Y - 5, myMouseRect.X, myMouseRect.Y + 5, Color.Black);
                //var brush = new SolidBrush(System.Drawing.Color.FromArgb(255, 255, 255));
                //Microsoft.Xna.Framework.Rectangle clientRect = new Microsoft.Xna.Framework.Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height);
                //drawingContext.DrawFilledRectangle( clientRect, Microsoft.Xna.Framework.Color.FromNonPremultiplied(255, 255, 255, 0)
                //    );
                //// draw rect svg size

                if (DrawGrid)
                {
                    DrawGridsAndScale();
                }

                if (_graphicsList != null)
                {
                    _graphicsList.Draw(DrawingContext);
                }

                DrawNetSelection(DrawingContext);

                drawingContext.End();
                //brush.Dispose();
            }
        }
예제 #3
0
        public void LoadContent()
        {
            PresentationParameters pp = GraphicsDevice.PresentationParameters;
            int bufferWidth           = pp.BackBufferWidth;
            int bufferHeight          = pp.BackBufferHeight;

            drawingTexture = new DrawingTexture(GraphicsDevice, bufferWidth, bufferHeight);
            drawingTexture.Clear(Microsoft.Xna.Framework.Color.White);

            XnaDrawingContext drawingContext = drawingTexture.DrawingContext;

            drawingContext.Begin();
            drawingContext.DrawLine(10, 20, 100, 20, Microsoft.Xna.Framework.Color.Red);
            drawingContext.DrawRectangle(120, 10, 100, 20, Microsoft.Xna.Framework.Color.Blue);
            drawingContext.DrawTriangle(240, 10, 240, 60, 200, 60, Microsoft.Xna.Framework.Color.Black);
            drawingContext.DrawEllipse(310, 10, 50, 50, Microsoft.Xna.Framework.Color.Green);
            drawingContext.DrawTexture(texture, new Vector2(10, 300), Microsoft.Xna.Framework.Color.White);
            drawingContext.DrawPolyline(new Vector2[] { new Vector2(410, 10), new Vector2(440, 10), new Vector2(420, 20), new Vector2(440, 40), new Vector2(410, 60) }, Microsoft.Xna.Framework.Color.Aqua);
            drawingContext.DrawFilledRectangle(120, 110, 50, 50, Microsoft.Xna.Framework.Color.Blue);
            drawingContext.DrawFilledTriangle(240, 110, 240, 160, 200, 160, Microsoft.Xna.Framework.Color.Brown);
            drawingContext.DrawFilledEllipse(310, 110, 80, 40, Microsoft.Xna.Framework.Color.Green);
            drawingContext.DrawText(SpriteFont, "Hello World!", new Vector2(120, 300), Microsoft.Xna.Framework.Color.Black);
            drawingContext.End();
        }
예제 #4
0
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            UpdateTimer();
            Update();

            viewProjMatrix   = viewMatrix * projMatrix;
            time             = (float)gameTimer.TotalGameTime.TotalSeconds;
            curTechniqueName = roundLineTechniqueNames[roundLineTechniqueIndex];

            //DrawSceneToTexture(screen);

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

            GraphicsDevice.Clear(backColor);


            if (SpriteFont != null && RoundLineManager != null && Effect != null)
            {
                //Draw Grid
                if (DrawGrid)
                {
                    DrawGridsAndScale();
                }

                drawingContext.Begin();
                ////drawingContext.Begin(
                ////    SpriteSortMode.Immediate,
                ////    BlendState.AlphaBlend,
                ////    SamplerState.LinearClamp,
                ////    DepthStencilState.None,
                ////    RasterizerState.CullNone,
                ////    null,
                ////    camera.get_transformation(GraphicsDevice));

                //drawingContext.DrawText(SpriteFont, "Camera X: " + camera.Pos.X + " Y: " + camera.Pos.Y, new Vector2(0, 0), Color.Black);
                drawingContext.DrawText(SpriteFont, "Mouse X: " + mousePos.X + " Y: " + mousePos.Y, new Vector2(0, 0), Color.Black);
                drawingContext.DrawText(SpriteFont, "Rect X: " + GraphicsDevice.Viewport.X + " Y: " + GraphicsDevice.Viewport.Y, new Vector2(0, 20), Color.Black);
                drawingContext.DrawText(SpriteFont, "Rect W: " + GraphicsDevice.Viewport.Width + " H: " + GraphicsDevice.Viewport.Height, new Vector2(0, 40), Color.Black);
                //drawingContext.DrawText(SpriteFont, "Viewport Width: " + this.GraphicsDevice.Viewport.Width + " Height: " + this.GraphicsDevice.Viewport.Height, new Vector2(0, 90), Color.Black);
                //drawingContext.DrawFilledRectangle(myMouseRect, Color.HotPink);
                ////drawingContext.DrawFilledRectangle(myOtherMouseRect, Color.Magenta);
                drawingContext.End();

                spriteBatch.Begin();
                drawingBatch.Begin();

                DrawNetSelection();

                if (_graphicsList != null)
                {
                    _graphicsList.Draw(spriteBatch);
                }

                //DrawRoundLine();

                //Always draw mouseTexture last

                // draw cursor
                spriteBatch.Draw(cursorTexture.Texture, mousePos, null, Color.White, 0f,
                                 Vector2.Zero, 1.0f, SpriteEffects.None, 0f);
                spriteBatch.End();
                drawingBatch.End();
            }

            //spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend,
            //    SamplerState.LinearClamp, DepthStencilState.Default,
            //    RasterizerState.CullNone);

            //spriteBatch.Draw(screen, new Rectangle(0, 0, this.Width, this.Height), Color.White);

            //spriteBatch.End();
        }