123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 |
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.File.BatchSaveComponet;
- using System;
- using System.Drawing;
- using System.IO;
- using System.Windows.Forms;
- namespace PaintDotNet.File
- {
- /// <summary>
- /// 批量保存
- /// </summary>
- internal class BatchSaveDialog : PdnBaseForm
- {
- private AppWorkspace appWorkspace;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.Button button3;
- private Button button4;
- private Panel panel1;
- private FolderBrowserDialog folderBrowserDialog1;
- private HandSaveControl handSaveControl;
- private AutoSaveControl autoSaveControl;
- /// <summary>
- /// 文件 - 批量保存自动配置
- /// </summary>
- public BatchSaveAutoModel batchSaveAutoModel;
- /// <summary>
- /// 1手动 2自动
- /// </summary>
- private int typesOf = 2;
- public BatchSaveDialog(AppWorkspace appWorkspace)
- {
- this.appWorkspace = appWorkspace;
- InitializeComponent();
- InitializeLanguageText();
- this.Text = PdnResources.GetString("Menu.File.BulkSave.Text");
- this.button3.Focus();
- this.autoSaveControl = new AutoSaveControl(this.appWorkspace);
- this.panel1.Controls.Add(this.autoSaveControl);
- }
- private void InitializeLanguageText()
- {
- batchSaveAutoModel = XmlSerializeHelper.DESerializer<BatchSaveAutoModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml", FileMode.Open));
- this.groupBox1.Text = PdnResources.GetString("Menu.Type.text");
- this.button3.Text = PdnResources.GetString("Menu.file.Batchsaving.autosave.text");
- this.button2.Text = PdnResources.GetString("Menu.file.Batchsaving.Savemanually.text");
- this.groupBox2.Text = PdnResources.GetString("Menu.saveroute.text");
- this.button4.Text = PdnResources.GetString("Menu.MeasureAction.MeasureSelect.Text");
- this.button1.Text = PdnResources.GetString("Menu.File.Save.Text");
- //this.textBox1.Text = batchSaveAutoModel.fileRoute;
- this.textBox1.Text = Startup.instance.configModel.FileOpenPath;
- }
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button3 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
- this.panel1 = new System.Windows.Forms.Panel();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox1.Controls.Add(this.button3);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Location = new System.Drawing.Point(13, 13);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(115, 386);
- this.groupBox1.TabIndex = 1;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "类型";
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(21, 59);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 0;
- this.button3.Text = "自动保存";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(21, 29);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 1;
- this.button2.Text = "手动保存";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // groupBox2
- //
- this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox2.Controls.Add(this.button4);
- this.groupBox2.Controls.Add(this.button1);
- this.groupBox2.Controls.Add(this.textBox1);
- this.groupBox2.Location = new System.Drawing.Point(134, 13);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(547, 52);
- this.groupBox2.TabIndex = 2;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "保存路径";
- //
- // button4
- //
- this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button4.Location = new System.Drawing.Point(385, 19);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 23);
- this.button4.TabIndex = 2;
- this.button4.Text = "选择";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button1
- //
- this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.button1.Location = new System.Drawing.Point(466, 19);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 1;
- this.button1.Text = "保存";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // textBox1
- //
- this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.textBox1.Location = new System.Drawing.Point(7, 20);
- this.textBox1.Name = "textBox1";
- this.textBox1.ReadOnly = true;
- this.textBox1.Size = new System.Drawing.Size(372, 21);
- this.textBox1.TabIndex = 0;
- //
- // panel1
- //
- this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.panel1.Location = new System.Drawing.Point(135, 72);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(546, 327);
- this.panel1.TabIndex = 3;
- //
- // BatchSaveDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(693, 411);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Name = "BatchSaveDialog";
- this.Text = "批量保存";
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.panel1, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 手动保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- this.typesOf = 1;
- this.handSaveControl = new HandSaveControl(appWorkspace);
- this.handSaveControl.Dock = DockStyle.Fill;
- this.panel1.Controls.Clear();
- this.panel1.Controls.Add(this.handSaveControl);
- }
- /// <summary>
- /// 自动保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- this.typesOf = 2;
- this.autoSaveControl = new AutoSaveControl(this.appWorkspace);
- this.panel1.Controls.Clear();
- this.panel1.Controls.Add(this.autoSaveControl);
- }
- /// <summary>
- /// 选择保存路径
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- DialogResult dialogResult = this.folderBrowserDialog1.ShowDialog();
- if(dialogResult == DialogResult.OK)
- {
- this.textBox1.Text = this.folderBrowserDialog1.SelectedPath;
- }
- }
-
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.textBox1.Text == null || this.textBox1.Text.Equals(""))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthesavepathfirst.text"));
- return;
- }
- if (!System.IO.Directory.Exists(this.textBox1.Text))
- {
- MessageBox.Show("文件夹不存在,请检查");
- return;
- }
- if (this.typesOf==1) //手动
- {
- //判断图片名称是否为空,并且判断list内是否有重复的文件名称 todo
- //this.handSaveControl.textBoxes;
- //this.handSaveControl.comboBoxes;
- bool next = true;
- for (int i=0; i< this.handSaveControl.textBoxes.Count; i++)
- {
- int sum = this.handSaveControl.textBoxes.FindAll(a => a.Text.Equals(this.handSaveControl.textBoxes[i].Text)).Count;
- if (sum > 1)
- {
- next = false;
- }
- }
- if(!next)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Thefilenandmodify.text")+"!");
- return;
- }
- //是否生成配置文件
- bool createConfig = this.handSaveControl.checkBox1.Checked;
- //保存后是否关闭图像
- bool afterSaveClost = this.handSaveControl.checkBox2.Checked;
- //保存时是否保存网格数据
- bool saveGridLine = this.handSaveControl.checkBox3.Checked;
- //标注及测量信息是否嵌入图像
- bool implantLabelAndMeasure = this.handSaveControl.checkBox4.Checked;
- //相信息是否嵌入图像
- bool implantPhase = this.handSaveControl.checkBox6.Checked;
- //是否压缩
- bool compress = this.handSaveControl.checkBox5.Checked;
- //压缩比例
- decimal compressRate = this.handSaveControl.numericUpDown1.Value;
- if (this.appWorkspace != null && this.appWorkspace.DocumentWorkspaces != null)
- {
- //组织包含所有名称的数组
- string[] fileNames = new string[this.appWorkspace.DocumentWorkspaces.Length];
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- string file = this.textBox1.Text + "\\" + this.handSaveControl.textBoxes[i].Text;
- file += this.handSaveControl.comboBoxes[i].SelectedValue;
- fileNames[i] = file;
- }
-
- // 1、检查是否存在重名 2、覆盖 3、移动
- int actionType = 1;
- for (int i = this.appWorkspace.DocumentWorkspaces.Length - 1; i >= 0 ; i--)
- {
- this.appWorkspace.DocumentWorkspaces[i].GraphicsList.UnselectAll();
- string fileName = this.textBox1.Text + "\\" + this.handSaveControl.textBoxes[i].Text;
- fileName += this.handSaveControl.comboBoxes[i].SelectedValue;
- //判断文件夹内是否存在重名的
- if (System.IO.File.Exists(fileName))
- {
- if (actionType == 1)
- {
- TaskButton saveTB = new TaskButton(
- PdnResources.GetImageResource("Icons.MenuFileSaveIcon.png").Reference,
- PdnResources.GetString("Menu.cover.Text"),
- //PdnResources.GetString("CloseWorkspaceAction.SaveButton.ActionText"),
- PdnResources.GetString("Menu.Replaceexistingfiles.Text")
- //PdnResources.GetString("CloseWorkspaceAction.SaveButton.ExplanationText")
- );
- TaskButton dontSaveTB = new TaskButton(
- PdnResources.GetImageResource("Icons.MenuFileCloseIcon.png").Reference,
- PdnResources.GetString("Menu.Movekeeptwofiles.Text"),
- //PdnResources.GetString("CloseWorkspaceAction.DontSaveButton.ActionText"),
- PdnResources.GetString("Menu.Thenewfilewillberenamed.Text")
- //PdnResources.GetString("CloseWorkspaceAction.DontSaveButton.ExplanationText")
- );
- TaskButton cancelTB = new TaskButton(
- PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
- PdnResources.GetString("CloseWorkspaceAction.CancelButton.ActionText"),
- PdnResources.GetString("CloseWorkspaceAction.CancelButton.ExplanationText"));
- string title = PdnResources.GetString("Menu.Thefilealreadyxists.Text");
- string introTextFormat = PdnResources.GetString("CloseWorkspaceAction.IntroText.Format");
- string introText = fileName;
- Image taskImage = DrawRulerHelper.ResizeImage(this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.CreateAliasedBitmap(), 115, 86, Base.Enum.ThumbnailMode.Cut);
- Form mainForm = appWorkspace.FindForm();
- if (mainForm != null)
- {
- PdnBaseForm asPDF = mainForm as PdnBaseForm;
- if (asPDF != null)
- {
- asPDF.RestoreWindow();
- }
- }
- Icon warningIcon;
- ImageResource warningIconImageRes = PdnResources.GetImageResource("Icons.WarningIcon.png");
- if (warningIconImageRes != null)
- {
- Image warningIconImage = warningIconImageRes.Reference;
- warningIcon = Utility.ImageToIcon(warningIconImage, false);
- }
- else
- {
- warningIcon = null;
- }
- //是否选中了为之后的n个冲突执行此操作
- bool useChecked = false;
- //获取在这个文件之后还有多少重名文件
- int num = FileOperationHelper.GetNumAfterThisFile(fileNames, i);
- TaskButton clickedTB = TaskDialog.Show(
- appWorkspace,
- warningIcon,
- title,
- taskImage,
- false,
- introText,
- new TaskButton[] { saveTB, dontSaveTB, cancelTB },
- saveTB,
- cancelTB,
- 340,
- true,
- num,
- out useChecked);
- if (clickedTB == saveTB) //覆盖
- {
- if(useChecked) actionType = 2;
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- else if (clickedTB == dontSaveTB) //移动
- {
- if (useChecked) actionType = 3;
- fileName = FileOperationHelper.GetReNameFile(fileName);
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- }
- else if (actionType == 2) //覆盖
- {
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- else if (actionType == 3) //移动
- {
- //获取新文件名
- fileName = FileOperationHelper.GetReNameFile(fileName);
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- }
- else
- {
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- }
- }
- batchSaveAutoModel.fileRoute = this.textBox1.Text;
- batchSaveAutoModel.createConfig = createConfig;
- batchSaveAutoModel.afterSaveClost = afterSaveClost;
- batchSaveAutoModel.saveGridLine = saveGridLine;
- batchSaveAutoModel.implantLabelAndMeasure = implantLabelAndMeasure;
- batchSaveAutoModel.implantPhase = implantPhase;
- batchSaveAutoModel.compress = compress;
- batchSaveAutoModel.compressRate = compressRate;
- batchSaveAutoModel.Whether = true;
- //另存为XML
- string stageModelXml = XmlSerializeHelper.XmlSerialize<BatchSaveAutoModel>(batchSaveAutoModel);
- string filePath = Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- MessageBox.Show(PdnResources.GetString("Menu.Batchsavesuccessfully.text"));
- this.Close();
- }
- else if(this.typesOf == 2) //自动
- {
- //新文件名
- string fileName = this.autoSaveControl.textBox1.Text;
- //开始数字
- decimal startNum = this.autoSaveControl.numericUpDown2.Value;
- //前缀
- string prefix = string.IsNullOrEmpty(this.autoSaveControl.textBox3.Text) ? "" : this.autoSaveControl.textBox3.Text + "_";
- //后缀
- string suffix = string.IsNullOrEmpty(this.autoSaveControl.textBox4.Text) ? "" : "_" + this.autoSaveControl.textBox4.Text;
- //图片格式
- string format = this.autoSaveControl.comboBox1.Text;
- //是否生成配置文件
- bool createConfig = this.autoSaveControl.checkBox1.Checked;
- //保存后是否关闭图像
- bool afterSaveClost = this.autoSaveControl.checkBox2.Checked;
- //保存时是否保存网格数据
- bool saveGridLine = this.autoSaveControl.checkBox3.Checked;
- //标注及测量信息是否嵌入图像
- bool implantLabelAndMeasure = this.autoSaveControl.checkBox4.Checked;
- //相信息是否嵌入图像
- bool implantPhase = this.autoSaveControl.checkBox6.Checked;
- //是否压缩
- bool compress = this.autoSaveControl.checkBox5.Checked;
- //压缩比例
- decimal compressRate = this.autoSaveControl.numericUpDown1.Value;
-
-
- if (string.IsNullOrEmpty(fileName))
- {
- //MessageBox.Show("请输入新文件名");
- //return;
- fileName = PdnResources.GetString("Menu.File.BulkSave.Text") + DateTime.Now.ToString("HHmmss");
- }
- //if (string.IsNullOrEmpty(prefix))
- //{
- // MessageBox.Show("请输入文件前缀名");
- // return;
- //}
- //if (string.IsNullOrEmpty(suffix))
- //{
- // MessageBox.Show("请输入文件后缀");
- // return;
- //}
- if (this.appWorkspace != null && this.appWorkspace.DocumentWorkspaces != null)
- {
- //组织包含所有名称的数组
- string[] fileNames = new string[this.appWorkspace.DocumentWorkspaces.Length];
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.appWorkspace.DocumentWorkspaces[i].GraphicsList.UnselectAll();
- string file = this.textBox1.Text + "\\" + prefix + fileName + "_" + (((int)startNum) + i) + suffix;
- file += this.autoSaveControl.comboBox1.SelectedValue;
- fileNames[i] = file;
- }
- // 1、检查是否存在重名 2、覆盖 3、移动
- int actionType = 1;
- for (int i = this.appWorkspace.DocumentWorkspaces.Length - 1; i >= 0 ; i--)
- {
- string fileName1 = this.textBox1.Text +"\\"+ prefix + fileName + "_" + (((int)startNum) + i) + suffix;
- fileName1 += this.autoSaveControl.comboBox1.SelectedValue;
- //判断文件夹内是否存在重名的
- if (System.IO.File.Exists(fileName1))
- {
- if (actionType == 1)
- {
- TaskButton saveTB = new TaskButton(
- PdnResources.GetImageResource("Icons.MenuFileSaveIcon.png").Reference,
- PdnResources.GetString("Menu.cover.Text"),
- PdnResources.GetString("Menu.Replaceexistingfiles.Text")
- );
- TaskButton dontSaveTB = new TaskButton(
- PdnResources.GetImageResource("Icons.MenuFileCloseIcon.png").Reference,
- PdnResources.GetString("Menu.Movekeeptwofiles.Text"),
- PdnResources.GetString("Menu.Thenewfilewillberenamed.Text")
- );
- TaskButton cancelTB = new TaskButton(
- PdnResources.GetImageResource("Icons.CancelIcon.png").Reference,
- PdnResources.GetString("CloseWorkspaceAction.CancelButton.ActionText"),
- PdnResources.GetString("CloseWorkspaceAction.CancelButton.ExplanationText"));
- string title = PdnResources.GetString("Menu.Thefilealreadyxists.Text");
- string introTextFormat = PdnResources.GetString("CloseWorkspaceAction.IntroText.Format");
- string introText = fileName;
- Image taskImage = DrawRulerHelper.ResizeImage(this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail/**CreateAliasedBitmap()**/, 115, 86, Base.Enum.ThumbnailMode.Cut);
- Form mainForm = appWorkspace.FindForm();
- if (mainForm != null)
- {
- PdnBaseForm asPDF = mainForm as PdnBaseForm;
- if (asPDF != null)
- {
- asPDF.RestoreWindow();
- }
- }
- Icon warningIcon;
- ImageResource warningIconImageRes = PdnResources.GetImageResource("Icons.WarningIcon.png");
- if (warningIconImageRes != null)
- {
- Image warningIconImage = warningIconImageRes.Reference;
- warningIcon = Utility.ImageToIcon(warningIconImage, false);
- }
- else
- {
- warningIcon = null;
- }
- //是否选中了为之后的n个冲突执行此操作
- bool useChecked = false;
- //获取在这个文件之后还有多少重名文件
- int num = FileOperationHelper.GetNumAfterThisFile(fileNames, i);
- TaskButton clickedTB = TaskDialog.Show(
- appWorkspace,
- warningIcon,
- title,
- taskImage,
- false,
- introText,
- new TaskButton[] { saveTB, dontSaveTB, cancelTB },
- saveTB,
- cancelTB,
- 340,
- true,
- num,
- out useChecked);
- if (clickedTB == saveTB) //覆盖
- {
- if (useChecked) actionType = 2;
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- else if (clickedTB == dontSaveTB) //移动
- {
- if (useChecked) actionType = 3;
- fileName1 = FileOperationHelper.GetReNameFile(fileName1);
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- }
- else if (actionType == 2) //覆盖
- {
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- else if (actionType == 3) //移动
- {
- //获取新文件名
- fileName1 = FileOperationHelper.GetReNameFile(fileName1);
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- }
- else
- {
- this.appWorkspace.DocumentWorkspaces[i].SaveForBatch(fileName1, createConfig, afterSaveClost, saveGridLine, implantLabelAndMeasure, compress, compressRate, implantPhase);
- }
- }
- }
- batchSaveAutoModel.fileRoute = this.textBox1.Text;
- batchSaveAutoModel.fileName = fileName;
- batchSaveAutoModel.startNum = startNum + this.appWorkspace.DocumentWorkspaces.Length;
- batchSaveAutoModel.prefix = prefix == "" ? prefix : prefix.Substring(0,prefix.Length-1);
- batchSaveAutoModel.suffix = suffix == "" ? suffix : suffix.Substring(1,suffix.Length - 1);
- batchSaveAutoModel.format = format;
- batchSaveAutoModel.createConfig = createConfig;
- batchSaveAutoModel.afterSaveClost = afterSaveClost;
- batchSaveAutoModel.saveGridLine = saveGridLine;
- batchSaveAutoModel.implantLabelAndMeasure = implantLabelAndMeasure;
- batchSaveAutoModel.implantPhase = implantPhase;
- batchSaveAutoModel.compress = compress;
- batchSaveAutoModel.compressRate = compressRate;
- batchSaveAutoModel.Whether = true;
- //另存为XML
- string stageModelXml = XmlSerializeHelper.XmlSerialize<BatchSaveAutoModel>(batchSaveAutoModel);
- string filePath = Application.StartupPath + @"\Config\Default\File\BatchSaveAuto.xml";
- FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create);
- MessageBox.Show(PdnResources.GetString("Menu.Batchsavesuccessfully.text"));
- this.Close();
- }
- appWorkspace.Widgets.ImageIndexDialog.InitData();
- }
- }
- }
|