/// ------------------------------------------------------------------------------------ /// <summary> /// Make sure to clean up after a view is closed. /// </summary> /// ------------------------------------------------------------------------------------ void m_viewsForm_FormClosed(object sender, FormClosedEventArgs e) { _viewsForm.FormClosing -= m_viewsForm_FormClosing; _viewsForm.FormClosed -= m_viewsForm_FormClosed; _viewsForm.Activated -= m_viewsForm_Activated; if (View != null) { DockView(); } _viewsForm.Dispose(); _viewsForm = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Moves the view's control from its form to the tab. /// </summary> /// ------------------------------------------------------------------------------------ public void UnDockView() { if (s_undockingInProgress || !_viewDocked) { return; } App.MsgMediator.SendMessage("BeginViewUnDocking", View); _undockingInProgress = true; s_undockingInProgress = true; if (OwningTabGroup.Controls.Contains(View)) { OwningTabGroup.Controls.Remove(View); } // Prepare the undocked view's form to host the view and be displayed. _viewsForm = new UndockedViewWnd(View); _viewsForm.FormClosing += m_viewsForm_FormClosing; _viewsForm.FormClosed += m_viewsForm_FormClosed; _viewsForm.Activated += m_viewsForm_Activated; if (TabImage != null) { _viewsForm.Icon = Icon.FromHandle(((Bitmap)TabImage).GetHicon()); } // Strip out accelerator key prefixes but keep ampersands that should be kept. var prjName = ((ITabView)View).Project.Name; var caption = Utils.RemoveAcceleratorPrefix(Text); var fmt = LocalizationManager.GetString("Views.UndockedViewCaptionFormat", "{0} ({1}) - {2}", "Parameter one is the project name; parameter 2 is the view name; parameter 3 is the application name."); _viewsForm.Text = string.Format(fmt, prjName, caption, Application.ProductName); Visible = false; // Inform the tab group that one of it's views has been undocked. _ignoreTabSelection = true; OwningTabGroup.ViewWasUnDocked(this); _ignoreTabSelection = false; s_undockingInProgress = false; _viewDocked = false; _undockingInProgress = false; _viewsForm.Show(); _viewsForm.Activate(); App.MsgMediator.SendMessage("ViewUndocked", View); }