MainForm.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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(CtrlPosSingle));
  31. ctrlTypes.Add("误差评估", typeof(CtrlWcpj));
  32. ctrlTypes.Add("卫星管理", typeof(CtrlSat));
  33. ctrlTypes.Add("星历管理", typeof(CtrlXl));
  34. ctrlTypes.Add("系统设置", typeof(CtrlSysSettings));
  35. this.bar1.OptionsBar.DistanceBetweenItems = 20;
  36. this.tabbedView1.UseDefault();
  37. btnSet.Visibility = BarItemVisibility.Never;
  38. btnWCPJ.Visibility = BarItemVisibility.Never;
  39. }
  40. protected override void OnLoad(EventArgs e)
  41. {
  42. base.OnLoad(e);
  43. DxHelper.WaitHelper.CloseForm();
  44. }
  45. private void btn_ItemClick(object sender, ItemClickEventArgs e)
  46. {
  47. var btnTxt = e?.Item?.Caption ?? "参估工具";
  48. BaseDocument doc = null;
  49. doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault();
  50. if (doc == null)
  51. {
  52. doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt);
  53. if (doc.Control is Form form)
  54. {
  55. form.Text = "";
  56. doc.Caption = btnTxt;
  57. }
  58. }
  59. tabbedView1.ActivateDocument(doc.Control);
  60. }
  61. protected override void OnFormClosing(FormClosingEventArgs e)
  62. {
  63. if (e.CloseReason == CloseReason.UserClosing)
  64. {
  65. if (XtraMessageBox.Show("确定要退出当前系统吗?", "确认消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
  66. {
  67. e.Cancel = true;
  68. return;
  69. }
  70. }
  71. Application.Exit();
  72. }
  73. }
  74. }