Event data for persisting extra data for a workspace cell page.
상속: XmlLoadingEventArgs
예제 #1
0
 private void OnSpaceControlPageLoading(object sender, PageLoadingEventArgs e)
 {
     KryptonDockingManager dockingManager = DockingManager;
     if (dockingManager != null)
     {
         DockPageLoadingEventArgs args = new DockPageLoadingEventArgs(dockingManager, e.XmlReader, e.Page);
         dockingManager.RaisePageLoading(args);
     }
 }
예제 #2
0
        /// <summary>
        /// Request this cell load and update state.
        /// </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 cell details and return the unique name of the selected page for the cell
            string      selectedPageUniqueName = workspace.ReadCellElement(xmlReader, this);
            KryptonPage selectedPage           = null;

            // If the cell 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 cell
                    if (xmlReader.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }

                    if (xmlReader.Name == "KP")
                    {
                        // Load the page details and optionally recreate the page
                        string      uniqueName = CommonHelper.XmlAttributeToText(xmlReader, "UN");
                        KryptonPage page       = workspace.ReadPageElement(xmlReader, uniqueName, existingPages);

                        if (xmlReader.Name != "CPD")
                        {
                            throw new ArgumentException("Expected 'CPD' element was not found");
                        }

                        bool finished = xmlReader.IsEmptyElement;

                        // Generate event so custom data can be loaded and/or the page to be added can be modified
                        PageLoadingEventArgs plea = new PageLoadingEventArgs(workspace, page, xmlReader);
                        workspace.OnPageLoading(plea);
                        page = plea.Page;

                        // Read everything until we get the end of custom data marker
                        while (!finished)
                        {
                            // Check it has the expected name
                            if (xmlReader.NodeType == XmlNodeType.EndElement)
                            {
                                finished = (xmlReader.Name == "CPD");
                            }

                            if (!finished)
                            {
                                if (!xmlReader.Read())
                                {
                                    throw new ArgumentException("An element was expected but could not be read in.");
                                }
                            }
                        }

                        // Read past the end of page element
                        if (!xmlReader.Read())
                        {
                            throw new ArgumentException("An element was expected but could not be read in.");
                        }

                        // Check it has the expected name
                        if (xmlReader.NodeType != XmlNodeType.EndElement)
                        {
                            throw new ArgumentException("End of 'KP' element expected but missing.");
                        }

                        // PageLoading event might have nulled the page value to prevent it being added
                        if (page != null)
                        {
                            // Remember the page that should become selected
                            if (!string.IsNullOrEmpty(page.UniqueName) && (page.UniqueName == selectedPageUniqueName))
                            {
                                // Can only selected a visible page
                                if (page.LastVisibleSet)
                                {
                                    selectedPage = page;
                                }
                            }

                            Pages.Add(page);
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Unknown element was encountered.");
                    }
                }while (true);
            }

            // Did we find a matching page that should become selected?
            // (and we are allowed to have selected tabs)
            if ((selectedPage != null) && AllowTabSelect)
            {
                SelectedPage = selectedPage;
            }
        }
예제 #3
0
        private void kryptonWorkspace_PageLoading(object sender, PageLoadingEventArgs e)
        {
            KryptonRichTextBox rtb;

            // If a new page then it does not have any children...
            if (e.Page.Controls.Count == 0)
            {
                // Add a rich text box as the child of the page
                rtb = new KryptonRichTextBox();
                rtb.Dock = DockStyle.Fill;
                rtb.StateCommon.Border.Draw = InheritBool.False;
                e.Page.Controls.Add(rtb);
                e.Page.Padding = new Padding(5);
            }
            else
                rtb = (KryptonRichTextBox)e.Page.Controls[0];

            // Move past the current xml element to the child CData
            e.XmlReader.Read();

            // Read in the stored text and use it in the rich text box
            rtb.Text = e.XmlReader.ReadContentAsString();
        }