MainForm.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using DevExpress.XtraBars;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using DevExpress.XtraBars.Docking2010.Views;
  12. using XdCxRhDW.App.UserControl;
  13. using DevExpress.XtraBars.Ribbon;
  14. using System.Threading;
  15. using XdCxRhDw.CpuCgTools;
  16. using DevExpress.XtraEditors;
  17. using ExtensionsDev;
  18. namespace XdCxRhDW
  19. {
  20. public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm
  21. {
  22. Dictionary<string, Type> ctrlTypes = new Dictionary<string, Type>();
  23. public MainForm()
  24. {
  25. InitializeComponent();
  26. ribbon.UseDefault();
  27. tabbedView1.UseDefault();
  28. ctrlTypes.Add("任务管理", typeof(CtrlHome));
  29. ctrlTypes.Add("参估结果", typeof(CtrlCgRes));
  30. ctrlTypes.Add("测向结果", typeof(CtrlCxRes));
  31. ctrlTypes.Add("定位结果", typeof(CtrlPosRes));
  32. ctrlTypes.Add("星历管理", typeof(CtrlXl));
  33. ctrlTypes.Add("天线管理", typeof(CtrlTx));
  34. ctrlTypes.Add("卫星管理", typeof(CtrlSat));
  35. ctrlTypes.Add("系统设置", typeof(CtrlSysSettings));
  36. ctrlTypes.Add("参估工具", typeof(FormCpuCg));
  37. btn_ItemClick(null, null);
  38. }
  39. private void btn_ItemClick(object sender, ItemClickEventArgs e)
  40. {
  41. var btnTxt = e?.Item?.Caption ?? "任务管理";
  42. BaseDocument doc = null;
  43. doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault();
  44. if (doc == null)
  45. {
  46. doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt);
  47. if (doc.Control is Form form)
  48. {
  49. form.Text = "";
  50. doc.Caption = btnTxt;
  51. }
  52. if (btnTxt == "任务管理")
  53. doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.False;
  54. else
  55. doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.True;
  56. }
  57. tabbedView1.ActivateDocument(doc.Control);
  58. }
  59. protected override void OnFormClosing(FormClosingEventArgs e)
  60. {
  61. if (e.CloseReason == CloseReason.UserClosing)
  62. {
  63. if (XtraMessageBox.Show("确定要退出当前系统吗?", "确认消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
  64. {
  65. e.Cancel = true;
  66. return;
  67. }
  68. }
  69. Application.Exit();
  70. }
  71. }
  72. }