using DevExpress.XtraEditors; using DevExpress.XtraTabbedMdi; using ReportTool.Views; using System; using System.Drawing; using System.Windows.Forms; namespace ReportTool { public partial class MainForm : Form { private SimpleButton _activeButton = null; public MainForm() { InitializeComponent(); LisReportFile.Click += Menu_Click; BloodReportFile.Click += Menu_Click; OtherReportFile.Click += Menu_Click; SignImage.Click += Menu_Click; this._activeButton = (LisReportFile as SimpleButton); this.ButtonMenuCommon(); } private void Menu_Click(object sender, EventArgs e) { this._activeButton.ForeColor = Color.White; this._activeButton.BackColor = Color.Transparent; this._activeButton.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; this._activeButton = (sender as SimpleButton); this.ButtonMenuCommon(); } private void ButtonMenuCommon() { Form currForm = null; switch (this._activeButton.Text) { case "LIS报告单": currForm = new LisReportFileForm("Lis"); break; case "输血报告单": currForm = new LisReportFileForm("Blood"); break; case "其他报告单": currForm = new LisReportFileForm("Other"); break; case "签名图片": currForm = new SignImageForm(); break; default: break; } if (currForm == null) return; this._activeButton.ForeColor = Color.Red; this._activeButton.BackColor = Color.WhiteSmoke; this._activeButton.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple; var tabPage = new DevExpress.XtraTab.XtraTabPage { Text = this._activeButton.Text, Name = "MainTabPage" }; currForm.TopLevel = false; currForm.FormBorderStyle = FormBorderStyle.None; currForm.Dock = DockStyle.Fill; currForm.Text = this._activeButton.Text; tabPage.Controls.Add(currForm); XtraTabControl.TabPages.Add(tabPage); XtraTabControl.TabPages.RemoveAt(0); currForm.Show(); } } }