public MainForm() { InitializeComponent(); this.Text = AssemblyTitle; string[] types = AnaFactory.GetAnalyzers(); ToolStripMenuItem tm = new ToolStripMenuItem(); tm.Text = "指标分析"; tm.Click += normDist_Click; this.tsMenuSelector.DropDownItems.Add(tm); foreach (string s in types) { tm = new ToolStripMenuItem(s); tm.Click += tm_Click; this.tsMenuSelector.DropDownItems.Add(tm); } }
void tm_Click(object sender, EventArgs e) { this.panel1.Controls.Clear(); ToolStripMenuItem mi = sender as ToolStripMenuItem; if (mi == null) { return; } IAbstrctAnalyzer dlg = AnaFactory.CreateAna(mi.Text); if (dlg == null) { return; } dlg.Db.Conn = new OleDbConnection(ConnectionBuilder.Instance.Conn); UserControl uc = (UserControl)dlg; uc.Parent = this.panel1; uc.Dock = DockStyle.Fill; uc.Show(); dlg.OnLog += OnMessageLog; }