设为首页 加入收藏

TOP

(八十一)c#Winform自定义控件-时间轴(一)
2019-10-09 20:05:57 】 浏览:106
Tags:八十一 c#Winform 定义 控件 -时间

前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492 企鹅群568015492

来都来了,点个【推荐】再走吧,谢谢

NuGet

Install-Package HZH_Controls

目录

https://www.cnblogs.com/bfyx/p/11364884.html

用处及效果

准备工作

没什么可准备的,直接开干吧。

思路:

2个panel,分别放标题和明细

然后重绘控件,在标题旁边画圆并且连线

开始

添加一个类来存放节点信息

 1  public class TimeLineItem
 2     {
 3         /// <summary>
 4         /// Gets or sets the title.
 5         /// </summary>
 6         /// <value>The title.</value>
 7         public string Title { get; set; }
 8         /// <summary>
 9         /// Gets or sets the details.
10         /// </summary>
11         /// <value>The details.</value>
12         public string Details { get; set; }
13     }

添加一个用户控件UCTimeLine

添加一些属性

  1 /// <summary>
  2         /// The line color
  3         /// </summary>
  4         private Color lineColor = TextColors.Light;
  5 
  6         /// <summary>
  7         /// Gets or sets the color of the line.
  8         /// </summary>
  9         /// <value>The color of the line.</value>
 10         [Description("连接线颜色"), Category("自定义")]
 11         public Color LineColor
 12         {
 13             get { return lineColor; }
 14             set
 15             {
 16                 lineColor = value;
 17                 Invalidate();
 18             }
 19         }
 20         /// <summary>
 21         /// The title font
 22         /// </summary>
 23         private Font titleFont = new Font("微软雅黑", 14f);
 24 
 25         /// <summary>
 26         /// Gets or sets the title font.
 27         /// </summary>
 28         /// <value>The title font.</value>
 29         [Description("标题字体"), Category("自定义")]
 30         public Font TitleFont
 31         {
 32             get { return titleFont; }
 33             set
 34             {
 35                 titleFont = value;
 36                 ReloadItems();
 37             }
 38         }
 39 
 40         /// <summary>
 41         /// The title forcolor
 42         /// </summary>
 43         private Color titleForcolor = TextColors.MoreDark;
 44 
 45         /// <summary>
 46         /// Gets or sets the title forcolor.
 47         /// </summary>
 48         /// <value>The title forcolor.</value>
 49         [Description("标题颜色"), Category("自定义")]
 50         public Color TitleForcolor
 51         {
 52             get { return titleForcolor; }
 53             set
 54             {
 55                 titleForcolor = value;
 56                 ReloadItems();
 57             }
 58         }
 59 
 60         /// <summary>
 61         /// The details font
 62         /// </summary>
 63         private Font detailsFont = new Font("微软雅黑", 10);
 64 
 65         /// <summary>
 66         /// Gets or sets the details font.
 67         /// </summary>
 68         /// <value>The details font.</value>
 69         [Description("详情字体"), Category("自定义")]
 70         public Font DetailsFont
 71         {
 72             get { return detailsFont; }
 73             set
 74             {
 75                 detailsFont = value;
 76                 ReloadItems();
 77             }
 78         }
 79 
 80         /// <summary>
 81         /// The details forcolor
 82         /// </summary>
 83         private Color detailsForcolor = TextColors.Light;
 84 
 85         /// <summary>
 86         /// Gets or sets the details forcolor.
 87         /// </summary>
 88         /// <value>The details forcolor.</value>
 89         [Description("详情颜色"), Category("自定义")]
 90         public Color DetailsForcolor
 91         {
 92             get { return detailsForcolor; }
 93             set
 94             {
 95                 detailsForcolor = value;
 96                 ReloadItems();
 97             }
 98         }
 99 
100         /// <summary>
101         /// The items
102         /// </summary>
103         TimeLineItem[] items;
10
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇c#---Socean.RPC实测[并发量13w][.. 下一篇Winform中设置ZedGraph的曲线符号..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目