Пример #1
0
 DockGroupItem AddItemAtLocation(DockGroup grp, DockItem it, string location, bool visible, DockItemStatus status)
 {
     string[] positions = location.Split(';');
     foreach (string pos in positions)
     {
         int i = pos.IndexOf('/');
         if (i == -1)
         {
             continue;
         }
         string    id = pos.Substring(0, i).Trim();
         DockGroup g  = grp.FindGroupContaining(id);
         if (g != null)
         {
             DockPosition dpos;
             try {
                 dpos = (DockPosition)Enum.Parse(typeof(DockPosition), pos.Substring(i + 1).Trim(), true);
             }
             catch {
                 continue;
             }
             DockGroupItem dgt = g.AddObject(it, dpos, id);
             dgt.SetVisible(visible);
             dgt.Status = status;
             return(dgt);
         }
     }
     return(null);
 }
Пример #2
0
        void DockTarget(DockItem item, int n)
        {
            DockGroupItem gitem = new DockGroupItem(Frame, item);

            dockObjects.Insert(n, gitem);
            gitem.ParentGroup = this;
            gitem.SetVisible(true);
            ResetVisibleGroups();
            CalcNewSizes();
        }
Пример #3
0
        public bool GetDockTarget(DockItem item, int px, int py, Gdk.Rectangle rect, out DockDelegate dockDelegate, out Gdk.Rectangle outrect)
        {
            dockDelegate = null;

            if (item != this.item && this.item.Visible && rect.Contains(px, py))
            {
                int          xdockMargin = (int)((double)rect.Width * (1.0 - DockFrame.ItemDockCenterArea)) / 2;
                int          ydockMargin = (int)((double)rect.Height * (1.0 - DockFrame.ItemDockCenterArea)) / 2;
                DockPosition pos;

/*        if (ParentGroup.Type == DockGroupType.Tabbed) {
 *        rect = new Gdk.Rectangle (rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin*2, rect.Height - ydockMargin*2);
 *        pos = DockPosition.CenterAfter;
 *      }
 */             if (px <= rect.X + xdockMargin && ParentGroup.Type != DockGroupType.Horizontal)
                {
                    outrect = new Gdk.Rectangle(rect.X, rect.Y, xdockMargin, rect.Height);
                    pos     = DockPosition.Left;
                }
                else if (px >= rect.Right - xdockMargin && ParentGroup.Type != DockGroupType.Horizontal)
                {
                    outrect = new Gdk.Rectangle(rect.Right - xdockMargin, rect.Y, xdockMargin, rect.Height);
                    pos     = DockPosition.Right;
                }
                else if (py <= rect.Y + ydockMargin && ParentGroup.Type != DockGroupType.Vertical)
                {
                    outrect = new Gdk.Rectangle(rect.X, rect.Y, rect.Width, ydockMargin);
                    pos     = DockPosition.Top;
                }
                else if (py >= rect.Bottom - ydockMargin && ParentGroup.Type != DockGroupType.Vertical)
                {
                    outrect = new Gdk.Rectangle(rect.X, rect.Bottom - ydockMargin, rect.Width, ydockMargin);
                    pos     = DockPosition.Bottom;
                }
                else
                {
                    outrect = new Gdk.Rectangle(rect.X + xdockMargin, rect.Y + ydockMargin, rect.Width - xdockMargin * 2, rect.Height - ydockMargin * 2);
                    pos     = DockPosition.Center;
                }

                dockDelegate = delegate(DockItem dit) {
                    DockGroupItem it = ParentGroup.AddObject(dit, pos, Id);
                    it.SetVisible(true);
                    ParentGroup.FocusItem(it);
                };
                return(true);
            }
            outrect = Gdk.Rectangle.Zero;
            return(false);
        }
Пример #4
0
        DockLayout GetDefaultLayout()
        {
            DockLayout group = new DockLayout(this);

            // Add items which don't have relative defaut positions

            List <DockItem> todock = new List <DockItem> ();

            foreach (DockItem item in container.Items)
            {
                if (string.IsNullOrEmpty(item.DefaultLocation))
                {
                    DockGroupItem dgt = new DockGroupItem(this, item);
                    dgt.SetVisible(item.DefaultVisible);
                    group.AddObject(dgt);
                }
                else
                {
                    todock.Add(item);
                }
            }

            // Add items with relative positions.
            int lastCount = 0;

            while (lastCount != todock.Count)
            {
                lastCount = todock.Count;
                for (int n = 0; n < todock.Count; n++)
                {
                    DockItem it = todock [n];
                    if (AddDefaultItem(group, it) != null)
                    {
                        todock.RemoveAt(n);
                        n--;
                    }
                }
            }

            // Items which could not be docked because of an invalid default location
            foreach (DockItem item in todock)
            {
                DockGroupItem dgt = new DockGroupItem(this, item);
                dgt.SetVisible(false);
                group.AddObject(dgt);
            }
//      group.Dump ();
            return(group);
        }