区域项目对照工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.9 KiB

using DevExpress.XtraEditors;
using DevExpress.XtraTab;
using RegionComparisonTool.Views;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace RegionComparisonTool
{
public partial class MainForm : Form
{
private SimpleButton _activeButton = null;
private BaseView _currForm = null;
private RcForm _rcForm = null;
public MainForm()
{
InitializeComponent();
RCMenu.Click += Menu_Click;
XtraTabControl.SizeChanged += XtraTabControl_SizeChanged;
}
private void XtraTabControl_SizeChanged(object sender, EventArgs e)
{
// 调整当前活动标签页中的窗体大小
if (XtraTabControl.SelectedTabPage != null)
{
AdjustFormSizeInTabPage(XtraTabControl.SelectedTabPage);
}
}
private void AdjustFormSizeInTabPage(XtraTabPage tabPage)
{
if (tabPage.Controls.Count > 0 && tabPage.Controls[0] is Form childForm)
{
this._rcForm.Size = tabPage.ClientSize;
ButtonMenuCommon();
}
}
private void Menu_Click(object sender, EventArgs e)
{
if(this._activeButton != null)
{
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()
{
this._currForm = null;
switch (this._activeButton.Text)
{
case "区域检验申请对照":
this._currForm = new RcForm();
this._rcForm = (RcForm)this._currForm;
break;
default:
break;
}
if (this._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"
};
this._currForm.TopLevel = false;
this._currForm.FormBorderStyle = FormBorderStyle.None;
this._currForm.Text = this._activeButton.Text;
this._currForm.Dock = DockStyle.Fill;
tabPage.Controls.Add(this._currForm);
XtraTabControl.TabPages.Add(tabPage);
XtraTabControl.TabPages.RemoveAt(0);
this._currForm.Show();
// 立即调整大小
this._currForm.Size = tabPage.ClientSize;
}
}
}