示例#1
0
            public void Add(BoxLayoutType type, AbstractLayoutable c)
            {
                int uTmp = 0, uSizeTmp = 0, tmp = 0;

                type.UV(c.VirtualX, c.VirtualY, ref uTmp, ref tmp);
                type.UV(c.VirtualWidth, c.VirtualHeight, ref uSizeTmp, ref tmp);
                _start = Math.Min(_start, uTmp);
                _size  = Math.Max(_size, (uTmp + uSizeTmp) - _start);
                _controls.Add(c);
            }
示例#2
0
 public void Merge(BoxLayoutType type, LayoutableGroup m2)
 {
     foreach (AbstractLayoutable c in m2._controls)
     {
         if (!this._controls.Contains(c))
         {
             this.Add(type, c);
         }
     }
 }
示例#3
0
            public bool Intersects(BoxLayoutType type, AbstractLayoutable c)
            {
                int uTmp = 0, uSizeTmp = 0, tmp = 0;

                type.UV(c.VirtualX, c.VirtualY, ref uTmp, ref tmp);
                type.UV(c.VirtualWidth, c.VirtualHeight, ref uSizeTmp, ref tmp);

                Rectangle r1 = new Rectangle(uTmp, 0, uSizeTmp, 1);
                Rectangle r2 = new Rectangle(_start, 0, _size, 1);

                return(r1.IntersectsWith(r2));
            }
示例#4
0
        private static void MergeIntersectingLayoutableGroups(BoxLayoutType boxType, List <LayoutableGroup> layoutableGroups)
        {
            List <LayoutableGroup> tmp1 = new List <LayoutableGroup>(layoutableGroups);
            List <LayoutableGroup> tmp2 = new List <LayoutableGroup>(layoutableGroups);

            foreach (LayoutableGroup l1 in tmp1)
            {
                foreach (LayoutableGroup l2 in tmp2)
                {
                    if (l1 != l2 && l1.Intersects(l2))
                    {
                        layoutableGroups.Remove(l1);
                        layoutableGroups.Remove(l2);
                        l1.Merge(boxType, l2);
                        layoutableGroups.Add(l1);
                    }
                }
            }
        }
 internal BoxLayout(BoxLayoutType layoutType, VirtualContainer layouted)
     : base(layouted)
 {
     _layoutType = layoutType;
 }
示例#6
0
 internal BoxLayout(BoxLayoutType layoutType, VirtualContainer layouted)
     : base(layouted)
 {
     _layoutType = layoutType;
 }
示例#7
0
 public LayoutableGroup(BoxLayoutType type, AbstractLayoutable c)
 {
     Add(type, c);
 }
示例#8
0
        private static void BuildInterimLayoutablesGroups(List <AbstractLayoutable> layoutables, BoxLayoutType boxType, List <LayoutableGroup> layoutableGroups)
        {
            foreach (AbstractLayoutable c in layoutables)
            {
                bool inserted = false;
                foreach (LayoutableGroup m in layoutableGroups)
                {
                    if (m.Intersects(boxType, c))
                    {
                        inserted = true;
                        m.Add(boxType, c);
                    }
                }

                if (!inserted)
                {
                    LayoutableGroup m = new LayoutableGroup(boxType, c);
                    layoutableGroups.Add(m);
                }
            }
        }
示例#9
0
        private void Create(BoxLayoutType boxType, VirtualContainer parent, int nestingDepth, List <LayoutableGroup> userConfiguredLayoutableGroups)
        {
            parent.LayoutManager = new BoxLayout(boxType, parent);

            if (parent.Layoutables.Count == 1)
            {
                return;
            }

            List <AbstractLayoutable> layoutables      = parent.Layoutables.Cast <AbstractLayoutable>().ToList();
            List <LayoutableGroup>    layoutableGroups = new List <LayoutableGroup>();

            BuildInterimLayoutablesGroups(layoutables, boxType, layoutableGroups);
            MergeIntersectingLayoutableGroups(boxType, layoutableGroups);
            layoutableGroups.Sort();
            ConfigureLayoutableGroups(userConfiguredLayoutableGroups, layoutableGroups);

            List <VirtualContainer> vc = new List <VirtualContainer>(layoutableGroups.Count);
            int uSizeTmp = 0, vSizeTmp = 0;

            boxType.UV(parent.VirtualWidth, parent.VirtualHeight, ref uSizeTmp, ref vSizeTmp);
            for (int i = 0; i < layoutableGroups.Count; i++)
            {
                if (i == 0)
                {
                    vc.Add(new VirtualContainer(parent));
                    vc[i].Grouped             = layoutableGroups[i].Fixed;
                    vc[i].CustomLayoutControl = layoutableGroups[i].CustomLayoutControl;
                    vc[i].LayoutManager       = new BoxLayout(boxType, vc[i]);

                    //U und V müssen nicht gesetzt werden, da sie beim
                    //ersten Element immer 0 sind;

                    boxType.SetVirtualUSize(vc[i], layoutableGroups[i].Start + layoutableGroups[i].Size);
                    boxType.SetVirtualVSize(vc[i], vSizeTmp);

                    foreach (AbstractLayoutable asl in layoutableGroups[i].Controls)
                    {
                        asl.VirtualX = asl.AbsoluteX - vc[i].AbsoluteX;
                        asl.VirtualY = asl.AbsoluteY - vc[i].AbsoluteY;
                        //code für die aktuelle Breite und Höhe
                        asl.Parent = vc[i];
                        vc[i].Add(asl);
                    }
                }
                if (i < layoutableGroups.Count - 1)
                {
                    int tmp = layoutableGroups[i + 1].Start - (layoutableGroups[i].Start + layoutableGroups[i].Size);
                    int endExtend;
                    int start;

                    endExtend = tmp / 2;
                    start     = tmp / 2;
                    if (tmp % 2 != 0)
                    {
                        start++;
                    }

                    tmp = boxType.GetVirtualUSize(vc[i]) + endExtend;
                    boxType.SetVirtualUSize(vc[i], tmp);

                    vc.Add(new VirtualContainer(parent));
                    //"V" muss nicht gesetzt werden, da es immer 0 ist...
                    vc[i + 1].Grouped             = layoutableGroups[i + 1].Fixed;
                    vc[i + 1].CustomLayoutControl = layoutableGroups[i + 1].CustomLayoutControl;
                    vc[i + 1].LayoutManager       = new BoxLayout(boxType, vc[i + 1]);
                    boxType.SetVirtualU(vc[i + 1], layoutableGroups[i + 1].Start - start);
                    boxType.SetVirtualUSize(vc[i + 1], layoutableGroups[i + 1].Size + start);
                    boxType.SetVirtualVSize(vc[i + 1], vSizeTmp);

                    foreach (AbstractLayoutable asl in layoutableGroups[i + 1].Controls)
                    {
                        asl.VirtualX = asl.AbsoluteX - vc[i + 1].AbsoluteX;
                        asl.VirtualY = asl.AbsoluteY - vc[i + 1].AbsoluteY;
                        //code für die aktuelle Breite und Höhe
                        asl.Parent = vc[i + 1];
                        vc[i + 1].Add(asl);
                    }
                }
                if (i == layoutableGroups.Count - 1)
                {
                    int tmp = uSizeTmp - (layoutableGroups[i].Start + layoutableGroups[i].Size);
                    tmp = tmp + boxType.GetVirtualUSize(vc[i]);
                    boxType.SetVirtualUSize(vc[i], tmp);
                }
            }

            parent.Layoutables = vc.Cast <AbstractLayoutable>().ToList();

            foreach (VirtualContainer v in vc)
            {
                Create(boxType.SubBoxLayoutType(), v, nestingDepth + 1, userConfiguredLayoutableGroups);
            }

            return;
        }