HardwareControlMenu.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using PaintDotNet.Data.Param;
  2. using PaintDotNet.Hardware;
  3. using System;
  4. using System.Globalization;
  5. using System.Windows.Forms;
  6. namespace PaintDotNet.Menus
  7. {
  8. /// <summary>
  9. /// 硬件控制菜单
  10. /// </summary>
  11. internal sealed class HardwareControlMenu : PdnMenuItem
  12. {
  13. private PdnMenuItem menuLocationNavigation;
  14. private PdnMenuItem menuStageSetting;
  15. private PdnMenuItem menuSetVoltage;
  16. private PdnMenuItem menuMotorizedLight;
  17. public HardwareControlMenu(int menuId)
  18. {
  19. InitializeComponent();
  20. this.MenuId = menuId;
  21. }
  22. protected override void OnAppWorkspaceChanged()
  23. {
  24. base.OnAppWorkspaceChanged();
  25. }
  26. private void InitializeComponent()
  27. {
  28. this.menuLocationNavigation = new PdnMenuItem(ActionType.LocationNavigation);
  29. this.menuLocationNavigation.AutomaticScript = false;
  30. this.menuStageSetting = new PdnMenuItem(ActionType.StageSetting);
  31. this.menuStageSetting.AutomaticScript = false;
  32. this.menuSetVoltage = new PdnMenuItem(ActionType.SetVoltage);
  33. this.menuSetVoltage.AutomaticScript = false;
  34. this.menuMotorizedLight = new PdnMenuItem(ActionType.MotorizedLight);
  35. this.menuMotorizedLight.AutomaticScript = false;
  36. //
  37. // 主菜单
  38. //
  39. this.DropDownItems.AddRange(new ToolStripItem[] {
  40. this.menuLocationNavigation,
  41. //menuStageSetting,
  42. this.menuSetVoltage,
  43. this.menuMotorizedLight
  44. });
  45. this.Name = "Menu.HardwareControl";
  46. this.Text = PdnResources.GetString("Menu.HardwareControl.Text");
  47. //
  48. // 位置导航
  49. //
  50. this.menuLocationNavigation.Click += new System.EventHandler(this.locationNavigation_Click);
  51. //
  52. // 设置电压
  53. //
  54. this.menuSetVoltage.Click += new System.EventHandler(this.setVoltage_Click);
  55. //
  56. // 电动偏光
  57. //
  58. this.menuMotorizedLight.Click += new System.EventHandler(this.motorizedLight_Click);
  59. //
  60. // 机台设置
  61. //
  62. this.menuStageSetting.Click += MenuStageSetting_Click;
  63. //
  64. // 加载菜单的文字和icon
  65. //
  66. this.LoadNames(this.Name);
  67. this.LoadIcons();
  68. }
  69. private void MenuStageSetting_Click(object sender, EventArgs e)
  70. {
  71. using (var form = new ParamSetingDialog(null))
  72. {
  73. form.ShowDialog();
  74. }
  75. }
  76. /// <summary>
  77. /// 电动偏光
  78. /// </summary>
  79. /// <param name="sender"></param>
  80. /// <param name="e"></param>
  81. private void motorizedLight_Click(object sender, EventArgs e)
  82. {
  83. using (MotorizedLightDialog af = new MotorizedLightDialog())
  84. {
  85. af.ShowDialog();
  86. }
  87. }
  88. /// <summary>
  89. /// 设置电压
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void setVoltage_Click(object sender, EventArgs e)
  94. {
  95. using (SetVoltageDialog af = new SetVoltageDialog())
  96. {
  97. af.ShowDialog();
  98. }
  99. }
  100. private void locationNavigation_Click(object sender, System.EventArgs e)
  101. {
  102. //new SCC().Show();
  103. Form form = Application.OpenForms["LocationNavigationDialog"];
  104. FloatingFormMethod.ShowFloatForm(form, form == null ? new LocationNavigationDialog(AppWorkspace)/*没有弹出的窗口对象则创建*/ : null, AppWorkspace);
  105. }
  106. private string GetCultureInfoName(CultureInfo ci)
  107. {
  108. CultureInfo en_US = new CultureInfo("en-US");
  109. if (ci.Equals(en_US))
  110. {
  111. return GetCultureInfoName(ci.Parent);
  112. }
  113. else
  114. {
  115. return ci.NativeName;
  116. }
  117. }
  118. }
  119. }