示例#1
0
 public void ChangePage(MainFormPage page)
 {
     BasePanel oldPage = CurrPage;
        switch (page)
        {
     case MainFormPage.Scheduler:
      CurrPage = SchedulerPage;
      break;
     case MainFormPage.Settings:
      CurrPage = SettingsPage;
      break;
        }
        if (oldPage != CurrPage)
        {
     contentPanel.SuspendLayout();
     if (oldPage != null)
      oldPage.Visible = false;
     if (CurrPage.Dock == DockStyle.None)
     {
      CurrPage.Anchor = AnchorStyles.Left | AnchorStyles.Right |
       AnchorStyles.Top;
      CurrPage.Left = 0;
      CurrPage.Top = 0;
      CurrPage.Width = contentPanel.Width;
     }
     CurrPage.Visible = true;
     CurrPage.BringToFront();
     contentPanel.ResumeLayout();
        }
 }
示例#2
0
 public void ChangePage(MainFormPage page)
 {
     BasePanel oldPage = CurrPage;
        switch (page)
        {
     case MainFormPage.Scheduler:
      CurrPage = SchedulerPage;
      break;
     case MainFormPage.Settings:
      CurrPage = SettingsPage;
      break;
        }
        if (oldPage != CurrPage)
        {
     contentPanel.SuspendLayout();
     contentPanel.Controls.Remove(oldPage);
     contentPanel.Controls.Add(CurrPage);
     if (CurrPage.Dock == DockStyle.None)
     {
      CurrPage.Anchor = AnchorStyles.Left | AnchorStyles.Right |
       AnchorStyles.Top;
      CurrPage.Left = 0;
      CurrPage.Top = 0;
      CurrPage.Width = contentPanel.Width;
     }
     contentPanel.ResumeLayout();
        }
 }
示例#3
0
        /// <summary>
        /// Changes the active page displayed in the form.
        /// </summary>
        /// <param name="page">The new page to change to. No action is done when the
        /// current page is the same as the new page requested</param>
        public void ChangePage(MainFormPage page)
        {
            BasePanel oldPage = CurrPage;

            switch (page)
            {
            case MainFormPage.Scheduler:
                CurrPage = SchedulerPage;
                break;

            case MainFormPage.Settings:
                CurrPage = SettingsPage;
                break;
            }

            if (oldPage != CurrPage)
            {
                contentPanel.SuspendLayout();

                //Hide the old page before showing the new one
                if (oldPage != null)
                {
                    oldPage.Visible = false;
                }

                //If the page is not set to dock, we need to specify the dimensions of the page
                //so it fits properly.
                if (CurrPage.Dock == DockStyle.None)
                {
                    CurrPage.Anchor = AnchorStyles.Left | AnchorStyles.Right |
                                      AnchorStyles.Top;
                    CurrPage.Left  = 0;
                    CurrPage.Top   = 0;
                    CurrPage.Width = contentPanel.Width;
                }

                //Show the new page then bring it to the top of the z-order.
                CurrPage.Visible = true;
                CurrPage.BringToFront();
                contentPanel.ResumeLayout();
            }
        }