private void MemoryViewClosedHandler(object sender, FormClosedEventArgs e)
        {
            MemoryViewWrapper c = (MemoryViewWrapper)sender;

            if (this.OnMemoryViewClosed != null)
            {
                OnMemoryViewClosed(c.Control, c.Index);
            }
        }
        public IContent CreateMemoryView(Control view, int memoryViewIndex)
        {
            //mStaticMainForm.CreateMemoryView(view);
            MemoryViewWrapper c = new MemoryViewWrapper(view, view.Text, memoryViewIndex);

            c.FormClosed += MemoryViewClosedHandler;
            //If we're currently loading an XML file, do not attempt to display the new memory view
            //Otherwise, display it.
            dockManager.AddMemoryView(c, !loadingInProgress);
            return(c);
        }
        public void AddMemoryView(MemoryViewWrapper view, bool display)
        {
            //TODO use a named constant for the string below
            string viewName = "MemoryView" + ":" + view.Index;

            EnrollView(view, viewName);

            view.FormClosed += delegate(object sender, FormClosedEventArgs e){
                UnenrollView(view);
            };

            if (!display)
            {
                return;
            }

            //Arranging the subwindows cannot be done consistently between the different docking window styles.
            if (this.DocumentStyle == DocumentStyle.SystemMdi)
            {
                //If the layout is "SystemMdi", the docking system is completely bypassed, and the resulting layout is pretty bad.
                view.Parent = (Form)this.Parent;
            }
            else
            {
                //The Docking Window library uses a single default size for all floating windows, and the only orthodox
                //way to set the window size is to specify a full set of bounds (including screen position). I rather like
                //the default screen position assigned to new windows (which causes them to cascade), so the below code is
                //a workaround which saves the current size (which is the original size of the memory view), then restores
                //it once the window is created.

                //In theory, the view.Pane.FloatWindow object should always be part of the API and non-null.
                //If a future update of the library causes some kind of problem with this code in the future,
                //that line can be removed without breaking the rest of the code.
                Size s = view.Size;
                view.Show(this, DockState.Float);
                view.Pane.FloatWindow.Size = view.Size = s;
            }
        }