using DevExpress.XtraBars; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DevExpress.XtraBars.Docking2010.Views; using XdDw.App.UserControl; using DevExpress.XtraBars.Ribbon; using System.Threading; using DevExpress.XtraEditors; using ExtensionsDev; namespace XdDw { public partial class MainForm : XtraForm { Dictionary ctrlTypes = new Dictionary(); public MainForm() { InitializeComponent(); ctrlTypes.Add("参估结果", typeof(CtrlCgRes)); ctrlTypes.Add("星地协同定位", typeof(CtrlPosXd)); ctrlTypes.Add("误差评估", typeof(CtrlWcpj)); ctrlTypes.Add("卫星管理", typeof(CtrlSat)); ctrlTypes.Add("星历管理", typeof(CtrlXl)); ctrlTypes.Add("系统设置", typeof(CtrlSysSettings)); this.bar1.OptionsBar.DistanceBetweenItems = 20; this.tabbedView1.UseDefault(); //btnSet.Visibility = BarItemVisibility.Never; btnWCPJ.Visibility = BarItemVisibility.Never; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); DxHelper.WaitHelper.CloseForm(); } private void btn_ItemClick(object sender, ItemClickEventArgs e) { var btnTxt = e?.Item?.Caption ?? "参估工具"; BaseDocument doc = null; doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault(); if (doc == null) { doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt); if (doc.Control is Form form) { form.Text = ""; doc.Caption = btnTxt; } } tabbedView1.ActivateDocument(doc.Control); } protected override void OnFormClosing(FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (XtraMessageBox.Show("确定要退出当前系统吗?", "确认消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { e.Cancel = true; return; } } Application.Exit(); } } }