本文整理汇总了C#中RoundStyle类的典型用法代码示例。如果您正苦于以下问题:C# RoundStyle类的具体用法?C# RoundStyle怎么用?C# RoundStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RoundStyle类属于命名空间,在下文中一共展示了RoundStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderBorder
public static void RenderBorder(Graphics g, Rectangle rect, Color borderColor,
ButtonBorderType borderType, int radius, RoundStyle roundType)
{
rect.Width--;
rect.Height--;
bool simpleRect = (borderType == ButtonBorderType.Rectangle && (roundType == RoundStyle.None || radius < 2));
SmoothingMode newMode = simpleRect ? SmoothingMode.HighSpeed : SmoothingMode.AntiAlias;
using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode))
{
using (Pen p = new Pen(borderColor))
{
if (simpleRect)
{
g.DrawRectangle(p, rect);
}
else if (borderType == ButtonBorderType.Ellipse)
{
g.DrawEllipse(p, rect);
}
else
{
using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false))
{
g.DrawPath(p, path);
}
}
}
}
}
示例2: RenderBackgroundInternal
internal static void RenderBackgroundInternal(
Graphics g,
Rectangle rect,
Color baseColor,
Color borderColor,
Color innerBorderColor,
RoundStyle style,
int roundWidth,
bool drawBorder,
bool drawGlass,
LinearGradientMode mode)
{
RenderBackgroundInternal(
g,
rect,
baseColor,
borderColor,
innerBorderColor,
style,
8,
0.45f,
drawBorder,
drawGlass,
mode);
}
示例3: CreatePath
public static GraphicsPath CreatePath(Rectangle rect, int radius, RoundStyle style, bool correction)
{
GraphicsPath path = new GraphicsPath();
int radiusCorrection = correction ? 1 : 0;
switch (style)
{
case RoundStyle.None:
path.AddRectangle(rect);
break;
case RoundStyle.All:
path.AddArc(rect.X, rect.Y, radius, radius, 180f, 90f);
path.AddArc((rect.Right - radius) - radiusCorrection, rect.Y, radius, radius, 270f, 90f);
path.AddArc((rect.Right - radius) - radiusCorrection, (rect.Bottom - radius) - radiusCorrection, radius, radius, 0f, 90f);
path.AddArc(rect.X, (rect.Bottom - radius) - radiusCorrection, radius, radius, 90f, 90f);
break;
case RoundStyle.Left:
path.AddArc(rect.X, rect.Y, radius, radius, 180f, 90f);
path.AddLine(rect.Right - radiusCorrection, rect.Y, rect.Right - radiusCorrection, rect.Bottom - radiusCorrection);
path.AddArc(rect.X, (rect.Bottom - radius) - radiusCorrection, radius, radius, 90f, 90f);
break;
case RoundStyle.Right:
path.AddArc((rect.Right - radius) - radiusCorrection, rect.Y, radius, radius, 270f, 90f);
path.AddArc((rect.Right - radius) - radiusCorrection, (rect.Bottom - radius) - radiusCorrection, radius, radius, 0f, 90f);
path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y);
break;
case RoundStyle.Top:
path.AddArc(rect.X, rect.Y, radius, radius, 180f, 90f);
path.AddArc((rect.Right - radius) - radiusCorrection, rect.Y, radius, radius, 270f, 90f);
path.AddLine(rect.Right - radiusCorrection, rect.Bottom - radiusCorrection, rect.X, rect.Bottom - radiusCorrection);
break;
case RoundStyle.Bottom:
path.AddArc((rect.Right - radius) - radiusCorrection, (rect.Bottom - radius) - radiusCorrection, radius, radius, 0f, 90f);
path.AddArc(rect.X, (rect.Bottom - radius) - radiusCorrection, radius, radius, 90f, 90f);
path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
break;
case RoundStyle.BottomLeft:
path.AddArc(rect.X, (rect.Bottom - radius) - radiusCorrection, radius, radius, 90f, 90f);
path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
path.AddLine(rect.Right - radiusCorrection, rect.Y, rect.Right - radiusCorrection, rect.Bottom - radiusCorrection);
break;
case RoundStyle.BottomRight:
path.AddArc((rect.Right - radius) - radiusCorrection, (rect.Bottom - radius) - radiusCorrection, radius, radius, 0f, 90f);
path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y);
path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y);
break;
}
path.CloseFigure();
return path;
}
示例4: CreateRegion
public static void CreateRegion(Control control, Rectangle bounds, int radius, RoundStyle roundStyle)
{
using (GraphicsPath path = GraphicsPathHelper.CreatePath(bounds, radius, roundStyle, true))
{
Region region = new Region(path);
path.Widen(Pens.White);
region.Union(path);
if (control.Region != null)
{
control.Region.Dispose();
}
control.Region = region;
}
}
示例5: Awake
/// <summary>
///
/// </summary>
void Awake()
{
//When you start from room scene, return to lobby for connect to server first.
if (!PhotonNetwork.connected || PhotonNetwork.room == null)
{
Application.LoadLevel(0);
return;
}
isFinish = false;
if ((string)PhotonNetwork.room.customProperties[PropiertiesKeys.RoomRoundKey] == "1")
{
m_RoundStyle = RoundStyle.Rounds;
}
else
{
m_RoundStyle = RoundStyle.OneMacht;
}
GetTime();
}
示例6: RenderRectangleGlass
public static void RenderRectangleGlass(Graphics g, Rectangle ownerRect,
int ownerRadius, RoundStyle ownerRoundTye, GlassPosition position,
float angle, float glassLengthFactor, Color glassColor, int alpha1, int alpha2)
{
if (!(glassLengthFactor > 0 && glassLengthFactor < 1))
throw new ArgumentException("glassLengthFactor must be between 0 and 1, but not include 0 and 1. ",
"glassLengthFactor");
Rectangle rect = CalcGlassRect(ownerRect, position, glassLengthFactor);
RoundStyle round = CalcRoundStyle(position, ownerRadius, ownerRoundTye);
if (rect.Width < 1 || rect.Height < 1)
return;
BasicBlockPainter.RenderLinearGradientBackground(
g,
rect,
Color.FromArgb(alpha1, glassColor),
Color.FromArgb(alpha2, glassColor),
angle,
ownerRadius,
round);
}
示例7: RenderBackgroundInternal
internal static void RenderBackgroundInternal(
Graphics g,
Rectangle rect,
Color baseColor,
Color borderColor,
Color innerBorderColor,
RoundStyle style,
bool drawBorder,
bool drawGlass,
System.Drawing.Drawing2D.LinearGradientMode mode)
{
RenderBackgroundInternal(
g,
rect,
baseColor,
borderColor,
innerBorderColor,
style,
8,
drawBorder,
drawGlass,
mode);
}
示例8: RenderFlatBackground
public static void RenderFlatBackground(Graphics g, Rectangle rect, Color backColor,
ButtonBorderType borderType, int radius, RoundStyle roundType)
{
SmoothingMode newMode;
bool simpleRect = (borderType == ButtonBorderType.Rectangle && (roundType == RoundStyle.None || radius < 2));
if (simpleRect)
{
newMode = SmoothingMode.HighSpeed;
}
else
{
newMode = SmoothingMode.AntiAlias;
rect.Width--;
rect.Height--;
}
using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode))
{
using (SolidBrush sb = new SolidBrush(backColor))
{
if (simpleRect)
{
g.FillRectangle(sb, rect);
}
else if (borderType == ButtonBorderType.Ellipse)
{
g.FillEllipse(sb, rect);
}
else
{
using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false))
{
g.FillPath(sb, path);
}
}
}
}
}
示例9: RenderLinearGradientBackground
public static void RenderLinearGradientBackground(Graphics g, Rectangle rect,
Color color1, Color color2, float angle, int radius, RoundStyle roundType)
{
SmoothingMode newMode;
bool simpleRect = (roundType == RoundStyle.None || radius < 2);
if (simpleRect)
{
newMode = SmoothingMode.HighSpeed;
}
else
{
newMode = SmoothingMode.AntiAlias;
rect.Width--;
rect.Height--;
}
if (rect.Width < 1 || rect.Height < 1)
return;
using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode))
{
using (LinearGradientBrush lb = new LinearGradientBrush(
rect, color1, color2, angle))
{
if (simpleRect)
{
g.FillRectangle(lb, rect);
}
else
{
using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false))
{
g.FillPath(lb, path);
}
}
}
}
}
示例10: RenderScrollBarArrowInternal
internal void RenderScrollBarArrowInternal(
Graphics g,
Rectangle rect,
//Color baseColor,
//Color borderColor,
//Color innerBorderColor,
Color arrowColor,
RoundStyle roundStyle,
bool drawBorder,
bool drawGlass,
ArrowDirection arrowDirection,
LinearGradientMode mode)
{
//RenderHelper.RenderBackgroundInternal(
// g,
// rect,
// baseColor,
// borderColor,
// innerBorderColor,
// roundStyle,
// 0,
// .45F,
// drawBorder,
// drawGlass,
// mode);
using (SolidBrush brush = new SolidBrush(arrowColor))
{
RenderArrowInternal(
g,
rect,
arrowDirection,
brush);
}
}
示例11: DrawCaptionBorder
private void DrawCaptionBorder(Graphics g, Rectangle captionRect , int roundWidth , RoundStyle style , Color innerBorderColor )
{
using (GraphicsPath path =
GraphicsPathHelper.CreatePath(captionRect, roundWidth, style, false))
{
using (Pen pen = new Pen(innerBorderColor))
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.DrawPath(pen, path);
}
}
}
示例12: CreateRoundedRect
public static GraphicsPath CreateRoundedRect(Rectangle rect, int radius, RoundStyle type, bool shorten)
{
GraphicsPath path = new GraphicsPath();
if (shorten)
{
rect.Width--;
rect.Height--;
}
if (radius < 2)
type = RoundStyle.None;
Rectangle rectTopLeft = new Rectangle(rect.X, rect.Y, radius, radius);
Rectangle rectTopRight = new Rectangle(rect.Right - radius, rect.Y, radius, radius);
Rectangle rectBottomLeft = new Rectangle(rect.X, rect.Bottom - radius, radius, radius);
Rectangle rectBottomRight = new Rectangle(rect.Right - radius, rect.Bottom - radius, radius, radius);
Point p1 = new Point(rect.X, rect.Y);
Point p2 = new Point(rect.Right, rect.Y);
Point p3 = new Point(rect.Right, rect.Bottom);
Point p4 = new Point(rect.X, rect.Bottom);
switch (type)
{
case RoundStyle.None:
path.AddRectangle(rect);
break;
case RoundStyle.All:
path.AddArc(rectTopLeft, 180, 90);
path.AddArc(rectTopRight, 270, 90);
path.AddArc(rectBottomRight, 0, 90);
path.AddArc(rectBottomLeft, 90, 90);
break;
case RoundStyle.Top:
path.AddArc(rectTopLeft, 180, 90);
path.AddArc(rectTopRight, 270, 90);
path.AddLine(p3, p4);
break;
case RoundStyle.Bottom:
path.AddArc(rectBottomRight, 0, 90);
path.AddArc(rectBottomLeft, 90, 90);
path.AddLine(p1, p2);
break;
case RoundStyle.Left:
path.AddArc(rectBottomLeft, 90, 90);
path.AddArc(rectTopLeft, 180, 90);
path.AddLine(p2, p3);
break;
case RoundStyle.Right:
path.AddArc(rectTopRight, 270, 90);
path.AddArc(rectBottomRight, 0, 90);
path.AddLine(p4, p1);
break;
default:
break;
}
path.CloseFigure();
return path;
}
示例13: CalcRoundStyle
private static RoundStyle CalcRoundStyle(GlassPosition pos, int radius, RoundStyle ownerStyle)
{
if (radius < 2 || ownerStyle == RoundStyle.None)
return RoundStyle.None;
switch (pos)
{
case GlassPosition.Fill:
return ownerStyle;
case GlassPosition.Top:
if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Top)
return RoundStyle.Top;
else
return RoundStyle.None;
case GlassPosition.Bottom:
if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Bottom)
return RoundStyle.Bottom;
else
return RoundStyle.None;
case GlassPosition.Left:
if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Left)
return RoundStyle.Left;
else
return RoundStyle.None;
case GlassPosition.Right:
if (ownerStyle == RoundStyle.All || ownerStyle == RoundStyle.Right)
return RoundStyle.Right;
else
return RoundStyle.None;
default:
return RoundStyle.None;
}
}
示例14: CreateRegion
/// <summary>
/// 样式绘制圆角
/// </summary>
/// <param name="hWnd">控件句柄</param>
/// <param name="radius">圆角</param>
/// <param name="roundStyle">圆角样式</param>
/// <param name="redraw">是否重画</param>
public static void CreateRegion(
IntPtr hWnd,
int radius,
RoundStyle roundStyle,
bool redraw)
{
RECT bounds = new RECT();
NativeMethods.GetWindowRect(hWnd, ref bounds);
Rectangle rect = new Rectangle(
Point.Empty, bounds.Size);
if (roundStyle != RoundStyle.None)
{
using (GraphicsPath path =
GraphicsPathHelper.CreatePath(
rect, radius, roundStyle, true))
{
using (Region region = new Region(path))
{
path.Widen(Pens.White);
region.Union(path);
IntPtr hDc = NativeMethods.GetWindowDC(hWnd);
try
{
using (Graphics g = Graphics.FromHdc(hDc))
{
NativeMethods.SetWindowRgn(hWnd, region.GetHrgn(g), redraw);
}
}
finally
{
NativeMethods.ReleaseDC(hWnd, hDc);
}
}
}
}
else
{
IntPtr hRgn = NativeMethods.CreateRectRgn(0, 0, rect.Width, rect.Height);
NativeMethods.SetWindowRgn(hWnd, hRgn, redraw);
}
}
示例15: CreateRegion
public static void CreateRegion(Control control, Rectangle bounds, int radius, RoundStyle roundStyle)
{
using (GraphicsPath path = CreatePath(bounds, radius, roundStyle, true))
{
Region region = new Region(path);
path.Widen(Pens.White);
region.Union(path);
control.Region = region;
}
}