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 XdCxRhDW.App.UserControl; using DevExpress.XtraBars.Ribbon; using System.Threading; using XdCxRhDw.CpuCgTools; using DevExpress.XtraEditors; using ExtensionsDev; namespace XdCxRhDW { public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm { Dictionary ctrlTypes = new Dictionary(); public MainForm() { InitializeComponent(); ribbon.UseDefault(); tabbedView1.UseDefault(); ctrlTypes.Add("任务管理", typeof(CtrlHome)); ctrlTypes.Add("参估结果", typeof(CtrlCgRes)); ctrlTypes.Add("测向结果", typeof(CtrlCxRes)); ctrlTypes.Add("定位结果", typeof(CtrlPosRes)); ctrlTypes.Add("星历管理", typeof(CtrlXl)); ctrlTypes.Add("天线管理", typeof(CtrlTx)); ctrlTypes.Add("卫星管理", typeof(CtrlSat)); ctrlTypes.Add("系统设置", typeof(CtrlSysSettings)); ctrlTypes.Add("参估工具", typeof(FormCpuCg)); btn_ItemClick(null, null); } 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; } if (btnTxt == "任务管理") doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.False; else doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.True; } 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(); } } }