Click here to Skip to main content
15,892,697 members
Articles / Programming Languages / XML

netTierGenerator

Rate me:
Please Sign up or sign in to vote.
4.81/5 (20 votes)
30 Nov 2008CPOL14 min read 67.6K   2.8K   108  
A 3-tier application framework and code generation tool - the way for rapid and effective development.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Sample.Common.Util;
using WinGUI.Controls.Store;
using WinGUI.Controls;

namespace WinGUI
{
    public partial class MainForm : Form
    {
        #region members

        private UserControl currentMainControl;

        #endregion members

        #region main form

        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            this.FillTreeView();

            this.currentMainControl = new StoreList();
            this.HandleControl();
            this.scMain.Panel2.Controls.Clear();
            this.scMain.Panel2.Controls.Add(currentMainControl);
        }

        #endregion main form

        #region tree view
        private void FillTreeView()
        {
            TreeNode mainNode = new TreeNode("Main Menu Item");
            this.tvMenu.Nodes.Add(mainNode);

            TreeNode storeNode = new TreeNode("Srtore Menu Item");
            mainNode.Nodes.Add(storeNode);

            TreeNode goodNode = new TreeNode("Good Item Node");
            storeNode.Nodes.Add(goodNode);
        }
        #endregion tree view

        #region menu

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #endregion menu

        #region current control
        private void HandleControl()
        {
            this.currentMainControl.Dock = DockStyle.Fill;
            if (this.currentMainControl is ICustomControl)
            {
                ICustomControl iCustomControl = this.currentMainControl as ICustomControl;
                iCustomControl.ActionComplete += new EventHandler<ActionCompleteEventArgs>(iCustomControl_ActionComplete);
            }
        }
        private void iCustomControl_ActionComplete(object sender, ActionCompleteEventArgs e)
        {
            if (this.currentMainControl is ICustomControl)
            {
                ICustomControl iCustomControl = this.currentMainControl as ICustomControl;
                iCustomControl.ActionComplete -= new EventHandler<ActionCompleteEventArgs>(iCustomControl_ActionComplete);
            }

            if (this.currentMainControl.GetType() == typeof(StoreList))
            {
                this.currentMainControl = new StoreItem();
            }
            else if (this.currentMainControl.GetType() == typeof(StoreItem))
            {
                this.currentMainControl = new StoreList();
            }

            if (this.currentMainControl is IItemControl)
            {
                IItemControl iItemControl = this.currentMainControl as IItemControl;
                if (iItemControl != null)
                {
                    iItemControl.LoadInfoModel(e.ItemInfoID);
                }
            }

            this.HandleControl();
            this.scMain.Panel2.Controls.Clear();
            this.scMain.Panel2.Controls.Add(currentMainControl);
        }
        #endregion current control
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions