示例#1
0
        /// <summary>
        /// Host a control in a new window with an optional parent
        /// </summary>
        /// <param name="name">The name of the window</param>
        /// <param name="control">The control to host</param>
        /// <param name="parentControl">The parent control</param>
        /// <returns>A component reference</returns>
        public IComponent HostControl(string name, Control control, Control parentControl)
        {
            if (InvokeRequired)
            {
                return((IComponent)Invoke(new Func <string, Control, Control, IComponent>(HostControl), name, control, parentControl));
            }
            else
            {
                DocumentForm form = new DocumentForm(name, control);
                DockContent  dock = null;

                if (parentControl != null)
                {
                    Control c = parentControl.Parent;

                    while (c != null)
                    {
                        if (c is DockContent)
                        {
                            dock = (DockContent)c;
                            break;
                        }

                        c = c.Parent;
                    }
                }

                if (dock != null)
                {
                    form.Show(dock.PanelPane, DockAlignment.Bottom, 0.5);
                }
                else
                {
                    form.Show(this.dockPanel, DockState.Document);
                }

                return(form);
            }
        }
示例#2
0
        /// <summary>
        /// Host a control in a new window with an optional parent
        /// </summary>
        /// <param name="name">The name of the window</param>
        /// <param name="control">The control to host</param>
        /// <param name="parentControl">The parent control</param>
        /// <returns>A component reference</returns>
        public IComponent HostControl(string name, Control control, Control parentControl)
        {
            if (InvokeRequired)
            {
                return (IComponent)Invoke(new Func<string, Control, Control, IComponent>(HostControl), name, control, parentControl);
            }
            else
            {
                DocumentForm form = new DocumentForm(name, control);
                DockContent dock = null;

                if (parentControl != null)
                {
                    Control c = parentControl.Parent;

                    while (c != null)
                    {
                        if (c is DockContent)
                        {
                            dock = (DockContent)c;
                            break;
                        }

                        c = c.Parent;
                    }
                }

                if (dock != null)
                {
                    form.Show(dock.PanelPane, DockAlignment.Bottom, 0.5);
                }
                else
                {
                    form.Show(this.dockPanel, DockState.Document);
                }

                return form;
            }
        }