System.Windows.Forms.ScrollableControl.CalculateCanvasSize C# (CSharp) Method

CalculateCanvasSize() private method

private CalculateCanvasSize ( bool canOverride ) : void
canOverride bool
return void
		internal virtual void CalculateCanvasSize (bool canOverride)
		{
			if(m_helper == null)
				return;
			Control child;
			int num_of_children;
			int width;
			int height;
			int extra_width;
			int extra_height;
			
			num_of_children = Controls.Count;
			width = 0;
			height = 0;
			
			extra_width = m_helper.HorizontalScroller == null ? 0 : m_helper.HorizontalScroller.IntValue;
			extra_height = m_helper.VerticalScroller == null ? 0 : m_helper.VerticalScroller.IntValue;
			if (dock_padding != null) {
				extra_width += dock_padding.Right;
				extra_height += dock_padding.Bottom;
			}
			
			for (int i = 0; i < num_of_children; i++) {
				child = Controls[i];
				if (child.Dock == DockStyle.Right) {
					extra_width += child.Width;
				} else if (child.Dock == DockStyle.Bottom) {
					extra_height += child.Height;
				}
			}
			
			if (!auto_scroll_min_size.IsEmpty) {
				width = auto_scroll_min_size.Width;
				height = auto_scroll_min_size.Height;
			}
			
			for (int i = 0; i < num_of_children; i++) {
				child = Controls[i];
				
				switch (child.Dock) {
				case DockStyle.Left:
					
					{
						if ((child.Right + extra_width) > width) {
							width = child.Right + extra_width;
						}
						continue;
					}

				
				case DockStyle.Top:
					
					{
						if ((child.Bottom + extra_height) > height) {
							height = child.Bottom + extra_height;
						}
						continue;
					}

				
				case DockStyle.Fill:
				case DockStyle.Right:
				case DockStyle.Bottom:
					
					{
						continue;
					}

				default:
					
					
					{
						AnchorStyles anchor;
						
						anchor = child.Anchor;
						
						if (((anchor & AnchorStyles.Left) != 0) && ((anchor & AnchorStyles.Right) == 0)) {
							if ((child.Right + extra_width) > width) {
								width = child.Right + extra_width;
							}
						}
						
						if (((anchor & AnchorStyles.Top) != 0) || ((anchor & AnchorStyles.Bottom) == 0)) {
							if ((child.Bottom + extra_height) > height) {
								height = child.Bottom + extra_height;
							}
						}
						continue;
					}

				}
			}
			
			canvas_size.Width = width;
			canvas_size.Height = height;
		}