Exemplo n.º 1
0
        public void Undock(DockWindow dw)
        {
            int idx = Children.IndexOf(dw);

            RemoveChild(dw);

            if (Children.Count == 0)
            {
                return;
            }

            if (dw.DockingPosition == Alignment.Left || dw.DockingPosition == Alignment.Top)
            {
                RemoveChild(idx);
                if (stretchedChild == dw)
                {
                    stretchedChild       = Children [idx];
                    stretchedChild.Width = stretchedChild.Height = Measure.Stretched;
                }
            }
            else
            {
                RemoveChild(idx - 1);
                if (stretchedChild == dw)
                {
                    stretchedChild       = Children [idx - 2];
                    stretchedChild.Width = stretchedChild.Height = Measure.Stretched;
                }
            }

            if (Children.Count == 1)
            {
                DockStack dsp = Parent as DockStack;
                if (dsp == null)
                {
                    Children [0].Width = Children [0].Height = Measure.Stretched;
                    return;
                }
                //remove level and move remaining obj to level above
                GraphicObject g = Children [0];
                RemoveChild(g);
                idx = dsp.Children.IndexOf(this);
                dsp.RemoveChild(this);
                dsp.InsertChild(idx, g);
                g.Width  = this.Width;
                g.Height = this.Height;
                if (dsp.stretchedChild == this)
                {
                    dsp.stretchedChild = g;
                }
                dsp.checkAlignments();
            }
            else
            {
                checkAlignments();
            }
        }
Exemplo n.º 2
0
        public void Dock(DockStack target)
        {
            lock (IFace.UpdateMutex) {
                IsDocked = true;
                //undockingMousePosOrig = lastMousePos;
                savedSlot    = this.LastPaintedSlot;
                wasResizable = Resizable;
                Resizable    = false;
                LastSlots    = LastPaintedSlot = Slot = default(Rectangle);
                Left         = Top = 0;

                IFace.RemoveWidget(this);

                target.Dock(this);
            }
        }
Exemplo n.º 3
0
        public void Undock()
        {
            lock (IFace.UpdateMutex) {
                DockStack ds = Parent as DockStack;
                ds.Undock(this);

                IFace.AddWidget(this);

                this.Left   = savedSlot.Left;
                this.Top    = savedSlot.Top;
                this.Width  = savedSlot.Width;
                this.Height = savedSlot.Height;

                IsDocked        = false;
                DockingPosition = Alignment.Undefined;
                Resizable       = wasResizable;
            }
        }
Exemplo n.º 4
0
        public void Dock(DockWindow dw)
        {
            DockStack activeStack = this;

            if (Children.Count == 1)
            {
                Orientation = dw.DockingPosition.GetOrientation();
                if (Children [0] is DockWindow)
                {
                    (Children [0] as DockWindow).DockingPosition = dw.DockingPosition.GetOpposite();
                }
            }
            else if (Children.Count > 0 && dw.DockingPosition.GetOrientation() != Orientation)
            {
                activeStack             = new DockStack(IFace);
                activeStack.Orientation = dw.DockingPosition.GetOrientation();
                activeStack.Width       = focusedChild.Width;
                activeStack.Height      = focusedChild.Height;
                int idx = Children.IndexOf(focusedChild);
                RemoveChild(focusedChild);
                focusedChild.Height = Measure.Stretched;
                focusedChild.Width  = Measure.Stretched;
                InsertChild(idx, activeStack);
                activeStack.AddChild(focusedChild);
                activeStack.stretchedChild = focusedChild;
                if (focusedChild is DockWindow)
                {
                    (focusedChild as DockWindow).DockingPosition = dw.DockingPosition.GetOpposite();
                }
                focusedChild = null;
            }

            Rectangle r         = ClientRectangle;
            int       vTreshold = (int)(r.Height * dockThresh);
            int       hTreshold = (int)(r.Width * dockThresh);

            Console.WriteLine("Docking {0} as {2} in {1}", dw.Name, activeStack.Name, dw.DockingPosition);
            switch (dw.DockingPosition)
            {
            case Alignment.Top:
                dw.Height = vTreshold;
                dw.Width  = Measure.Stretched;
                activeStack.InsertChild(0, dw);
                activeStack.InsertChild(1, new Splitter(IFace));
                break;

            case Alignment.Bottom:
                dw.Height = vTreshold;
                dw.Width  = Measure.Stretched;
                activeStack.AddChild(new Splitter(IFace));
                activeStack.AddChild(dw);
                break;

            case Alignment.Left:
                dw.Width  = hTreshold;
                dw.Height = Measure.Stretched;
                activeStack.InsertChild(0, dw);
                activeStack.InsertChild(1, new Splitter(IFace));
                break;

            case Alignment.Right:
                dw.Width  = hTreshold;
                dw.Height = Measure.Stretched;
                activeStack.AddChild(new Splitter(IFace));
                activeStack.AddChild(dw);
                break;

            case Alignment.Center:
                dw.Width = dw.Height = Measure.Stretched;
                AddChild(dw);
                stretchedChild = dw;
                break;
            }
        }