/// <summary> /// Draws an inset or raised line connecting the two points specified by /// the coordinate pairs. This method draws only horizontal or vertical /// lines. If the line is not horizontal or vertical, this method throws an /// ArgumentException. If the line is horizontal, the pixels are /// drawn just below the specified grid line. If the line is /// vertical, the pixels are drawn just to the right of the /// the specified grid line. /// </summary> /// <param name="x1">x coordinate of the first grid point.</param> /// <param name="y1">y coordinate of the first grid point.</param> /// <param name="x2">x coordinate of the second grid point.</param> /// <param name="y2">y coordinate of the second grid point.</param> /// <param name="style">Specifies the raised or inset style.</param> /// <param name="depth">Specifies the depth of the raised or inset line or rectangle. /// Valid values are 1 and 2.</param> public void Draw3DLine(int x1, int y1, int x2, int y2, ThreeDStyle style, int depth) { this.Draw3DLine(new Point(x1, y1), new Point(x2, y2), style, depth); }
/// <summary> /// Draws an inset or raised line connecting the two points specified by /// the coordinate pairs. This method draws only horizontal or vertical /// lines. If the line is not horizontal or vertical, this method throws an /// ArgumentException. If the line is horizontal, the pixels are /// drawn just below the specified grid line. If the line is /// vertical, the pixels are drawn just to the right of the /// the specified grid line. /// </summary> /// <param name="p1">Point structure that specifies the first grid point to connect.</param> /// <param name="p2">Point structure that specifies the second grid point to connect.</param> /// <param name="style">Specifies the raised or inset style.</param> /// <param name="depth">Specifies the depth of the raised or inset line or rectangle. /// Valid values are 1 and 2.</param> public void Draw3DLine(Point p1, Point p2, ThreeDStyle style, int depth) { if (p1.X != p2.X && p1.Y != p2.Y) throw new ArgumentException(); if (depth != 1 && depth != 2) throw new ArgumentException(); if (depth == 1) { switch (style) { case ThreeDStyle.Inset: case ThreeDStyle.Groove: if (p1.Y == p2.Y) { DrawLine(SystemPens.ControlDark, p1, p2); Point pl1 = new Point(p1.X, p1.Y + 1); Point pl2 = new Point(p2.X, p2.Y + 1); DrawLine(SystemPens.ControlLightLight, pl1, pl2); } else { DrawLine(SystemPens.ControlDark, p1, p2); Point pl1 = new Point(p1.X + 1, p1.Y); Point pl2 = new Point(p2.X + 1, p2.Y); DrawLine(SystemPens.ControlLightLight, pl1, pl2); } break; case ThreeDStyle.Raised: case ThreeDStyle.Ridge: if (p1.Y == p2.Y) { DrawLine(SystemPens.ControlLightLight, p1, p2); Point pd1 = new Point(p1.X, p1.Y + 1); Point pd2 = new Point(p2.X, p2.Y + 1); DrawLine(SystemPens.ControlDark, pd1, pd2); } else { DrawLine(SystemPens.ControlLightLight, p1, p2); Point pd1 = new Point(p1.X + 1, p1.Y); Point pd2 = new Point(p2.X + 1, p2.Y); DrawLine(SystemPens.ControlDark, pd1, pd2); } break; } } else if (depth == 2) { switch (style) { case ThreeDStyle.Inset: case ThreeDStyle.Groove: if (p1.Y == p2.Y) { DrawLine(SystemPens.ControlDarkDark, p1, p2); Point pp1 = new Point(p1.X, p1.Y + 1); Point pp2 = new Point(p2.X, p2.Y + 1); DrawLine(SystemPens.ControlDark, pp1, pp2); pp1.Y++; pp2.Y++; DrawLine(SystemPens.ControlLight, pp1, pp2); pp1.Y++; pp2.Y++; DrawLine(SystemPens.ControlLightLight, pp1, pp2); } else { DrawLine(SystemPens.ControlDarkDark, p1, p2); Point pp1 = new Point(p1.X + 1, p1.Y); Point pp2 = new Point(p2.X + 1, p2.Y); DrawLine(SystemPens.ControlDark, pp1, pp2); pp1.X++; pp2.X++; DrawLine(SystemPens.ControlLight, pp1, pp2); pp1.X++; pp2.X++; DrawLine(SystemPens.ControlLightLight, pp1, pp2); } break; case ThreeDStyle.Raised: case ThreeDStyle.Ridge: if (p1.Y == p2.Y) { DrawLine(SystemPens.ControlLightLight, p1, p2); Point pp1 = new Point(p1.X, p1.Y + 1); Point pp2 = new Point(p2.X, p2.Y + 1); DrawLine(SystemPens.ControlLight, pp1, pp2); pp1.Y++; pp2.Y++; DrawLine(SystemPens.ControlDark, pp1, pp2); pp1.Y++; pp2.Y++; DrawLine(SystemPens.ControlDarkDark, pp1, pp2); } else { DrawLine(SystemPens.ControlLightLight, p1, p2); Point pp1 = new Point(p1.X + 1, p1.Y); Point pp2 = new Point(p2.X + 1, p2.Y); DrawLine(SystemPens.ControlLight, pp1, pp2); pp1.X++; pp2.X++; DrawLine(SystemPens.ControlDark, pp1, pp2); pp1.X++; pp2.X++; DrawLine(SystemPens.ControlDarkDark, pp1, pp2); } break; } } }