コード例 #1
0
 internal int getChildWidth(DockingContainer child)
 {
     if (this.getContainerType() == ContainerType.TabContents)
     {
         return(this._tabContainer.Width);
     }
     else if (this.getContainerType() == ContainerType.SplitContents)
     {
         if (child == _sContainer.Panel1.Controls[0])
         {
             return(_sContainer.SplitterDistance);
         }
         else
         {
             if (_sContainer.Orientation == Orientation.Vertical)
             {
                 return(_sContainer.Width - _sContainer.SplitterDistance);
             }
             else
             {
                 return(_sContainer.Height - _sContainer.SplitterDistance);
             }
         }
     }
     else
     {
         //this is not possible
         return(this.Width);
     }
 }
コード例 #2
0
        public override void addChild(DockingContainer child, DockStyle dock, bool isRemainSize = true)
        {
            if (_id == _initContentId)
            {
                this.Controls.Remove(_initObj);
                Content = child;
                this.Controls.Add(child);
                child.Dock = DockStyle.Fill;
                //this.Name = child.Name;
                //this._id = child._id;
                //showTitleBar(true);
                this.setContainerType(ContainerType.SingleContent);

                /*
                 * this.Controls.Remove(_initObj);
                 * Content = child.Content;
                 * this.Controls.Add(child.Content);
                 * this.Name = child.Name;
                 * this._id = child._id;
                 * showTitleBar(true);
                 * setType( = ContainerType.SingleContent;
                 */
            }
            else
            {
                base.addChild(child, dock, isRemainSize);
            }
        }
コード例 #3
0
        public DockingContainer(DockingRoot root, DockingContainer parent, String name, Control contents, int id, DockStyle initDock) : base()
        {
            if (root != null)
            {
                _root = root;
            }
            else
            {
                _root = this as DockingRoot;
            }
            _initDock      = initDock;
            _parent        = parent;
            Content        = contents;
            this.Name      = name;
            _draggingPopup = new DraggingPopup(_root, null); //평소에는 숨어있다가 Drag할 때에만 나타난다.
            _titleBar      = new TitleBar(this, _draggingPopup, _root);
            InitializeComponent();


            this.Width    = Content.Width;
            this.Height   = Content.Height;
            this.Location = new Point(0, 0);
            this._tabContainer.SetBounds(0, 0, this.Width, this.Height);
            this._tabContainer.Alignment             = TabAlignment.Bottom;
            this._tabContainer.SelectedIndexChanged += new EventHandler(_tabContainer_SelectedIndexChanged);
            this._sContainer.SetBounds(0, 0, this.Width, this.Height);
            _id = id;
            this.DoubleBuffered = true;

            // _draggingPopup.MdiParent = _root.getMdiForm();


            //if(Content!=null) Content.Resize += new EventHandler(_contents_Resize);


            this.SuspendLayout();

            titleBarInitSetting();

            Content.Location = new Point(0, _titleBar.Height);
            contents.Dock    = DockStyle.Fill;
            this.Controls.Add(contents);

            this.ResumeLayout();

            showTitleBar(true, name);

            this.Dock = DockStyle.Fill;
            if (_root != this)
            {
                _root.Connect(this.Name, this);
            }


            _tabContainer.TabIndexChanged += new EventHandler(_tabContainer_TabIndexChanged);
        }
コード例 #4
0
        void DockItOn(DockingContainer popup)
        {
            DockingContainer dockParent = _selectedDockingContainer;

            IconCenter.ButtonPosition pos = _posToDock;

            if (pos == IconCenter.ButtonPosition.NotOnTheButton)
            {
                return;
            }

            switch (pos)
            {
            case IconCenter.ButtonPosition.B_BottomHalf:
                dockParent.addChild(popup, DockStyle.Bottom);
                break;

            case IconCenter.ButtonPosition.B_BottomRemain:
                dockParent.addChild(popup, DockStyle.Bottom, true);
                break;

            case IconCenter.ButtonPosition.B_Center:
                dockParent.addChild(popup, DockStyle.Fill);
                break;

            case IconCenter.ButtonPosition.B_LeftHalf:
                dockParent.addChild(popup, DockStyle.Left);
                break;

            case IconCenter.ButtonPosition.B_LeftRemain:
                dockParent.addChild(popup, DockStyle.Left, true);
                break;

            case IconCenter.ButtonPosition.B_RightHalf:
                dockParent.addChild(popup, DockStyle.Right);
                break;

            case IconCenter.ButtonPosition.B_RightRemain:
                dockParent.addChild(popup, DockStyle.Right, true);
                break;

            case IconCenter.ButtonPosition.B_TopHalf:
                dockParent.addChild(popup, DockStyle.Top);
                break;

            case IconCenter.ButtonPosition.B_TopRemain:
                dockParent.addChild(popup, DockStyle.Top, true);
                break;
            }
            this.Connect(popup.Name, popup);
            popup.setNowInPopup(false);
            popup.hidePopup();

            this.Refresh();
        }
コード例 #5
0
        internal void DragEnd(DockingContainer movingObj, int x, int y)
        {
            _iconCenter.Hide();
            _selection.Hide();
            foreach (Control c in _iconSide)
            {
                c.Hide();
            }

            DockItOn(movingObj);
        }
コード例 #6
0
 void addToTab(Sides side, DockingContainer child)
 {
     if (child.getContainerType() == ContainerType.SingleContent)
     {
         addAChildWithSingleContentToTabContainer(_tabSide[(int)side], child);
     }
     else //tabContents
     {
         addAChildWithTabContentToTabContainer(_tabSide[(int)side], child);
     }
 }
コード例 #7
0
 internal DraggingPopup(DockingRoot root, DockingContainer parent, int no = -1, String name = "DockingForm")
     : base((no < 0) ? ++(DraggingPopup.windowId) : no, name)
 {
     InitializeComponent();
     _root = root;
     if (_parent != null)
     {
         _parent = parent;
     }
     _draggingEvent = new MouseEventHandler(DraggingPopup_MouseMove);
 }
コード例 #8
0
        internal void addAChildWithSingleContentToTabContainer(TabControl container, DockingContainer child)
        {
            container.TabPages.Add(child.Name, child.Name);
            child.SetBounds(0, 0, container.Width, container.Height - TITLE_BAR_HEIGHT);
            container.TabPages[child.Name].Controls.Add(child.Content);
            container.TabPages[child.Name].Tag    = child._id;
            container.TabPages[child.Name].Width  = container.Width;
            container.TabPages[child.Name].Height = container.Height - 20;

            _childId.Add(child.Name, child._id);
            _root.Disconnect(child.Name);
        }
コード例 #9
0
        void addChildOnCenter(DockingContainer child)
        {
            child.SetBounds(0, 0, this.Width, this.Height);

            if (this.getContainerType() == ContainerType.SingleContent) //(Content is TabControl) == false)
            {
                _tabContainer.TabPages.Add(this.Name, this.Name);       //insert current content to tab
                this.Content.Dock = DockStyle.Fill;
                this.Content.SetBounds(0, 0, this.Width, this.Height);
                _tabContainer.TabPages[this.Name].Controls.Add(this.Content);
                _tabContainer.TabPages[this.Name].Tag = this._id;
                _childId.Add(this.Name, this._id);
                //_childId.Add(child.Name, child._id);
                if (child.getContainerType() == ContainerType.SingleContent)
                {
                    addAChildWithSingleContentToTabContainer(_tabContainer, child);
                }
                else //else TabContents
                {
                    addAChildWithTabContentToTabContainer(_tabContainer, child);
                }

                //this.Controls.Remove(Content);

                _tabContainer.Height = this.Height - TITLE_BAR_HEIGHT;
                _tabContainer.Width  = this.Width;
                _tabContainer.Dock   = DockStyle.Fill;

                Content = _tabContainer;

                this.Controls.Add(_tabContainer);

                showTitleBar(true, _tabContainer.TabPages[0].Name);
            }
            else //else TabContents
            {
                if (child.getContainerType() == ContainerType.SingleContent)
                {
                    addAChildWithSingleContentToTabContainer(_tabContainer, child);
                }
                else //else TabContents
                {
                    addAChildWithTabContentToTabContainer(_tabContainer, child);
                }
            }
            //_root.Disconnect(child.Name);
            this.setContainerType(ContainerType.TabContents);
            //this.Name = child.Name; //가장 최근에 선택된 tab의 이름을 가져온다.
            //this._id = _childId[child.Name];
            showTitleBar(true, child.Name);
            _tabContainer.SelectTab(child.Name);
        }
コード例 #10
0
        public virtual void addChild(DockingContainer child, DockStyle dock, Boolean isRemainSize = true)
        {
            child.setParent(this);

            if (dock == DockStyle.Fill)
            {
                addChildOnCenter(child);
            }
            else
            {
                addChildOnSide(dock, child, isRemainSize);
            }
        }
コード例 #11
0
        internal void addAChildWithTabContentToTabContainer(TabControl container, DockingContainer child)
        {
            String name = "";

            foreach (TabPage c in child.TabContainer.TabPages)
            {
                container.TabPages.Add(c);
                _childId.Add(c.Name, Int32.Parse(c.Tag.ToString()));
                c.Width  = container.Width;
                c.Height = container.Height - 20;
                name     = c.Name;
            }
            _root.Disconnect(child.Name);
        }
コード例 #12
0
 public Boolean setContent(DockingContainer c = null)
 {
     if (_parent == c)
     {
         return(false);
     }
     //this.SuspendLayout();
     this.Padding = new Padding(5);
     if (c != null)
     {
         _parent = c;
     }
     this.Controls.Add(_parent);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     //this.ResumeLayout();
     return(true);
 }
コード例 #13
0
        internal TitleBar(DockingContainer parent, DraggingPopup popup, DockingRoot root)
            : base()
        {
            InitializeComponent();
            _parent    = parent;
            _popup     = popup;
            _root      = root;
            _mouseDown = new MouseEventHandler(TitleBar_MouseDown);
            _mouseUp   = new MouseEventHandler(TitleBar_MouseUp);
            _mouseMove = new MouseEventHandler(TitleBar_MouseMove);

            this.Text          = parent.Name;
            B_X.Click         += new EventHandler(B_X_Click);
            B_Pin.Click       += new EventHandler(B_Pin_Click);
            B_DownArrow.Click += new EventHandler(B_DownArrow_Click);
            this.MouseDown    += _mouseDown;
            //this.MouseMove += _mouseMove;
        }
コード例 #14
0
 internal void reSizeSplitDistanceForChild(DockingContainer child, int size) //child 에서 크기조정을 요청할 때 호출된다.
 {
     if (_sContainer.Panel1.Controls[0] == child)
     {
         _sContainer.SplitterDistance = size;
     }
     else
     {
         if (_sContainer.Orientation == Orientation.Horizontal)
         {
             _sContainer.SplitterDistance = this.Width - size;
         }
         else
         {
             _sContainer.SplitterDistance = this.Height - size;
         }
     }
 }
コード例 #15
0
        internal void addToTab(DockingContainer child, DockStyle dock)
        {
            switch (dock)
            {
            case DockStyle.Left:
                addToTab(Sides.Left, child);
                break;

            case DockStyle.Right:
                addToTab(Sides.Right, child);
                break;

            case DockStyle.Top:
                addToTab(Sides.Top, child);
                break;

            case DockStyle.Bottom:
                addToTab(Sides.Bottom, child);
                break;
            }
        }
コード例 #16
0
        internal void Dragging(DockingContainer movingObj, int x, int y)
        {
            int maxDepth = 0;
            int depth;
            DockingContainer selectedSuccessor = null;

            this.Invalidate();
            foreach (DockingContainer d in _successors.Values)
            {
                //for (int i = 0; i < _successors.Count; i++)
                //{

                if (CoodinateHandling.isEntered(d, 0, 0) && d.isInPopup() == false)
                {
                    if ((depth = d.getDepth()) > maxDepth)
                    {
                        maxDepth          = depth;
                        selectedSuccessor = d;
                    }
                }
            }
            if (maxDepth > 0)
            {
                Rectangle rect   = CoodinateHandling.FromClientToClient(selectedSuccessor, this);
                Point     center = CoodinateHandling.getCenter(rect, _iconCenter.Width, _iconCenter.Height);

                ShowSelection(checkIfOverCenterBtns(), selectedSuccessor, movingObj);
                _iconCenter.SetBounds(center.X, center.Y, 0, 0, BoundsSpecified.Location);
                _iconCenter.Show();
                _iconCenter.BringToFront();
                _iconCenter.label1.Text = "" + selectedSuccessor.getDepth() + "/" + selectedSuccessor.Name + "/" + selectedSuccessor.getContainerType().ToString();
            }
            else
            {
                _selection.Hide();
            }
        }
コード例 #17
0
        protected virtual void PopChildFromThis(DockingContainer child)
        {
            //this.SuspendLayout();
            if (this.getContainerType() == ContainerType.SplitContents)
            {
                DockingContainer rest;
                if (_sContainer.Panel1.Controls.Count == 0 || (_sContainer.Panel1.Controls[0] as DockingContainer) == child)
                {
                    rest = _sContainer.Panel2.Controls[0] as DockingContainer;
                    _sContainer.Panel1.Controls.Clear();
                }
                else
                {
                    rest = _sContainer.Panel1.Controls[0] as DockingContainer;
                    _sContainer.Panel2.Controls.Clear();
                }

                this.Controls.Remove(_sContainer);
                //_sContainer.Dispose();


                if (rest.getContainerType() == ContainerType.SingleContent)
                {
                    Content = rest.Content;
                    //rest.Content = null;
                    Content.Dock = DockStyle.Fill;
                    this.Controls.Add(Content);
                    this._id = rest._id;
                    _children.Clear();
                    _childId.Clear();
                    this.Name = rest.Name;
                    showTitleBar(true, rest.Name);
                    _root.Disconnect(rest.Name);    //기존의 rest는 사라질 것이므로 연결을 끊고
                    _root.Connect(rest.Name, this); //rest의 모든 내용을 계승한 this를 대신 연결한다.

                    this.setContainerType(ContainerType.SingleContent);
                }
                else if (rest.getContainerType() == ContainerType.TabContents)
                {
                    //_tabContainer.Dispose();
                    _tabContainer = rest._tabContainer;
                    _tabContainer.SetBounds(0, 0, this.Width, this.Height - TITLE_BAR_HEIGHT);
                    _tabContainer.Dock = DockStyle.Bottom;

                    //rest._tabContainer = null;
                    _children = rest._children;
                    //rest._children = null;
                    _childId = rest._childId;
                    //rest._childId = null;
                    Content = _tabContainer;
                    this.Controls.Add(_tabContainer);

                    this.Name = rest.Name;
                    showTitleBar(true, rest.Name);

                    _root.Disconnect(rest.Name);    //기존의 rest는 사라질 것이므로 연결을 끊고
                    _root.Connect(rest.Name, this); //rest의 모든 내용을 계승한 this를 대신 연결한다.

                    setContainerType(ContainerType.TabContents);
                }
                else //splitContainer - splitContainer는 _root와 연결되어 있지 않으므로 connection을 끊을 필요가 없다.
                {
                    _sContainer        = rest._sContainer;
                    _sContainer.Width  = this.Width;
                    _sContainer.Height = this.Height;
                    _sContainer.Dock   = DockStyle.Fill;
                    //rest._sContainer = null;
                    _children = rest._children;
                    //rest._children = null;
                    _childId = rest._childId;
                    //rest._childId = null;
                    Content = _sContainer;
                    this.Controls.Add(rest._sContainer);
                    //showTitleBar(true, rest.Name);

                    setContainerType(ContainerType.SplitContents);
                }
            }
            else // ContainerType 이 SingleType일 때이다.
            {
                this.Controls.Remove(child);
                this.Content = null;
                if (OnBlankContent != null)
                {
                    OnBlankContent();
                }
                setContainerType(ContainerType.SingleContent);
            }
            // this.ResumeLayout();
            //child.Dispose(true);
        }
コード例 #18
0
        void addChildOnSide(DockStyle newChildDock, DockingContainer newChild, Boolean isRemainSize)
        {
            showTitleBar(false, "");
            _root.Disconnect(this.Name); //새로운 것을 만들고 자기 자신은 루트와의 연결을 끊는다.
            // SplitContainer가 되면 titleBar가 사라진다.
            DockingContainer oldChild = new DockingContainer(_root, this, this.Name, Content, _id, _initDock);

            oldChild._type    = this._type;
            oldChild._childId = this._childId;
            _id            = -1; //컨테이너만 가지고 있을 것이므로 선택된 id가 없다.
            _titleBar.Text = "";

            this._childId = new Dictionary <String, int>(); //연결을 끊고 새로운 id List를 만든다.
            _tabContainer = new TabControl();               //연결을 끊고 새로운 TabContainer를 만든다.

            //orientation을 선택한다.
            int newSize, oldSize, parentSize;

            if (newChildDock == DockStyle.Left || newChildDock == DockStyle.Right)
            {
                newSize = newChild.Width;
                oldSize = this.Width;
                if (_parent == null)
                {
                    parentSize = this.Width;                  //parent가 null인 경우는 root일 경우.
                }
                else
                {
                    parentSize = _parent.Width;
                }
                _sContainer.Orientation = Orientation.Vertical;
            }
            else
            {
                newSize = newChild.Height;
                oldSize = this.Height;
                if (_parent == null)
                {
                    parentSize = this.Height;
                }
                else
                {
                    parentSize = _parent.Height;
                }
                _sContainer.Orientation = Orientation.Horizontal;
            }
            this.SuspendLayout();

            if (newChildDock == DockStyle.Left || newChildDock == DockStyle.Top)
            {
                _sContainer.Panel1.Controls.Add(newChild);
                _sContainer.Panel2.Controls.Add(oldChild);
                this._children.Add(newChild);
                this._children.Add(oldChild);
                this._sContainer.SplitterDistance = newSize;
            }
            else
            {
                _sContainer.Panel1.Controls.Add(oldChild);
                _sContainer.Panel2.Controls.Add(newChild);
                this._children.Add(oldChild);
                this._children.Add(newChild);
                this._sContainer.SplitterDistance = oldSize;
            }

            //크기 조정을 한다.
            if (isRemainSize)
            {
                if (parentSize < newSize + oldSize)
                {
                    newSize = oldSize = oldSize / 2; //부모에게 크기 조정 요청할 필요 없음.
                }
                else
                {
                    if (_root != this)
                    {
                        _parent.reSizeSplitDistanceForChild(this, newSize + oldSize);
                    }
                    else
                    {
                        throw new Exception("예상치 못한 상황. 루트이면서 부모의 크기보다 작다?");  //이런 상황 없음
                    }
                }
            }
            else
            {
                newSize = oldSize = oldSize / 2; //부모에게 크기 조정 요청할 필요 없음.
            }

            if (newChildDock == DockStyle.Left || newChildDock == DockStyle.Top)
            {
                this._sContainer.SplitterDistance = newSize;
            }
            else
            {
                this._sContainer.SplitterDistance = oldSize;
            }

            this.Controls.Remove(Content);
            Content = _sContainer;
            this.Controls.Add(_sContainer);
            this.setContainerType(ContainerType.SplitContents);

            this.Name = "";
            this.ResumeLayout();
        }
コード例 #19
0
 void checkInHotArea(DockingContainer movingObj, int x, int y)
 {
 }
コード例 #20
0
 internal void setParent(DockingContainer parent)
 {
     _parent = parent;
 }
コード例 #21
0
        void ShowSelection(IconCenter.ButtonPosition pos, DockingContainer dockParent, DockingContainer popup)
        {
            if (pos == IconCenter.ButtonPosition.NotOnTheButton)
            {
                _selection.Hide();
                return;
            }
            _selectedDockingContainer = dockParent;
            _posToDock = pos;
            Size      popupSize     = popup.ClientSize;
            Rectangle dockScreen    = CoodinateHandling.GetScreenRect(dockParent);
            Size      parentSize    = dockParent.Parent.ClientSize;
            Rectangle selectionRect = new Rectangle(dockScreen.Location, dockScreen.Size);

            switch (pos)
            {
            case IconCenter.ButtonPosition.B_BottomHalf:
                selectionRect.Y += selectionRect.Height = dockScreen.Height / 2;
                break;

            case IconCenter.ButtonPosition.B_BottomRemain:
                if (dockScreen.Height + popupSize.Height > parentSize.Height)
                {
                    selectionRect.Y += selectionRect.Height = dockScreen.Height / 2;
                }
                else
                {
                    selectionRect.Height = popupSize.Height;
                    selectionRect.Y     += dockScreen.Height - popupSize.Height;
                }
                break;

            case IconCenter.ButtonPosition.B_Center:
                //그대로
                break;

            case IconCenter.ButtonPosition.B_LeftHalf:
                selectionRect.Width /= 2;
                break;

            case IconCenter.ButtonPosition.B_LeftRemain:
                if (dockScreen.Width + popupSize.Width > parentSize.Width)
                {
                    selectionRect.Width /= 2;
                }
                else
                {
                    selectionRect.Width = popupSize.Width;
                }
                break;

            case IconCenter.ButtonPosition.B_RightHalf:
                selectionRect.X += selectionRect.Width = selectionRect.Width / 2;
                break;

            case IconCenter.ButtonPosition.B_RightRemain:
                if (dockScreen.Width + popupSize.Width > parentSize.Width)
                {
                    selectionRect.Width /= 2;
                }
                else
                {
                    selectionRect.Width = popupSize.Width;
                }
                selectionRect.X += dockScreen.Width - selectionRect.Width;
                break;

            case IconCenter.ButtonPosition.B_TopHalf:
                selectionRect.Height /= 2;
                break;

            case IconCenter.ButtonPosition.B_TopRemain:
                if (dockScreen.Height + popupSize.Height > parentSize.Height)
                {
                    selectionRect.Height = selectionRect.Height /= 2;
                }
                else
                {
                    selectionRect.Height = popupSize.Height;
                }
                break;

            case IconCenter.ButtonPosition.NotOnTheButton:
                _selection.Hide();
                break;
            }
            _selection.SetBounds(selectionRect.X, selectionRect.Y, selectionRect.Width, selectionRect.Height);
            _selection.Show();
            _selection.BringToFront();
            this.Refresh();
        }
コード例 #22
0
 internal void DragBegin(DockingContainer movingObj, int x, int y)
 {
     showSideIcon();
 }
コード例 #23
0
 protected override void PopChildFromThis(DockingContainer child)
 {
     base.PopChildFromThis(child);
 }
コード例 #24
0
 internal void Connect(String name, DockingContainer aSuccessor)
 {
     _successors.Add(name, aSuccessor);
 }