MainForm.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. btn_ItemClick(null, null);
  31. }
  32. private void btn_ItemClick(object sender, ItemClickEventArgs e)
  33. {
  34. var btnTxt = e?.Item?.Caption ?? "任务管理";
  35. BaseDocument doc = null;
  36. doc = tabbedView1.Documents.Find(p => p.Control.GetType() == ctrlTypes[btnTxt]).FirstOrDefault();
  37. if (doc == null)
  38. {
  39. doc = tabbedView1.AddDocument((Control)Activator.CreateInstance(ctrlTypes[btnTxt]), btnTxt);
  40. if (doc.Control is Form form)
  41. {
  42. form.Text = "";
  43. doc.Caption = btnTxt;
  44. }
  45. if (btnTxt == "任务管理")
  46. doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.False;
  47. else
  48. doc.Properties.AllowClose = DevExpress.Utils.DefaultBoolean.True;
  49. }
  50. tabbedView1.ActivateDocument(doc.Control);
  51. }
  52. }
  53. }