本文整理汇总了C#中System.Windows.Forms.Padding.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Padding.Equals方法的具体用法?C# Padding.Equals怎么用?C# Padding.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Padding
的用法示例。
在下文中一共展示了Padding.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyPadding
/// <summary>
/// Return the provided rectangle with visual orientation specific padding applied.
/// </summary>
/// <param name="orientation">Orientation to apply padding with.</param>
/// <param name="rect">Starting rectangle.</param>
/// <param name="padding">Padding to be applied.</param>
/// <returns>Updated rectangle.</returns>
public static Rectangle ApplyPadding(VisualOrientation orientation,
Rectangle rect,
Padding padding)
{
// Ignore an empty padding value
if (!padding.Equals(CommonHelper.InheritPadding))
{
// The orientation determines how the border padding is
// used to reduce the space available for children
switch (orientation)
{
case VisualOrientation.Top:
rect = new Rectangle(rect.X + padding.Left, rect.Y + padding.Top,
rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
break;
case VisualOrientation.Bottom:
rect = new Rectangle(rect.X + padding.Right, rect.Y + padding.Bottom,
rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
break;
case VisualOrientation.Left:
rect = new Rectangle(rect.X + padding.Top, rect.Y + padding.Right,
rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
break;
case VisualOrientation.Right:
rect = new Rectangle(rect.X + padding.Bottom, rect.Y + padding.Left,
rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
break;
default:
// Should never happen!
Debug.Assert(false);
break;
}
}
return rect;
}
示例2: ApplyPadding
private Rectangle ApplyPadding(Rectangle rect, Padding padding)
{
// Ignore an empty padding value
if (!padding.Equals(CommonHelper.InheritPadding))
{
// Get the orientation to use for applying the padding
VisualOrientation orientation = Orientation;
// Do we need to apply right to left?
if (_rightToLeftLayout && (_rightToLeft == RightToLeft.Yes))
{
// Reverse the left and right only
switch (orientation)
{
case VisualOrientation.Left:
orientation = VisualOrientation.Right;
break;
case VisualOrientation.Right:
orientation = VisualOrientation.Left;
break;
}
}
// The orientation determines how the border padding is
// used to reduce the space available for children
switch (orientation)
{
case VisualOrientation.Top:
rect = new Rectangle(rect.X + padding.Left, rect.Y + padding.Top,
rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
break;
case VisualOrientation.Bottom:
rect = new Rectangle(rect.X + padding.Left, rect.Y + padding.Bottom,
rect.Width - padding.Horizontal, rect.Height - padding.Vertical);
break;
case VisualOrientation.Left:
rect = new Rectangle(rect.X + padding.Top, rect.Y + padding.Left,
rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
break;
case VisualOrientation.Right:
rect = new Rectangle(rect.X + padding.Bottom, rect.Y + padding.Left,
rect.Width - padding.Vertical, rect.Height - padding.Horizontal);
break;
default:
// Should never happen!
Debug.Assert(false);
break;
}
}
return rect;
}
示例3: ApplyPadding
public static Size ApplyPadding(Orientation orientation, Size size, Padding padding)
{
if (!padding.Equals(InheritPadding))
{
switch (orientation)
{
case Orientation.Horizontal:
size.Width += padding.Horizontal;
size.Height += padding.Vertical;
return size;
case Orientation.Vertical:
size.Width += padding.Vertical;
size.Height += padding.Horizontal;
return size;
}
}
return size;
}