示例#1
0
文件: Extensions.cs 项目: mind0n/hive
        private static void GenerateSplitter(Control target, EmbedType type, EmbedableTag tag, out SplitContainer splitter, out SplitterPanel fillPanel, out SplitterPanel contentPanel, bool isSizable)
        {
            splitter  = new SplitContainer();
            fillPanel = null;

            if (type == EmbedType.Left || type == EmbedType.Right)
            {
                splitter.Orientation = Orientation.Vertical;
                if (type == EmbedType.Left)
                {
                    fillPanel    = splitter.Panel1;
                    contentPanel = splitter.Panel2;
                    if (!isSizable)
                    {
                        splitter.FixedPanel = FixedPanel.Panel1;
                    }
                }
                else
                {
                    fillPanel    = splitter.Panel2;
                    contentPanel = splitter.Panel1;
                    if (!isSizable)
                    {
                        splitter.FixedPanel = FixedPanel.Panel2;
                    }
                }
            }
            else
            {
                splitter.Orientation = Orientation.Horizontal;
                if (type == EmbedType.Top)
                {
                    fillPanel    = splitter.Panel1;
                    contentPanel = splitter.Panel2;
                    if (!isSizable)
                    {
                        splitter.FixedPanel = FixedPanel.Panel1;
                    }
                }
                else
                {
                    fillPanel    = splitter.Panel2;
                    contentPanel = splitter.Panel1;
                    if (!isSizable)
                    {
                        splitter.FixedPanel = FixedPanel.Panel2;
                    }
                }
            }
            if (tag != null && tag.ContentRegion != null && tag.ContentRegion.Controls.Count > 0)            // target.Controls.Count > 0)
            {
                foreach (Control item in target.Controls)
                {
                    target.Controls.Remove(item);

                    contentPanel.Controls.Add(item);
                }
            }
            tag.ContentRegion = contentPanel;
        }
示例#2
0
文件: Extensions.cs 项目: mind0n/hive
        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();
            }
        }
示例#3
0
文件: Extensions.cs 项目: mind0n/hive
        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);
                }
            }
        }
示例#4
0
文件: Extensions.cs 项目: mind0n/hive
        public static EmbedableTag GetInstance(Control parent)
        {
            EmbedableTag tag;

            if (parent.Tag == null)
            {
                tag = new EmbedableTag();
                tag.ContentRegion = parent;
            }
            else if (parent.Tag is EmbedableTag)
            {
                tag = parent.Tag as EmbedableTag;
            }
            else
            {
                tag               = new EmbedableTag();
                tag["value"]      = parent.Tag;
                tag.ContentRegion = parent;
            }
            parent.Tag = tag;
            return(tag);
        }
示例#5
0
文件: Extensions.cs 项目: mind0n/hive
        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);
                }
            }
        }