Exemplo n.º 1
0
        internal DialogBoxForm(string title, Control content, Size exactSize, DialogSizeHint sizeHint, bool allowResize)
        {
            InitializeComponent();
            Text = title;

            _content = content;

            // important - if we do not set a minimum size, the full content may not be displayed
            _content.MinimumSize = _content.Size;
            _content.Dock        = DockStyle.Fill;

            // adjust size of client area
            this.ClientSize = exactSize != Size.Empty ? exactSize : SizeHintHelper.TranslateHint(sizeHint, _content.Size);

            if (allowResize)
            {
                FormBorderStyle = FormBorderStyle.Sizable;
                MinimumSize     = base.SizeFromClientSize(_content.Size);
            }

            _contentPanel.Controls.Add(_content);

            // Resize the dialog if size of the underlying content changed
            _content.SizeChanged += OnContentSizeChanged;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="content"></param>
        /// <param name="exactSize"></param>
        /// <param name="sizeHint"></param>
        private WorkspaceDialogBoxForm(string title, Control content, Size exactSize, DialogSizeHint sizeHint)
        {
            InitializeComponent();
            this.Text = title;

            _content = content;

            // important - if we do not set a minimum size, the full content may not be displayed
            _content.MinimumSize = _content.Size;
            _content.Dock        = DockStyle.Fill;

            // adjust size of client area to its ideal size
            var contentSize = exactSize != Size.Empty ? exactSize : SizeHintHelper.TranslateHint(sizeHint, _content.Size);

            this.ClientSize = contentSize;            // +new Size(0, 4);

            // record the ideal size for future reference
            _idealSize = this.Size;

            _contentPanel.Controls.Add(_content);
        }