Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Core/Grid.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Core/Grid.cs
r2768 r4068 1 1 using System; 2 using System.Collections.Generic;3 using System.Text;4 2 using System.Drawing; 5 using System.Windows.Forms;6 3 using System.Drawing.Drawing2D; 7 4 8 namespace Netron.Diagramming.Core 9 { 10 public class Grid 11 { 12 // ------------------------------------------------------------------ 13 /// <summary> 14 /// Constructor. 15 /// </summary> 16 // ------------------------------------------------------------------ 17 public Grid() 18 { 19 } 5 namespace Netron.Diagramming.Core { 6 public class Grid { 7 // ------------------------------------------------------------------ 8 /// <summary> 9 /// Constructor. 10 /// </summary> 11 // ------------------------------------------------------------------ 12 public Grid() { 13 } 20 14 21 public static void Paint( 22 Graphics g, 23 RectangleF area, 24 float horizontalSpacing, 25 float verticalSpacing, 26 float penWidth) 27 { 28 //ControlPaint.DrawGrid( 29 // g, 30 // area, 31 // new Size(20, 20), 32 // Color.Wheat); 15 public static void Paint( 16 Graphics g, 17 RectangleF area, 18 float horizontalSpacing, 19 float verticalSpacing, 20 float penWidth) { 21 //ControlPaint.DrawGrid( 22 // g, 23 // area, 24 // new Size(20, 20), 25 // Color.Wheat); 33 26 34 35 36 37 38 39 40 27 //g.SmoothingMode = SmoothingMode.HighQuality; 28 //g.CompositingQuality = CompositingQuality.HighQuality; 29 //g.InterpolationMode = InterpolationMode.HighQualityBicubic; 30 g.SetClip(area); 31 float sideLength = Math.Min(area.Width, area.Height); 32 float horizSpacing = sideLength / horizontalSpacing; 33 float vertSpacing = sideLength / verticalSpacing; 41 34 42 43 44 35 Pen majorPen = new Pen(Color.DarkGray); 36 majorPen.Width = penWidth; 37 majorPen.DashStyle = DashStyle.Dot; 45 38 46 47 48 49 50 51 39 float top = area.Top; // The top y coord. 40 float bottom = area.Bottom; // The bottom y coord. 41 float left = area.Left; // The left y coord. 42 float right = area.Right; // The right y coord. 43 PointF p1; // The starting point for the grid line. 44 PointF p2; // The end point for the grid line. 52 45 53 // Draw the horizontal lines, starting at the top. 54 for (float i = top; i <= bottom; i += horizontalSpacing) 55 { 56 p1 = new PointF(left, i); 57 p2 = new PointF(right, i); 58 g.DrawLine(majorPen, p1, p2); 59 } 46 // Draw the horizontal lines, starting at the top. 47 for (float i = top; i <= bottom; i += horizontalSpacing) { 48 p1 = new PointF(left, i); 49 p2 = new PointF(right, i); 50 g.DrawLine(majorPen, p1, p2); 51 } 60 52 61 // Draw the major vertical lines, starting at the left edge. 62 for (float i = left; i <= right; i += verticalSpacing) 63 { 64 p1 = new PointF(i, top); 65 p2 = new PointF(i, bottom); 66 g.DrawLine(majorPen, p1, p2); 67 } 68 g.ResetClip(); 69 } 53 // Draw the major vertical lines, starting at the left edge. 54 for (float i = left; i <= right; i += verticalSpacing) { 55 p1 = new PointF(i, top); 56 p2 = new PointF(i, bottom); 57 g.DrawLine(majorPen, p1, p2); 58 } 59 g.ResetClip(); 70 60 } 61 } 71 62 }
Note: See TracChangeset
for help on using the changeset viewer.