public static void BeginEmbed(this Control control) { EmbedableTag tag = EmbedableTag.GetInstance(control); if (tag.NewlyEmbededControls.Count > 0) { tag.EmbededControls.AddRange(tag.NewlyEmbededControls); tag.NewlyEmbededControls.Clear(); } }
public static void EmbedInto(this Control child, Control parent, EmbedType type, EmbededCallback embededCallback, bool isFixed = false, bool isSizable = false) { if (child != null && parent != null) { EmbedableTag tag = EmbedableTag.GetInstance(parent); tag.NewlyEmbededControls.Add(child); tag.Parent = parent; Control container = tag.ContentRegion; if (type == EmbedType.Fill || type == EmbedType.None) { child.EmbedInto(container, type == EmbedType.Fill); return; } #region Generate SplitContainer according to the EmbedType SplitContainer splitter; SplitterPanel fillPanel; SplitterPanel contentPanel; GenerateSplitter(parent, type, tag, out splitter, out fillPanel, out contentPanel, isSizable); #endregion if (splitter != null) { splitter.IsSplitterFixed = isFixed; } fillPanel.Controls.Add(child); container.Controls.Add(splitter); splitter.Dock = DockStyle.Fill; tag.ContentRegion = contentPanel; #region Adjust fill panel size AdjustFillPanel(child, type, splitter); #endregion if (child is ScreenRegion) { child.Show(); } if (embededCallback != null) { embededCallback(child); } } }
public static void EndEmbed(this Control control) { EmbedableTag tag = EmbedableTag.GetInstance(control); if (tag == null) { return; } foreach (Control item in tag.NewlyEmbededControls) { try { MethodInfo info = item.GetType().GetMethod(STR_Embeded); if (info != null) { info.Invoke(item, new object[] { tag }); } } catch (Exception e) { ErrorHandler.Handle(e); } } }