MainForm.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 XzXdDw.App.UserControl;
  13. using DevExpress.XtraBars.Ribbon;
  14. using System.Threading;
  15. using DevExpress.XtraEditors;
  16. using ExtensionsDev;
  17. namespace XzXdDw
  18. {
  19. public partial class MainForm : XtraForm
  20. {
  21. Dictionary<string, Type> ctrlTypes = new Dictionary<string, Type>();
  22. public MainForm()
  23. {
  24. InitializeComponent();
  25. ctrlTypes.Add("参数估计", typeof(CtrlCgTool));
  26. ctrlTypes.Add("参估结果", typeof(CtrlCgRes));
  27. ctrlTypes.Add("用户识别", typeof(CtrlUserCheck));
  28. ctrlTypes.Add("星座协同定位", typeof(CtrlPosXz));
  29. ctrlTypes.Add("星地协同定位", typeof(CtrlPosXd));
  30. ctrlTypes.Add("误差评估", typeof(CtrlWcpj));
  31. ctrlTypes.Add("卫星管理", typeof(CtrlSat));
  32. ctrlTypes.Add("星历管理", typeof(CtrlXl));
  33. ctrlTypes.Add("系统设置", typeof(CtrlSysSettings));
  34. this.bar1.OptionsBar.DistanceBetweenItems = 20;
  35. this.tabbedView1.UseDefault();
  36. btnSet.Visibility = BarItemVisibility.Never;
  37. btnWCPJ.Visibility = BarItemVisibility.Never;
  38. }
  39. protected override void OnLoad(EventArgs e)
  40. {
  41. base.OnLoad(e);
  42. DxHelper.WaitHelper.CloseForm();
  43. }
  44. private void btn_ItemClick(object sender, ItemClickEventArgs e)
  45. {
  46. var btnTxt = e?.Item?.Caption ?? "参估工具";
  47. BaseDocument doc = null;
  48. doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault();
  49. if (doc == null)
  50. {
  51. doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt);
  52. if (doc.Control is Form form)
  53. {
  54. form.Text = "";
  55. doc.Caption = btnTxt;
  56. }
  57. }
  58. tabbedView1.ActivateDocument(doc.Control);
  59. }
  60. protected override void OnFormClosing(FormClosingEventArgs e)
  61. {
  62. if (e.CloseReason == CloseReason.UserClosing)
  63. {
  64. if (XtraMessageBox.Show("确定要退出当前系统吗?", "确认消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
  65. {
  66. e.Cancel = true;
  67. return;
  68. }
  69. }
  70. Application.Exit();
  71. }
  72. }
  73. }