Пример #1
0
        protected override void OnShown(EventArgs e)
        {
            if (string.IsNullOrEmpty(this.Text))
            {
                //this.Text = WelClientConfig.SystemName + " " + WelClientConfig.SystemVersion + " " + WelClientConfig.UserName;
            }


            DockingTabPage tabPage = this.dockingTab.SelectedTabControl as DockingTabPage;

            if (null != tabPage)
            {
                foreach (Control control in tabPage.Controls)
                {
                    Form formTemp = control as Form;
                    if (null != formTemp)
                    {
                        Type       type = formTemp.GetType();
                        MethodInfo info = type.GetMethod("InitDockingTabTheme", BindingFlags.Instance | BindingFlags.NonPublic);
                        if (null != info)
                        {
                            info.Invoke(formTemp, new object[] { this.dockingTab });
                        }
                    }
                }
            }

            base.OnShown(e);
        }
Пример #2
0
        //*** Add 2009/07/09 End K.Misu
        #endregion

        #region Protected Methods
        protected override void OnControlAdded(ControlEventArgs e)
        {
            //コントロールの追加
            base.OnControlAdded(e);
            DockingTabPage tpCurrent = e.Control as DockingTabPage;

            if (null != tpCurrent)
            {
                listTabPages.Add(tpCurrent);
                nTabCount++;

                if (!_isTab && 1 < this.Controls.Count)
                {
                    DockingTabPage tpPrevious = null;
                    if (this.Controls.Count == 2)
                    {
                        tpPrevious = this.Controls[0] as DockingTabPage;
                    }
                    else
                    {
                        tpPrevious = this.Controls[this.Controls.Count - 2] as DockingTabPage;
                    }
                    int nLocationY = tpPrevious.Location.Y;
                    nLocationY         = tpPrevious.FolderOpened ? (nLocationY + nOpenHeight) : (nLocationY + nClosedHeight);
                    tpCurrent.Location = new Point(nLocationX, nLocationY);
                    tpCurrent.Focus();
                }
            }
        }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void popMenuExpandeAll_Click(object sender, EventArgs e)
 {
     if (dockingTab.IsTab)
     {
         dockingTab.IsTab = false;
         this.popMenu.Items["popMenuOpenAllPage"].Visible  = true;
         this.popMenu.Items["popMenuCloseAllPage"].Visible = true;
         this.popMenu.Items["popMenuExpandeAll"].Text      = "Expande All";
         foreach (Control c in dockingTab.Controls)
         {
             DockingTabPage captionPanel = c as DockingTabPage;
             if (null != captionPanel)
             {
                 captionPanel.MouseDown += new MouseEventHandler(captionPanel_MouseDown);
                 captionPanel.MouseUp   += new MouseEventHandler(captionPanel_MouseUp);
             }
         }
     }
     else
     {
         dockingTab.IsTab = true;
         this.popMenu.Items["popMenuOpenAllPage"].Visible  = false;
         this.popMenu.Items["popMenuCloseAllPage"].Visible = false;
         this.popMenu.Items["popMenuExpandeAll"].Text      = "Expande All";
     }
 }
Пример #4
0
        private void dockingTab_MouseDown(object sender, MouseEventArgs e)
        {
            if (MouseButtons.Right == e.Button)
            {
                dtpWantClose = this.dockingTab.TabControlFromPos(e.Location) as DockingTabPage;

                if (null != dtpWantClose)
                {
                    this.popMenu.Items["popMenuClose"].Visible = dtpWantClose.CanRedock;
                    //this.popMenu.Items["popMenuCloseOther"].Visible = dtpWantClose.CanRedock;

                    //if (dtpWantClose.BusinessName == WelConsts.DefaultFormName.WelTreeMenu)
                    //{
                    //    this.popMenu.Items["popMenuCloseOther"].Visible = true;
                    //}
                    //else
                    //{
                    //    this.popMenu.Items["popMenuCloseOther"].Visible = dtpWantClose.CanRedock;
                    //}
                    this.popMenu.Items["popMenuClose"].Enabled      = dtpWantClose.CanClose;
                    this.popMenu.Items["popMenuCloseOther"].Enabled = dtpWantClose.CanClose;
                    dockingTab.ContextMenuStrip = this.popMenu;
                }
            }
        }
Пример #5
0
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            //新規Window
            if (!DesignMode && MouseButtons.Left == e.Button)
            {
                DockingTabPage tp = TabControlFromPos(e.Location) as DockingTabPage;
                if (null != tp && !IsMouseOnArrow)
                {
                    //親が自動生成ドッキングフォームで最後の一枚の場合分離せず
                    //if (Parent is DockingForm)
                    //{
                    //    // dblclick時の動作は、切り離しのみに統一 Redockは行わない
                    //    //if (tp.OriginalParent != null && (Parent as Form).Modal == false)
                    //    //{
                    //    //    tp.OriginalParent.ReDockTabPage(tp);
                    //    //}
                    //}
                    if (tp.CanRedock && 1 < this.TabCount)
                    {
                        OpenNewTabPage(tp);
                    }

                    else if (null != tp && tp.Controls.Count > 0 && null != tp.Controls[0] && tp.Controls[0] is Form)
                    {
                        tp.Controls[0].Focus();
                    }
                }
            }
        }
Пример #6
0
        private void SetTabPageFocus(DockingTabPage currentProcessPage)
        {
            if (TabCount == 0)
            {
                if (Parent is DockingForm)
                {
                    ((DockingForm)Parent).Hide();
                    return;
                }
            }

            if (0 < TabCount && null != currentProcessPage)
            {
                if (-1 == nCurrentRemovedPageNo)
                {
                    this.SelectedTabControl = currentProcessPage;
                }
                else
                {
                    if (nCurrentRemovedPageNo == this.Controls.Count && 0 < nCurrentRemovedPageNo)
                    {
                        this.SelectedTabControl = this.Controls[this.Controls.Count - 1];
                    }
                    else
                    {
                        this.SelectedTabControl = this.Controls[nCurrentRemovedPageNo];
                    }
                }
            }
        }
Пример #7
0
        private void ResetPageLocationWhenRemoved(DockingTabPage currentProcessPage)
        {
            int nLocationY = 0;

            if (null != currentProcessPage && -1 != nCurrentRemovedPageNo)
            {
                nLocationY = this.Controls[0].Location.Y;
                if (0 == nCurrentRemovedPageNo)
                {
                    nLocationY = currentProcessPage.FolderOpened ? nLocationY - nOpenHeight : nLocationY - nClosedHeight;
                }
            }

            this.SuspendLayout();
            for (int i = 0; i < this.Controls.Count; i++)
            {
                DockingTabPage tpTemp = this.Controls[i] as DockingTabPage;
                if (null != tpTemp)
                {
                    tpTemp.Width    = this.Width - nScrollBarWith;
                    tpTemp.Height   = tpTemp.FolderOpened ? nOpenHeight : nClosedHeight;
                    tpTemp.Location = new Point(nLocationX, nLocationY);
                    nLocationY      = tpTemp.FolderOpened ? (nLocationY + nOpenHeight) : (nLocationY + nClosedHeight);
                }
            }
            this.ResumeLayout(false);
            this.PerformLayout();
            this.Invalidate();
        }
Пример #8
0
        /// <summary>
        /// タブを閉じる。
        /// </summary>
        /// <returns></returns>
        public bool CloseTabPage()
        {
            if (!this.CanRedock)
            {
                return(true);
            }

            for (int i = this.ChildTabPages.Count - 1; i >= 0; i--)
            {
                DockingTabPage item = this.ChildTabPages[i];
                if (!item.CloseTabPage())
                {
                    return(false);
                }
            }
            this.ChildTabPages.Clear();
            DockingTab tab = this.Parent as DockingTab;

            if (tab != null)
            {
                tab.SelectedTabControl = this;
            }
            this.IsClosing = true;
            bool result = CloseFormsInTabPage();

            this.IsClosing = false;
            return(result);
        }
Пример #9
0
        public void RemoveTabPage(DockingTabPage tp)
        {
            for (int i = 0; i < this.Controls.Count; i++)
            {
                if (object.Equals(tp, this.Controls[i]))
                {
                    nCurrentRemovedPageNo = i;
                    //*** Add Sta BugFix:0004187 2009/04/27 nitta
                    //無駄にループしているので追加
                    break;
                    //*** Add End BugFix:0004187 2009/04/27 nitta
                }
            }

            //*** Add Sta BugFix:0004187 2009/04/27 nitta
            tp.AutoScroll = false;
            //レイアウト編集のイベントが発生するため停止
            this.SuspendLayout();
            tp.SuspendLayout();
            tp.Hide();
            //*** Add End BugFix:0004187 2009/04/27 nitta

            Controls.Remove(tp);
            nCurrentRemovedPageNo = -1;

            //*** Add Sta BugFix:0004187 2009/04/27 nitta
            tp.ResumeLayout(true);
            this.ResumeLayout(true);
            //*** Add End BugFix:0004187 2009/04/27 nitta
        }
Пример #10
0
 /// <summary>
 /// タブを閉じる。
 /// </summary>
 /// <param name="cancelTabPage">キャンセルするタブ</param>
 /// <returns></returns>
 public bool CloseTabPage(DockingTabPage cancelTabPage)
 {
     for (int i = this.TabPages.Count - 1; i >= 0; i--)
     {
         DockingTabPage item = this.TabPages[i];
         if (cancelTabPage != null)
         {
             //キャンセル対象ならスキップ
             if (object.ReferenceEquals(item, cancelTabPage))
             {
                 continue;
             }
             //子にキャンセル対象があればスキップ
             else if (item.ContainsChildren(cancelTabPage))
             {
                 continue;
             }
         }
         if (!item.CloseTabPage())
         {
             return(false);
         }
     }
     if (cancelTabPage != null)
     {
         this.SelectedTabControl = cancelTabPage;
     }
     return(true);
 }
Пример #11
0
 private void popMenuCloseAllPage_Click(object sender, EventArgs e)
 {
     foreach (Control c in dockingTab.Controls)
     {
         DockingTabPage captionPanel = c as DockingTabPage;
         captionPanel.FolderOpened = false;
     }
 }
Пример #12
0
        private void dockingTab_ControlRemoved(object sender, ControlEventArgs e)
        {
            DockingTabPage captionPanel = e.Control as DockingTabPage;

            if (null != captionPanel)
            {
                captionPanel.MouseDown -= new MouseEventHandler(captionPanel_MouseDown);
                captionPanel.MouseUp   -= new MouseEventHandler(captionPanel_MouseUp);
            }
        }
Пример #13
0
        public void OpenNewTabPageAsDialog(DockingTabPage tp)
        {
            DockingForm df = new DockingForm();

            df.Size = new Size(this.Size.Width + SystemInformation.Border3DSize.Width * 2,
                               this.Size.Height + SystemInformation.CaptionHeight + SystemInformation.Border3DSize.Height * 2);
            df.DockingTab.ReDockTabPage(tp);
            df.Text = tp.Text;
            df.PerformLayout();
            df.ShowDialog();
        }
Пример #14
0
        public void ReDockTabPage(DockingTabPage tp)
        {
            if (tp.Parent is DockingTab)
            {
                DockingTab tabPanel = tp.Parent as DockingTab;
                //移動
                tabPanel.RemoveTabPage(tp);

                Controls.Add(tp);
                SelectedTabControl = tp;
            }
        }
Пример #15
0
        //*** Add 2009/07/09 Sta K.Misu
        /// <summary>
        /// 直系の親に指定したタブが含まれるか
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public bool ContainsParent(DockingTabPage parent)
        {
            if (this.ParentTabPage == null)
            {
                return(false);
            }

            if (object.ReferenceEquals(this.ParentTabPage, parent))
            {
                return(true);
            }
            return(this.ParentTabPage.ContainsParent(parent));
        }
Пример #16
0
        private void captionPanel_MouseDown(object sender, MouseEventArgs e)
        {
            if (MouseButtons.Right == e.Button)
            {
                dtpWantClose = sender as DockingTabPage;

                if (null != dtpWantClose)
                {
                    this.popMenu.Items["popMenuClose"].Visible      = dtpWantClose.CanRedock;
                    this.popMenu.Items["popMenuCloseOther"].Visible = dtpWantClose.CanRedock;
                    dtpWantClose.ContextMenuStrip = this.popMenu;
                }
            }
        }
Пример #17
0
 /// <summary>
 /// DragDropイベントを処理関数です。
 /// </summary>
 /// <param name="drgevent">イベントパラメータです。</param>
 protected override void OnDragDrop(DragEventArgs drgevent)
 {
     if (drgevent.Data.GetFormats().Length == 1)
     {
         DockingTabPage tp = drgevent.Data.GetData(drgevent.Data.GetFormats()[0]) as DockingTabPage;
         if (null != tp)
         {
             if (tp.CanRedock && tp.Parent is DockingTab && tp.Parent != this)
             {
                 //移動
                 ReDockTabPage(tp);
             }
         }
     }
 }
Пример #18
0
        /// <summary>
        /// DragOverイベントを処理関数です。
        /// </summary>
        /// <param name="drgevent">イベントパラメータです。</param>
        protected override void OnDragOver(DragEventArgs drgevent)
        {
            if (drgevent.Data.GetFormats().Length == 1)
            {
                DockingTabPage tp = drgevent.Data.GetData(drgevent.Data.GetFormats()[0]) as DockingTabPage;
                if (null != tp)
                {
                    if (tp.CanRedock && tp.Parent is DockingTab && tp.Parent != this)
                    {
                        drgevent.Effect = drgevent.AllowedEffect;
                    }
                }
            }

            base.OnDragOver(drgevent);
        }
Пример #19
0
        protected override void OnControlRemoved(ControlEventArgs e)
        {
            base.OnControlRemoved(e);

            DockingTabPage tp = e.Control as DockingTabPage;

            if (null != tp)
            {
                listTabPages.Remove(tp);
                nTabCount--;

                if (!_isTab && 0 < this.Controls.Count)
                {
                    ResetPageLocationWhenRemoved(tp);
                }
                SetTabPageFocus(tp);
            }
        }
Пример #20
0
 protected override void TabSetting(Control c)
 {
     if (IsTab)
     {
         c.Visible = false;
         c.Dock    = DockStyle.Fill;
         CaptionBasePanel cp = c as CaptionBasePanel;
         if (cp != null)
         {
             cp.TextVisible          = false;
             cp.FolderOpened         = true;
             cp.FolderOpenedChanged -= new EventHandler <EventArgs>(cp_FolderOpenedChanged);
             DockingTabPage it = c as DockingTabPage;
             if (it != null)
             {
                 it.MainControl.AutoSize = false;
             }
         }
     }
     else
     {
         CaptionBasePanel cp = c as CaptionBasePanel;
         if (cp != null)
         {
             cp.TextVisible          = true;
             cp.FolderOpened         = false;
             cp.FolderOpenedChanged += new EventHandler <EventArgs>(cp_FolderOpenedChanged);
             DockingTabPage it = c as DockingTabPage;
             if (it != null)
             {
                 it.MainControl.AutoSize = false;
             }
         }
         c.Dock = DockStyle.None;
         if (c.Enabled)
         {
             c.Visible = true;
         }
         else
         {
             c.Visible = false;
         }
     }
 }
Пример #21
0
 /// <summary>
 /// 子に指定したタブが含まれるか
 /// </summary>
 /// <param name="child"></param>
 /// <returns></returns>
 public bool ContainsChildren(DockingTabPage child)
 {
     if (this.ChildTabPages.Count == 0)
     {
         return(false);
     }
     foreach (DockingTabPage item in this.ChildTabPages)
     {
         if (object.ReferenceEquals(item, child))
         {
             return(true);
         }
         if (item.ContainsChildren(child))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #22
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (!DesignMode)
            {
                if (e.Button == MouseButtons.Left)
                {
                    DockingTabPage tp = this.SelectedTabControl as DockingTabPage;
                    if (null != tp)
                    {
                        if (tp.CanRedock)
                        {
                            this.DoDragDrop(this.SelectedTabControl, DragDropEffects.Move);
                        }
                    }
                }
            }
        }
Пример #23
0
        private void cp_FolderOpenedChanged(object sender, EventArgs e)
        {
            if (!_isTab)
            {
                DockingTabPage tpCurrent  = sender as DockingTabPage;
                int            nCurrentNo = -1;

                if (tpCurrent.FolderOpened)
                {
                    tpCurrent.Height = nOpenHeight;
                }
                else
                {
                    tpCurrent.Height = nClosedHeight;
                }
                tpCurrent.Width = this.Width - nScrollBarWith;

                for (int i = 0; i < this.Controls.Count; i++)
                {
                    if (object.Equals(tpCurrent, this.Controls[i]))
                    {
                        nCurrentNo = i;
                    }
                    if (-1 != nCurrentNo && i > nCurrentNo)
                    {
                        if (tpCurrent.FolderOpened)
                        {
                            this.Controls[i].Location = new Point(nLocationX,
                                                                  this.Controls[i].Location.Y + nOpenHeight - nClosedHeight);
                        }
                        else
                        {
                            this.Controls[i].Location = new Point(nLocationX,
                                                                  this.Controls[i].Location.Y - nOpenHeight + nClosedHeight);
                        }
                    }
                }
            }
        }
Пример #24
0
 //*** Add 2009/07/09 End K.Misu
 //*** Add 2009/07/06 Sta K.Misu
 /// <summary>
 /// TabPageを閉じます。
 /// </summary>
 protected bool CloseFormsInTabPage()
 {
     foreach (Control control in this.Controls)
     {
         Form formTemp = control as Form;
         if (null != formTemp)
         {
             bool bIsClosable = true;
             //this.IsCloseMessageShown = false;
             Type       type = formTemp.GetType();
             MethodInfo info = type.GetMethod("ProcessClose", BindingFlags.Instance | BindingFlags.NonPublic);
             if (null != info)
             {
                 bIsClosable = (bool)info.Invoke(formTemp, null);
             }
             //ProcessCloseがTrueならBusinessFormのMainCloseが既に処理されているので
             //絶対にCloseしないといけない。
             if (bIsClosable)
             {
                 //this.IsCloseMessageShown = true;
                 formTemp.Close();
                 //this.IsCloseMessageShown = false;
             }
             if (!bIsClosable)
             {
                 return(false);
             }
         }
     }
     if (this.Parent is DockingTab)
     {
         DockingTab dtpParent = this.Parent as DockingTab;
         dtpParent.SuspendLayout();
         this.SuspendLayout();
         dtpParent.RemoveTabPage(this);
         dtpParent.ResumeLayout(true);
         if (dtpParent.TabPages.Count > 0)
         {
             DockingTabPage selectTabPage = null;
             if (this.ParentTabPage != null && dtpParent.TabPages.Contains(this.ParentTabPage))
             {
                 selectTabPage = this.ParentTabPage;
             }
             else
             {
                 selectTabPage = dtpParent.TabPages[dtpParent.TabPages.Count - 1];
             }
             dtpParent.SelectedTabControl = selectTabPage;
         }
         if (this.ParentTabPage != null)
         {
             if (this.ParentTabPage.ChildTabPages.Contains(this))
             {
                 this.ParentTabPage.ChildTabPages.Remove(this);
             }
             this.ParentTabPage = null;
         }
         this.Dispose();
     }
     return(true);
 }