A simple navigation framework

Source: Internet
Author: User

If you do not want to use the wizard control in. net webparts, you can design a simple one. I designed a simple wizard framework with the following ideas:

1. First, there will be a wizard class. I call it Navigation. The wizard class has a container that contains all the forms in this wizard. The wizard provides all the core functions in the Wizard framework, such as start, next step, previous step, and finish.

2. design a form base class, which is currently called BaseForm. all wizard forms inherit from this base class. Some hooks must be reserved for the base class (in C #, they can be designed as virtual or abstract, and c ++ can be virtual ), perform the specific form logic for each derived subclass form. For example, you need to update the Form title and process the business logic. In addition, the window contains some wizard controls (Next, Previou, Finish, Cancel ). Finally, you must associate Navigation with the form base class.

3. Continue all the wizard forms from BaseForm and implement the Hook method of the base class.

 

The following is the main framework code written in C:

public class Navigation{    public List<BaseForm> container;    public int currentIndex;    public void Start() {currentIndex = 0; container[currentIndex].Show();}    public void Finish() {currentIndex = container.Count-1;}    public void Next();    public void Previous();     public Navigation()     {            currentIndex = 0;            container  = new List<BaseForm>();      }     public void InitNavContainer()     {             // TODO: Add your wizard forms step by step            container.Add(.....)     }    public int IsHeadForm()    {          return (currentIndex == 0);    }         public int IsTailForm()    {          return (currentIndex == container.Count - 1);    }}

 

Below is the form base class:

   1:  public class BaseForm : Form
   2:  {
   3:        public abstract void DoSomething();
   4:        public Button btnNext;
   5:        public Button btnPrevious;
   6:        public Button btnFinish;
   7:        public Button btnCancel;
   8:   
   9:        public Navigation navigation;
  10:   
  11:       public BaseForm(Navigation _navigation)
  12:      {
  13:            navigation = _navigation;
  14:       }
  15:   
  16:      public void OnNext()
  17:     {
  18:            navigation.Next();
  19:     }
  20:   
  21:     ........
  22:  }

The subform code is very simple, so the code is directly written without the compile compiler. C # sucks.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.