SettingMenu.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. using Metis.Setting;
  2. using PaintDotNet.Base;
  3. using PaintDotNet.Data.Param;
  4. using PaintDotNet.Setting;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Globalization;
  8. using System.Windows.Forms;
  9. namespace PaintDotNet.Menus
  10. {
  11. /// <summary>
  12. /// 设置菜单
  13. /// </summary>
  14. internal sealed class SettingMenu : PdnMenuItem
  15. {
  16. private PdnMenuItem menuGeneralSetting;
  17. private PdnMenuItem menuGridSetting;
  18. private PdnMenuItem menuWatermarkSetting;
  19. private PdnMenuItem menuWorkTypeSetting;
  20. private PdnMenuItem menuRuleSetting;
  21. private PdnMenuItem menuLabelSetting;
  22. private PdnMenuItem menuMeasureSetting;
  23. private PdnMenuItem menuWorkFlowSetting;
  24. private ToolStripSeparator menuToolsSeperator1;
  25. private PdnMenuItem menuFocusSetting;
  26. private ToolStripSeparator menuToolsSeperator2;
  27. private PdnMenuItem menuModuleSetting;
  28. private PdnMenuItem menuImportExportSetting;
  29. private ToolStripSeparator menuToolsSeperator3;
  30. public SettingMenu(int menuId)
  31. {
  32. InitializeComponent();
  33. this.MenuId = menuId;
  34. //在脚本中不显示
  35. this.CanUseInScript = false;
  36. this.AutomaticScript = false;
  37. }
  38. protected override void OnAppWorkspaceChanged()
  39. {
  40. base.OnAppWorkspaceChanged();
  41. }
  42. private void InitializeComponent()
  43. {
  44. this.menuGeneralSetting = new PdnMenuItem(ActionType.GeneralSetting);
  45. this.menuGridSetting = new PdnMenuItem(ActionType.GridSetting);
  46. this.menuWatermarkSetting = new PdnMenuItem(ActionType.WatermarkSetting);
  47. this.menuWorkTypeSetting = new PdnMenuItem(ActionType.WorkTypeSetting);
  48. this.menuRuleSetting = new PdnMenuItem(ActionType.RuleSetting);
  49. this.menuLabelSetting = new PdnMenuItem(ActionType.LabelSetting);
  50. this.menuMeasureSetting = new PdnMenuItem(ActionType.MeasureSetting);
  51. this.menuWorkFlowSetting = new PdnMenuItem(ActionType.WorkFlowSetting);
  52. this.menuToolsSeperator1 = new ToolStripSeparator();
  53. this.menuFocusSetting = new PdnMenuItem(ActionType.FocusSetting);
  54. this.menuToolsSeperator2 = new ToolStripSeparator();
  55. this.menuModuleSetting = new PdnMenuItem(ActionType.ModuleSetting);
  56. this.menuImportExportSetting = new PdnMenuItem(ActionType.ImportExportSetting);
  57. this.menuToolsSeperator3 = new ToolStripSeparator();
  58. //
  59. // 主菜单
  60. //
  61. this.DropDownItems.AddRange(new ToolStripItem[] {
  62. this.menuGeneralSetting,
  63. this.menuGridSetting,
  64. this.menuWatermarkSetting,
  65. this.menuWorkTypeSetting,
  66. this.menuRuleSetting,
  67. this.menuLabelSetting,
  68. this.menuMeasureSetting,
  69. this.menuWorkFlowSetting,
  70. this.menuToolsSeperator1,
  71. this.menuFocusSetting,
  72. this.menuToolsSeperator2,
  73. this.menuModuleSetting,
  74. this.menuToolsSeperator3,
  75. this.menuImportExportSetting
  76. });
  77. this.Name = "Menu.Setting";
  78. this.Text = PdnResources.GetString("Menu.Setting.Text");
  79. //
  80. // 常规设置
  81. //
  82. this.menuGeneralSetting.Click += new EventHandler(MenuGeneralSetting_Click);
  83. //
  84. // 网格设置
  85. //
  86. this.menuGridSetting.Click += new EventHandler(MenuGridSetting_Click);
  87. //
  88. // 水印设置
  89. //
  90. this.menuWatermarkSetting.Click += new EventHandler(WatermarkSettingsDialog_Click);
  91. //
  92. // 工型设置
  93. //
  94. this.menuWorkTypeSetting.Click += new EventHandler(MenuWorkTypeSetting_Click);
  95. //
  96. // 标尺设置
  97. //
  98. this.menuRuleSetting.Click += new EventHandler(MenuRulerSetting_Click); ;
  99. //
  100. // 标注设置
  101. //
  102. this.menuLabelSetting.Click += new EventHandler(MenuLabelSetting_Click);
  103. //
  104. // 测量设置
  105. //
  106. this.menuMeasureSetting.Click += new EventHandler(MenuMeasureSetting_Click);
  107. //
  108. // 工作流程
  109. //
  110. this.menuWorkFlowSetting.Click += new EventHandler(MenuWorkFlowSetting_Click);
  111. //
  112. // 聚焦参数
  113. //
  114. this.menuFocusSetting.Click += new EventHandler(menuFocusSetting_Click);
  115. //
  116. // 模块管理
  117. //
  118. this.menuModuleSetting.Click += new EventHandler(MenuModuleSetting_Click);
  119. //
  120. // 导入导出管理
  121. //
  122. this.menuImportExportSetting.Click += new EventHandler(MenuImportExportSetting_Click);
  123. this.menuImportExportSetting.Text = PdnResources.GetString("ImportAndExportSet");
  124. //
  125. // 加载菜单的文字和icon
  126. //
  127. this.LoadNames(this.Name);
  128. this.LoadIcons();
  129. }
  130. /// <summary>
  131. /// 常规设置
  132. /// </summary>
  133. /// <param name="sender"></param>
  134. /// <param name="e"></param>
  135. private void MenuGeneralSetting_Click(object sender, EventArgs e)
  136. {
  137. if (AppWorkspace.startScriptRecording)
  138. {
  139. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  140. }
  141. using (GeneralSettingDialog af = new GeneralSettingDialog(AppWorkspace))
  142. {
  143. af.StartPosition = FormStartPosition.CenterScreen;
  144. af.ShowDialog(AppWorkspace);
  145. }
  146. }
  147. /// <summary>
  148. /// 网格设置
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void MenuGridSetting_Click(object sender, EventArgs e)
  153. {
  154. if (AppWorkspace.startScriptRecording)
  155. {
  156. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  157. }
  158. //using (GridSettingDialog af = new GridSettingDialog(AppWorkspace))
  159. //{
  160. // af.StartPosition = FormStartPosition.CenterScreen;
  161. // af.ShowDialog(AppWorkspace);
  162. //}
  163. using (GridSettingForm af = new GridSettingForm(AppWorkspace))
  164. {
  165. af.StartPosition = FormStartPosition.CenterScreen;
  166. af.ShowDialog(AppWorkspace);
  167. }
  168. }
  169. /// <summary>
  170. /// 聚焦参数
  171. /// </summary>
  172. /// <param name="sender"></param>
  173. /// <param name="e"></param>
  174. private void menuFocusSetting_Click(object sender, EventArgs e)
  175. {
  176. if (AppWorkspace.startScriptRecording)
  177. {
  178. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  179. }
  180. using (FocusingParameter fp = new FocusingParameter())
  181. {
  182. fp.StartPosition = FormStartPosition.CenterScreen;
  183. fp.ShowDialog(AppWorkspace);
  184. }
  185. }
  186. private void MenuModuleSetting_Click(object sender, EventArgs e)
  187. {
  188. if (AppWorkspace.startScriptRecording)
  189. {
  190. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  191. }
  192. using (ModuleManageDialog af = new ModuleManageDialog(AppWorkspace))
  193. {
  194. af.StartPosition = FormStartPosition.CenterScreen;
  195. af.ShowDialog(AppWorkspace);
  196. }
  197. }
  198. /// <summary>
  199. /// 标尺设置
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void MenuRulerSetting_Click(object sender, EventArgs e)
  204. {
  205. if (AppWorkspace.startScriptRecording)
  206. {
  207. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  208. }
  209. using (RulerSettingDialog af = new RulerSettingDialog(AppWorkspace))
  210. {
  211. af.StartPosition = FormStartPosition.CenterScreen;
  212. af.ShowDialog(AppWorkspace);
  213. }
  214. }
  215. /// <summary>
  216. /// 测量设置
  217. /// </summary>
  218. /// <param name="sender"></param>
  219. /// <param name="e"></param>
  220. private void MenuMeasureSetting_Click(object sender, EventArgs e)
  221. {
  222. if (AppWorkspace.startScriptRecording)
  223. {
  224. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  225. }
  226. using (MeasureSettingDialog af = new MeasureSettingDialog(AppWorkspace))
  227. {
  228. af.StartPosition = FormStartPosition.CenterScreen;
  229. af.ShowDialog(AppWorkspace);
  230. }
  231. }
  232. /// <summary>
  233. /// 标注设置
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. private void MenuLabelSetting_Click(object sender, EventArgs e)
  238. {
  239. if (AppWorkspace.startScriptRecording)
  240. {
  241. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  242. }
  243. using (LabelSettingDialog af = new LabelSettingDialog(AppWorkspace))
  244. {
  245. af.StartPosition = FormStartPosition.CenterScreen;
  246. af.ShowDialog();
  247. }
  248. }
  249. /// <summary>
  250. /// 工作流程
  251. /// </summary>
  252. /// <param name="sender"></param>
  253. /// <param name="e"></param>
  254. private void MenuWorkFlowSetting_Click(object sender, EventArgs e)
  255. {
  256. if (AppWorkspace.startScriptRecording)
  257. {
  258. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  259. }
  260. using (WorkFlowSettingDialog af = new WorkFlowSettingDialog(AppWorkspace))
  261. {
  262. af.StartPosition = FormStartPosition.CenterScreen;
  263. af.ShowDialog();
  264. }
  265. }
  266. private string GetCultureInfoName(CultureInfo ci)
  267. {
  268. CultureInfo en_US = new CultureInfo("en-US");
  269. if (ci.Equals(en_US))
  270. {
  271. return GetCultureInfoName(ci.Parent);
  272. }
  273. else
  274. {
  275. return ci.NativeName;
  276. }
  277. }
  278. /// <summary>
  279. /// 工型设置
  280. /// </summary>
  281. /// <param name="sender"></param>
  282. /// <param name="e"></param>
  283. private void MenuWorkTypeSetting_Click(object sender, EventArgs e)
  284. {
  285. if (AppWorkspace.startScriptRecording)
  286. {
  287. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  288. }
  289. using (WorkTypeSettingDialog af = new WorkTypeSettingDialog())
  290. {
  291. af.StartPosition = FormStartPosition.CenterScreen;
  292. af.ShowDialog(AppWorkspace);
  293. }
  294. }
  295. /// <summary>
  296. /// 水印设置
  297. /// </summary>
  298. /// <param name="sender"></param>
  299. /// <param name="e"></param>
  300. private void WatermarkSettingsDialog_Click(object sender, EventArgs e)
  301. {
  302. if (AppWorkspace.startScriptRecording)
  303. {
  304. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  305. }
  306. using (WatermarkSettingsDialog af = new WatermarkSettingsDialog())
  307. {
  308. af.StartPosition = FormStartPosition.CenterScreen;
  309. af.ShowDialog(AppWorkspace);
  310. }
  311. }
  312. /// <summary>
  313. /// 导入导出设置
  314. /// </summary>
  315. /// <param name="sender"></param>
  316. /// <param name="e"></param>
  317. private void MenuImportExportSetting_Click(object sender, EventArgs e)
  318. {
  319. if (AppWorkspace.startScriptRecording)
  320. {
  321. AppWorkspace.SetScriptStartRecording(((PdnMenuItem)sender).MenuId, ((PdnMenuItem)sender).Text, new List<Args>());
  322. }
  323. using (ImportExportSettingDialog af = new ImportExportSettingDialog())
  324. {
  325. af.StartPosition = FormStartPosition.CenterScreen;
  326. af.ShowDialog(AppWorkspace);
  327. }
  328. }
  329. }
  330. }