一个自绘的导航栏控件,类似WINDOWS的左侧导航栏
1using System;
2
3using System.Collections.Generic;
4
5using System.ComponentModel;
6
7using System.Drawing;
8
9using System.Data;
10
11using System.Text;
12
13using System.Windows.Forms;
14
15using System.Drawing.Drawing2D;
16
17using System.Threading;
18
19
20
21namespace ShadePanelControl
22
23{
24
25 public partial class ShadePanelControl : UserControl
26
27 {
28
29 private LinearGradientBrush lgBrush;
30
31 private Color startColor = Color.White;
32
33 private Color endColor = Color.Silver;
34
35 private Color frameColor = Color.Silver;
36
37 private string titleString = "标题一";
38
39 private int topPanelHeight = 20;
40
41 private Color titleStringColor = Color.Gray;
42
43 private bool beenExpand = false;
44
45 private int height;
46
47
48
49 public int Height1
50
51 {
52
53 get { return this.Height; }
54
55 set
56
57 {
58
59 this.Height = value;
60
61 height = value;
62
63 this.Invalidate();
64
65 }
66
67 }
68
69
70
71 [Category("TitleStringColor"), Description("标题颜色")]
72
73 public Color TitleStringColor
74
75 {
76
77 get { return titleStringColor; }
78
79 set
80
81 {
82
83 titleStringColor = value;
84
85 this.Invalidate();
86
87 }
88
89 }
90
91
92
93
94
95 Arribute Set Or Get#region Arribute Set Or Get
96
97 [Category("TopPanelHeight"), Description("标题高度")]
98
99 public int TopPanelHeight
100
101 {
102
103 get { return topPanelHeight; }
104
105 set
106
107 {
108
109 topPanelHeight = value;
110
111 panel_Top.Height = topPanelHeight;
112
113 this.Invalidate();
114
115 }
116
117 }
118
119 [Category("TitleString"), Description("标题")]
120
121 public string TitleString
122
123 {
124
125 get { return titleString; }
126
127 set
128
129 {
130
131 titleString = value;
132
133 this.Invalidate();
134
135 }
136
137 }
138
139 [Category("FrameColor"), Description("边框线的颜色")]
140
141 public Color FrameColor
142
143 {
144
145 get { return frameColor; }
146
147 set
148
149 {
150
151 frameColor = value;
152
153 this.Invalidate();
154
155 }
156
157 }
158
159
160
161 [Category("EndColor"), Description("Panel的结束颜色")]
162
163 public Color EndColor
164
165 {
166
167 get { return endColor; }
168
169 set
170
171 {
172
173 endColor = value;
174
175 this.Invalidate();
176
177 }
178
179 }
180
181
182
183 [Category("StartColor"), Description("Panel的起始颜色")]
184
185 public Color StartColor
186
187 {
188
189 get { return startColor; }
190
191 set
192
193 {
194
195 startColor = value;
196
197 this.Invalidate();
198
199 }
200
201 }
202
203 #endregion
204
205 public ShadePanelControl()
206
207 {
208
209 InitializeComponent();
210
211 this.height = this.Height;
212
213 }
214
215 protected override void OnPaint(PaintEventArgs e)
216
217 {
218
219 DrawPanel(e.Graphics);
220
221 DrawSolidLine(e.Graphics);
222
223 DrawTitleString(e.Graphics);
224
225 base.OnPaint(e);
226
227 }
228
229
230
231 /**//// <summary>
232
233 /// 绘制渐变框
234
235 /// </summary>
236
237 /// <param name="g"></param>
2
3using System.Collections.Generic;
4
5using System.ComponentModel;
6
7using System.Drawing;
8
9using System.Data;
10
11using System.Text;
12
13using System.Windows.Forms;
14
15using System.Drawing.Drawing2D;
16
17using System.Threading;
18
19
20
21namespace ShadePanelControl
22
23{
24
25 public partial class ShadePanelControl : UserControl
26
27 {
28
29 private LinearGradientBrush lgBrush;
30
31 private Color startColor = Color.White;
32
33 private Color endColor = Color.Silver;
34
35 private Color frameColor = Color.Silver;
36
37 private string titleString = "标题一";
38
39 private int topPanelHeight = 20;
40
41 private Color titleStringColor = Color.Gray;
42
43 private bool beenExpand = false;
44
45 private int height;
46
47
48
49 public int Height1
50
51 {
52
53 get { return this.Height; }
54
55 set
56
57 {
58
59 this.Height = value;
60
61 height = value;
62
63 this.Invalidate();
64
65 }
66
67 }
68
69
70
71 [Category("TitleStringColor"), Description("标题颜色")]
72
73 public Color TitleStringColor
74
75 {
76
77 get { return titleStringColor; }
78
79 set
80
81 {
82
83 titleStringColor = value;
84
85 this.Invalidate();
86
87 }
88
89 }
90
91
92
93
94
95 Arribute Set Or Get#region Arribute Set Or Get
96
97 [Category("TopPanelHeight"), Description("标题高度")]
98
99 public int TopPanelHeight
100
101 {
102
103 get { return topPanelHeight; }
104
105 set
106
107 {
108
109 topPanelHeight = value;
110
111 panel_Top.Height = topPanelHeight;
112
113 this.Invalidate();
114
115 }
116
117 }
118
119 [Category("TitleString"), Description("标题")]
120
121 public string TitleString
122
123 {
124
125 get { return titleString; }
126
127 set
128
129 {
130
131 titleString = value;
132
133 this.Invalidate();
134
135 }
136
137 }
138
139 [Category("FrameColor"), Description("边框线的颜色")]
140
141 public Color FrameColor
142
143 {
144
145 get { return frameColor; }
146
147 set
148
149 {
150
151 frameColor = value;
152
153 this.Invalidate();
154
155 }
156
157 }
158
159
160
161 [Category("EndColor"), Description("Panel的结束颜色")]
162
163 public Color EndColor
164
165 {
166
167 get { return endColor; }
168
169 set
170
171 {
172
173 endColor = value;
174
175 this.Invalidate();
176
177 }
178
179 }
180
181
182
183 [Category("StartColor"), Description("Panel的起始颜色")]
184
185 public Color StartColor
186
187 {
188
189 get { return startColor; }
190
191 set
192
193 {
194
195 startColor = value;
196
197 this.Invalidate();
198
199 }
200
201 }
202
203 #endregion
204
205 public ShadePanelControl()
206
207 {
208
209 InitializeComponent();
210
211 this.height = this.Height;
212
213 }
214
215 protected override void OnPaint(PaintEventArgs e)
216
217 {
218
219 DrawPanel(e.Graphics);
220
221 DrawSolidLine(e.Graphics);
222
223 DrawTitleString(e.Graphics);
224
225 base.OnPaint(e);
226
227 }
228
229
230
231 /**//// <summary>
232
233 /// 绘制渐变框
234
235 /// </summary>
236
237 /// <param name="g"></param>