Inheritance: System.ComponentModel.Component, IWorkspaceItem
Beispiel #1
0
        /// <summary>
        /// Request this sequence save its information about children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlWriter">Xml writer to save information into.</param>
        public void SaveToXml(KryptonWorkspace workspace, XmlWriter xmlWriter)
        {
            // Output standard values appropriate for all Sequence instances
            xmlWriter.WriteStartElement("WS");
            workspace.WriteSequenceElement(xmlWriter, this);

            // Persist each child sequence/cell in turn
            foreach (object child in Children)
            {
                KryptonWorkspaceSequence sequence = child as KryptonWorkspaceSequence;
                if (sequence != null)
                {
                    sequence.SaveToXml(workspace, xmlWriter);
                }

                KryptonWorkspaceCell cell = child as KryptonWorkspaceCell;
                if (cell != null)
                {
                    cell.SaveToXml(workspace, xmlWriter);
                }
            }

            // Terminate the workspace element
            xmlWriter.WriteEndElement();
        }
Beispiel #2
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);
                    }
                }
            }
        }
        /// <summary>
        /// Converts the given value object to the specified type, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An ITypeDescriptorContext that provides a format context.</param>
        /// <param name="culture">A CultureInfo. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed.</param>
        /// <param name="value">The Object to convert.</param>
        /// <param name="destinationType">The Type to convert the value parameter to.</param>
        /// <returns>An Object that represents the converted value.</returns>
        public override object ConvertTo(ITypeDescriptorContext context,
                                         System.Globalization.CultureInfo culture,
                                         object value,
                                         Type destinationType)
        {
            // Can always convert to a string representation
            if (destinationType == typeof(string))
            {
                KryptonWorkspaceSequence sequence = (KryptonWorkspaceSequence)value;
                return(sequence.ToString());
            }

            // Let base class attempt other conversions
            return(base.ConvertTo(context, culture, value, destinationType));
        }
        /// <summary>
        /// Occurs when the component is being removed from the designer.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">A ComponentEventArgs containing event data.</param>
        protected override void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our control is being removed
            if (e.Component == Navigator)
            {
                // If this workspace cell is inside a parent
                KryptonWorkspaceCell cell = (KryptonWorkspaceCell)Navigator;
                // Cell an only be inside a workspace sequence
                KryptonWorkspaceSequence sequence = (KryptonWorkspaceSequence)cell.WorkspaceParent;
                // Remove the cell from the parent
                sequence?.Children.Remove(cell);
            }

            base.OnComponentRemoving(sender, e);
        }
Beispiel #5
0
 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);
             }
         }
     }
 }
        /// <summary>
        /// Request this sequence load and recreate children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlReader">Xml reader for loading information.</param>
        /// <param name="existingPages">Dictionary on existing pages before load.</param>
        public void LoadFromXml(KryptonWorkspace workspace,
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the sequence details
            workspace.ReadSequenceElement(xmlReader, this);

            // If the sequence contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                    {
                        throw new ArgumentException("An element was expected but could not be read in.");
                    }

                    // Is this the end of the sequence
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    // Is it another sequence?
                    switch (xmlReader.Name)
                    {
                    case "WS":
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence();
                        sequence.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(sequence);
                        break;

                    case "WC":
                        KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                        cell.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(cell);
                        break;

                    default:
                        throw new ArgumentException("Unknown element was encountered.");
                    }
                }while (true);
            }
        }
        private void OnComponentRemoving(object sender, ComponentEventArgs e)
        {
            // If our sequence is being removed
            if (e.Component == _sequence)
            {
                // Need access to host in order to delete a component
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                // Climb the workspace item tree to get the top most sequence
                KryptonWorkspace workspace     = null;
                IWorkspaceItem   workspaceItem = _sequence;
                while (workspaceItem.WorkspaceParent != null)
                {
                    workspaceItem = workspaceItem.WorkspaceParent;
                }

                // Grab the workspace control that contains the top most sequence
                if ((workspaceItem != null) && (workspaceItem is KryptonWorkspaceSequence))
                {
                    KryptonWorkspaceSequence sequence = (KryptonWorkspaceSequence)workspaceItem;
                    workspace = sequence.WorkspaceControl;
                }

                // We need to remove all children from the sequence
                for (int j = _sequence.Children.Count - 1; j >= 0; j--)
                {
                    Component comp = _sequence.Children[j] as Component;

                    // If the component is a control...
                    if ((comp is Control) && (workspace != null))
                    {
                        // We need to manually remove it from the workspace controls collection
                        KryptonReadOnlyControls readOnlyControls = (KryptonReadOnlyControls)workspace.Controls;
                        readOnlyControls.RemoveInternal(comp as Control);
                    }

                    host.DestroyComponent(comp);

                    // Must remove the child after it has been destroyed otherwise the component destroy method
                    // will not be able to climb the sequence chain to find the parent workspace instance
                    _sequence.Children.Remove(comp);
                }
            }
        }
Beispiel #8
0
        public void DebugOutput(int indent)
        {
            Console.WriteLine("{0}Sequence Count:{1} Visible:{1}", new string(' ', indent * 2), Children.Count, Visible);

            foreach (object child in Children)
            {
                KryptonWorkspaceSequence sequence = child as KryptonWorkspaceSequence;
                if (sequence != null)
                {
                    sequence.DebugOutput(indent + 1);
                }

                KryptonWorkspaceCell cell = child as KryptonWorkspaceCell;
                if (cell != null)
                {
                    cell.DebugOutput(indent + 1);
                }
            }
        }
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate the designer with.</param>
        public override void Initialize(IComponent component)
        {
            Debug.Assert(component != null);

            // Validate the parameter reference
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            // Let base class do standard stuff
            base.Initialize(component);

            // Cast to correct type
            _sequence = (KryptonWorkspaceSequence)component;

            // Get access to the services
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed/changed
            _changeService.ComponentRemoving += OnComponentRemoving;
        }
Beispiel #10
0
        /// <summary>
        /// Perform the drop action associated with the target.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="data">Data to pass to the target to process drop.</param>
        /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns>
        public override bool PerformDrop(Point screenPt, PageDragEndData data)
        {
            // Transfer the dragged pages into a new cell
            KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
            KryptonPage          page = ProcessDragEndData(Workspace, cell, data);

            // If no pages are transferred then we do nothing and no longer need cell instance
            if (page == null)
            {
                cell.Dispose();
            }
            else
            {
                // If the root is not the same direction as that needed for the drop then...
                bool dropHorizontal = (Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Right);
                if ((dropHorizontal && (Workspace.Root.Orientation == Orientation.Vertical)) ||
                    (!dropHorizontal && (Workspace.Root.Orientation == Orientation.Horizontal)))
                {
                    // Create a new sequence and place all existing root items into it
                    KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(Workspace.Root.Orientation);
                    for (int i = Workspace.Root.Children.Count - 1; i >= 0; i--)
                    {
                        Component child = Workspace.Root.Children[i];
                        Workspace.Root.Children.RemoveAt(i);
                        sequence.Children.Insert(0, child);
                    }

                    // Put the new sequence in the root so all items are now grouped together
                    Workspace.Root.Children.Add(sequence);

                    // Switch the direction of the root
                    Workspace.Root.Orientation = Workspace.Root.Orientation == Orientation.Horizontal
                        ? Orientation.Vertical
                        : Orientation.Horizontal;
                }

                // Add to the start or the end of the root sequence?
                if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                {
                    Workspace.Root.Children.Insert(0, cell);
                }
                else
                {
                    Workspace.Root.Children.Add(cell);
                }

                // Make the last page transfer the newly selected page of the cell
                // Does the cell allow the selection of tabs?
                if (cell.AllowTabSelect)
                {
                    cell.SelectedPage = page;
                }

                // Need to layout so the new cell has been added as a child control and
                // therefore can receive the focus we want to give it immediately afterwards
                Workspace.PerformLayout();

                if (!cell.IsDisposed)
                {
                    // Without this DoEvents() call the dropping of multiple pages in a complex arrangement causes an exception for
                    // a complex reason that is hard to work out (i.e. I'm not entirely sure). Something to do with using select to
                    // change activation is causing the source workspace control to dispose to earlier.
                    Application.DoEvents();
                    cell.Select();
                }
            }

            return(true);
        }
Beispiel #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create three cells that each contain two pages
            KryptonWorkspaceCell cell1 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell2 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell3 = new KryptonWorkspaceCell();
            cell1.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });
            cell2.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });
            cell3.Pages.AddRange(new KryptonPage[] { CreatePage(), CreatePage() });

            // Create a vertical sequence that contains two of the pages
            KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(Orientation.Vertical);
            sequence.Children.AddRange(new KryptonWorkspaceCell[] { cell2, cell3 });

            // Remove starting contents and add a cell with a sequence
            kryptonWorkspace.Root.Children.Clear();
            kryptonWorkspace.Root.Children.Add(cell1);
            kryptonWorkspace.Root.Children.Add(sequence);
        }
        /// <summary>
        /// Perform the drop action associated with the target.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="data">Data to pass to the target to process drop.</param>
        /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns>
        public override bool PerformDrop(Point screenPt, PageDragEndData data)
        {
            // Transfer the dragged pages into a new cell
            KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
            KryptonPage page = ProcessDragEndData(Workspace, cell, data);

            // If no pages are transferred then we do nothing and no longer need cell instance
            if (page == null)
                cell.Dispose();
            else
            {
                // If the root is not the same direction as that needed for the drop then...
                bool dropHorizontal = (Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Right);
                if ((dropHorizontal && (Workspace.Root.Orientation == Orientation.Vertical)) ||
                    (!dropHorizontal && (Workspace.Root.Orientation == Orientation.Horizontal)))
                {
                    // Create a new sequence and place all existing root items into it
                    KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(Workspace.Root.Orientation);
                    for (int i = Workspace.Root.Children.Count - 1; i >= 0; i--)
                    {
                        Component child = Workspace.Root.Children[i];
                        Workspace.Root.Children.RemoveAt(i);
                        sequence.Children.Insert(0, child);
                    }

                    // Put the new sequence in the root so all items are now grouped together
                    Workspace.Root.Children.Add(sequence);

                    // Switch the direction of the root
                    if (Workspace.Root.Orientation == Orientation.Horizontal)
                        Workspace.Root.Orientation = Orientation.Vertical;
                    else
                        Workspace.Root.Orientation = Orientation.Horizontal;
                }

                // Add to the start or the end of the root sequence?
                if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                    Workspace.Root.Children.Insert(0, cell);
                else
                    Workspace.Root.Children.Add(cell);

                // Make the last page transfer the newly selected page of the cell
                if (page != null)
                {
                    // Does the cell allow the selection of tabs?
                    if (cell.AllowTabSelect)
                        cell.SelectedPage = page;

                    // Need to layout so the new cell has been added as a child control and
                    // therefore can receive the focus we want to give it immediately afterwards
                    Workspace.PerformLayout();

                    if (!cell.IsDisposed)
                    {
                        // Without this DoEvents() call the dropping of multiple pages in a complex arrangement causes an exception for
                        // a complex reason that is hard to work out (i.e. I'm not entirely sure). Something to do with using select to
                        // change activation is causing the source workspace control to dispose to earlier.
                        Application.DoEvents();
                        cell.Select();
                    }
                }
            }

            return true;
        }
        /// <summary>
        /// Perform the drop action associated with the target.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="data">Data to pass to the target to process drop.</param>
        /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns>
        public override bool PerformDrop(Point screenPt, PageDragEndData data)
        {
            // We need a parent sequence in order to perform drop
            KryptonWorkspaceSequence parent = Cell.WorkspaceParent as KryptonWorkspaceSequence;
            if (parent != null)
            {
                // Transfer the dragged pages into a new cell
                KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                KryptonPage page = ProcessDragEndData(Workspace, cell, data);

                // If no pages are transferred then we do nothing and no longer need cell instance
                if (page == null)
                    cell.Dispose();
                else
                {
                    // If the parent sequence is not the same direction as that needed for the drop then...
                    bool dropHorizontal = (Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Right);
                    if ((dropHorizontal && (parent.Orientation == Orientation.Vertical)) ||
                        (!dropHorizontal && (parent.Orientation == Orientation.Horizontal)))
                    {
                        // Find opposite direction to the parent sequence
                        Orientation sequenceOrientation;
                        if (parent.Orientation == Orientation.Horizontal)
                            sequenceOrientation = Orientation.Vertical;
                        else
                            sequenceOrientation = Orientation.Horizontal;

                        // Create a new sequence and transfer the target cell into it
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(sequenceOrientation);
                        int index = parent.Children.IndexOf(_cell);
                        parent.Children.RemoveAt(index);
                        sequence.Children.Add(_cell);

                        // Put the sequence into the place where the target cell used to be
                        parent.Children.Insert(index, sequence);

                        // Add new cell to the start or the end of the new sequence?
                        if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                            sequence.Children.Insert(0, cell);
                        else
                            sequence.Children.Add(cell);
                    }
                    else
                    {
                        // Find position of the target cell
                        int index = parent.Children.IndexOf(_cell);

                        // Add new cell before or after the target cell?
                        if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                            parent.Children.Insert(index, cell);
                        else
                            parent.Children.Insert(index + 1, cell);
                    }

                    // Make the last page transfered the newly selected page of the cell
                    if (page != null)
                    {
                        // Does the cell allow the selection of tabs?
                        if (cell.AllowTabSelect)
                            cell.SelectedPage = page;

                        // Need to layout so the new cell has been added as a child control and
                        // therefore can receive the focus we want to give it immediately afterwards
                        Workspace.PerformLayout();

                        if (!cell.IsDisposed)
                        {
                            // Without this DoEvents() call the dropping of multiple pages in a complex arrangement causes an exception for
                            // a complex reason that is hard to work out (i.e. I'm not entirely sure). Something to do with using select to
                            // change activation is causing the source workspace control to dispose to earlier.
                            Application.DoEvents();
                            cell.Select();
                        }
                    }
                }
            }

            return true;
        }
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate the designer with.</param>
        public override void Initialize(IComponent component)
        {
            Debug.Assert(component != null);

            // Validate the parameter reference
            if (component == null) throw new ArgumentNullException("component");

            // Let base class do standard stuff
            base.Initialize(component);

            // Cast to correct type
            _sequence = (KryptonWorkspaceSequence)component;

            // Get access to the services
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed/changed
            _changeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
        }
Beispiel #15
0
        /// <summary>
        /// Perform the drop action associated with the target.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="data">Data to pass to the target to process drop.</param>
        /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns>
        public override bool PerformDrop(Point screenPt, PageDragEndData data)
        {
            // We need a parent sequence in order to perform drop
            if (Cell.WorkspaceParent is KryptonWorkspaceSequence parent)
            {
                // Transfer the dragged pages into a new cell
                KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                KryptonPage          page = ProcessDragEndData(Workspace, cell, data);

                // If no pages are transferred then we do nothing and no longer need cell instance
                if (page == null)
                {
                    cell.Dispose();
                }
                else
                {
                    // If the parent sequence is not the same direction as that needed for the drop then...
                    bool dropHorizontal = (Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Right);
                    if ((dropHorizontal && (parent.Orientation == Orientation.Vertical)) ||
                        (!dropHorizontal && (parent.Orientation == Orientation.Horizontal)))
                    {
                        // Find opposite direction to the parent sequence
                        Orientation sequenceOrientation = parent.Orientation == Orientation.Horizontal
                            ? Orientation.Vertical
                            : Orientation.Horizontal;

                        // Create a new sequence and transfer the target cell into it
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence(sequenceOrientation);
                        int index = parent.Children.IndexOf(Cell);
                        parent.Children.RemoveAt(index);
                        sequence.Children.Add(Cell);

                        // Put the sequence into the place where the target cell used to be
                        parent.Children.Insert(index, sequence);

                        // Add new cell to the start or the end of the new sequence?
                        if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                        {
                            sequence.Children.Insert(0, cell);
                        }
                        else
                        {
                            sequence.Children.Add(cell);
                        }
                    }
                    else
                    {
                        // Find position of the target cell
                        int index = parent.Children.IndexOf(Cell);

                        // Add new cell before or after the target cell?
                        if ((Edge == VisualOrientation.Left) || (Edge == VisualOrientation.Top))
                        {
                            parent.Children.Insert(index, cell);
                        }
                        else
                        {
                            parent.Children.Insert(index + 1, cell);
                        }
                    }

                    // Make the last page transferred the newly selected page of the cell
                    if (page != null)
                    {
                        // Does the cell allow the selection of tabs?
                        if (cell.AllowTabSelect)
                        {
                            cell.SelectedPage = page;
                        }

                        // Need to layout so the new cell has been added as a child control and
                        // therefore can receive the focus we want to give it immediately afterwards
                        Workspace.PerformLayout();

                        if (!cell.IsDisposed)
                        {
                            // Without this DoEvents() call the dropping of multiple pages in a complex arrangement causes an exception for
                            // a complex reason that is hard to work out (i.e. I'm not entirely sure). Something to do with using select to
                            // change activation is causing the source workspace control to dispose to earlier.
                            Application.DoEvents();
                            cell.Select();
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #16
0
        private void buttonFloatingComplex_Click(object sender, EventArgs e)
        {
            // Add single page to a new floating window
            KryptonDockingFloatingWindow window = kryptonDockingManager.AddFloatingWindow("Floating",
                                                                                          new KryptonPage[] { NewInput() },
                                                                                          new Size(500, 400));

            // Create a sequence that contains two cells, with a page in each cell
            KryptonWorkspaceSequence seq = new KryptonWorkspaceSequence(Orientation.Vertical);
            KryptonWorkspaceCell cell1 = new KryptonWorkspaceCell();
            KryptonWorkspaceCell cell2 = new KryptonWorkspaceCell();
            seq.Children.AddRange(new Component[] { cell1, cell2 });
            cell1.Pages.Add(NewPropertyGrid());
            cell2.Pages.Add(NewDocument());

            // Add new sequence into the floating window
            window.FloatspaceElement.FloatspaceControl.Root.Children.Add(seq);
        }
Beispiel #17
0
        private void buttonNewSequences_Click(object sender, EventArgs e)
        {
            // Remove all existing workspace content
            kryptonWorkspace.Root.Children.Clear();

            // Create a horizontal sequence with two cells
            KryptonWorkspaceSequence sequence2 = new KryptonWorkspaceSequence(Orientation.Horizontal);
            sequence2.Children.Add(CreateCell());
            sequence2.Children.Add(CreateCell());
            sequence2.Children.Add(CreateCell());

            // Create a vertical sequence with two cells and the horizontal sequence
            KryptonWorkspaceSequence sequence1 = new KryptonWorkspaceSequence(Orientation.Vertical);
            sequence1.Children.Add(CreateCell(2, "25*,25*"));
            sequence1.Children.Add(CreateCell(2, "25*,25*"));
            sequence1.Children.Add(sequence2);

            // Root contains two cells and the vertical sequence
            kryptonWorkspace.Root.Children.Add(CreateCell(1, "25*,25*"));
            kryptonWorkspace.Root.Children.Add(CreateCell(1, "25*,25*"));
            kryptonWorkspace.Root.Children.Add(sequence1);

            // We want the root cells to be layed out horizontally
            kryptonWorkspace.Root.Orientation = Orientation.Horizontal;
        }
 /// <summary>
 /// Initialize a new instance of the KryptonWorkspaceCollection class.
 /// </summary>
 /// <param name="sequence">Reference to the owning sequence.</param>
 public KryptonWorkspaceCollection(KryptonWorkspaceSequence sequence)
 {
     _sequence = sequence;
 }
        /// <summary>
        /// Request this sequence load and recreate children.
        /// </summary>
        /// <param name="workspace">Reference to owning workspace instance.</param>
        /// <param name="xmlReader">Xml reader for loading information.</param>
        /// <param name="existingPages">Dictionary on existing pages before load.</param>
        public void LoadFromXml(KryptonWorkspace workspace, 
                                XmlReader xmlReader,
                                UniqueNameToPage existingPages)
        {
            // Load the sequence details
            workspace.ReadSequenceElement(xmlReader, this);

            // If the sequence contains nothing then exit immediately
            if (!xmlReader.IsEmptyElement)
            {
                do
                {
                    // Read the next Element
                    if (!xmlReader.Read())
                        throw new ArgumentException("An element was expected but could not be read in.");

                    // Is this the end of the sequence
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                        break;

                    // Is it another sequence?
                    if (xmlReader.Name == "WS")
                    {
                        KryptonWorkspaceSequence sequence = new KryptonWorkspaceSequence();
                        sequence.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(sequence);
                    }
                    else if (xmlReader.Name == "WC")
                    {
                        KryptonWorkspaceCell cell = new KryptonWorkspaceCell();
                        cell.LoadFromXml(workspace, xmlReader, existingPages);
                        Children.Add(cell);
                    }
                    else
                        throw new ArgumentException("Unknown element was encountered.");
                }
                while (true);
            }
        }