Example #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Occurs when a docking window's default location is requested.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The <c>DockingWindowDefaultLocationEventArgs</c> that contains data related to this event.</param>
        private void OnDockSiteWindowDefaultLocationRequested(object sender, DockingWindowDefaultLocationEventArgs e)
        {
            if (e.Window.SerializationId == "bottomLeft1")
            {
                if (e.State == DockingWindowState.Docked)
                {
                    // Dock in hierarchy under the left tool window
                    var targetToolWindow = dockSite.ToolWindows.FirstOrDefault(tw => tw.SerializationId == "left1");
                    if ((targetToolWindow != null) && (targetToolWindow.IsOpen))
                    {
                        e.Target = targetToolWindow;
                        e.Side   = Side.Bottom;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Occurs when a docking window's default location is requested.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The <c>DockingWindowDefaultLocationEventArgs</c> that contains data related to this event.</param>
        private void OnDockSiteWindowDefaultLocationRequested(object sender, DockingWindowDefaultLocationEventArgs e)
        {
            if (!this.IsDockingWindowAValidContainer(e))
            {
                return;
            }

            // Get the region
            var region = this.Region;

            if (region == null)
            {
                return;
            }

            var viewModel = e.Window.DataContext as ToolItemViewModel;

            if (viewModel != null)
            {
                // Get the dock state
                var dockState = (ToolItemState) new ToolItemStateConverter().Convert(e.State, typeof(ToolItemState), null, null);

                // Query the tool view-model for default locations relative to other tool view-models
                var defaultLocations = viewModel.GetDefaultLocations(dockState);
                if (defaultLocations != null)
                {
                    foreach (var defaultLocation in defaultLocations)
                    {
                        if ((defaultLocation != null) && (!string.IsNullOrEmpty(defaultLocation.TargetSerializationId)))
                        {
                            var targetViewModel = region.Views.OfType <ToolItemViewModel>().FirstOrDefault(vm => vm.SerializationId == defaultLocation.TargetSerializationId);
                            if ((targetViewModel != null) && (targetViewModel.IsOpen))
                            {
                                // Another open tool view-model was located
                                var targetWindow = dockSite.ContainerFromItem(targetViewModel);
                                if (targetWindow != null)
                                {
                                    e.Target = targetWindow;
                                    e.Side   = (Side) new ToolItemDockSideConverter().ConvertBack(defaultLocation.DockSide, typeof(Side), null, null);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }