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.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)