Esempio n. 1
0
        public static SplitContainer Embed(Control parentControl, Control childControl, DockType dock, bool isFixedSize = false)
        {
            if (parentControl == null || childControl == null)
            {
                return null;
            }
			if (!(childControl is EmbededForm) || EmbededForm.IsEmbeded(childControl))
			{
				return null;
			}
            IDockableTag tag = parentControl.Tag as IDockableTag;
            if (tag == null)
            {
                tag = new DockTag { ContentRegion = parentControl };
                parentControl.Tag = tag;
            }
            tag.AddForm(childControl);
            Control container = tag.GetContentRegion();
            if (container == null)
            {
                return null;
            }
            SplitContainer splitter = new SplitContainer();
            splitter.IsSplitterFixed = isFixedSize;
            Control originContainer = null;
            Control parentContainer = AdjustSplitter(childControl, dock, splitter, ref originContainer);
            if (parentContainer == null)
            {
                parentContainer = container;
                originContainer = container;
            }
            tag.SetContentRegion(originContainer);
            if (container.Controls.Count > 0)
            {
                if (originContainer == null)
                {
                    return null;
                }
                foreach (Control c in container.Controls)
                {
                    container.Controls.Remove(c);
                    originContainer.Controls.Add(c);
                }
            }

            container.Controls.Add(splitter);
            splitter.Dock = DockStyle.Fill;
            parentControl.Tag = tag;

            EmbededForm.Embed(childControl, parentContainer, true, true);
            return splitter;
        }
Esempio n. 2
0
        public virtual void EmbedInto(Control targetControl, DockType dockType, bool isFixedSize = false)
        {
            IDockableTag target = null;
            if (!(targetControl.Tag is IDockableTag))
            {
                return;
            }
            target = targetControl.Tag as IDockableTag;
            if (target == null)
            {
                target = new DockTag { ContentRegion = targetControl };
                targetControl.Tag = target;
            }
            target.AddForm(this);
            Control container = target.GetContentRegion();
            if (container == null)
            {
                return;
            }
            originalParent = targetControl;
            SplitContainer splitter = new SplitContainer();
            splitter.IsSplitterFixed = isFixedSize;
            Control originContainer = null;
            Control parentContainer = PickSplitter(dockType, splitter, ref originContainer);
            if (parentContainer == null)
            {
                parentContainer = container;
                originContainer = container;
            }
            target.SetContentRegion(originContainer);

            if (container.Controls.Count > 0)
            {
                if (originContainer == null)
                {
                    return;
                }
                for (int l = container.Controls.Count - 1, i=l; i >= 0; i--)
                {
                    Control c = container.Controls[i];
                    container.Controls.Remove(c);
                    originContainer.Controls.Add(c);
                }
            }

            container.Controls.Add(splitter);
            splitter.Dock = DockStyle.Fill;
            targetControl.Tag = target;

            EmbedInto(parentContainer, true);
        }
Esempio n. 3
0
 private void InitDockTag(Panel target)
 {
     DockTag dTag = new DockTag();
     dTag.ContentRegion = target;
     target.Tag = dTag;
 }