/// <summary> /// Draw CAD 2D Point /// </summary> /// <param name="spriteBatch"></param> /// <param name="p"></param> private void drawPoint(CADSpriteBatch spriteBatch, Point2D p, Color col) { Vector2 spv = this.pointToLocation(p); spriteBatch.Draw( this.TexturePoint, new Vector2(spv.X - 2, spv.Y - 2), null, null, new Vector2(0, 0), 0f, null, col, SpriteEffects.None, spriteBatch.LayerDepth ); }
/// <summary> /// Draws CAD 2D Drawing Panel /// </summary> /// <param name="spriteBatch"></param> public void draw(CADSpriteBatch spriteBatch) { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Draw Background Color // spriteBatch.LayerDepth = this.ldBackRectangle; spriteBatch.drawRectangle(this.Left, this.Top, this.Width, this.Height, this.BackgroundColor); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Draw Grid // spriteBatch.LayerDepth = this.ldGrid; // Vertical decimal x = 0; while (x <= DocSizeMmX) { int xd = (int)(x * this.RatioDotsPerMm); spriteBatch.drawLine( this.Left + xd - this.DocViewXOffset, this.Top - this.DocViewYOffset, this.DocSizeDotsY, this.getGridColor(), true ); x = x + this.gridStepMm; } // Horizontal decimal y = 0; while (y <= DocSizeMmY) { int yd = (int)(y * this.RatioDotsPerMm); spriteBatch.drawLine( this.Left - this.DocViewXOffset, this.Top + yd - this.DocViewYOffset, this.DocSizeDotsX, this.getGridColor() ); y = y + this.gridStepMm; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Draw Document Content // // Draw Shapes spriteBatch.LayerDepth = this.ldContentShapes; foreach (Shape p in this.File.Shapes) { if (this.Toolbox.SelectTool.Elements.Contains(p)) { // Selected Point this.drawShape(spriteBatch, p, Color.Red); } else { this.drawShape(spriteBatch, p, Color.LightGreen); } } // Draw Points spriteBatch.LayerDepth = this.ldContentPoints; foreach (Point2D p in this.File.Points) { if (this.Toolbox.SelectTool.Elements.Contains(p)) { // Selected Point this.drawPoint(spriteBatch, p, Color.Red); spriteBatch.DrawString( this.FontCanvas, (this.Toolbox.SelectTool.Elements.IndexOf(p) + 1).ToString(), this.pointToLocation(p) + new Vector2(5, 5), Color.Red ); } else { this.drawPoint(spriteBatch, p, Color.White); } } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Draw Machine Location // spriteBatch.LayerDepth = this.ldMachinePosition; if (this.Machine != null && this.TextureMachineTool != null) { Vector2 spv = this.pointToLocation(this.Machine.Position); spriteBatch.Draw( this.TextureMachineTool, new Vector2(spv.X - 12, spv.Y - 12), null, null, new Vector2(0, 0), 0f, null, Color.White, SpriteEffects.None, spriteBatch.LayerDepth ); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Draw Cursor Point // spriteBatch.LayerDepth = this.ldCursor; if (this.isCanvasHovered() || this.isCanvasPushed()) { Point2D p = this.mouseCursorToPoint(this.Mouse.CurrentState); string description = String.Format("X:{0},Y:{1}", p.X, p.Y); Point2D sp = this.getNearestSnapPoint(p); if (this.Toolbox.SelectedTool.GetType() == typeof(PointTool)) { this.drawPoint(spriteBatch, sp, Color.Green); } string snapDesc = String.Format("X:{0},Y:{1}", sp.X, sp.Y); spriteBatch.DrawString( this.FontCanvas, description, new Vector2(this.Mouse.CurrentState.X + 20, this.Mouse.CurrentState.Y), Color.Red, 0f, new Vector2(0, 0), new Vector2(1, 1), SpriteEffects.None, spriteBatch.LayerDepth ); spriteBatch.DrawString( this.FontCanvas, snapDesc, new Vector2(this.Mouse.CurrentState.X + 20, this.Mouse.CurrentState.Y + 20), Color.Green, 0f, new Vector2(0, 0), new Vector2(1, 1), SpriteEffects.None, spriteBatch.LayerDepth ); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Draw Scroll Bars // spriteBatch.LayerDepth = this.ldScrollBars; // - Vertical Scroll Bar if (this.VerticalScrollVisible) { scrollBarVertical.draw(spriteBatch); } // - Horizontal Scroll Bar if (this.HorizontalScrollVisible) { scrollBarHorizontal.draw(spriteBatch); } }