-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloatingToolStripGradientPanel.cs
More file actions
154 lines (135 loc) · 4.53 KB
/
FloatingToolStripGradientPanel.cs
File metadata and controls
154 lines (135 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing;
namespace FloatingToolStripLibrary
{
public partial class FloatingToolStripGradientPanel : ToolStripPanel
{
/// <summary>
/// FloatingToolStripLibrary.FloatingToolStripGradientPanel クラスの新しいインスタンスを初期化します.
/// </summary>
public FloatingToolStripGradientPanel()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.ResizeRedraw,
true
);
BackColor = Color.Lavender;
BackColor2 = Color.CornflowerBlue;
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
}
#region BackColor
private Color _BackColor;
/// <summary>
/// コンポーネントの背景色のグラデーションの開始色です.
/// </summary>
[Category("表示")]
[DefaultValue(typeof(Color), "Color.Lavender")]
[Description("コンポーネントの背景色のグラデーションの開始色です.")]
public new Color BackColor
{
get
{
if (this._BackColor != Color.Empty)
{
return this._BackColor;
}
if (this.Parent != null)
{
return this.Parent.BackColor;
}
return Control.DefaultBackColor;
}
set
{
this._BackColor = value;
this.Refresh();
}
}
public override void ResetBackColor()
{
this.BackColor = Color.Empty;
}
private Boolean ShouldSerializeBackColor()
{
return this._BackColor != Color.Empty;
}
#endregion
#region BackColor2
private Color _BackColor2;
/// <summary>
/// コンポーネントの背景色のグラデーションの終了色です.
/// </summary>
[Category("表示")]
[DefaultValue(typeof(Color), "Color.CornflowerBlue")]
[Description("コンポーネントの背景色のグラデーションの終了色です.")]
public Color BackColor2
{
get
{
if (this._BackColor2 != Color.Empty)
{
return this._BackColor2;
}
if (this.Parent != null)
{
return this.Parent.BackColor;
}
return Control.DefaultBackColor;
}
set
{
this._BackColor2 = value;
this.Refresh();
}
}
public void ResetBackColor2()
{
this.BackColor2 = Color.Empty;
}
private Boolean ShouldSerializeBackColor2()
{
return this._BackColor2 != Color.Empty;
}
#endregion
private LinearGradientMode _GradientMode;
/// <summary>
/// コンポーネントの背景色のグラデーションの方向です.
/// </summary>
[Category("表示")]
[DefaultValue(typeof(LinearGradientMode), "Horizontal")]
[Description("コンポーネントの背景色のグラデーションの方向です.")]
public LinearGradientMode GradientMode
{
get { return this._GradientMode; }
set
{
this._GradientMode = value;
this.Invalidate();
}
}
private void FloatingToolStripGradientPanel_Paint(object sender, PaintEventArgs e)
{
if ((this.BackColor == Color.Transparent) || (this.BackColor2 == Color.Transparent))
{
base.OnPaintBackground(e);
}
if (this.ClientRectangle.Width != 0 && this.ClientRectangle.Height != 0)
{
using (LinearGradientBrush lgb = new LinearGradientBrush(this.ClientRectangle, this.BackColor, this.BackColor2, this.GradientMode))
{
e.Graphics.FillRectangle(lgb, this.ClientRectangle);
}
}
}
}
}