Ejemplo n.º 1
0
        /// <summary>
        /// Occurs when the <c>Layout.EvenlyDistributeFavorFocused</c> menu item is clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnLayoutEvenlyDistributeFavorFocusedMenuItemClick(object sender, RoutedEventArgs e)
        {
            var descendents = VisualTreeHelperExtended.GetAllDescendants <SplitContainer>(dockSite);

            if (descendents != null)
            {
                foreach (var splitContainer in descendents)
                {
                    // Look for SplitContainers that contain the focused element, and increase the ratios for that slot
                    var visualCount   = splitContainer.Children.Count;
                    var desiredRatios = new double[visualCount];
                    for (int i = 0, visibleChildCount = 0; i < visualCount; i++)
                    {
                        // Default ratio, must also ensure that we don't pass a ratio that is less than or equal to 0
                        desiredRatios[i] = 1;

                        // Get the child and verify that it is visible
                        var child = splitContainer.Children[i] as FrameworkElement;
                        if ((child != null) && (child.Visibility == Visibility.Visible))
                        {
                            // If the child has the keyboard focus, then increase it's ratio
                            if (child.IsKeyboardFocusWithin)
                            {
                                desiredRatios[visibleChildCount] = 3;
                            }
                            visibleChildCount++;
                        }
                    }

                    splitContainer.ResizeSlots(desiredRatios);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the selected <see cref="DataGridColumnHeader"/>.
        /// </summary>
        /// <param name="datagrid">The datagrid.</param>
        private static void UpdateSelectedHeaders(DataGridControl datagrid)
        {
            if (null == datagrid)
            {
                return;
            }

            // Get the list of headers
            IList <DependencyObject> headers = VisualTreeHelperExtended.GetAllDescendants(datagrid, typeof(DataGridColumnHeader));

            if (null == headers || 0 == headers.Count)
            {
                return;
            }

            // Update the selection based on the current tracking modes
            SelectionTrackingModes trackingModes = GetTrackingModes(datagrid);

            if (0 != (trackingModes & SelectionTrackingModes.Headers))
            {
                // Update header selections, if any
                foreach (DataGridColumnHeader header in headers)
                {
                    // Determine if the column associated with this header has any selected cells
                    bool isSelected = false;
                    foreach (DataGridCellInfo cellInfo in datagrid.SelectedCells)
                    {
                        if (cellInfo.Column == header.Column)
                        {
                            isSelected = true;
                            break;
                        }
                    }

                    // Update the selection for this header
                    if (isSelected != GetIsSelectedHeader(header))
                    {
                        if (isSelected)
                        {
                            header.SetValue(IsSelectedHeaderPropertyKey, true);
                        }
                        else
                        {
                            header.ClearValue(IsSelectedHeaderPropertyKey);
                        }
                    }
                }
            }
            else
            {
                // Clear header selections, if any
                foreach (DataGridColumnHeader header in headers)
                {
                    if (GetIsSelectedHeader(header))
                    {
                        header.ClearValue(IsSelectedHeaderPropertyKey);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the focused <see cref="DataGridColumnHeader"/>.
        /// </summary>
        private static void UpdateFocusedHeader(DataGridControl datagrid)
        {
            if (null == datagrid)
            {
                return;
            }

            // Get the list of headers
            IList <DependencyObject> headers = VisualTreeHelperExtended.GetAllDescendants(datagrid, typeof(DataGridColumnHeader));

            if (null == headers || 0 == headers.Count)
            {
                return;
            }

            // Update the focus based on the current tracking Modes
            FocusTrackingModes trackingModes = GetTrackingModes(datagrid);

            if (0 != (trackingModes & FocusTrackingModes.Headers))
            {
                // Get the focused cell, if any, and look for an ancestor cell when editing cell
                DataGridCell cell = Keyboard.FocusedElement as DataGridCell;
                if (cell == null)
                {
                    cell = VisualTreeHelperExtended.GetAncestor(Keyboard.FocusedElement as FrameworkElement, typeof(DataGridCell)) as DataGridCell;
                }

                // Update header focus, if any
                foreach (DataGridColumnHeader header in headers)
                {
                    // Determine if the column associated with this header if focused
                    bool isFocused = (null != cell && cell.Column == header.Column);

                    // Update the focus for this header
                    if (isFocused != GetIsFocusedHeader(header))
                    {
                        if (isFocused)
                        {
                            header.SetValue(IsFocusedHeaderPropertyKey, true);
                        }
                        else
                        {
                            header.ClearValue(IsFocusedHeaderPropertyKey);
                        }
                    }
                }
            }
            else
            {
                // Clear header focus, if any
                foreach (DataGridColumnHeader header in headers)
                {
                    if (GetIsFocusedHeader(header))
                    {
                        header.ClearValue(IsFocusedHeaderPropertyKey);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static DockSite FindDock()
        { //  Modified to use Actipro's helper methods, since I need to be bound to Actipro for
          //  the DockSite I might as well use their helper methods :)
          //  TODO: Fix This
            var rootVisual = VisualTreeHelperExtended.GetRoot(Application.Current.MainWindow);

            return(VisualTreeHelperExtended.GetAllDescendants(rootVisual, typeof(DockSite)).FirstOrDefault() as DockSite);
        }
Ejemplo n.º 5
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Occurs when the <c>Layout.EvenlyDistribute</c> menu item is clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnLayoutEvenlyDistributeMenuItemClick(object sender, RoutedEventArgs e)
        {
            var descendents = VisualTreeHelperExtended.GetAllDescendants <SplitContainer>(dockSite);

            if (descendents != null)
            {
                foreach (var splitContainer in descendents)
                {
                    splitContainer.ResizeSlots();
                }
            }
        }
Ejemplo n.º 6
0
        public void Show(object rootModel)
        {
            var dockingWindow = CreateDockingWindow(rootModel, _dockSite);

            //dockingWindow.Open();
            dockingWindow.Activate();

            if (dockingWindow is ToolWindow)
            {
                var descendents = VisualTreeHelperExtended.GetAllDescendants(_dockSite, typeof(SplitContainer));
                foreach (SplitContainer splitContainer in descendents)
                {
                    splitContainer.ResizeSlots(2.1, 7.9);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Occurs when the <c>Layout.EvenlyDistributeDocumentsOnly</c> menu item is clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnLayoutEvenlyDistributeDocumentsOnlyMenuItemClick(object sender, RoutedEventArgs e)
        {
            var workspace = dockSite.PrimaryDockHost.Workspace;

            if (workspace != null)
            {
                var descendents = VisualTreeHelperExtended.GetAllDescendants <SplitContainer>(workspace);
                if (descendents != null)
                {
                    foreach (var splitContainer in descendents)
                    {
                        splitContainer.ResizeSlots();
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Occurs when the <c>Layout.RandomlyDistribute</c> menu item is clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnLayoutRandomlyDistributeMenuItemClick(object sender, RoutedEventArgs e)
        {
            var descendents = VisualTreeHelperExtended.GetAllDescendants <SplitContainer>(dockSite);

            if (descendents != null)
            {
                var random = new Random();
                foreach (var splitContainer in descendents)
                {
                    splitContainer.ResizeSlots(
                        random.NextDouble() * 8 + 1,
                        random.NextDouble() * 6 + 1,
                        random.NextDouble() * 4 + 1,
                        random.NextDouble() * 2 + 1);
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Occurs when the <c>Layout.EvenlyDistributeToolsOnly</c> menu item is clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnLayoutEvenlyDistributeToolsOnlyMenuItemClick(object sender, RoutedEventArgs e)
        {
            var descendents = VisualTreeHelperExtended.GetAllDescendants <SplitContainer>(dockSite);

            if (descendents != null)
            {
                foreach (var splitContainer in descendents)
                {
                    if (VisualTreeHelperExtended.GetAncestor <Workspace>(splitContainer) != null)
                    {
                        continue;
                    }

                    splitContainer.ResizeSlots();
                }
            }
        }