/// <summary> /// Handles the <c>WindowUnregistered</c> event of the <c>DockSite</c> control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DockingWindowEventArgs"/> instance containing the event data.</param> private static void OnDockSiteWindowUnregistered(object sender, DockingWindowEventArgs e) { DockSite dockSite = sender as DockSite; if (dockSite == null) { return; } // Ensure the DockingWindow exists and is generated for an item DockingWindow dockingWindow = e.Window; if (dockingWindow == null || !dockingWindow.IsContainerForItem) { return; } // Need to remove the window from the list of windows that are waiting to be opened IList <DockingWindow> windowsPendingOpen = dockSite.GetValue(WindowsPendingOpenProperty) as IList <DockingWindow>; if (windowsPendingOpen != null) { int index = windowsPendingOpen.IndexOf(dockingWindow); if (index != -1) { windowsPendingOpen.RemoveAt(index); } } }
///////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Gets the value of the <see cref="IsManagedProperty"/> attached property for a specified <see cref="DockSite"/>. /// </summary> /// <param name="obj">The object to which the attached property is retrieved.</param> /// <returns> /// <c>true</c> if the specified <see cref="DockSite"/> is being managed; otherwise <c>false</c>. /// </returns> public static bool GetIsManaged(DockSite obj) { if (null == obj) { throw new ArgumentNullException("obj"); } return((bool)obj.GetValue(DockSiteViewModelBehavior.IsManagedProperty)); }
/// <summary> /// Handles the <c>WindowRegistered</c> event of the <c>DockSite</c> control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DockingWindowEventArgs"/> instance containing the event data.</param> private static void OnDockSiteWindowRegistered(object sender, DockingWindowEventArgs e) { DockSite dockSite = sender as DockSite; if (dockSite == null) { return; } // Ensure the DockingWindow exists and is generated for an item DockingWindow dockingWindow = e.Window; if (dockingWindow == null || !dockingWindow.IsContainerForItem) { return; } // Pass down the name, if any as this cannot be done via a Style if (string.IsNullOrEmpty(dockingWindow.Name)) { var viewModel = dockingWindow.DataContext as ToolItemViewModel; if (viewModel != null && !string.IsNullOrEmpty(viewModel.Name)) { dockingWindow.Name = viewModel.Name; } } // Open the DockingWindow, if it's not already open if (!dockingWindow.IsOpen) { if (!dockSite.IsLoaded) { // Need to delay the opening until after the DockSite is loaded because it's content will not be loaded IList <DockingWindow> windowsPendingOpen = dockSite.GetValue(WindowsPendingOpenProperty) as IList <DockingWindow>; if (windowsPendingOpen == null) { windowsPendingOpen = new List <DockingWindow>(); dockSite.SetValue(WindowsPendingOpenProperty, windowsPendingOpen); } windowsPendingOpen.Add(dockingWindow); } else { OpenDockingWindow(dockSite, dockingWindow); } } }
/// <summary> /// Handles the <c>Loaded</c> event of the <c>DockSite</c> control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private static void OnDockSiteLoaded(object sender, RoutedEventArgs e) { DockSite dockSite = sender as DockSite; if (dockSite == null) { return; } // Open any windows that were waiting for the DockSite to be loaded IList <DockingWindow> windowsPendingOpen = dockSite.GetValue(WindowsPendingOpenProperty) as IList <DockingWindow>; dockSite.ClearValue(WindowsPendingOpenProperty); if (windowsPendingOpen != null && windowsPendingOpen.Count != 0) { foreach (DockingWindow dockingWindow in windowsPendingOpen) { OpenDockingWindow(dockSite, dockingWindow); } } }
///////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Gets the value of the <see cref="IsManagedProperty"/> attached property for a specified <see cref="DockSite"/>. /// </summary> /// <param name="obj">The object to which the attached property is retrieved.</param> /// <returns> /// <c>true</c> if the specified <see cref="DockSite"/> is being managed; otherwise <c>false</c>. /// </returns> public static bool GetIsManaged(DockSite obj) { if (null == obj) throw new ArgumentNullException("obj"); return (bool)obj.GetValue(DockSiteViewModelBehavior.IsManagedProperty); }