Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        public Control OpenView()
        {
            App.StatusBarLabel.Text = string.Empty;

            // Check if the view is already loaded.
            if (View != null)
            {
                if (_viewsForm != null)
                {
                    _viewsForm.Activate();
                }
                else if (View != null)
                {
                    View.Visible = true;
                }

                return(View);
            }

            View = _viewProvider();
            App.MsgMediator.SendMessage("BeginViewOpen", View);
            View.Dock = DockStyle.Fill;

            if (!(View is ITabView))
            {
                Utils.MsgBox(string.Format("Error: {0} is not based on ITabView!", View.GetType()));
            }

            try
            {
                if (View is IxCoreColleague)
                {
                    App.AddMediatorColleague(View as IxCoreColleague);
                }
            }
            catch { }

            DockView();
            App.MsgMediator.SendMessage("ViewOpened", View);
            return(View);
        }