/// <summary>
        /// Restores the docking state of a <see cref="WeifenLuo.WinFormsUI.Docking.DockPanel"/>
        /// and its tool windows.
        /// </summary>
        /// <param name="key">The key identifying the containing form class.</param>
        /// <returns>
        ///     <c>true</c> if the deserialization was successful; otherwise, <c>false</c>.
        /// </returns>
        public bool RestoreDockingState(string key)
        {
            if (!layouts.ContainsKey(key))
            {
                return(false);
            }
            if (!workspaces.ContainsKey(key))
            {
                return(false);
            }

            var dockingXml = layouts[key].DockingInfo;

            try
            {
                using (var stream = new MemoryStream())
                    using (var writer = new StreamWriter(stream))
                    {
                        writer.Write(dockingXml);
                        writer.Flush();
                        stream.Seek(0L, SeekOrigin.Begin);
                        workspaces[key].LoadFromXml(stream, target =>
                        {
                            Delta.CertXplorer.Logging.ILogService log = This.Logger;

                            if (string.IsNullOrEmpty(target))
                            {
                                log.Info("Unable to load window: no guid was provided");
                                return(null);
                            }

                            Guid guid = Guid.Empty;
                            try { guid = new Guid(target); }
                            catch (Exception ex)
                            {
                                var debugException = ex;
                            }

                            if (guid == Guid.Empty)
                            {
                                log.Info(string.Format("Unable to load window with guid {0}.", target));
                                return(null);
                            }

                            ToolWindow window = null;
                            if (toolWindows.ContainsKey(key))
                            {
                                var dict = toolWindows[key];
                                if (dict.ContainsKey(guid))
                                {
                                    window = dict[guid];
                                }
                            }

                            if (window == null)
                            {
                                log.Info(string.Format("Unable to load window with guid {0}.", target));
                                return(null);
                            }
                            else
                            {
                                return(window.ToDockableWindow());
                            }
                        }, false);

                        writer.Close();
                    }
            }
            catch (Exception ex)
            {
                This.Logger.Error(string.Format(
                                      "Unable to restore docking state from the layout key {0}.", key), ex);
                return(false);
            }

            return(true);
        }