本文整理汇总了C#中IArrangedElement.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# IArrangedElement.SetBounds方法的具体用法?C# IArrangedElement.SetBounds怎么用?C# IArrangedElement.SetBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IArrangedElement
的用法示例。
在下文中一共展示了IArrangedElement.SetBounds方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDock
public static void SetDock(IArrangedElement element, DockStyle value) {
Debug.Assert(!HasCachedBounds(element.Container),
"Do not call this method with an active cached bounds list.");
if (GetDock(element) != value) {
//valid values are 0x0 to 0x5
if (!ClientUtils.IsEnumValid(value, (int)value, (int)DockStyle.None, (int)DockStyle.Fill)){
throw new InvalidEnumArgumentException("value", (int)value, typeof(DockStyle));
}
bool dockNeedsLayout = CommonProperties.GetNeedsDockLayout(element);
CommonProperties.xSetDock(element, value);
using (new LayoutTransaction(element.Container as Control, element, PropertyNames.Dock)) {
// VSWHDIBEY 227715 if the item is autosized, calling setbounds performs a layout, which
// if we havent set the anchor info properly yet makes dock/anchor layout cranky.
if (value == DockStyle.None) {
if (dockNeedsLayout) {
// We are transitioning from docked to not docked, restore the original bounds.
element.SetBounds(CommonProperties.GetSpecifiedBounds(element), BoundsSpecified.None);
// VSWHIDBEY 159532 restore Anchor information as its now relevant again.
UpdateAnchorInfo(element);
}
}
else {
// Now setup the new bounds.
//
element.SetBounds(CommonProperties.GetSpecifiedBounds(element), BoundsSpecified.All);
}
}
}
Debug.Assert(GetDock(element) == value, "Error setting Dock value.");
}
示例2: SetMinimumSize
/// SetMinimumSize
/// Sets the minimum size for an element.
internal static void SetMinimumSize(IArrangedElement element, Size value) {
Debug.Assert(value != GetMinimumSize(element, new Size(-7109, -7107)),
"PERF: Caller should guard against setting MinimumSize to original value.");
element.Properties.SetSize(_minimumSizeProperty, value);
using (new LayoutTransaction(element.Container as Control, element, PropertyNames.MinimumSize)) {
// Element bounds may need to inflated to new minimum
//
Rectangle bounds = element.Bounds;
bounds.Width = Math.Max(bounds.Width, value.Width);
bounds.Height = Math.Max(bounds.Height, value.Height);
element.SetBounds(bounds, BoundsSpecified.Size);
}
Debug.Assert(GetMinimumSize(element, new Size(-7109, -7107)) == value, "Error detected setting MinimumSize.");
}
示例3: xLayoutDockedControl
// Helper method that either sets the element bounds or does the preferredSize computation based on
// the value of measureOnly.
private static void xLayoutDockedControl(IArrangedElement element, Rectangle newElementBounds, bool measureOnly, ref Size preferredSize, ref Rectangle remainingBounds) {
if (measureOnly) {
Size neededSize = new Size(
Math.Max(0, newElementBounds.Width - remainingBounds.Width),
Math.Max(0, newElementBounds.Height - remainingBounds.Height));
DockStyle dockStyle = GetDock(element);
if ((dockStyle == DockStyle.Top) || (dockStyle == DockStyle.Bottom)) {
neededSize.Width = 0;
}
if ((dockStyle == DockStyle.Left) || (dockStyle == DockStyle.Right)) {
neededSize.Height = 0;
}
if (dockStyle != DockStyle.Fill) {
preferredSize += neededSize;
remainingBounds.Size += neededSize;
}
else if(dockStyle == DockStyle.Fill && CommonProperties.GetAutoSize(element)) {
Size elementPrefSize = element.GetPreferredSize(neededSize);
remainingBounds.Size += elementPrefSize;
preferredSize += elementPrefSize;
}
} else {
element.SetBounds(newElementBounds, BoundsSpecified.None);
#if DEBUG
Control control = element as Control;
newElementBounds.Size = control.ApplySizeConstraints(newElementBounds.Size);
// This usually happens when a Control overrides its SetBoundsCore or sets size during OnResize
// to enforce constraints like AutoSize. Generally you can just move this code to Control.GetAdjustedSize
// and then PreferredSize will also pick up these constraints. See ComboBox as an example.
//
if (CommonProperties.GetAutoSize(element) && !CommonProperties.GetSelfAutoSizeInDefaultLayout(element)) {
Debug.Assert(
(newElementBounds.Width < 0 || element.Bounds.Width == newElementBounds.Width) &&
(newElementBounds.Height < 0 || element.Bounds.Height == newElementBounds.Height),
"Element modified its bounds during docking -- PreferredSize will be wrong. See comment near this assert.");
}
#endif
}
}
示例4: SetAutoSize
/// SetAutoSize
/// Sets whether or not the layout engines should treat this control as auto sized.
internal static void SetAutoSize(IArrangedElement element, bool value) {
Debug.Assert(value != GetAutoSize(element), "PERF: Caller should guard against setting AutoSize to original value.");
BitVector32 state = GetLayoutState(element);
state[_autoSizeSection] = value ? 1 : 0;
SetLayoutState(element, state);
if(value == false) {
// If autoSize is being turned off, restore the control to its specified bounds.
element.SetBounds(GetSpecifiedBounds(element), BoundsSpecified.None);
}
Debug.Assert(GetAutoSize(element) == value, "Error detected setting AutoSize.");
}
示例5: SetMaximumSize
/// SetMaximumSize
/// Sets the maximum size for an element.
internal static void SetMaximumSize(IArrangedElement element, Size value) {
Debug.Assert(value != GetMaximumSize(element, new Size(-7109, -7107)),
"PERF: Caller should guard against setting MaximumSize to original value.");
element.Properties.SetSize(_maximumSizeProperty, value);
// Element bounds may need to truncated to new maximum
//
Rectangle bounds = element.Bounds;
bounds.Width = Math.Min(bounds.Width, value.Width);
bounds.Height = Math.Min(bounds.Height, value.Height);
element.SetBounds(bounds, BoundsSpecified.Size);
// element.SetBounds does a SetBoundsCore. We still need to explicitly refresh parent layout.
LayoutTransaction.DoLayout(element.Container, element, PropertyNames.MaximumSize);
Debug.Assert(GetMaximumSize(element, new Size(-7109, -7107)) == value, "Error detected setting MaximumSize.");
}
示例6: SetMinimumSize
internal static void SetMinimumSize(IArrangedElement element, Size value)
{
element.Properties.SetSize(_minimumSizeProperty, value);
using (new LayoutTransaction(element.Container as Control, element, PropertyNames.MinimumSize))
{
Rectangle bounds = element.Bounds;
bounds.Width = Math.Max(bounds.Width, value.Width);
bounds.Height = Math.Max(bounds.Height, value.Height);
element.SetBounds(bounds, BoundsSpecified.Size);
}
}
示例7: SetMaximumSize
internal static void SetMaximumSize(IArrangedElement element, Size value)
{
element.Properties.SetSize(_maximumSizeProperty, value);
Rectangle bounds = element.Bounds;
bounds.Width = Math.Min(bounds.Width, value.Width);
bounds.Height = Math.Min(bounds.Height, value.Height);
element.SetBounds(bounds, BoundsSpecified.Size);
LayoutTransaction.DoLayout(element.Container, element, PropertyNames.MaximumSize);
}
示例8: SetAutoSize
internal static void SetAutoSize(IArrangedElement element, bool value)
{
BitVector32 layoutState = GetLayoutState(element);
layoutState[_autoSizeSection] = value ? 1 : 0;
SetLayoutState(element, layoutState);
if (!value)
{
element.SetBounds(GetSpecifiedBounds(element), BoundsSpecified.None);
}
}
示例9: xLayoutDockedControl
private static void xLayoutDockedControl(IArrangedElement element, Rectangle newElementBounds, bool measureOnly, ref Size preferredSize, ref Rectangle remainingBounds)
{
if (measureOnly)
{
Size proposedSize = new Size(Math.Max(0, newElementBounds.Width - remainingBounds.Width), Math.Max(0, newElementBounds.Height - remainingBounds.Height));
DockStyle dock = GetDock(element);
switch (dock)
{
case DockStyle.Top:
case DockStyle.Bottom:
proposedSize.Width = 0;
break;
}
if ((dock == DockStyle.Left) || (dock == DockStyle.Right))
{
proposedSize.Height = 0;
}
if (dock != DockStyle.Fill)
{
preferredSize += proposedSize;
remainingBounds.Size += proposedSize;
}
else if ((dock == DockStyle.Fill) && CommonProperties.GetAutoSize(element))
{
Size size2 = element.GetPreferredSize(proposedSize);
remainingBounds.Size += size2;
preferredSize += size2;
}
}
else
{
element.SetBounds(newElementBounds, BoundsSpecified.None);
}
}
示例10: SetDock
public static void SetDock(IArrangedElement element, DockStyle value)
{
if (GetDock(element) != value)
{
if (!System.Windows.Forms.ClientUtils.IsEnumValid(value, (int) value, 0, 5))
{
throw new InvalidEnumArgumentException("value", (int) value, typeof(DockStyle));
}
bool needsDockLayout = CommonProperties.GetNeedsDockLayout(element);
CommonProperties.xSetDock(element, value);
using (new LayoutTransaction(element.Container as Control, element, PropertyNames.Dock))
{
if (value == DockStyle.None)
{
if (needsDockLayout)
{
element.SetBounds(CommonProperties.GetSpecifiedBounds(element), BoundsSpecified.None);
UpdateAnchorInfo(element);
}
}
else
{
element.SetBounds(CommonProperties.GetSpecifiedBounds(element), BoundsSpecified.All);
}
}
}
}