日期:2014-05-20  浏览次数:20911 次

有什么办法可以在界面上画斜线

下面这个类是一个用户控件,在C#里面画直线的,有什么办法可以画斜线呢?
**********************************************************************************************************
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;

namespace Line
{
   
  public class LineControl : Control
  {
  private LineType m_lineType = LineType.Horizontal;
  private Color m_lineColor = Color.Blue;
  private Color m_shadowColor = Color.Gray;
  private int m_lineWidth = 2;
  private Size m_shadowOffset = new Size(1, 1);
  public LineControl()
  {
  this.SetStyle(ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true);
  this.SetStyle(ControlStyles.UserMouse |
  ControlStyles.Selectable |
  ControlStyles.StandardClick |
  ControlStyles.StandardDoubleClick, false);
  }
  [Category("线")]
  [Description("阴影的偏移量")]
  [DefaultValue(typeof(Size), "1,1")]
  public Size ShadowOffset
  {
  get { return m_shadowOffset; }
  set
  {

  m_shadowOffset = value;
  this.SetSize();
  this.Invalidate();
  }
  }
  [Category("线")]
  [Description("宽度")]
  [DefaultValue(2)]
  public int LineWidth
  {
  get { return m_lineWidth; }
  set
  {
  if (value < 1) value = 1;
  m_lineWidth = value;
  this.SetSize();
  this.Invalidate();
  }
  }
  [Category("线")]
  [Description("类型")]
  [DefaultValue(typeof(LineType), "Horizontal")]
  public LineType LineType
  {
  get { return m_lineType; }
  set
  {
  if (m_lineType != value)
  {
  int linelen = 0;
  if (m_lineType == LineType.Horizontal)
  {
  linelen = this.Width;
  }
  else
  {
  linelen = this.Height;
  }
  m_lineType = value;
  if (value == LineType.Horizontal)
  {
  this.Width = linelen;
  }
  else
  {
  this.Height = linelen;
  }
  this.SetSize();
  this.Invalidate();
  }
  }
  }
  [Category("线")]
  [Description("颜色")]
  [DefaultValue(typeof(Color), "Blue")]
  public Color LineColor
  {
  get { return m_lineColor; }
  set
  {
  m_lineColor = value;
  this.Invalidate();