Dreamine.UI.WinForms
1.0.1
Dreamine.UI.WinForms 사용자 인터페이스 기능과 구성 요소를 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
DreamineDrawHelper.cs
이 파일의 문서화 페이지로 가기
1
using
System.Drawing;
2
using
System.Drawing.Drawing2D;
3
4
namespace
Dreamine.UI.WinForms
;
5
14
public
static
class
DreamineDrawHelper
15
{
48
public
static
GraphicsPath
RoundedRect
(RectangleF r,
float
radius)
49
{
50
if
(radius <= 0) { var p =
new
GraphicsPath(); p.AddRectangle(r);
return
p; }
51
float
d = radius * 2f;
52
var path =
new
GraphicsPath();
53
path.AddArc(r.X, r.Y, d, d, 180, 90);
54
path.AddArc(r.Right - d, r.Y, d, d, 270, 90);
55
path.AddArc(r.Right - d, r.Bottom - d, d, d, 0, 90);
56
path.AddArc(r.X, r.Bottom - d, d, d, 90, 90);
57
path.CloseFigure();
58
return
path;
59
}
60
93
public
static
GraphicsPath
RoundedRect
(Rectangle r,
float
radius)
94
=>
RoundedRect
((RectangleF)r, radius);
95
144
public
static
void
FillRoundedRect
(Graphics g, Brush fill, Pen? border,
145
Rectangle rect,
float
radius)
146
{
147
g.SmoothingMode = SmoothingMode.AntiAlias;
148
using
var path =
RoundedRect
(rect, radius);
149
g.FillPath(fill, path);
150
if
(border !=
null
) g.DrawPath(border, path);
151
}
152
209
public
static
void
FillRoundedGradient
(Graphics g, Color top, Color bottom, Pen? border,
210
Rectangle rect,
float
radius)
211
{
212
if
(rect.Width <= 0 || rect.Height <= 0)
return
;
213
g.SmoothingMode = SmoothingMode.AntiAlias;
214
using
var path =
RoundedRect
(rect, radius);
215
using
var brush =
new
LinearGradientBrush(rect, top, bottom, LinearGradientMode.Vertical);
216
g.FillPath(brush, path);
217
if
(border !=
null
) g.DrawPath(border, path);
218
}
219
260
public
static
void
DrawShineOverlay
(Graphics g, Color shineColor, Rectangle rect,
float
radius)
261
{
262
if
(rect.Width <= 0 || rect.Height <= 0)
return
;
263
var shineRect =
new
Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height / 2);
264
if
(shineRect.Width <= 0 || shineRect.Height <= 0)
return
;
265
using
var path =
RoundedRect
(shineRect, radius * 0.7f);
266
var c1 = Color.FromArgb(80, shineColor);
267
var c2 = Color.FromArgb(0, shineColor);
268
using
var brush =
new
LinearGradientBrush(shineRect, c1, c2, LinearGradientMode.Vertical);
269
g.FillPath(brush, path);
270
}
271
320
public
static
void
DrawCenteredText
(Graphics g,
string
text, Font font, Color color, Rectangle rect)
321
{
322
using
var brush =
new
SolidBrush(color);
323
var sf =
new
StringFormat
324
{
325
Alignment = StringAlignment.Center,
326
LineAlignment = StringAlignment.Center,
327
Trimming = StringTrimming.EllipsisCharacter
328
};
329
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
330
g.DrawString(text, font, brush, rect, sf);
331
}
332
373
public
static
Color
Blend
(Color base_, Color overlay,
float
alpha)
374
{
375
int
r = (int)(base_.R + (overlay.R - base_.R) * alpha);
376
int
g_ = (int)(base_.G + (overlay.G - base_.G) * alpha);
377
int
b = (int)(base_.B + (overlay.B - base_.B) * alpha);
378
return
Color.FromArgb(255,
379
Math.Clamp(r, 0, 255),
380
Math.Clamp(g_, 0, 255),
381
Math.Clamp(b, 0, 255));
382
}
383
}
Dreamine.UI.WinForms
Definition
DreamineButton.cs:6
Dreamine.UI.WinForms.DreamineDrawHelper
Definition
DreamineDrawHelper.cs:15
Dreamine.UI.WinForms.DreamineDrawHelper.FillRoundedRect
static void FillRoundedRect(Graphics g, Brush fill, Pen? border, Rectangle rect, float radius)
Definition
DreamineDrawHelper.cs:144
Dreamine.UI.WinForms.DreamineDrawHelper.RoundedRect
static GraphicsPath RoundedRect(Rectangle r, float radius)
Definition
DreamineDrawHelper.cs:93
Dreamine.UI.WinForms.DreamineDrawHelper.RoundedRect
static GraphicsPath RoundedRect(RectangleF r, float radius)
Definition
DreamineDrawHelper.cs:48
Dreamine.UI.WinForms.DreamineDrawHelper.Blend
static Color Blend(Color base_, Color overlay, float alpha)
Definition
DreamineDrawHelper.cs:373
Dreamine.UI.WinForms.DreamineDrawHelper.FillRoundedGradient
static void FillRoundedGradient(Graphics g, Color top, Color bottom, Pen? border, Rectangle rect, float radius)
Definition
DreamineDrawHelper.cs:209
Dreamine.UI.WinForms.DreamineDrawHelper.DrawCenteredText
static void DrawCenteredText(Graphics g, string text, Font font, Color color, Rectangle rect)
Definition
DreamineDrawHelper.cs:320
Dreamine.UI.WinForms.DreamineDrawHelper.DrawShineOverlay
static void DrawShineOverlay(Graphics g, Color shineColor, Rectangle rect, float radius)
Definition
DreamineDrawHelper.cs:260
DreamineDrawHelper.cs
다음에 의해 생성됨 :
1.17.0