MainForm.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 DevExpress.XtraEditors;
  16. using ExtensionsDev;
  17. namespace XdCxRhDW
  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(CtrlCg));
  26. ctrlTypes.Add("用户分离", typeof(CtrlUserCheck));
  27. ctrlTypes.Add("星座协同定位", typeof(CtrlPosXz));
  28. ctrlTypes.Add("星地协同定位", typeof(CtrlPosXd));
  29. ctrlTypes.Add("误差评估", typeof(CtrlWcpj));
  30. ctrlTypes.Add("卫星管理", typeof(CtrlSat));
  31. ctrlTypes.Add("星历管理", typeof(CtrlXl));
  32. ctrlTypes.Add("系统设置", typeof(CtrlSysSettings));
  33. this.bar1.OptionsBar.DistanceBetweenItems = 20;
  34. this.tabbedView1.UseDefault();
  35. }
  36. private void btn_ItemClick(object sender, ItemClickEventArgs e)
  37. {
  38. var btnTxt = e?.Item?.Caption ?? "参估工具";
  39. BaseDocument doc = null;
  40. doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault();
  41. if (doc == null)
  42. {
  43. doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt);
  44. if (doc.Control is Form form)
  45. {
  46. form.Text = "";
  47. doc.Caption = btnTxt;
  48. }
  49. }
  50. tabbedView1.ActivateDocument(doc.Control);
  51. }
  52. protected override void OnFormClosing(FormClosingEventArgs e)
  53. {
  54. if (e.CloseReason == CloseReason.UserClosing)
  55. {
  56. if (XtraMessageBox.Show("确定要退出当前系统吗?", "确认消息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
  57. {
  58. e.Cancel = true;
  59. return;
  60. }
  61. }
  62. Application.Exit();
  63. }
  64. }
  65. }