示例#1
0
		internal void CloseContent(DockContent content)
		{
			if (content == null)
				return;

			if (!content.CloseButton)
				return;

			if (content.HideOnClose)
				content.Hide();
			else
			{
				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				// Workaround for .Net Framework bug: removing control from Form may cause form
				// unclosable.
				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				Form form = FindForm();
				if (ContainsFocus)
				{
					if (form is FloatWindow)
					{
						((FloatWindow)form).DummyControl.Focus();
						form.ActiveControl = ((FloatWindow)form).DummyControl;
					}
					else if (DockPanel != null)
					{
						DockPanel.DummyControl.Focus();
						if (form != null)
							form.ActiveControl = DockPanel.DummyControl;
					}
				}
				//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
				
				content.Close();
			}
		}
示例#2
0
		private void ShowWindow(DockContent window, MenuItem menuItem)
		{
			menuItem.Checked = !menuItem.Checked;

			if (menuItem.Checked)
			{
				window.Show(dockPanel);
			}
			else
			{
				window.Hide();
			}
		}
示例#3
0
        /// <exclude/>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN)
            {
                if (IsDisposed)
                {
                    return;
                }

                uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam);
                if (result == 2 && DockPanel.AllowRedocking && this.AllowRedocking)                     // HITTEST_CAPTION
                {
                    Activate();
                    m_dockPanel.DragHandler.BeginDragFloatWindow(this);
                }
                else
                {
                    base.WndProc(ref m);
                }

                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_CLOSE)
            {
                if (DockList.Count == 0)
                {
                    base.WndProc(ref m);
                    return;
                }

                for (int i = DockList.Count - 1; i >= 0; i--)
                {
                    DockContentCollection contents = DockList[i].Contents;
                    for (int j = contents.Count - 1; j >= 0; j--)
                    {
                        DockContent content = contents[j];
                        if (content.DockState != DockState.Float)
                        {
                            continue;
                        }

                        if (!content.CloseButton)
                        {
                            continue;
                        }

                        if (content.HideOnClose)
                        {
                            content.Hide();
                        }
                        else
                        {
                            content.Close();
                        }
                    }
                }

                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK)
            {
                uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam);
                if (result != 2)                        // HITTEST_CAPTION
                {
                    base.WndProc(ref m);
                    return;
                }

                // Restore to panel
                DockContent activeContent = DockPanel.ActiveContent;
                foreach (DockPane pane in DockList)
                {
                    if (pane.DockState != DockState.Float)
                    {
                        continue;
                    }
                    pane.RestoreToPanel();
                }
                if (activeContent != null)
                {
                    activeContent.Activate();
                }

                return;
            }
            else if (m.Msg == WM_CHECKDISPOSE)
            {
                if (DockList.Count == 0)
                {
                    Dispose();
                }

                return;
            }

            base.WndProc(ref m);
        }