Пример #1
0
        /// <summary>
        /// Shows a docking window for a given view.
        /// If is has been shown before, restore it position. Otherwise dock it to the right side.
        /// </summary>
        /// <param name="name">View to show.</param>
        /// <param name="dockingStyle">Docking style.</param>
        /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
        /// <returns></returns>
        public IDockableViewModel ShowWindow(string name, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle)
        {
            IDockableViewModel d         = null;
            string             accessKey = this.SelectedShellViewModel.FullFileName;

            if (this.viewLookup.ContainsKey(accessKey))
            {
                if (this.viewLookup[accessKey].ContainsKey(name))
                {
                    d = this.viewLookup[accessKey][name].View;
                }
            }

            if (this.viewLookup.ContainsKey(TransientPanesKey))
            {
                if (this.viewLookup[TransientPanesKey].ContainsKey(name))
                {
                    d = this.viewLookup[TransientPanesKey][name].View;
                }
            }

            if (d != null)
            {
                ShowWindow(d, dockingStyle, dockingAnchorStyle);
                return(d);
            }

            return(null);
        }
Пример #2
0
 /// <summary>
 /// Shows a docking window for a given view.
 /// If is has been shown before, restore its position. Otherwise dock it to the right side.
 /// </summary>
 /// <param name="view">View to dock.</param>
 /// <param name="dockingStyle">Docking style.</param>
 /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
 /// <param name="dockedInDocumentPane">True if this view should be shown in the document pane window. False otherwise.</param>
 public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle, bool dockedInDocumentPane)
 {
     this.ShowWindow(view, dockingStyle, dockingAnchorStyle, dockedInDocumentPane, this.SelectedShellViewModel.FullFileName);
 }
Пример #3
0
        /// <summary>
        /// Shows a docking window for a given view.
        /// If is has been shown before, restore its position. Otherwise dock it to the right side.
        /// </summary>
        /// <param name="view">View to dock.</param>
        /// <param name="dockingStyle">Docking style.</param>
        /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
        /// <param name="dockedInDocumentPane">True if this view should be shown in the document pane window. False otherwise.</param>
        /// <param name="fullFileName">File name.</param>
        public virtual void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle, bool dockedInDocumentPane, string fullFileName)
        {
            if (!view.IsInitialized)
            {
                view.InitializeVM();
            }

            string accessKey = fullFileName;

            if (this.IsTransientViewModel(view.GetType()))
            {
                accessKey = TransientPanesKey;
                if (viewLookup.ContainsKey(TransientPanesKey))
                {
                    if (viewLookup[TransientPanesKey].ContainsKey(view.DockingPaneName))
                    {
                        ModelToolWindowPane p = viewLookup[TransientPanesKey][view.DockingPaneName].Pane;
                        if (p != null)
                        {
                            if (((IVsWindowFrame)p.Frame).IsVisible() != VSConstants.S_OK)
                            {
                                return;
                            }
                        }
                    }
                }
            }
            if (!viewLookup.ContainsKey(accessKey))
            {
                viewLookup.Add(accessKey, new Dictionary <string, ViewLookUp>());
            }

            if (!viewLookup[accessKey].ContainsKey(view.DockingPaneName))
            {
                if (!dockedInDocumentPane)
                {
                    int key;
                    if (!this.viewTypeNameLookup.ContainsKey(view.DockingPaneType.FullName))
                    {
                        key = 0;
                    }
                    else
                    {
                        key = this.viewTypeNameLookup[view.DockingPaneType.FullName].Count;
                    }

                    ModelToolWindowPane window = this.package.FindToolWindow(this.package.GetToolWindowType(view.DockingPaneType), key, true) as ModelToolWindowPane;
                    if ((window == null) || (window.Frame == null))
                    {
                        throw new NotSupportedException("Can not show window!");
                    }
                    window.Content.DataContext = view;
                    window.Caption             = view.DockingPaneTitle;

                    // subscribe to events
                    window.PaneClosed += new EventHandler(Window_PaneClosed);

                    // get window frame
                    IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

                    // add lookup information
                    viewLookup[accessKey][view.DockingPaneName] = new ViewLookUp(view, window);
                    view.IsDockingPaneVisible = true;
                    paneViewLookup.Add(ModelPackage.GetPersistenceSlot(windowFrame), view.DockingPaneName);

                    if (!this.viewTypeNameLookup.ContainsKey(view.DockingPaneType.FullName))
                    {
                        this.viewTypeNameLookup[view.DockingPaneType.FullName] = new List <string>();
                    }
                    this.viewTypeNameLookup[view.DockingPaneType.FullName].Add(view.DockingPaneName);

                    // show window
                    windowFrame.Show();
                }
                else
                {
                    viewLookup[accessKey][view.DockingPaneName] = new ViewLookUp(view);

                    if (accessKey != TransientPanesKey)
                    {
                        this.packageController.AvailableShellVMsReversed[accessKey].VisibleDocumentPanes.Add(view);
                        if (this.packageController.AvailableShellVMsReversed[accessKey].SelectedDocumentPane == null)
                        {
                            this.packageController.AvailableShellVMsReversed[accessKey].SelectedDocumentPane = view;
                        }
                    }
                    else
                    {
                        this.SelectedShellViewModel.VisibleDocumentPanes.Add(view);
                        if (this.SelectedShellViewModel.SelectedDocumentPane == null)
                        {
                            this.SelectedShellViewModel.SelectedDocumentPane = view;
                        }
                    }
                    view.IsDockingPaneVisible = true;
                }
            }

            // show docking window
            if (!dockedInDocumentPane)
            {
                if (viewLookup[accessKey][view.DockingPaneName].Pane != null)
                {
                    if (((IVsWindowFrame)viewLookup[accessKey][view.DockingPaneName].Pane.Frame).IsVisible() != VSConstants.S_OK)
                    {
                        ((IVsWindowFrame)viewLookup[accessKey][view.DockingPaneName].Pane.Frame).Show();
                        viewLookup[accessKey][view.DockingPaneName].View.IsDockingPaneVisible = true;
                    }
                }
            }
            else
            {
                if (this.SelectedShellViewModel.HiddenDocumentPanes.Contains(view))
                {
                    this.SelectedShellViewModel.HiddenDocumentPanes.Remove(view);
                    this.SelectedShellViewModel.VisibleDocumentPanes.Add(view);

                    if (this.SelectedShellViewModel.SelectedDocumentPane == null)
                    {
                        this.SelectedShellViewModel.SelectedDocumentPane = view;
                    }
                }
                view.IsDockingPaneVisible = true;
            }

            if (this.IsTransientViewModel(view.GetType()))
            {
                // update all IsDockingPaneVisible
                foreach (ShellMainViewModel v in this.packageController.AvailableShellVMs.Keys)
                {
                    BaseDockingViewModel foundVm = v.FindViewModel(view.GetType());
                    foundVm.IsDockingPaneVisible = true;
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Shows a docking window for a given view.
 /// If is has been shown before, restore it position. Otherwise dock it to the right side.
 /// </summary>
 /// <param name="view">View to dock.</param>
 /// <param name="dockingSyle">Docking style.</param>
 public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingSyle)
 {
     ShowWindow(view, dockingSyle, DockingPaneAnchorStyle.None);
 }
Пример #5
0
 /// <summary>
 /// Shows a docking window for a given view.
 /// If is has been shown before, restore it position. Otherwise dock it to the right side.
 /// </summary>
 /// <param name="view">View to dock.</param>
 /// <param name="dockingStyle">Docking style.</param>
 /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
 /// <param name="fullFileName">File name.</param>
 public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle, string fullFileName)
 {
     this.ShowWindow(view, dockingStyle, dockingAnchorStyle, view.DockingPaneStyle == DockingPaneStyle.DockedInDocumentPane, fullFileName);
 }
        /// <summary>
        /// Shows a docking window for a given view.  
        /// If is has been shown before, restore its position. Otherwise dock it to the right side.
        /// </summary>
        /// <param name="view">View to dock.</param>
        /// <param name="dockingStyle">Docking style.</param>
        /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
        /// <param name="dockedInDocumentPane">True if this view should be shown in the document pane window. False otherwise.</param>
        /// <param name="fullFileName">File name.</param>
        public virtual void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle, bool dockedInDocumentPane, string fullFileName)
        {
            if (!view.IsInitialized)
                view.InitializeVM();

            string accessKey = fullFileName;
            if (this.IsTransientViewModel(view.GetType()))
            {
                accessKey = TransientPanesKey;
                if( viewLookup.ContainsKey(TransientPanesKey) )
                    if (viewLookup[TransientPanesKey].ContainsKey(view.DockingPaneName))
                    {
                        ModelToolWindowPane p = viewLookup[TransientPanesKey][view.DockingPaneName].Pane;
                        if (p != null)
                        {
                            if (((IVsWindowFrame)p.Frame).IsVisible() != VSConstants.S_OK)
                                return;
                        }
                    }
            }
            if (!viewLookup.ContainsKey(accessKey))
                viewLookup.Add(accessKey, new Dictionary<string, ViewLookUp>());

            if (!viewLookup[accessKey].ContainsKey(view.DockingPaneName))
            {
                if (!dockedInDocumentPane)
                {
                    int key;
                    if (!this.viewTypeNameLookup.ContainsKey(view.DockingPaneType.FullName))
                        key = 0;
                    else
                        key = this.viewTypeNameLookup[view.DockingPaneType.FullName].Count;

                    ModelToolWindowPane window = this.package.FindToolWindow(this.package.GetToolWindowType(view.DockingPaneType), key, true) as ModelToolWindowPane;
                    if ((window == null) || (window.Frame == null))
                    {
                        throw new NotSupportedException("Can not show window!");
                    }
                    window.Content.DataContext = view;
                    window.Caption = view.DockingPaneTitle;

                    // subscribe to events
                    window.PaneClosed += new EventHandler(Window_PaneClosed);

                    // get window frame
                    IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

                    // add lookup information
                    viewLookup[accessKey][view.DockingPaneName] = new ViewLookUp(view, window);
                    view.IsDockingPaneVisible = true;
                    paneViewLookup.Add(ModelPackage.GetPersistenceSlot(windowFrame), view.DockingPaneName);

                    if (!this.viewTypeNameLookup.ContainsKey(view.DockingPaneType.FullName))
                        this.viewTypeNameLookup[view.DockingPaneType.FullName] = new List<string>();
                    this.viewTypeNameLookup[view.DockingPaneType.FullName].Add(view.DockingPaneName);

                    // show window
                    windowFrame.Show();

                }
                else
                {
                    viewLookup[accessKey][view.DockingPaneName] = new ViewLookUp(view);

                    if (accessKey != TransientPanesKey)
                    {
                        this.packageController.AvailableShellVMsReversed[accessKey].VisibleDocumentPanes.Add(view);
                        if (this.packageController.AvailableShellVMsReversed[accessKey].SelectedDocumentPane == null)
                            this.packageController.AvailableShellVMsReversed[accessKey].SelectedDocumentPane = view;
                    }
                    else
                    {
                        this.SelectedShellViewModel.VisibleDocumentPanes.Add(view);
                        if (this.SelectedShellViewModel.SelectedDocumentPane == null)
                            this.SelectedShellViewModel.SelectedDocumentPane = view;
                    }
                    view.IsDockingPaneVisible = true;                    
                }
            }

            // show docking window
            if (!dockedInDocumentPane)
            {
                if (viewLookup[accessKey][view.DockingPaneName].Pane != null)
                    if (((IVsWindowFrame)viewLookup[accessKey][view.DockingPaneName].Pane.Frame).IsVisible() != VSConstants.S_OK)
                    {
                        ((IVsWindowFrame)viewLookup[accessKey][view.DockingPaneName].Pane.Frame).Show();
                        viewLookup[accessKey][view.DockingPaneName].View.IsDockingPaneVisible = true;
                    }
            }
            else
            {
                if (this.SelectedShellViewModel.HiddenDocumentPanes.Contains(view))
                {
                    this.SelectedShellViewModel.HiddenDocumentPanes.Remove(view);
                    this.SelectedShellViewModel.VisibleDocumentPanes.Add(view);

                    if (this.SelectedShellViewModel.SelectedDocumentPane == null)
                        this.SelectedShellViewModel.SelectedDocumentPane = view;
                }
                view.IsDockingPaneVisible = true;
            }

            if (this.IsTransientViewModel(view.GetType()))
            {
                // update all IsDockingPaneVisible
                foreach (ShellMainViewModel v in this.packageController.AvailableShellVMs.Keys)
                {
                    BaseDockingViewModel foundVm = v.FindViewModel(view.GetType());
                    foundVm.IsDockingPaneVisible = true;
                }
            }
        }
        /// <summary>
        /// Shows a docking window for a given view.  
        /// If is has been shown before, restore it position. Otherwise dock it to the right side.
        /// </summary>
        /// <param name="name">View to show.</param>
        /// <param name="dockingStyle">Docking style.</param>
        /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
        /// <returns></returns>
        public IDockableViewModel ShowWindow(string name, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle)
        {
            IDockableViewModel d = null;
            string accessKey = this.SelectedShellViewModel.FullFileName;
            if (this.viewLookup.ContainsKey(accessKey))
                if (this.viewLookup[accessKey].ContainsKey(name))
                {
                    d = this.viewLookup[accessKey][name].View;
                }

            if (this.viewLookup.ContainsKey(TransientPanesKey))
                if (this.viewLookup[TransientPanesKey].ContainsKey(name))
                {
                    d = this.viewLookup[TransientPanesKey][name].View;
                }

            if (d != null)
            {
                ShowWindow(d, dockingStyle, dockingAnchorStyle);
                return d;
            }

            return null;
        }
 /// <summary>
 /// Shows a docking window for a given view.  
 /// If is has been shown before, restore its position. Otherwise dock it to the right side.
 /// </summary>
 /// <param name="view">View to dock.</param>
 /// <param name="dockingStyle">Docking style.</param>
 /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
 /// <param name="dockedInDocumentPane">True if this view should be shown in the document pane window. False otherwise.</param>
 public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle, bool dockedInDocumentPane)
 {
     this.ShowWindow(view, dockingStyle, dockingAnchorStyle, dockedInDocumentPane, this.SelectedShellViewModel.FullFileName);
 }
 /// <summary>
 /// Shows a docking window for a given view.  
 /// If is has been shown before, restore it position. Otherwise dock it to the right side.
 /// </summary>
 /// <param name="view">View to dock.</param>
 /// <param name="dockingStyle">Docking style.</param>
 /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
 /// <param name="fullFileName">File name.</param>
 public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle, string fullFileName)
 {
     this.ShowWindow(view, dockingStyle, dockingAnchorStyle, view.DockingPaneStyle == DockingPaneStyle.DockedInDocumentPane, fullFileName);
 }
 /// <summary>
 /// Shows a docking window for a given view.  
 /// If is has been shown before, restore it position. Otherwise dock it to the right side.
 /// </summary>
 /// <param name="view">View to dock.</param>
 /// <param name="dockingSyle">Docking style.</param>
 public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingSyle)
 {
     ShowWindow(view, dockingSyle, DockingPaneAnchorStyle.None);
 }
        /// <summary>
        /// Shows a docking window for a given view.  
        /// If is has been shown before, restore it position. Otherwise dock it to the right side.
        /// </summary>
        /// <param name="name">View to show.</param>
        /// <param name="dockingStyle">Docking style.</param>
        /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
        /// <returns></returns>
        public IDockableViewModel ShowWindow(string name, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle)
        {
            if (viewLookup.ContainsKey(name))
            {
                IDockableViewModel d = viewLookup[name].View;

                ShowWindow(d, dockingStyle, dockingAnchorStyle);
                return d;
            }

            return null;

            /*
            foreach(IDockableViewModel d in viewLookup.Keys)
                if (d.DockingPaneName == name)
                {
                    ShowWindow(d, dockingStyle, dockingAnchorStyle);
                    return d;
                }

            return null;
            */
        }
        /// <summary>
        /// Shows a docking window for a given view.  
        /// If is has been shown before, restore it position. Otherwise dock it to the right side.
        /// </summary>
        /// <param name="view">View to dock.</param>
        /// <param name="dockingStyle">Docking style.</param>
        /// <param name="dockingAnchorStyle">Docking anchor style. Only usefull for DockingPaneStyle.Docked.</param>
        public void ShowWindow(IDockableViewModel view, DockingPaneStyle dockingStyle, DockingPaneAnchorStyle dockingAnchorStyle)
        {
            // init resource dictionaries for plugin hosters
            if (view is IPluginHosterViewModel)
            {
                IPluginHosterViewModel pHost = (IPluginHosterViewModel)view;
                if (pHost.IsVMPlugin)
                {
                    if (!pHost.VMPluginDictionaryInitialized)
                        try
                        {
                            if (pHost.VMPlugin.GetViewModelRessourceDictionary() != null)
                                if (System.Windows.Application.Current != null)
                                {
                                    System.Windows.Application.Current.Resources.BeginInit();
                                    System.Windows.Application.Current.Resources.MergedDictionaries.Add(pHost.VMPlugin.GetViewModelRessourceDictionary());
                                    System.Windows.Application.Current.Resources.EndInit();
                                }
                            pHost.VMPluginDictionaryInitialized = true;
                        }
                        catch
                        {
                            pHost.VMPluginDictionaryInitialized = false;
                        }
                }
            }
            if (!this.isRestoringLayout)
            {
                if (!view.IsInitialized)
                    view.InitializeVM();

                if (view is IRibbonDockableViewModel && this.Ribbon != null)
                    if (!((IRibbonDockableViewModel)view).IsRibbonMenuInitialized)
                    {
                        ((IRibbonDockableViewModel)view).CreateRibbonMenu(this.Ribbon);
                    }
            }

            if (!viewLookup.ContainsKey(view.DockingPaneName))
            {
                DockableContent content = new DockableContent();
                content.Name = view.DockingPaneName;
                content.Title = view.DockingPaneTitle;
                content.Content = view;
                content.StateChanged += new System.Windows.RoutedEventHandler(content_StateChanged);
                if (view.ActivationMode == ActivationMode.Normal)
                    content.IsActiveContentChanged += new EventHandler(content_IsActiveContentChanged);
                content.ContextChangeKind = ConvertToContextChangeKind(view.DockingContextChangeKind);

                viewLookup.Add(view.DockingPaneName, new ViewLookUp(view, content));
                
                if (this.isRestoringLayout)
                {
                    this.MainDockingManager.AddPaneForLayoutRestore(content);
                }
                else
                {
                    if (dockingStyle == DockingPaneStyle.Floating)
                    {
                        content.FloatingWindowSize = new Size(view.FloatingWindowDesiredWidth, view.FloatingWindowDesiredHeight);
                        content.ShowAsFloatingWindow(this.MainDockingManager, true);
                    }
                    else if (dockingStyle == DockingPaneStyle.DockedInDocumentPane)
                        content.ShowAsDocument(this.MainDockingManager);
                    else
                    {
                        if (view.DockedWindowDesiredWidth > 0)
                            content.DesiredWidth = view.DockedWindowDesiredWidth;
                        if (view.DockedWindowDesiredHeight > 0)
                            content.DesiredHeight = view.DockedWindowDesiredHeight;

                        AnchorStyle style = ConvertToAnchorStyle(dockingAnchorStyle);
                        if (style != AnchorStyle.None)
                        {
                            content.Show(this.MainDockingManager, style);
                        }
                        else
                            content.Show(this.MainDockingManager);
                    }
                }
            }

            // show docking window
            if (!this.isRestoringLayout)
            if (!viewLookup[view.DockingPaneName].Pane.IsVisible)
            {
                if (dockingStyle == DockingPaneStyle.Floating)
                {
                    viewLookup[view.DockingPaneName].Pane.FloatingWindowSize = new Size(view.FloatingWindowDesiredWidth, view.FloatingWindowDesiredHeight);
                    viewLookup[view.DockingPaneName].Pane.ShowAsFloatingWindow(this.MainDockingManager, true);
                }
                else if (dockingStyle == DockingPaneStyle.DockedInDocumentPane)
                    viewLookup[view.DockingPaneName].Pane.ShowAsDocument(this.MainDockingManager);
                else
                    viewLookup[view.DockingPaneName].Pane.Show(this.MainDockingManager);

                view.IsDockingPaneVisible = true;
            }
        }