Пример #1
0
        private void CompactPromoteLeafs(CompactFlags flags)
        {
            if ((flags & CompactFlags.PromoteLeafs) == CompactFlags.PromoteLeafs)
            {
                // Search for child sequence items
                for (int i = Children.Count - 1; i >= 0; i--)
                {
                    // If a sequence and that sequence has just a single child
                    KryptonWorkspaceSequence sequence = Children[i] as KryptonWorkspaceSequence;
                    if ((sequence != null) && (sequence.Children.Count == 1))
                    {
                        // Extract the leaf
                        Component leaf = sequence.Children[0];
                        sequence.Children.RemoveAt(0);

                        // Use the sequence size in the promoted child so the display remains constant
                        if (leaf is KryptonWorkspaceCell)
                        {
                            ((KryptonWorkspaceCell)leaf).StarSize = sequence.StarSize;
                        }

                        if (leaf is KryptonWorkspaceSequence)
                        {
                            ((KryptonWorkspaceSequence)leaf).StarSize = sequence.StarSize;
                        }

                        // Replace the sequence with its leaf child
                        Children.RemoveAt(i);
                        Children.Insert(i, leaf);
                    }
                }
            }
        }
Пример #2
0
		public void Compact(CompactFlags flags) {
			// When  entries are removed because of compacting this may cause the container object 
			// to start a compacting request. Prevent this recursion by using a simple varible.
			if (!_compacting) {
				// We never compact when loading/initializing the contents
				if (!_initializing) {
					_compacting = true;
					_root.Compact(flags);
					_compacting = false;
                    
					EnforceAtLeastOneLeaf();
				}
			}
		}
 private void CompactRemoveEmptySequences(CompactFlags flags)
 {
     if ((flags & CompactFlags.RemoveEmptySequences) == CompactFlags.RemoveEmptySequences)
     {
         // Search for child sequence items
         for (int i = Children.Count - 1; i >= 0; i--)
         {
             // If a sequence and that sequence does not have any children
             if ((Children[i] is KryptonWorkspaceSequence sequence) && (sequence.Children.Count == 0))
             {
                 Children.RemoveAt(i);
             }
         }
     }
 }
        /// <summary>
        /// Perform any compacting actions allowed by the flags.
        /// </summary>
        /// <param name="flags">Set of compacting actions allowed.</param>
        public void Compact(CompactFlags flags)
        {
            if (!DesignMode)
            {
                // Compact each child
                foreach (Component component in Children)
                {
                    if (component is IWorkspaceItem item)
                    {
                        item.Compact(flags);
                    }
                }

                CompactRemoveEmptyCells(flags);
                CompactRemoveEmptySequences(flags);
                CompactPromoteLeafs(flags);
            }
        }
        private void CompactRemoveEmptyCells(CompactFlags flags)
        {
            if ((flags & CompactFlags.RemoveEmptyCells) == CompactFlags.RemoveEmptyCells)
            {
                // Search for child cell items
                for (int i = Children.Count - 1; i >= 0; i--)
                {
                    // If a cell and that cell does not have any pages
                    if ((Children[i] is KryptonWorkspaceCell cell) && (cell.Pages.Count == 0))
                    {
                        Children.RemoveAt(i);

                        // If the cell is not inside a controls collection then we need to dispose of it here
                        // because the layout code will never try and dispose on remove from controls collection
                        // as it is not inside the controls collection
                        if ((cell.Parent == null) && (cell.DisposeOnRemove))
                        {
                            cell.Dispose();
                        }
                    }
                }
            }
        }
Пример #6
0
 public void Compact(CompactFlags flags)
 {
     // When  entries are removed because of compacting this may cause the container object 
     // to start a compacting request. Prevent this recursion by using a simple varible.
     if (!_compacting)
     {
         // We never compact when loading/initializing the contents
         if (!_initializing)
         {
             _compacting = true;
             _root.Compact(flags);
             _compacting = false;
             
             EnforceAtLeastOneLeaf();
         }
     }
 }
Пример #7
0
 public void ResetCompactOptions()
 {
     CompactOptions = CompactFlags.All;
 }
Пример #8
0
 /// <summary>
 /// Perform any compacting actions allowed by the flags.
 /// </summary>
 /// <param name="flags">Set of compacting actions allowed.</param>
 public void Compact(CompactFlags flags)
 {
     if (!DesignMode)
     {
     }
 }
Пример #9
0
		public void ResetCompactOptions() {
			CompactOptions = CompactFlags.All;
		}
 private void CompactRemoveEmptySequences(CompactFlags flags)
 {
     if ((flags & CompactFlags.RemoveEmptySequences) == CompactFlags.RemoveEmptySequences)
     {
         // Search for child sequence items
         for (int i = Children.Count - 1; i >= 0; i--)
         {
             // If a sequence and that sequence does not have any children
             KryptonWorkspaceSequence sequence = Children[i] as KryptonWorkspaceSequence;
             if ((sequence != null) && (sequence.Children.Count == 0))
                 Children.RemoveAt(i);
         }
     }
 }
        private void CompactRemoveEmptyCells(CompactFlags flags)
        {
            if ((flags & CompactFlags.RemoveEmptyCells) == CompactFlags.RemoveEmptyCells)
            {
                // Search for child cell items
                for (int i = Children.Count - 1; i >= 0; i--)
                {
                    // If a cell and that cell does not have any pages
                    KryptonWorkspaceCell cell = Children[i] as KryptonWorkspaceCell;
                    if ((cell != null) && (cell.Pages.Count == 0))
                    {
                        Children.RemoveAt(i);

                        // If the cell is not inside a controls collection then we need to dispose of it here
                        // because the layout code will never try and dispose on remove from controls collection
                        // as it is not inside the controls collection
                        if ((cell.Parent == null) && (cell.DisposeOnRemove))
                            cell.Dispose();
                    }
                }
            }
        }
        private void CompactPromoteLeafs(CompactFlags flags)
        {
            if ((flags & CompactFlags.PromoteLeafs) == CompactFlags.PromoteLeafs)
            {
                // Search for child sequence items
                for (int i = Children.Count - 1; i >= 0; i--)
                {
                    // If a sequence and that sequence has just a single child
                    KryptonWorkspaceSequence sequence = Children[i] as KryptonWorkspaceSequence;
                    if ((sequence != null) && (sequence.Children.Count == 1))
                    {
                        // Extract the leaf
                        Component leaf = sequence.Children[0];
                        sequence.Children.RemoveAt(0);

                        // Use the sequence size in the promoted child so the display remains constant
                        if (leaf is KryptonWorkspaceCell)
                            ((KryptonWorkspaceCell)leaf).StarSize = sequence.StarSize;

                        if (leaf is KryptonWorkspaceSequence)
                            ((KryptonWorkspaceSequence)leaf).StarSize = sequence.StarSize;

                        // Replace the sequence with its leaf child
                        Children.RemoveAt(i);
                        Children.Insert(i, leaf);
                    }
                }
            }
        }
        /// <summary>
        /// Perform any compacting actions allowed by the flags.
        /// </summary>
        /// <param name="flags">Set of compacting actions allowed.</param>
        public void Compact(CompactFlags flags)
        {
            if (!DesignMode)
            {
                // Compact each child
                foreach (Component component in Children)
                {
                    IWorkspaceItem item = component as IWorkspaceItem;
                    if (item != null)
                        item.Compact(flags);
                }

                CompactRemoveEmptyCells(flags);
                CompactRemoveEmptySequences(flags);
                CompactPromoteLeafs(flags);
            }
        }