示例#1
0
        public void DockUnDock()
        {
            if (this.isDocked)
            {
                if (this.undockedForm == null)
                {
                    undockedForm              = new Form();
                    undockedForm.Text         = UndockedWindowTitle(source);
                    source.PropertyChanged   -= Server_PropertyChanged;
                    source.PropertyChanged   += Server_PropertyChanged;
                    undockedForm.Icon         = Program.MainWindow.Icon;
                    undockedForm.FormClosing += new FormClosingEventHandler(delegate(object sender, FormClosingEventArgs e)
                    {
                        this.DockUnDock();
                    });
                    undockedForm.StartPosition = FormStartPosition.CenterScreen;
                    undockedForm.Resize       += new EventHandler(
                        delegate(Object o, EventArgs a)
                    {
                        if (undockedForm.WindowState == FormWindowState.Minimized)
                        {
                            vncTabView.Pause();
                        }
                        else
                        {
                            vncTabView.Unpause();
                        }
                    });
                }

                this.Controls.Remove(vncTabView);
                undockedForm.Controls.Add(vncTabView);

                oldScaledSetting = vncTabView.scaleCheckBox.Checked;

                vncTabView.showHeaderBar(!source.is_control_domain, true);

                undockedForm.ClientSize = vncTabView.GrowToFit();

                if (oldUndockedSize != Size.Empty &&
                    oldUndockedLocation != Point.Empty &&
                    HelpersGUI.WindowIsOnScreen(oldUndockedLocation, oldUndockedSize))
                {
                    undockedForm.Size          = oldUndockedSize;
                    undockedForm.StartPosition = FormStartPosition.Manual;
                    undockedForm.Location      = oldUndockedLocation;
                }

                undockedForm.HelpButton = true;
                //undockedForm.MinimizeBox = false;
                //undockedForm.MaximizeBox = false;
                undockedForm.HelpButtonClicked += undockedForm_HelpButtonClicked;
                undockedForm.HelpRequested     += undockedForm_HelpRequested;

                undockedForm.Show();

                if (Properties.Settings.Default.PreserveScaleWhenUndocked)
                {
                    vncTabView.scaleCheckBox.Checked = oldScaledSetting;
                }

                this.reattachConsoleButton.Show();
                this.findConsoleButton.Show();
            }
            else
            {
                //save location of undock vnc control
                this.oldUndockedLocation = undockedForm.Location;
                this.oldUndockedSize     = undockedForm.Size;

                if (!Properties.Settings.Default.PreserveScaleWhenUndocked)
                {
                    vncTabView.scaleCheckBox.Checked = oldScaledSetting;
                }

                this.reattachConsoleButton.Hide();
                this.findConsoleButton.Hide();

                undockedForm.Hide();
                vncTabView.showHeaderBar(true, false);
                undockedForm.Controls.Remove(vncTabView);
                this.Controls.Add(vncTabView);

                undockedForm.Dispose();
                undockedForm = null;
            }

            vncTabView.UpdateDockButton();

            vncTabView.UpdateParentMinimumSize();

            //Every time we dock / undock I'm going to force an unpause to make sure we don't ever pause a visible one.
            vncTabView.Unpause();
            vncTabView.focus_vnc();
        }