MainForm.cs 2.3 KB

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