private static void Adjust(FluidControl c, Size oldContainerSize, Size newContainerSize, SizeF scaleFactor) { Rectangle bounds = c.Bounds; int left = bounds.Left; int right = bounds.Right; int top = bounds.Top; int bottom = bounds.Bottom; AnchorStyles a = c.Anchor; if ((a & AnchorStyles.Right) != 0) { int dw = newContainerSize.Width - oldContainerSize.Width; right += dw; if ((a & AnchorStyles.Left) == 0) { left += dw; } } if ((a & AnchorStyles.Bottom) != 0) { int dh = newContainerSize.Height - oldContainerSize.Height; bottom += dh; if ((a & AnchorStyles.Top) == 0) { top += dh; } } Rectangle b = new Rectangle(left, top, right - left, bottom - top); if (c.Bounds.Size != b.Size) { c.Scale(scaleFactor); } c.Bounds = b; }
private static void Adjust(FluidControl c, Size oldContainerSize, Size newContainerSize, SizeF scaleFactor) { Rectangle bounds = c.Bounds; int left = bounds.Left; int right = bounds.Right; int top = bounds.Top; int bottom = bounds.Bottom; AnchorStyles a = c.Anchor; if ((a & AnchorStyles.Right) != 0) { int dw = newContainerSize.Width - oldContainerSize.Width; right += dw; if ((a & AnchorStyles.Left) == 0) { left += dw; } } if ((a & AnchorStyles.Bottom) != 0) { int dh = newContainerSize.Height - oldContainerSize.Height; bottom += dh; if ((a & AnchorStyles.Top) == 0) { top += dh; } } Rectangle b = new Rectangle(left, top, right - left, bottom - top); if (c.Bounds.Size != b.Size) { c.Scale(scaleFactor); } c.Bounds = b; }