예제 #1
0
        private bool ChangePage(int prevPageIndex, int nextPageIndex)
        {
            //nextPageはBeforePageChangeイベントハンドラにて変更される可能性があるため、変数にする
            int nextPageIndex2 = nextPageIndex;

            BeforePageChangeEventArgs e = new BeforePageChangeEventArgs(prevPageIndex, nextPageIndex2);

            this.OnBeforePageChange(e);

            //変更されたNextPageの検証
            bool validNextPage = (0 <= nextPageIndex2 && nextPageIndex2 < this.TabPages.Count);
            //終了判定
            bool finishedPage = (nextPageIndex2 == -1);

            //Page変更しない場合、falseを返す
            if (e.Cancel || (!validNextPage && !finishedPage))
            {
                return(false);
            }

            //遷移条件のリセット
            this.m_CanGoBack = true;
            this.m_CanGoNext = true;
            this.m_CanCancel = true;

            //===========================================
            //現在表示しているページを元に戻す
            if (0 <= prevPageIndex)
            {
                TabPage prevPage = this.TabPages[prevPageIndex];
                prevPage.Controls.Add(this.m_CurrentPanel);
            }

            //===========================================
            if (validNextPage)
            {
                TabPage nextPage = this.TabPages[nextPageIndex2];
                //次に表示するページの状態確認
                if (nextPage.Controls.Count != 1)
                {
                    this.InitializePage(nextPage);
                }
                this.m_CurrentPanel  = nextPage.Controls[0] as Panel;
                this.m_CurrentStepNo = nextPageIndex2;

                //---------------------------------
                this.SuspendLayout();
                this.MainPanel.SuspendLayout();

                this.m_CurrentPanel.Dock = DockStyle.Fill;

                this.MainPanel.Controls.Add(this.m_CurrentPanel);
                this.MainPanel.ResumeLayout();
                this.ResumeLayout();
                //---------------------------------
            }

            this.ChangeButtonStatus();

            this.OnAfterPageChange(new AfterPageChangeEventArgs(prevPageIndex, nextPageIndex2));

            return(true);
        }
예제 #2
0
 /// <summary>
 /// BeforePageChangeイベントを発生させます。
 /// </summary>
 /// <param name="e"></param>
 protected void OnBeforePageChange(BeforePageChangeEventArgs e)
 {
     this.BeforePageChange?.Invoke(this, e);
 }