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 CG.App.UserControl; using DevExpress.XtraBars.Ribbon; using System.Threading; using DevExpress.XtraEditors; using ExtensionsDev; using DxHelper; namespace CG { public partial class MainForm : XtraForm { Dictionary ctrlTypes = new Dictionary(); public MainForm() { InitializeComponent(); btnDto.ImageOptions.SvgImage = SvgHelper.LoadFromFile("Image\\初值预估.svg"); ctrlTypes.Add("参数估计", typeof(CtrlCgTool)); ctrlTypes.Add("用户识别", typeof(CtrlUserCheck)); ctrlTypes.Add("时差初值预估", typeof(CtrlDto)); ctrlTypes.Add("系统设置", typeof(CtrlSysSettings)); this.bar1.OptionsBar.DistanceBetweenItems = 20; this.tabbedView1.UseDefault(); btnSet.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(); } } }