当前位置: 首页>>代码示例>>C#>>正文


C# Control.GetAutoSizeMode方法代码示例

本文整理汇总了C#中Control.GetAutoSizeMode方法的典型用法代码示例。如果您正苦于以下问题:C# Control.GetAutoSizeMode方法的具体用法?C# Control.GetAutoSizeMode怎么用?C# Control.GetAutoSizeMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Control的用法示例。


在下文中一共展示了Control.GetAutoSizeMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LayoutAutoSizeContainer

		void LayoutAutoSizeContainer (Control container)
		{
			int left;
			int top;
			int width;
			int height;

			if (!container.VisibleInternal || container.ControlLayoutType == Control.LayoutType.Dock || !container.AutoSize)
				return;

			left = container.Left;
			top = container.Top;

			Size preferredsize = container.PreferredSize;

			if (container.GetAutoSizeMode () == AutoSizeMode.GrowAndShrink) {
				width = preferredsize.Width;
				height = preferredsize.Height;
			} else {
				width = container.ExplicitBounds.Width;
				height = container.ExplicitBounds.Height;
				if (preferredsize.Width > width)
					width = preferredsize.Width;
				if (preferredsize.Height > height)
					height = preferredsize.Height;
			}

			// Sanity
			if (width < container.MinimumSize.Width)
				width = container.MinimumSize.Width;

			if (height < container.MinimumSize.Height)
				height = container.MinimumSize.Height;

			if (container.MaximumSize.Width != 0 && width > container.MaximumSize.Width)
				width = container.MaximumSize.Width;

			if (container.MaximumSize.Height != 0 && height > container.MaximumSize.Height)
				height = container.MaximumSize.Height;

			container.SetBoundsInternal (left, top, width, height, BoundsSpecified.None);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:42,代码来源:DefaultLayout.cs

示例2: GetPreferredControlSize

		private Size GetPreferredControlSize (Control child)
		{
			int width;
			int height;
			Size preferredsize = child.PreferredSize;

			if (child.GetAutoSizeMode () == AutoSizeMode.GrowAndShrink || (child.Dock != DockStyle.None && !(child is Button) && !(child is FlowLayoutPanel))) {
				width = preferredsize.Width;
				height = preferredsize.Height;
			} else {
				width = child.ExplicitBounds.Width;
				height = child.ExplicitBounds.Height;
				if (preferredsize.Width > width)
					width = preferredsize.Width;
				if (preferredsize.Height > height)
					height = preferredsize.Height;
			}
			if (child.AutoSize && child is FlowLayoutPanel && child.Dock != DockStyle.None) {
				switch (child.Dock) {
				case DockStyle.Left:
				case DockStyle.Right:
					if (preferredsize.Width < child.ExplicitBounds.Width && preferredsize.Height < child.Parent.PaddingClientRectangle.Height)
						width = preferredsize.Width;
					break;
				case DockStyle.Top:
				case DockStyle.Bottom:
					if (preferredsize.Height < child.ExplicitBounds.Height && preferredsize.Width < child.Parent.PaddingClientRectangle.Width)
						height = preferredsize.Height;
					break;
				}
			}
			// Sanity
			if (width < child.MinimumSize.Width)
				width = child.MinimumSize.Width;

			if (height < child.MinimumSize.Height)
				height = child.MinimumSize.Height;

			if (child.MaximumSize.Width != 0 && width > child.MaximumSize.Width)
				width = child.MaximumSize.Width;

			if (child.MaximumSize.Height != 0 && height > child.MaximumSize.Height)
				height = child.MaximumSize.Height;
				
			return new Size (width, height);
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:46,代码来源:DefaultLayout.cs

示例3: GetPreferredControlSize

		private Size GetPreferredControlSize (Control child)
		{
			int width;
			int height;
			Size preferredsize = child.PreferredSize;

			if (child.GetAutoSizeMode () == AutoSizeMode.GrowAndShrink || (child.Dock != DockStyle.None && !(child is Button))) {
				width = preferredsize.Width;
				height = preferredsize.Height;
			} else {
				width = child.ExplicitBounds.Width;
				height = child.ExplicitBounds.Height;
				if (preferredsize.Width > width)
					width = preferredsize.Width;
				if (preferredsize.Height > height)
					height = preferredsize.Height;
			}

			// Sanity
			if (width < child.MinimumSize.Width)
				width = child.MinimumSize.Width;

			if (height < child.MinimumSize.Height)
				height = child.MinimumSize.Height;

			if (child.MaximumSize.Width != 0 && width > child.MaximumSize.Width)
				width = child.MaximumSize.Width;

			if (child.MaximumSize.Height != 0 && height > child.MaximumSize.Height)
				height = child.MaximumSize.Height;
				
			return new Size (width, height);
		}
开发者ID:carrie901,项目名称:mono,代码行数:33,代码来源:DefaultLayout.cs


注:本文中的Control.GetAutoSizeMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。