专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > C#

有什么办法可以在界面上画斜线,该怎么解决

发布时间:2011-06-21 11:32:26 文章来源:www.iduyao.cn 采编人员:星星草
有什么办法可以在界面上画斜线

下面这个类是一个用户控件,在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();
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: