BatchSaveDialog.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. using Resources;
  2. using SmartCoalApplication.Base;
  3. using SmartCoalApplication.Base.CommTool;
  4. using SmartCoalApplication.Base.SettingModel;
  5. using SmartCoalApplication.Core;
  6. using SmartCoalApplication.File.BatchSaveComponet;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. namespace SmartCoalApplication.File
  18. {
  19. /// <summary>
  20. /// 批量保存
  21. /// </summary>
  22. internal class BatchSaveDialog : PdnBaseForm
  23. {
  24. private AppWorkspace appWorkspace;
  25. private System.Windows.Forms.GroupBox groupBox1;
  26. private System.Windows.Forms.GroupBox groupBox2;
  27. private System.Windows.Forms.TextBox textBox1;
  28. private System.Windows.Forms.Button button1;
  29. private System.Windows.Forms.Button button2;
  30. private System.Windows.Forms.Button button3;
  31. private Button button4;
  32. private Panel panel1;
  33. private FolderBrowserDialog folderBrowserDialog1;
  34. private HandSaveControl handSaveControl;
  35. private AutoSaveControl autoSaveControl;
  36. /// <summary>
  37. /// 文件 - 批量保存自动配置
  38. /// </summary>
  39. public BatchSaveAutoModel batchSaveAutoModel;
  40. /// <summary>
  41. /// 1手动 2自动
  42. /// </summary>
  43. private int typesOf = 2;
  44. public BatchSaveDialog(AppWorkspace appWorkspace)
  45. {
  46. this.appWorkspace = appWorkspace;
  47. InitializeComponent();
  48. InitializeLanguageText();
  49. this.Text = PdnResources.GetString("Menu.File.BulkSave.Text");
  50. this.button3.Focus();
  51. this.autoSaveControl = new AutoSaveControl(this.appWorkspace);
  52. this.panel1.Controls.Add(this.autoSaveControl);
  53. }
  54. private void InitializeLanguageText()
  55. {
  56. batchSaveAutoModel = XmlSerializeHelper.DESerializer<BatchSaveAutoModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml", FileMode.Open));
  57. this.groupBox1.Text = PdnResources.GetString("Menu.Type.text");
  58. this.button3.Text = PdnResources.GetString("Menu.file.Batchsaving.autosave.text");
  59. this.button2.Text = PdnResources.GetString("Menu.file.Batchsaving.Savemanually.text");
  60. this.groupBox2.Text = PdnResources.GetString("Menu.saveroute.text");
  61. this.button4.Text = PdnResources.GetString("Menu.MeasureAction.MeasureSelect.Text");
  62. this.button1.Text = PdnResources.GetString("Menu.File.Save.Text");
  63. this.textBox1.Text = batchSaveAutoModel.fileRoute;
  64. }
  65. private void InitializeComponent()
  66. {
  67. this.groupBox1 = new System.Windows.Forms.GroupBox();
  68. this.button3 = new System.Windows.Forms.Button();
  69. this.button2 = new System.Windows.Forms.Button();
  70. this.groupBox2 = new System.Windows.Forms.GroupBox();
  71. this.button4 = new System.Windows.Forms.Button();
  72. this.button1 = new System.Windows.Forms.Button();
  73. this.textBox1 = new System.Windows.Forms.TextBox();
  74. this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
  75. this.panel1 = new System.Windows.Forms.Panel();
  76. this.groupBox1.SuspendLayout();
  77. this.groupBox2.SuspendLayout();
  78. this.SuspendLayout();
  79. //
  80. // groupBox1
  81. //
  82. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  83. | System.Windows.Forms.AnchorStyles.Left)));
  84. this.groupBox1.Controls.Add(this.button3);
  85. this.groupBox1.Controls.Add(this.button2);
  86. this.groupBox1.Location = new System.Drawing.Point(13, 13);
  87. this.groupBox1.Name = "groupBox1";
  88. this.groupBox1.Size = new System.Drawing.Size(115, 386);
  89. this.groupBox1.TabIndex = 1;
  90. this.groupBox1.TabStop = false;
  91. this.groupBox1.Text = "类型";
  92. //
  93. // button3
  94. //
  95. this.button3.Location = new System.Drawing.Point(21, 59);
  96. this.button3.Name = "button3";
  97. this.button3.Size = new System.Drawing.Size(75, 23);
  98. this.button3.TabIndex = 0;
  99. this.button3.Text = "自动保存";
  100. this.button3.UseVisualStyleBackColor = true;
  101. this.button3.Click += new System.EventHandler(this.button3_Click);
  102. //
  103. // button2
  104. //
  105. this.button2.Location = new System.Drawing.Point(21, 29);
  106. this.button2.Name = "button2";
  107. this.button2.Size = new System.Drawing.Size(75, 23);
  108. this.button2.TabIndex = 1;
  109. this.button2.Text = "手动保存";
  110. this.button2.UseVisualStyleBackColor = true;
  111. this.button2.Click += new System.EventHandler(this.button2_Click);
  112. //
  113. // groupBox2
  114. //
  115. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  116. | System.Windows.Forms.AnchorStyles.Right)));
  117. this.groupBox2.Controls.Add(this.button4);
  118. this.groupBox2.Controls.Add(this.button1);
  119. this.groupBox2.Controls.Add(this.textBox1);
  120. this.groupBox2.Location = new System.Drawing.Point(134, 13);
  121. this.groupBox2.Name = "groupBox2";
  122. this.groupBox2.Size = new System.Drawing.Size(547, 52);
  123. this.groupBox2.TabIndex = 2;
  124. this.groupBox2.TabStop = false;
  125. this.groupBox2.Text = "保存路径";
  126. //
  127. // button4
  128. //
  129. this.button4.Location = new System.Drawing.Point(385, 19);
  130. this.button4.Name = "button4";
  131. this.button4.Size = new System.Drawing.Size(75, 23);
  132. this.button4.TabIndex = 2;
  133. this.button4.Text = "选择";
  134. this.button4.UseVisualStyleBackColor = true;
  135. this.button4.Click += new System.EventHandler(this.button4_Click);
  136. //
  137. // button1
  138. //
  139. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  140. | System.Windows.Forms.AnchorStyles.Left)
  141. | System.Windows.Forms.AnchorStyles.Right)));
  142. this.button1.Location = new System.Drawing.Point(466, 19);
  143. this.button1.Name = "button1";
  144. this.button1.Size = new System.Drawing.Size(75, 23);
  145. this.button1.TabIndex = 1;
  146. this.button1.Text = "保存";
  147. this.button1.UseVisualStyleBackColor = true;
  148. this.button1.Click += new System.EventHandler(this.button1_Click);
  149. //
  150. // textBox1
  151. //
  152. this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  153. | System.Windows.Forms.AnchorStyles.Left)
  154. | System.Windows.Forms.AnchorStyles.Right)));
  155. this.textBox1.Location = new System.Drawing.Point(7, 20);
  156. this.textBox1.Name = "textBox1";
  157. this.textBox1.ReadOnly = true;
  158. this.textBox1.Size = new System.Drawing.Size(372, 21);
  159. this.textBox1.TabIndex = 0;
  160. //
  161. // panel1
  162. //
  163. this.panel1.Location = new System.Drawing.Point(135, 72);
  164. this.panel1.Name = "panel1";
  165. this.panel1.Size = new System.Drawing.Size(546, 327);
  166. this.panel1.TabIndex = 3;
  167. //
  168. // BatchSaveDialog
  169. //
  170. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  171. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  172. this.ClientSize = new System.Drawing.Size(693, 411);
  173. this.Controls.Add(this.panel1);
  174. this.Controls.Add(this.groupBox2);
  175. this.Controls.Add(this.groupBox1);
  176. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
  177. this.MaximizeBox = false;
  178. this.MinimizeBox = false;
  179. this.Name = "BatchSaveDialog";
  180. this.Text = "批量保存";
  181. this.Controls.SetChildIndex(this.groupBox1, 0);
  182. this.Controls.SetChildIndex(this.groupBox2, 0);
  183. this.Controls.SetChildIndex(this.panel1, 0);
  184. this.groupBox1.ResumeLayout(false);
  185. this.groupBox2.ResumeLayout(false);
  186. this.groupBox2.PerformLayout();
  187. this.ResumeLayout(false);
  188. }
  189. /// <summary>
  190. /// 手动保存
  191. /// </summary>
  192. /// <param name="sender"></param>
  193. /// <param name="e"></param>
  194. private void button2_Click(object sender, EventArgs e)
  195. {
  196. this.typesOf = 1;
  197. this.handSaveControl = new HandSaveControl(appWorkspace);
  198. this.panel1.Controls.Clear();
  199. this.panel1.Controls.Add(this.handSaveControl);
  200. }
  201. /// <summary>
  202. /// 自动保存
  203. /// </summary>
  204. /// <param name="sender"></param>
  205. /// <param name="e"></param>
  206. private void button3_Click(object sender, EventArgs e)
  207. {
  208. this.typesOf = 2;
  209. this.autoSaveControl = new AutoSaveControl(this.appWorkspace);
  210. this.panel1.Controls.Clear();
  211. this.panel1.Controls.Add(this.autoSaveControl);
  212. }
  213. /// <summary>
  214. /// 选择保存路径
  215. /// </summary>
  216. /// <param name="sender"></param>
  217. /// <param name="e"></param>
  218. private void button4_Click(object sender, EventArgs e)
  219. {
  220. DialogResult dialogResult = this.folderBrowserDialog1.ShowDialog();
  221. if (dialogResult == DialogResult.OK)
  222. {
  223. this.textBox1.Text = this.folderBrowserDialog1.SelectedPath;
  224. }
  225. }
  226. /// <summary>
  227. /// 保存
  228. /// </summary>
  229. /// <param name="sender"></param>
  230. /// <param name="e"></param>
  231. private void button1_Click(object sender, EventArgs e)
  232. {
  233. if (this.textBox1.Text == null || this.textBox1.Text.Equals(""))
  234. {
  235. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthesavepathfirst.text"));
  236. return;
  237. }
  238. if (!System.IO.Directory.Exists(this.textBox1.Text))
  239. {
  240. MessageBox.Show("文件夹不存在,请检查");
  241. return;
  242. }
  243. if (this.typesOf == 1) //手动
  244. {
  245. //判断图片名称是否为空,并且判断list内是否有重复的文件名称 todo
  246. //this.handSaveControl.textBoxes;
  247. //this.handSaveControl.comboBoxes;
  248. bool next = true;
  249. for (int i = 0; i < this.handSaveControl.textBoxes.Count; i++)
  250. {
  251. int sum = this.handSaveControl.textBoxes.FindAll(a => a.Text.Equals(this.handSaveControl.textBoxes[i].Text)).Count;
  252. if (sum > 1)
  253. {
  254. next = false;
  255. }
  256. }
  257. if (!next)
  258. {
  259. MessageBox.Show(PdnResources.GetString("Menu.Thefilenandmodify.text") + "!");
  260. return;
  261. }
  262. //是否生成配置文件
  263. bool createConfig = this.handSaveControl.checkBox1.Checked;
  264. //保存后是否关闭图像
  265. bool afterSaveClost = this.handSaveControl.checkBox2.Checked;
  266. //是否压缩
  267. bool compress = this.handSaveControl.checkBox5.Checked;
  268. //压缩比例
  269. decimal compressRate = this.handSaveControl.numericUpDown1.Value;
  270. if (this.appWorkspace != null && this.appWorkspace.DocumentWorkspaces != null)
  271. {
  272. //组织包含所有名称的数组
  273. string[] fileNames = new string[this.appWorkspace.DocumentWorkspaces.Length];
  274. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  275. {
  276. string file = this.textBox1.Text + "\\" + this.handSaveControl.textBoxes[i].Text;
  277. file += this.handSaveControl.comboBoxes[i].SelectedValue;
  278. fileNames[i] = file;
  279. }
  280. // 1、检查是否存在重名 2、覆盖 3、移动
  281. int actionType = 1;
  282. for (int i = this.appWorkspace.DocumentWorkspaces.Length - 1; i >= 0; i--)
  283. {
  284. string fileName = this.textBox1.Text + "\\" + this.handSaveControl.textBoxes[i].Text;
  285. fileName += this.handSaveControl.comboBoxes[i].SelectedValue;
  286. //判断文件夹内是否存在重名的
  287. if (System.IO.File.Exists(fileName))
  288. {
  289. if (actionType == 1)
  290. {
  291. TaskButton saveTB = new TaskButton(
  292. PdnResources.GetImageResource("Icons.MenuFileSaveIcon.png").Reference,
  293. PdnResources.GetString("Menu.cover.Text"),
  294. //PdnResources.GetString("CloseWorkspaceAction.SaveButton.ActionText"),
  295. PdnResources.GetString("Menu.Replaceexistingfiles.Text")
  296. //PdnResources.GetString("CloseWorkspaceAction.SaveButton.ExplanationText")
  297. );
  298. TaskButton dontSaveTB = new TaskButton(
  299. PdnResources.GetImageResource("Icons.MenuFileCloseIcon.png").Reference,
  300. PdnResources.GetString("Menu.Movekeeptwofiles.Text"),
  301. //PdnResources.GetString("CloseWorkspaceAction.DontSaveButton.ActionText"),
  302. PdnResources.GetString("Menu.Thenewfilewillberenamed.Text")
  303. //PdnResources.GetString("CloseWorkspaceAction.DontSaveButton.ExplanationText")
  304. );
  305. TaskButton cancelTB = new TaskButton(
  306. PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
  307. PdnResources.GetString("CloseWorkspaceAction.CancelButton.ActionText"),
  308. PdnResources.GetString("CloseWorkspaceAction.CancelButton.ExplanationText"));
  309. string title = PdnResources.GetString("Menu.Thefilealreadyxists.Text");
  310. string introTextFormat = PdnResources.GetString("CloseWorkspaceAction.IntroText.Format");
  311. string introText = fileName;
  312. Image taskImage = DrawRulerHelper.ResizeImage(this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.CreateAliasedBitmap(), 115, 86, Base.Enum.ThumbnailMode.Cut);
  313. Form mainForm = appWorkspace.FindForm();
  314. if (mainForm != null)
  315. {
  316. PdnBaseForm asPDF = mainForm as PdnBaseForm;
  317. if (asPDF != null)
  318. {
  319. asPDF.RestoreWindow();
  320. }
  321. }
  322. Icon warningIcon;
  323. ImageResource warningIconImageRes = PdnResources.GetImageResource("Icons.WarningIcon.png");
  324. if (warningIconImageRes != null)
  325. {
  326. Image warningIconImage = warningIconImageRes.Reference;
  327. warningIcon = Utility.ImageToIcon(warningIconImage, false);
  328. }
  329. else
  330. {
  331. warningIcon = null;
  332. }
  333. //是否选中了为之后的n个冲突执行此操作
  334. bool useChecked = false;
  335. //获取在这个文件之后还有多少重名文件
  336. int num = FileOperationHelper.GetNumAfterThisFile(fileNames, i);
  337. TaskButton clickedTB = TaskDialog.Show(
  338. appWorkspace,
  339. warningIcon,
  340. title,
  341. taskImage,
  342. false,
  343. introText,
  344. new TaskButton[] { saveTB, dontSaveTB, cancelTB },
  345. saveTB,
  346. cancelTB,
  347. 340,
  348. true,
  349. num,
  350. out useChecked);
  351. if (clickedTB == saveTB) //覆盖
  352. {
  353. if (useChecked) actionType = 2;
  354. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  355. }
  356. else if (clickedTB == dontSaveTB) //移动
  357. {
  358. if (useChecked) actionType = 3;
  359. fileName = FileOperationHelper.GetReNameFile(fileName);
  360. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  361. }
  362. }
  363. else if (actionType == 2) //覆盖
  364. {
  365. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  366. }
  367. else if (actionType == 3) //移动
  368. {
  369. //获取新文件名
  370. fileName = FileOperationHelper.GetReNameFile(fileName);
  371. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  372. }
  373. }
  374. else
  375. {
  376. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  377. }
  378. }
  379. }
  380. batchSaveAutoModel.fileRoute = this.textBox1.Text;
  381. batchSaveAutoModel.createConfig = createConfig;
  382. batchSaveAutoModel.afterSaveClost = afterSaveClost;
  383. batchSaveAutoModel.compress = compress;
  384. batchSaveAutoModel.compressRate = compressRate;
  385. batchSaveAutoModel.Whether = true;
  386. //另存为XML
  387. string stageModelXml = XmlSerializeHelper.XmlSerialize<BatchSaveAutoModel>(batchSaveAutoModel);
  388. string filePath = Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml";
  389. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  390. MessageBox.Show(PdnResources.GetString("Menu.Batchsavesuccessfully.text"));
  391. this.Close();
  392. }
  393. else if (this.typesOf == 2) //自动
  394. {
  395. //新文件名
  396. string fileName = this.autoSaveControl.textBox1.Text;
  397. //开始数字
  398. decimal startNum = this.autoSaveControl.numericUpDown2.Value;
  399. //前缀
  400. string prefix = string.IsNullOrEmpty(this.autoSaveControl.textBox3.Text) ? "" : this.autoSaveControl.textBox3.Text + "_";
  401. //后缀
  402. string suffix = string.IsNullOrEmpty(this.autoSaveControl.textBox4.Text) ? "" : "_" + this.autoSaveControl.textBox4.Text;
  403. //图片格式
  404. string format = this.autoSaveControl.comboBox1.Text;
  405. //是否生成配置文件
  406. bool createConfig = this.autoSaveControl.checkBox1.Checked;
  407. //保存后是否关闭图像
  408. bool afterSaveClost = this.autoSaveControl.checkBox2.Checked;
  409. //是否压缩
  410. bool compress = this.autoSaveControl.checkBox5.Checked;
  411. //压缩比例
  412. decimal compressRate = this.autoSaveControl.numericUpDown1.Value;
  413. if (string.IsNullOrEmpty(fileName))
  414. {
  415. //MessageBox.Show("请输入新文件名");
  416. //return;
  417. fileName = PdnResources.GetString("Menu.File.BulkSave.Text") + DateTime.Now.ToString("HHmmss");
  418. }
  419. //if (string.IsNullOrEmpty(prefix))
  420. //{
  421. // MessageBox.Show("请输入文件前缀名");
  422. // return;
  423. //}
  424. //if (string.IsNullOrEmpty(suffix))
  425. //{
  426. // MessageBox.Show("请输入文件后缀");
  427. // return;
  428. //}
  429. if (this.appWorkspace != null && this.appWorkspace.DocumentWorkspaces != null)
  430. {
  431. //组织包含所有名称的数组
  432. string[] fileNames = new string[this.appWorkspace.DocumentWorkspaces.Length];
  433. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  434. {
  435. string file = this.textBox1.Text + "\\" + prefix + fileName + "_" + (((int)startNum) + i) + suffix;
  436. file += this.autoSaveControl.comboBox1.SelectedValue;
  437. fileNames[i] = file;
  438. }
  439. // 1、检查是否存在重名 2、覆盖 3、移动
  440. int actionType = 1;
  441. for (int i = this.appWorkspace.DocumentWorkspaces.Length - 1; i >= 0; i--)
  442. {
  443. string fileName1 = this.textBox1.Text + "\\" + prefix + fileName + "_" + (((int)startNum) + i) + suffix;
  444. fileName1 += this.autoSaveControl.comboBox1.SelectedValue;
  445. //判断文件夹内是否存在重名的
  446. if (System.IO.File.Exists(fileName1))
  447. {
  448. if (actionType == 1)
  449. {
  450. TaskButton saveTB = new TaskButton(
  451. PdnResources.GetImageResource("Icons.MenuFileSaveIcon.png").Reference,
  452. PdnResources.GetString("Menu.cover.Text"),
  453. PdnResources.GetString("Menu.Replaceexistingfiles.Text")
  454. );
  455. TaskButton dontSaveTB = new TaskButton(
  456. PdnResources.GetImageResource("Icons.MenuFileCloseIcon.png").Reference,
  457. PdnResources.GetString("Menu.Movekeeptwofiles.Text"),
  458. PdnResources.GetString("Menu.Thenewfilewillberenamed.Text")
  459. );
  460. TaskButton cancelTB = new TaskButton(
  461. PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
  462. PdnResources.GetString("CloseWorkspaceAction.CancelButton.ActionText"),
  463. PdnResources.GetString("CloseWorkspaceAction.CancelButton.ExplanationText"));
  464. string title = PdnResources.GetString("Menu.Thefilealreadyxists.Text");
  465. string introTextFormat = PdnResources.GetString("CloseWorkspaceAction.IntroText.Format");
  466. string introText = fileName;
  467. Image taskImage = DrawRulerHelper.ResizeImage(this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail/**CreateAliasedBitmap()**/, 115, 86, Base.Enum.ThumbnailMode.Cut);
  468. Form mainForm = appWorkspace.FindForm();
  469. if (mainForm != null)
  470. {
  471. PdnBaseForm asPDF = mainForm as PdnBaseForm;
  472. if (asPDF != null)
  473. {
  474. asPDF.RestoreWindow();
  475. }
  476. }
  477. Icon warningIcon;
  478. ImageResource warningIconImageRes = PdnResources.GetImageResource("Icons.WarningIcon.png");
  479. if (warningIconImageRes != null)
  480. {
  481. Image warningIconImage = warningIconImageRes.Reference;
  482. warningIcon = Utility.ImageToIcon(warningIconImage, false);
  483. }
  484. else
  485. {
  486. warningIcon = null;
  487. }
  488. //是否选中了为之后的n个冲突执行此操作
  489. bool useChecked = false;
  490. //获取在这个文件之后还有多少重名文件
  491. int num = FileOperationHelper.GetNumAfterThisFile(fileNames, i);
  492. TaskButton clickedTB = TaskDialog.Show(
  493. appWorkspace,
  494. warningIcon,
  495. title,
  496. taskImage,
  497. false,
  498. introText,
  499. new TaskButton[] { saveTB, dontSaveTB, cancelTB },
  500. saveTB,
  501. cancelTB,
  502. 340,
  503. true,
  504. num,
  505. out useChecked);
  506. if (clickedTB == saveTB) //覆盖
  507. {
  508. if (useChecked) actionType = 2;
  509. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  510. }
  511. else if (clickedTB == dontSaveTB) //移动
  512. {
  513. if (useChecked) actionType = 3;
  514. fileName1 = FileOperationHelper.GetReNameFile(fileName1);
  515. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  516. }
  517. }
  518. else if (actionType == 2) //覆盖
  519. {
  520. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  521. }
  522. else if (actionType == 3) //移动
  523. {
  524. //获取新文件名
  525. fileName1 = FileOperationHelper.GetReNameFile(fileName1);
  526. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  527. }
  528. }
  529. else
  530. {
  531. this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, false, false, compress, compressRate, false);
  532. }
  533. }
  534. }
  535. batchSaveAutoModel.fileRoute = this.textBox1.Text;
  536. batchSaveAutoModel.fileName = fileName;
  537. batchSaveAutoModel.startNum = startNum + this.appWorkspace.DocumentWorkspaces.Length;
  538. batchSaveAutoModel.prefix = prefix;
  539. batchSaveAutoModel.suffix = suffix;
  540. batchSaveAutoModel.format = format;
  541. batchSaveAutoModel.createConfig = createConfig;
  542. batchSaveAutoModel.afterSaveClost = afterSaveClost;
  543. batchSaveAutoModel.compress = compress;
  544. batchSaveAutoModel.compressRate = compressRate;
  545. batchSaveAutoModel.Whether = true;
  546. //另存为XML
  547. string stageModelXml = XmlSerializeHelper.XmlSerialize<BatchSaveAutoModel>(batchSaveAutoModel);
  548. string filePath = Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml";
  549. FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
  550. MessageBox.Show(PdnResources.GetString("Menu.Batchsavesuccessfully.text"));
  551. this.Close();
  552. }
  553. }
  554. }
  555. }