protected void HandleApplicationMouseLUp(Point mousePos) { // If we released the mouse button while we were dragging a torn tab, put that tab into a new window if (m_tornTab != null) { TitleBarTabItem tabToRelease = null; lock (m_tornTabLock) { if (m_tornTab != null) { tabToRelease = m_tornTab; m_tornTab = null; } } if (tabToRelease != null) { TitleBarTabMainForm newWindow = (TitleBarTabMainForm)Activator.CreateInstance(m_parentForm.GetType()); // Set the initial window position and state properly if (newWindow.WindowState == FormWindowState.Maximized) { Screen screen = Screen.AllScreens.First(s => s.WorkingArea.Contains(Cursor.Position)); newWindow.StartPosition = FormStartPosition.Manual; newWindow.WindowState = FormWindowState.Normal; newWindow.Left = screen.WorkingArea.Left; newWindow.Top = screen.WorkingArea.Top; newWindow.Width = screen.WorkingArea.Width; newWindow.Height = screen.WorkingArea.Height; } else { newWindow.Left = Cursor.Position.X; newWindow.Top = Cursor.Position.Y; } tabToRelease.Parent = newWindow; m_parentForm.ApplicationContext.OpenWindow(newWindow); newWindow.Show(); newWindow.Tabs.Add(tabToRelease); newWindow.SelectedTabIndex = 0; newWindow.ResizeTabContents(); m_tornTabForm.Close(); m_tornTabForm = null; if (m_parentForm.Tabs.Count == 0) { m_parentForm.Close(); } } } OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, Cursor.Position.X, Cursor.Position.Y, 0)); }
/// <summary>Constructor; takes the initial window to display and, if it's not closing, opens it and shows it.</summary> /// <param name="initialFormInstance">Initial window to display.</param> public void Start(TitleBarTabMainForm initialFormInstance) { if (initialFormInstance.IsClosing) { ExitThread(); } else { OpenWindow(initialFormInstance); initialFormInstance.Show(); } }