MainForm.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using DataSimulation.Forms.UserControl;
  2. using DevExpress.XtraBars.Docking2010.Views;
  3. using DevExpress.XtraBars;
  4. using DevExpress.XtraBars.Docking2010.Views.Tabbed;
  5. using ExtensionsDev;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. namespace DataSimulation.Forms
  15. {
  16. public partial class MainForm : DevExpress.XtraBars.Ribbon.RibbonForm
  17. {
  18. Dictionary<string, Type> ctrlTypes = new Dictionary<string, Type>();
  19. public MainForm()
  20. {
  21. InitializeComponent();
  22. ribbon.UseDefault();
  23. tabbedView1.UseDefault();
  24. ctrlTypes.Add("任务管理", typeof(CtrlHome));
  25. ctrlTypes.Add("历史任务", typeof(CtrlHistoryTask));
  26. ctrlTypes.Add("星历管理", typeof(CtrlXl));
  27. ctrlTypes.Add("卫星管理", typeof(CtrlSat));
  28. ctrlTypes.Add("天线管理", typeof(CtrlAnt));
  29. ctrlTypes.Add("参考站管理", typeof(CtrlRef));
  30. ctrlTypes.Add("航迹管理", typeof(CtrlFlight));
  31. btn_ItemClick(null, null);
  32. }
  33. private void btn_ItemClick(object sender, ItemClickEventArgs e)
  34. {
  35. var btnTxt = e?.Item?.Caption ?? "任务管理";
  36. BaseDocument doc = null;
  37. doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault();
  38. if (doc == null)
  39. {
  40. doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt);
  41. if (doc.Control is Form form)
  42. {
  43. form.Text = "";
  44. doc.Caption = btnTxt;
  45. }
  46. if (btnTxt == "任务管理")
  47. doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.False;
  48. else
  49. doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.True;
  50. }
  51. tabbedView1.ActivateDocument(doc.Control);
  52. }
  53. }
  54. }