private void OnDockspaceBeforePageDrag(object sender, PageDragCancelEventArgs e)
        {
            // Validate the list of names to those that are still present in the dockspace
            List <KryptonPage> pages = new List <KryptonPage>();

            foreach (KryptonPage page in e.Pages)
            {
                if (!(page is KryptonStorePage) && (DockspaceControl.CellForPage(page) != null))
                {
                    pages.Add(page);
                }
            }

            // Only need to start docking dragging if we have some valid pages
            if (pages.Count != 0)
            {
                // Ask the docking manager for a IDragPageNotify implementation to handle the dragging operation
                KryptonDockingManager dockingManager = DockingManager;
                dockingManager?.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages);
            }

            // Always take over docking
            e.Cancel = true;
        }
        private void OnDockspaceSeparatorMoveRect(object sender, SplitterMoveRectMenuArgs e)
        {
            // Cast to correct type and grab associated dockspace element
            KryptonDockspaceSeparator separatorControl = (KryptonDockspaceSeparator)sender;
            KryptonDockingDockspace   dockspaceElement = _lookupSeparator[separatorControl];

            // Events are generated from the parent docking manager
            KryptonDockingManager dockingManager = DockingManager;

            if (dockingManager != null)
            {
                // Allow the movement rectangle to be modified by event handlers
                DockspaceSeparatorResizeEventArgs dockspaceResizeRectArgs = new DockspaceSeparatorResizeEventArgs(separatorControl, dockspaceElement, FindMovementRect(dockspaceElement, e.MoveRect));
                dockingManager.RaiseDockspaceSeparatorResize(dockspaceResizeRectArgs);
                e.MoveRect = dockspaceResizeRectArgs.ResizeRect;
            }

            if (GetParentType(typeof(KryptonDockingControl)) is KryptonDockingControl c)
            {
                // Inform our owning control that an update is starting, this will prevent drawing of the control area
                c.PropogateAction(DockingPropogateAction.StartUpdate, (string[])null);
                _update = true;
            }
        }
        private void OnPanelDisposed(object sender, EventArgs e)
        {
            // Unhook from events so the control can be garbage collected
            _panel.Disposed -= OnPanelDisposed;

            // Events are generated from the parent docking manager
            KryptonDockingManager dockingManager = DockingManager;

            if (dockingManager != null)
            {
                // Only generate the removed event if we have already fired the adding event.
                if (_panelEventFired)
                {
                    AutoHiddenGroupPanelEventArgs panelArgs = new AutoHiddenGroupPanelEventArgs(_panel, this);
                    dockingManager.RaiseAutoHiddenGroupPanelRemoved(panelArgs);
                }
            }

            // Make sure the sliding panel is also disposed
            if (!_slidePanel.IsDisposed)
            {
                _slidePanel.Dispose();
            }
        }
Example #4
0
        /// <summary>
        /// Saves docking configuration information using a provider xml writer.
        /// </summary>
        /// <param name="xmlWriter">Xml writer object.</param>
        public override void SaveElementToXml(XmlWriter xmlWriter)
        {
            // Output navigator docking element
            xmlWriter.WriteStartElement(XmlElementName);
            xmlWriter.WriteAttributeString(@"N", Name);
            xmlWriter.WriteAttributeString(@"C", DockableNavigatorControl.Pages.Count.ToString());

            // Persist each child page in turn
            KryptonDockingManager dockingManager = DockingManager;

            foreach (KryptonPage page in DockableNavigatorControl.Pages)
            {
                // Are we allowed to save the page?
                if (page.AreFlagsSet(KryptonPageFlags.AllowConfigSave))
                {
                    xmlWriter.WriteStartElement("KP");
                    CommonHelper.TextToXmlAttribute(xmlWriter, @"UN", page.UniqueName);
                    CommonHelper.TextToXmlAttribute(xmlWriter, @"S", CommonHelper.BoolToString(page is KryptonStorePage));
                    CommonHelper.TextToXmlAttribute(xmlWriter, @"V", CommonHelper.BoolToString(page.LastVisibleSet), @"True");

                    // Give event handlers a chance to save custom data with the page
                    xmlWriter.WriteStartElement(@"CPD");
                    DockPageSavingEventArgs args = new DockPageSavingEventArgs(dockingManager, xmlWriter, page);
                    dockingManager.RaisePageSaving(args);
                    xmlWriter.WriteEndElement();

                    // Terminate the page element
                    xmlWriter.WriteEndElement();
                }
            }

            // Output an xml for the contained workspace

            // Terminate the workspace element
            xmlWriter.WriteFullEndElement();
        }
        /// <summary>
        /// Occurs when a page is added to a cell in the workspace.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">A KryptonPageEventArgs containing the event data.</param>
        protected override void OnSpaceCellPageInserting(object sender, KryptonPageEventArgs e)
        {
            // Remove any store page for the unique name of this page being added. In either case of adding a store
            // page or a regular page we want to ensure there does not exist a store page for that same unique name.
            KryptonDockingManager dockingManager = DockingManager;

            if (dockingManager != null)
            {
                if (e.Item is KryptonStorePage)
                {
                    KryptonFloatspace floatspace = sender as KryptonFloatspace;
                    if ((floatspace != null) && (floatspace.CellForPage(e.Item) != null))
                    {
                        // Prevent this existing store page from being removed due to the Propogate action below. This can
                        // occur because a cell with pages is added in one go and so insert events are generated for the
                        // existing pages inside the cell to ensure that the event is always fired consistently.
                        IgnoreStorePage = (KryptonStorePage)e.Item;
                    }
                }

                dockingManager.PropogateAction(ClearStoreAction, new string[] { e.Item.UniqueName });
                IgnoreStorePage = null;
            }
        }
Example #6
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)
        {
            // Find our docking edge
            KryptonDockingEdge dockingEdge = null;

            switch (Edge)
            {
            case VisualOrientation.Left:
                dockingEdge = ControlElement["Left"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Right:
                dockingEdge = ControlElement["Right"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Top:
                dockingEdge = ControlElement["Top"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Bottom:
                dockingEdge = ControlElement["Bottom"] as KryptonDockingEdge;
                break;
            }

            // Find the docked edge
            KryptonDockingEdgeDocked dockedEdge = dockingEdge?["Docked"] as KryptonDockingEdgeDocked;
            KryptonDockingManager    manager    = dockedEdge?.DockingManager;

            if (manager != null)
            {
                // Create a list of pages that are allowed to be transferred into the dockspace
                var transferPages       = new List <KryptonPage>();
                var transferUniqueNames = new List <string>();
                foreach (KryptonPage page in data.Pages)
                {
                    if (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked))
                    {
                        // Use event to indicate the page is becoming docked and allow it to be cancelled
                        CancelUniqueNameEventArgs args = new(page.UniqueName, false);
                        manager?.RaisePageDockedRequest(args);

                        if (!args.Cancel)
                        {
                            transferPages.Add(page);
                            transferUniqueNames.Add(page.UniqueName);
                        }
                    }
                }

                // Transfer valid pages into the new dockspace
                if (transferPages.Count > 0)
                {
                    // Convert the incoming pages into store pages for restoring later
                    manager.PropogateAction(DockingPropogateAction.StorePages, transferUniqueNames.ToArray());

                    // Create a new dockspace at the start of the list so it is closest to the control edge
                    KryptonDockingDockspace dockspace = (_outsideEdge ? dockedEdge.InsertDockspace(0) : dockedEdge.AppendDockspace());

                    // Add pages into the target
                    dockspace.Append(transferPages.ToArray());

                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Perform docking element specific actions for loading a child xml.
        /// </summary>
        /// <param name="xmlReader">Xml reader object.</param>
        /// <param name="pages">Collection of available pages.</param>
        /// <param name="child">Optional reference to existing child docking element.</param>
        protected override void LoadChildDockingElement(XmlReader xmlReader,
                                                        KryptonPageCollection pages,
                                                        IDockingElement child)
        {
            KryptonDockingManager manager = DockingManager;

            // Is it the expected xml element name?
            if (xmlReader.Name != "KP")
            {
                throw new ArgumentException("Element name 'KP' was expected but found '" + xmlReader.Name + "' instead.");
            }

            // Get the unique name of the page
            string uniqueName = xmlReader.GetAttribute("UN");
            string boolStore = xmlReader.GetAttribute("S");
            string boolVisible = xmlReader.GetAttribute("V");

            KryptonPage page;

            // If the entry is for just a placeholder...
            if (CommonHelper.StringToBool(boolStore))
            {
                // Recreate the requested store page and append
                page = new KryptonStorePage(uniqueName, "AutoHiddenGroup");
                AutoHiddenGroupControl.Pages.Add(page);
            }
            else
            {
                // Can we find a provided page to match the incoming layout?
                page = pages[uniqueName];
                if (page == null)
                {
                    // Generate event so developer can create and supply the page now
                    RecreateLoadingPageEventArgs args = new RecreateLoadingPageEventArgs(uniqueName);
                    manager.RaiseRecreateLoadingPage(args);
                    if (!args.Cancel)
                    {
                        page = args.Page;

                        // Add recreated page to the looking dictionary
                        if ((page != null) && (pages[page.UniqueName] == null))
                        {
                            pages.Add(page);
                        }
                    }
                }

                if (page != null)
                {
                    // Use the loaded visible state
                    page.Visible = CommonHelper.StringToBool(boolVisible);

                    // Create a proxy around the page and append it
                    KryptonAutoHiddenProxyPage proxyPage = new KryptonAutoHiddenProxyPage(page);
                    AutoHiddenGroupControl.Pages.Add(proxyPage);
                }
            }

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

            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
            DockPageLoadingEventArgs pageLoading = new DockPageLoadingEventArgs(manager, xmlReader, page);
            manager.RaisePageLoading(pageLoading);

            // 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.");
                    }
                }
            }

            if (!xmlReader.Read())
            {
                throw new ArgumentException("An element was expected but could not be read in.");
            }
        }
 /// <summary>
 /// Initialize a new instance of the DockGlobalSavingEventArgs class.
 /// </summary>
 /// <param name="manager">Reference to owning docking manager instance.</param>
 /// <param name="xmlWriter">Xml writer for persisting custom data.</param>
 public DockGlobalSavingEventArgs(KryptonDockingManager manager,
                                  XmlWriter xmlWriter)
 {
     DockingManager = manager;
     XmlWriter      = xmlWriter;
 }
Example #9
0
 /// <summary>
 /// Initialize a new instance of the DockGlobalLoadingEventArgs class.
 /// </summary>
 /// <param name="manager">Reference to owning docking manager instance.</param>
 /// <param name="xmlReading">Xml reader for persisting custom data.</param>
 public DockGlobalLoadingEventArgs(KryptonDockingManager manager,
                                   XmlReader xmlReading)
 {
     DockingManager = manager;
     XmlReader      = xmlReading;
 }
Example #10
0
        /// <summary>
        /// Loads docking configuration information using a provider xml reader.
        /// </summary>
        /// <param name="xmlReader">Xml reader object.</param>
        /// <param name="pages">Collection of available pages for adding.</param>
        public override void LoadElementFromXml(XmlReader xmlReader, KryptonPageCollection pages)
        {
            // Is it the expected xml element name?
            if (xmlReader.Name != XmlElementName)
            {
                throw new ArgumentException($@"Element name '{XmlElementName}' was expected but found '{xmlReader.Name}' instead.");
            }

            // Grab the element attributes
            string elementName  = xmlReader.GetAttribute(@"N");
            string elementCount = xmlReader.GetAttribute(@"C");

            // Check the name matches up
            if (elementName != Name)
            {
                throw new ArgumentException($@"Attribute 'N' value '{Name}' was expected but found '{elementName}' instead.");
            }

            // Remove any existing pages in the navigator
            DockableNavigatorControl.Pages.Clear();

            // If there are children then load them
            int count = int.Parse(elementCount);

            if (count > 0)
            {
                KryptonDockingManager manager = DockingManager;
                for (int i = 0; i < count; i++)
                {
                    // Read past this element
                    if (!xmlReader.Read())
                    {
                        throw new ArgumentException(@"An element was expected but could not be read in.");
                    }

                    // Is it the expected xml element name?
                    if (xmlReader.Name != @"KP")
                    {
                        throw new ArgumentException($@"Element name 'KP' was expected but found '{xmlReader.Name}' instead.");
                    }

                    // Get the unique name of the page
                    string uniqueName  = CommonHelper.XmlAttributeToText(xmlReader, @"UN");
                    bool   boolStore   = CommonHelper.StringToBool(CommonHelper.XmlAttributeToText(xmlReader, @"S"));
                    bool   boolVisible = CommonHelper.StringToBool(CommonHelper.XmlAttributeToText(xmlReader, @"V", @"True"));

                    // If the entry is for just a placeholder...
                    KryptonPage page;
                    if (boolStore)
                    {
                        // Recreate the requested store page and append
                        page = new KryptonStorePage(uniqueName, _storeName);
                        DockableNavigatorControl.Pages.Add(page);
                    }
                    else
                    {
                        // Can we find a provided page to match the incoming layout?
                        page = pages[uniqueName];
                        if (page == null)
                        {
                            // Generate event so developer can create and supply the page now
                            RecreateLoadingPageEventArgs args = new RecreateLoadingPageEventArgs(uniqueName);
                            manager.RaiseRecreateLoadingPage(args);

                            if (!args.Cancel && (args.Page != null))
                            {
                                page = args.Page;
                            }
                        }

                        if (page != null)
                        {
                            // Use the loaded visible state
                            page.Visible = boolVisible;

                            // Remove from provided collection as we can only add it once to the docking hierarchy
                            pages.Remove(page);

                            // Add into the navigator
                            DockableNavigatorControl.Pages.Add(page);
                        }
                    }

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

                    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
                    DockPageLoadingEventArgs pageLoading = new DockPageLoadingEventArgs(manager, xmlReader, page);
                    manager.RaisePageLoading(pageLoading);

                    // 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.");
                            }
                        }
                    }

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

            // Read past this element to the end element
            if (!xmlReader.Read())
            {
                throw new ArgumentException(@"An element was expected but could not be read in.");
            }
        }
 /// <summary>
 /// Initialize a new instance of the DockPageSavingEventArgs class.
 /// </summary>
 /// <param name="manager">Reference to owning docking manager instance.</param>
 /// <param name="xmlWriter">Xml writer for persisting custom data.</param>
 /// <param name="page">Reference to page being saved.</param>
 public DockPageSavingEventArgs(KryptonDockingManager manager,
                                XmlWriter xmlWriter,
                                KryptonPage page)
     : base(manager, xmlWriter) =>
Example #12
0
 /// <summary>
 /// Initialize a new instance of the DockingManagerStringsBase class.
 /// </summary>
 /// <param name="docking">Reference to owning docking manager.</param>
 public DockingManagerStringsBase(KryptonDockingManager docking)
 {
 }
        private void OnSpaceControlRecreateLoadingPage(object sender, RecreateLoadingPageEventArgs e)
        {
            KryptonDockingManager dockingManager = DockingManager;

            dockingManager?.RaiseRecreateLoadingPage(e);
        }
 /// <summary>
 /// Initialize a new instance of the DockPageLoadingEventArgs class.
 /// </summary>
 /// <param name="manager">Reference to owning docking manager instance.</param>
 /// <param name="xmlReading">Xml reader for persisting custom data.</param>
 /// <param name="page">Reference to page being loaded.</param>
 public DockPageLoadingEventArgs(KryptonDockingManager manager,
                                 XmlReader xmlReading,
                                 KryptonPage page)
     : base(manager, xmlReading) =>
Example #15
0
        /// <summary>
        /// Initialize a new instance of the DockingManagerStringsBase class.
        /// </summary>
        /// <param name="docking">Reference to owning docking manager.</param>
        public DockingManagerStringsBase(KryptonDockingManager docking)
        {
            // Define the encryted licence information
            EncryptedLicenseProvider.SetParameters(_licenseParameters);

            // If an error has already been shown, then no need to test license again
            bool validated = _usageShown;

            if (!validated)
            {
                // Is there a valid license registered?
                License license = null;
                validated = LicenseManager.IsValid(typeof(KryptonDockingManager), this, out license);

                // Valid license is not enough!
                if (validated)
                {
                    validated = false;
                    EncryptedLicense encryptedLicense = license as EncryptedLicense;
                    string[]         productInfo      = encryptedLicense.ProductInfo.Split(',');

                    // Must contain two fields separated by a comma
                    if (productInfo.Length == 2)
                    {
                        // Both fields must not be empty
                        if (!string.IsNullOrEmpty(productInfo[0]) &&
                            !string.IsNullOrEmpty(productInfo[1]))
                        {
                            // Product code must be ...
                            //    'S' = Krypton Suite
                            // And version number...
                            //    '440'
                            validated = (productInfo[1].Equals("440")) && (productInfo[0][0] == 'S');
                        }
                    }
                }

                // Remember to release resources no longer needed
                if (license != null)
                {
                    license.Dispose();
                }
            }

            // If we need to indicate the invalid licensing state...
            if (!validated)
            {
                // Get hold of the assembly version number
                Version thisVersion = Assembly.GetExecutingAssembly().GetName().Version;

                // We want a unique 30 day evaluation period for each major/minor version
                EvaluationMonitor monitor = new EvaluationMonitor(_monitorId + thisVersion.Major.ToString() + thisVersion.Minor.ToString());

                // If the first time we have failed to get the licence or
                // the 30 days evaluation period has expired or the component
                // has been created over a 3000 times then...
                if ((monitor.UsageCount == 0) ||
                    (monitor.UsageCount > 3000) ||
                    (monitor.DaysInUse > 30))
                {
                    // At runtime show a NAG screen to prevent unauthorized use of the control
                    if (LicenseManager.CurrentContext.UsageMode == LicenseUsageMode.Runtime)
                    {
                        MessageBox.Show("This application was created using an unlicensed version of\n" +
                                        "the Krypton Suite control from Component Factory Pty Ltd.\n\n" +
                                        "You must contact your software supplier in order to resolve\n" +
                                        "the licencing issue.",
                                        "Unlicensed Application",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        LicenseInstallForm form = new LicenseInstallForm();
                        form.ShowDialog(typeof(KryptonDockingManager));
                    }
                }
            }

            // No need to perform check check more than once
            _usageShown = true;
        }