MainForm.cs 2.4 KB

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