AutoSaveControl.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using PaintDotNet.Base.SettingModel;
  11. using PaintDotNet.Base.CommTool;
  12. using System.IO;
  13. namespace PaintDotNet.File.BatchSaveComponet
  14. {
  15. internal class AutoSaveControl : UserControl
  16. {
  17. public CheckBox checkBox5;
  18. public CheckBox checkBox4;
  19. public CheckBox checkBox3;
  20. public CheckBox checkBox2;
  21. public CheckBox checkBox1;
  22. private Label label1;
  23. public TextBox textBox1;
  24. private Label label2;
  25. private Label label3;
  26. private Label label4;
  27. private Label label5;
  28. public TextBox textBox3;
  29. public TextBox textBox4;
  30. public ComboBox comboBox1;
  31. private Label label6;
  32. public NumericUpDown numericUpDown1;
  33. public NumericUpDown numericUpDown2;
  34. private AppWorkspace appWorkspace;
  35. public CheckBox checkBox6;
  36. /// <summary>
  37. /// 文件 - 批量保存自动配置
  38. /// </summary>
  39. public BatchSaveAutoModel batchSaveAutoModel;
  40. public AutoSaveControl(AppWorkspace appWorkspace)
  41. {
  42. this.appWorkspace = appWorkspace;
  43. InitializeComponent();
  44. InitializeLanguageText();
  45. InitializeData();
  46. InitializationData();
  47. }
  48. private void InitializeData()
  49. {
  50. this.comboBox1.DataSource = new BindingSource(InvariantData.fileFormatDictionary, null);
  51. this.comboBox1.DisplayMember = "Value";
  52. this.comboBox1.ValueMember = "Key";
  53. batchSaveAutoModel = XmlSerializeHelper.DESerializer<BatchSaveAutoModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml", FileMode.Open));
  54. }
  55. private void InitializationData()
  56. {
  57. //BatchSaveAutoModel batchSaveAutoModel = new BatchSaveAutoModel();
  58. this.textBox1.Text = batchSaveAutoModel.fileName;
  59. this.numericUpDown2.Value = batchSaveAutoModel.startNum;
  60. this.textBox3.Text = batchSaveAutoModel.prefix;
  61. this.textBox4.Text = batchSaveAutoModel.suffix;
  62. this.comboBox1.Text = batchSaveAutoModel.format;
  63. this.checkBox1.Checked = batchSaveAutoModel.createConfig;
  64. this.checkBox2.Checked = batchSaveAutoModel.afterSaveClost;
  65. this.checkBox3.Checked = batchSaveAutoModel.saveGridLine;
  66. this.checkBox4.Checked = batchSaveAutoModel.implantLabelAndMeasure;
  67. this.checkBox5.Checked = batchSaveAutoModel.compress;
  68. this.checkBox6.Checked = batchSaveAutoModel.implantPhase;
  69. this.numericUpDown1.Value = batchSaveAutoModel.compressRate;
  70. }
  71. private void InitializeLanguageText()
  72. {
  73. this.checkBox5.Text = PdnResources.GetString("Menu.Compressionratio.text");
  74. this.checkBox4.Text = PdnResources.GetString("Menu.Annotationandmddedintheimage.text");
  75. this.checkBox3.Text = PdnResources.GetString("Menu.Savegriddata.text");
  76. this.checkBox2.Text = PdnResources.GetString("Menu.Closeimageaftersaving.text");
  77. this.checkBox1.Text = PdnResources.GetString("Menu.Generateconfigurationfile.text");
  78. this.label1.Text = PdnResources.GetString("Menu.file.Batchsaving.Newfilename.text") + ":";
  79. this.label2.Text = PdnResources.GetString("Menu.file.Batchsaving.Startnumber.text") + ":";
  80. this.label3.Text = PdnResources.GetString("Menu.file.Batchsaving.Prefix.text") + ":";
  81. this.label4.Text = PdnResources.GetString("Menu.file.Batchsaving.postfix.text") + ":";
  82. this.label5.Text = PdnResources.GetString("Menu.file.Batchsaving.ImageFormat.text") + ":";
  83. }
  84. private void InitializeComponent()
  85. {
  86. this.checkBox5 = new System.Windows.Forms.CheckBox();
  87. this.checkBox4 = new System.Windows.Forms.CheckBox();
  88. this.checkBox3 = new System.Windows.Forms.CheckBox();
  89. this.checkBox2 = new System.Windows.Forms.CheckBox();
  90. this.checkBox1 = new System.Windows.Forms.CheckBox();
  91. this.label1 = new System.Windows.Forms.Label();
  92. this.textBox1 = new System.Windows.Forms.TextBox();
  93. this.label2 = new System.Windows.Forms.Label();
  94. this.label3 = new System.Windows.Forms.Label();
  95. this.label4 = new System.Windows.Forms.Label();
  96. this.label5 = new System.Windows.Forms.Label();
  97. this.textBox3 = new System.Windows.Forms.TextBox();
  98. this.textBox4 = new System.Windows.Forms.TextBox();
  99. this.comboBox1 = new System.Windows.Forms.ComboBox();
  100. this.label6 = new System.Windows.Forms.Label();
  101. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  102. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  103. this.checkBox6 = new System.Windows.Forms.CheckBox();
  104. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  105. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  106. this.SuspendLayout();
  107. //
  108. // checkBox5
  109. //
  110. this.checkBox5.AutoSize = true;
  111. this.checkBox5.Location = new System.Drawing.Point(72, 172);
  112. this.checkBox5.Name = "checkBox5";
  113. this.checkBox5.Size = new System.Drawing.Size(72, 16);
  114. this.checkBox5.TabIndex = 20;
  115. this.checkBox5.Text = "压缩比例";
  116. this.checkBox5.UseVisualStyleBackColor = true;
  117. //
  118. // checkBox4
  119. //
  120. this.checkBox4.AutoSize = true;
  121. this.checkBox4.Location = new System.Drawing.Point(298, 148);
  122. this.checkBox4.Name = "checkBox4";
  123. this.checkBox4.Size = new System.Drawing.Size(156, 16);
  124. this.checkBox4.TabIndex = 19;
  125. this.checkBox4.Text = "标注和测量信息嵌入图像";
  126. this.checkBox4.UseVisualStyleBackColor = true;
  127. //
  128. // checkBox3
  129. //
  130. this.checkBox3.AutoSize = true;
  131. this.checkBox3.Location = new System.Drawing.Point(72, 148);
  132. this.checkBox3.Name = "checkBox3";
  133. this.checkBox3.Size = new System.Drawing.Size(96, 16);
  134. this.checkBox3.TabIndex = 18;
  135. this.checkBox3.Text = "保存网格数据";
  136. this.checkBox3.UseVisualStyleBackColor = true;
  137. //
  138. // checkBox2
  139. //
  140. this.checkBox2.AutoSize = true;
  141. this.checkBox2.Location = new System.Drawing.Point(298, 125);
  142. this.checkBox2.Name = "checkBox2";
  143. this.checkBox2.Size = new System.Drawing.Size(108, 16);
  144. this.checkBox2.TabIndex = 17;
  145. this.checkBox2.Text = "保存后关闭图像";
  146. this.checkBox2.UseVisualStyleBackColor = true;
  147. //
  148. // checkBox1
  149. //
  150. this.checkBox1.AutoSize = true;
  151. this.checkBox1.Location = new System.Drawing.Point(72, 125);
  152. this.checkBox1.Name = "checkBox1";
  153. this.checkBox1.Size = new System.Drawing.Size(96, 16);
  154. this.checkBox1.TabIndex = 16;
  155. this.checkBox1.Text = "生成配置文件";
  156. this.checkBox1.UseVisualStyleBackColor = true;
  157. //
  158. // label1
  159. //
  160. this.label1.AutoSize = true;
  161. this.label1.Location = new System.Drawing.Point(14, 14);
  162. this.label1.Name = "label1";
  163. this.label1.Size = new System.Drawing.Size(65, 12);
  164. this.label1.TabIndex = 21;
  165. this.label1.Text = "新文件名:";
  166. //
  167. // textBox1
  168. //
  169. this.textBox1.Location = new System.Drawing.Point(73, 10);
  170. this.textBox1.MaxLength = 20;
  171. this.textBox1.Name = "textBox1";
  172. this.textBox1.Size = new System.Drawing.Size(144, 21);
  173. this.textBox1.TabIndex = 22;
  174. //
  175. // label2
  176. //
  177. this.label2.AutoSize = true;
  178. this.label2.Location = new System.Drawing.Point(229, 14);
  179. this.label2.Name = "label2";
  180. this.label2.Size = new System.Drawing.Size(65, 12);
  181. this.label2.TabIndex = 23;
  182. this.label2.Text = "开始数字:";
  183. //
  184. // label3
  185. //
  186. this.label3.AutoSize = true;
  187. this.label3.Location = new System.Drawing.Point(38, 41);
  188. this.label3.Name = "label3";
  189. this.label3.Size = new System.Drawing.Size(41, 12);
  190. this.label3.TabIndex = 24;
  191. this.label3.Text = "前缀:";
  192. //
  193. // label4
  194. //
  195. this.label4.AutoSize = true;
  196. this.label4.Location = new System.Drawing.Point(253, 41);
  197. this.label4.Name = "label4";
  198. this.label4.Size = new System.Drawing.Size(41, 12);
  199. this.label4.TabIndex = 25;
  200. this.label4.Text = "后缀:";
  201. //
  202. // label5
  203. //
  204. this.label5.AutoSize = true;
  205. this.label5.Location = new System.Drawing.Point(14, 68);
  206. this.label5.Name = "label5";
  207. this.label5.Size = new System.Drawing.Size(65, 12);
  208. this.label5.TabIndex = 26;
  209. this.label5.Text = "图片格式:";
  210. //
  211. // textBox3
  212. //
  213. this.textBox3.Location = new System.Drawing.Point(73, 37);
  214. this.textBox3.MaxLength = 20;
  215. this.textBox3.Name = "textBox3";
  216. this.textBox3.Size = new System.Drawing.Size(144, 21);
  217. this.textBox3.TabIndex = 28;
  218. //
  219. // textBox4
  220. //
  221. this.textBox4.Location = new System.Drawing.Point(301, 37);
  222. this.textBox4.MaxLength = 20;
  223. this.textBox4.Name = "textBox4";
  224. this.textBox4.Size = new System.Drawing.Size(144, 21);
  225. this.textBox4.TabIndex = 29;
  226. //
  227. // comboBox1
  228. //
  229. this.comboBox1.FormattingEnabled = true;
  230. this.comboBox1.Location = new System.Drawing.Point(73, 64);
  231. this.comboBox1.Name = "comboBox1";
  232. this.comboBox1.Size = new System.Drawing.Size(144, 20);
  233. this.comboBox1.TabIndex = 30;
  234. //
  235. // label6
  236. //
  237. this.label6.AutoSize = true;
  238. this.label6.Location = new System.Drawing.Point(193, 174);
  239. this.label6.Name = "label6";
  240. this.label6.Size = new System.Drawing.Size(11, 12);
  241. this.label6.TabIndex = 32;
  242. this.label6.Text = "%";
  243. //
  244. // numericUpDown1
  245. //
  246. this.numericUpDown1.Location = new System.Drawing.Point(150, 170);
  247. this.numericUpDown1.Name = "numericUpDown1";
  248. this.numericUpDown1.Size = new System.Drawing.Size(36, 21);
  249. this.numericUpDown1.TabIndex = 31;
  250. //
  251. // numericUpDown2
  252. //
  253. this.numericUpDown2.Location = new System.Drawing.Point(300, 10);
  254. this.numericUpDown2.Maximum = new decimal(new int[] {
  255. 2147483647,
  256. 0,
  257. 0,
  258. 0});
  259. this.numericUpDown2.Name = "numericUpDown2";
  260. this.numericUpDown2.Size = new System.Drawing.Size(144, 21);
  261. this.numericUpDown2.TabIndex = 33;
  262. //
  263. // checkBox6
  264. //
  265. this.checkBox6.AutoSize = true;
  266. this.checkBox6.Location = new System.Drawing.Point(298, 172);
  267. this.checkBox6.Name = "checkBox6";
  268. this.checkBox6.Size = new System.Drawing.Size(108, 16);
  269. this.checkBox6.TabIndex = 34;
  270. this.checkBox6.Text = "相信息嵌入图像";
  271. this.checkBox6.UseVisualStyleBackColor = true;
  272. //
  273. // AutoSaveControl
  274. //
  275. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  276. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  277. this.Controls.Add(this.checkBox6);
  278. this.Controls.Add(this.numericUpDown2);
  279. this.Controls.Add(this.label6);
  280. this.Controls.Add(this.numericUpDown1);
  281. this.Controls.Add(this.comboBox1);
  282. this.Controls.Add(this.textBox4);
  283. this.Controls.Add(this.textBox3);
  284. this.Controls.Add(this.label5);
  285. this.Controls.Add(this.label4);
  286. this.Controls.Add(this.label3);
  287. this.Controls.Add(this.label2);
  288. this.Controls.Add(this.textBox1);
  289. this.Controls.Add(this.label1);
  290. this.Controls.Add(this.checkBox5);
  291. this.Controls.Add(this.checkBox4);
  292. this.Controls.Add(this.checkBox3);
  293. this.Controls.Add(this.checkBox2);
  294. this.Controls.Add(this.checkBox1);
  295. this.Margin = new System.Windows.Forms.Padding(0);
  296. this.Name = "AutoSaveControl";
  297. this.Size = new System.Drawing.Size(546, 327);
  298. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  299. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  300. this.ResumeLayout(false);
  301. this.PerformLayout();
  302. }
  303. }
  304. }