コード例 #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets the first <see cref="ToolWindow"/> associated with the specified dock group.
        /// </summary>
        /// <param name="dockSite">The dock site to search.</param>
        /// <param name="dockGroup">The dock group.</param>
        /// <returns>
        /// A <see cref="ToolWindow"/>; otherwise, <see langword="null"/>.
        /// </returns>
        private static ToolWindow GetToolWindow(DockSite dockSite, string dockGroup)
        {
            if (dockSite != null && !string.IsNullOrEmpty(dockGroup))
            {
                foreach (ToolWindow toolWindow in dockSite.ToolWindows)
                {
                    ToolItemViewModel toolItemViewModel = toolWindow.DataContext as ToolItemViewModel;
                    if (toolItemViewModel != null && toolItemViewModel.DockGroup == dockGroup)
                    {
                        return(toolWindow);
                    }
                }
            }

            return(null);
        }
コード例 #2
0
 /// <summary>
 /// Opens the specified docking window.
 /// </summary>
 /// <param name="dockSite">The dock site that owns the docking window.</param>
 /// <param name="dockingWindow">The docking window to open.</param>
 private static void OpenDockingWindow(DockSite dockSite, DockingWindow dockingWindow)
 {
     if (!dockingWindow.IsOpen)
     {
         if (dockingWindow is DocumentWindow)
         {
             dockingWindow.Open();
         }
         else
         {
             ToolWindow        toolWindow        = dockingWindow as ToolWindow;
             ToolItemViewModel toolItemViewModel = dockingWindow.DataContext as ToolItemViewModel;
             if (toolWindow != null && toolItemViewModel != null)
             {
                 // Look for a ToolWindow within the same group, if found then dock to that group, otherwise either dock or auto-hide the window
                 ToolWindow targetToolWindow = GetToolWindow(dockSite, toolItemViewModel.DockGroup);
                 if (targetToolWindow != null && !Equals(targetToolWindow, toolWindow))
                 {
                     toolWindow.Dock(targetToolWindow, Direction.Content);
                 }
                 else if (toolItemViewModel.IsInitiallyHidden)
                 {
                     toolWindow.AutoHide(toolItemViewModel.DefaultDock);
                 }
                 else
                 {
                     toolWindow.Dock(dockSite, toolItemViewModel.DefaultDock);
                 }
             }
             else
             {
                 dockingWindow.Open();
             }
         }
     }
 }