diff --git a/MifareOneTool/Form1.Designer.cs b/MifareOneTool/Form1.Designer.cs index 174b5f3..102a1ff 100644 --- a/MifareOneTool/Form1.Designer.cs +++ b/MifareOneTool/Form1.Designer.cs @@ -91,13 +91,15 @@ this.label1 = new System.Windows.Forms.Label(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.groupBox13 = new System.Windows.Forms.GroupBox(); + this.checkBoxDefIsAdv = new System.Windows.Forms.CheckBox(); this.groupBox12 = new System.Windows.Forms.GroupBox(); this.numericCLIFontSize = new System.Windows.Forms.NumericUpDown(); this.label10 = new System.Windows.Forms.Label(); this.buttonCLIColor = new System.Windows.Forms.Button(); this.label9 = new System.Windows.Forms.Label(); - this.checkBoxWriteProtect = new System.Windows.Forms.CheckBox(); this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.checkBoxWriteProtect = new System.Windows.Forms.CheckBox(); this.checkBoxAutoLoadKey = new System.Windows.Forms.CheckBox(); this.checkBoxAutoABN = new System.Windows.Forms.CheckBox(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); @@ -107,8 +109,7 @@ this.remoteVersionLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripCheckUpdate = new System.Windows.Forms.ToolStripSplitButton(); this.timer1 = new System.Windows.Forms.Timer(this.components); - this.groupBox13 = new System.Windows.Forms.GroupBox(); - this.checkBoxDefIsAdv = new System.Windows.Forms.CheckBox(); + this.checkBoxAutoSave = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,11 +123,11 @@ this.groupBox9.SuspendLayout(); this.groupBox8.SuspendLayout(); this.tabPage3.SuspendLayout(); + this.groupBox13.SuspendLayout(); this.groupBox12.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericCLIFontSize)).BeginInit(); this.groupBox6.SuspendLayout(); this.statusStrip1.SuspendLayout(); - this.groupBox13.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -732,8 +733,8 @@ this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(232, 165); this.label5.TabIndex = 9; - this.label5.Text = "从这里开始\r\n\r\n\r\n\r\n\r\n\r\n\r\n本工具仅支持SAK=08/18/28的\r\n卡片复制。\r\n若要复制S70卡片,请在高级界\r\n面上取消勾选“数据写入保护”。\r\n" + - ""; + this.label5.Text = "从这里开始\r\n\r\n\r\n\r\n\r\n\r\n\r\n本工具仅支持SAK=08/18/28的\r\n卡片复制。SAK28无一键解密。\r\n若要复制S70卡片,请在高级界\r\n面上取消勾选" + + "“数据写入保护”。\r\n"; // // tabPage1 // @@ -825,6 +826,28 @@ this.tabPage3.Text = "软件设置"; this.tabPage3.UseVisualStyleBackColor = true; // + // groupBox13 + // + this.groupBox13.Controls.Add(this.checkBoxAutoSave); + this.groupBox13.Controls.Add(this.checkBoxDefIsAdv); + this.groupBox13.Location = new System.Drawing.Point(3, 109); + this.groupBox13.Name = "groupBox13"; + this.groupBox13.Size = new System.Drawing.Size(200, 71); + this.groupBox13.TabIndex = 13; + this.groupBox13.TabStop = false; + this.groupBox13.Text = "偏好设置"; + // + // checkBoxDefIsAdv + // + this.checkBoxDefIsAdv.AutoSize = true; + this.checkBoxDefIsAdv.Location = new System.Drawing.Point(9, 24); + this.checkBoxDefIsAdv.Name = "checkBoxDefIsAdv"; + this.checkBoxDefIsAdv.Size = new System.Drawing.Size(179, 19); + this.checkBoxDefIsAdv.TabIndex = 0; + this.checkBoxDefIsAdv.Text = "自动转到高级操作模式"; + this.checkBoxDefIsAdv.UseVisualStyleBackColor = true; + this.checkBoxDefIsAdv.CheckedChanged += new System.EventHandler(this.checkBoxDefIsAdv_CheckedChanged); + // // groupBox12 // this.groupBox12.Controls.Add(this.numericCLIFontSize); @@ -893,6 +916,18 @@ this.label9.TabIndex = 13; this.label9.Text = "终端文字颜色"; // + // groupBox6 + // + this.groupBox6.Controls.Add(this.checkBoxWriteProtect); + this.groupBox6.Controls.Add(this.checkBoxAutoLoadKey); + this.groupBox6.Controls.Add(this.checkBoxAutoABN); + this.groupBox6.Location = new System.Drawing.Point(3, 3); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(200, 100); + this.groupBox6.TabIndex = 0; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "卡操作相关"; + // // checkBoxWriteProtect // this.checkBoxWriteProtect.AutoSize = true; @@ -906,18 +941,6 @@ this.checkBoxWriteProtect.UseVisualStyleBackColor = true; this.checkBoxWriteProtect.CheckedChanged += new System.EventHandler(this.checkBoxWriteProtect_CheckedChanged); // - // groupBox6 - // - this.groupBox6.Controls.Add(this.checkBoxWriteProtect); - this.groupBox6.Controls.Add(this.checkBoxAutoLoadKey); - this.groupBox6.Controls.Add(this.checkBoxAutoABN); - this.groupBox6.Location = new System.Drawing.Point(3, 3); - this.groupBox6.Name = "groupBox6"; - this.groupBox6.Size = new System.Drawing.Size(200, 100); - this.groupBox6.TabIndex = 0; - this.groupBox6.TabStop = false; - this.groupBox6.Text = "卡操作相关"; - // // checkBoxAutoLoadKey // this.checkBoxAutoLoadKey.AutoSize = true; @@ -999,26 +1022,16 @@ this.timer1.Enabled = true; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // groupBox13 + // checkBoxAutoSave // - this.groupBox13.Controls.Add(this.checkBoxDefIsAdv); - this.groupBox13.Location = new System.Drawing.Point(3, 109); - this.groupBox13.Name = "groupBox13"; - this.groupBox13.Size = new System.Drawing.Size(200, 71); - this.groupBox13.TabIndex = 13; - this.groupBox13.TabStop = false; - this.groupBox13.Text = "偏好设置"; - // - // checkBoxDefIsAdv - // - this.checkBoxDefIsAdv.AutoSize = true; - this.checkBoxDefIsAdv.Location = new System.Drawing.Point(9, 24); - this.checkBoxDefIsAdv.Name = "checkBoxDefIsAdv"; - this.checkBoxDefIsAdv.Size = new System.Drawing.Size(179, 19); - this.checkBoxDefIsAdv.TabIndex = 0; - this.checkBoxDefIsAdv.Text = "自动转到高级操作模式"; - this.checkBoxDefIsAdv.UseVisualStyleBackColor = true; - this.checkBoxDefIsAdv.CheckedChanged += new System.EventHandler(this.checkBoxDefIsAdv_CheckedChanged); + this.checkBoxAutoSave.AutoSize = true; + this.checkBoxAutoSave.Location = new System.Drawing.Point(9, 46); + this.checkBoxAutoSave.Name = "checkBoxAutoSave"; + this.checkBoxAutoSave.Size = new System.Drawing.Size(173, 19); + this.checkBoxAutoSave.TabIndex = 1; + this.checkBoxAutoSave.Text = "自动以UID名保存文件"; + this.checkBoxAutoSave.UseVisualStyleBackColor = true; + this.checkBoxAutoSave.CheckedChanged += new System.EventHandler(this.checkBoxAutoSave_CheckedChanged); // // Form1 // @@ -1033,6 +1046,7 @@ this.MaximizeBox = false; this.Name = "Form1"; this.Text = "MifareOne Tool"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); @@ -1049,6 +1063,8 @@ this.groupBox9.PerformLayout(); this.groupBox8.ResumeLayout(false); this.tabPage3.ResumeLayout(false); + this.groupBox13.ResumeLayout(false); + this.groupBox13.PerformLayout(); this.groupBox12.ResumeLayout(false); this.groupBox12.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericCLIFontSize)).EndInit(); @@ -1056,8 +1072,6 @@ this.groupBox6.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); - this.groupBox13.ResumeLayout(false); - this.groupBox13.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1144,6 +1158,7 @@ private System.Windows.Forms.Label label10; private System.Windows.Forms.GroupBox groupBox13; private System.Windows.Forms.CheckBox checkBoxDefIsAdv; + private System.Windows.Forms.CheckBox checkBoxAutoSave; } } diff --git a/MifareOneTool/Form1.cs b/MifareOneTool/Form1.cs index b86b3c6..d8680ba 100644 --- a/MifareOneTool/Form1.cs +++ b/MifareOneTool/Form1.cs @@ -47,33 +47,55 @@ namespace MifareOneTool } else if (e.ProgressPercentage == 101) { - SaveFileDialog ofd = new SaveFileDialog(); - ofd.AddExtension = true; - ofd.DefaultExt = ".mfd"; - ofd.Title = "请选择MFD文件保存位置及文件名"; - ofd.OverwritePrompt = true; - ofd.Filter = "MFD文件|*.mfd|DUMP文件|*.dump"; - if (File.Exists(omfd) && new FileInfo(omfd).Length > 1) + if (lastuid != "") { - if (ofd.ShowDialog() == DialogResult.OK) + if (File.Exists(omfd) && new FileInfo(omfd).Length > 1) { - if (File.Exists(ofd.FileName)) + string filename = lastuid + "_" + DateTime.Now.ToString() + ".mfd"; + if (File.Exists(filename)) { - File.Delete(ofd.FileName); + File.Delete(filename); } - File.Move(omfd, ofd.FileName); - logAppend("##已保存-" + ofd.FileName + "##"); + File.Move(omfd, filename); + logAppend("##已自动保存-" + filename + "##"); } else { File.Delete(omfd); - logAppend("##未保存##"); + logAppend("##缓存文件异常##"); } + lastuid = ""; } else { - File.Delete(omfd); - logAppend("##缓存文件异常##"); + SaveFileDialog ofd = new SaveFileDialog(); + ofd.AddExtension = true; + ofd.DefaultExt = ".mfd"; + ofd.Title = "请选择MFD文件保存位置及文件名"; + ofd.OverwritePrompt = true; + ofd.Filter = "MFD文件|*.mfd|DUMP文件|*.dump"; + if (File.Exists(omfd) && new FileInfo(omfd).Length > 1) + { + if (ofd.ShowDialog() == DialogResult.OK) + { + if (File.Exists(ofd.FileName)) + { + File.Delete(ofd.FileName); + } + File.Move(omfd, ofd.FileName); + logAppend("##已保存-" + ofd.FileName + "##"); + } + else + { + File.Delete(omfd); + logAppend("##未保存##"); + } + } + else + { + File.Delete(omfd); + logAppend("##缓存文件异常##"); + } } omfd = ""; Text = "MifareOne Tool - 运行完毕"; @@ -177,7 +199,7 @@ namespace MifareOneTool string pattern = @"UID\s\(NFCID1\)\: ([0-9A-Fa-f]{2}\s\s[0-9A-Fa-f]{2}\s\s[0-9A-Fa-f]{2}\s\s[0-9A-Fa-f]{2})"; if (Regex.IsMatch(rawStr, pattern)) { - uid = Regex.Match(rawStr, pattern).Captures[0].Value.Replace(" ", "").Replace("UID(NFCID1):",""); ; + uid = Regex.Match(rawStr, pattern).Captures[0].Value.Replace(" ", "").Replace("UID(NFCID1):", ""); ; } else { @@ -208,17 +230,24 @@ namespace MifareOneTool return; } + string lastuid = ""; + private void buttonMfRead_Click(object sender, EventArgs e) { if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; string rmfd = "MfRead.tmp"; string kt = "A"; string nn = ""; + string uid; if (checkBoxAutoLoadKey.Checked) { - string uid = GetUID(); + uid = GetUID(); LoadUidKey(uid); } + if (checkBoxAutoSave.Checked) + { + lastuid = GetUID(); + } if (checkBoxAutoABN.Checked && keymfd != "") { kt = "C"; @@ -425,6 +454,10 @@ namespace MifareOneTool } } } + if (checkBoxAutoSave.Checked) + { + lastuid = GetUID(); + } BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(mfoc); bgw.WorkerReportsProgress = true; @@ -551,7 +584,10 @@ namespace MifareOneTool { if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; string rmfd = "BmfRead.tmp"; - + if (checkBoxAutoSave.Checked) + { + lastuid = GetUID(); + } BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(bmf_read); bgw.WorkerReportsProgress = true; @@ -1084,6 +1120,10 @@ namespace MifareOneTool } } } + if (checkBoxAutoSave.Checked) + { + lastuid = GetUID(); + } BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(mfoc); bgw.WorkerReportsProgress = true; @@ -1117,6 +1157,10 @@ namespace MifareOneTool } string rmfd = "Mfoc.tmp"; string key = "-f " + filename + " "; + if (checkBoxAutoSave.Checked) + { + lastuid = GetUID(); + } BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(mfocCMD); bgw.WorkerReportsProgress = true; @@ -1248,5 +1292,15 @@ namespace MifareOneTool { Properties.Settings.Default.DefIsAdv = checkBoxDefIsAdv.Checked; } + + private void Form1_FormClosing(object sender, FormClosingEventArgs e) + { + Properties.Settings.Default.Save(); + } + + private void checkBoxAutoSave_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.AutoSave = checkBoxAutoSave.Checked; + } } } diff --git a/MifareOneTool/Properties/AssemblyInfo.cs b/MifareOneTool/Properties/AssemblyInfo.cs index c19822e..e37fa4f 100644 --- a/MifareOneTool/Properties/AssemblyInfo.cs +++ b/MifareOneTool/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.3.0")] -[assembly: AssemblyFileVersion("1.6.3.0")] +[assembly: AssemblyVersion("1.6.4.0")] +[assembly: AssemblyFileVersion("1.6.4.0")] diff --git a/MifareOneTool/Properties/Settings.Designer.cs b/MifareOneTool/Properties/Settings.Designer.cs index 8ee28c2..fbdb891 100644 --- a/MifareOneTool/Properties/Settings.Designer.cs +++ b/MifareOneTool/Properties/Settings.Designer.cs @@ -103,5 +103,17 @@ namespace MifareOneTool.Properties { this["DefIsAdv"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool AutoSave { + get { + return ((bool)(this["AutoSave"])); + } + set { + this["AutoSave"] = value; + } + } } } diff --git a/MifareOneTool/Properties/Settings.settings b/MifareOneTool/Properties/Settings.settings index 559f313..aab9dcd 100644 --- a/MifareOneTool/Properties/Settings.settings +++ b/MifareOneTool/Properties/Settings.settings @@ -23,5 +23,8 @@ False + + False + \ No newline at end of file diff --git a/MifareOneTool/app.config b/MifareOneTool/app.config index 42c64cd..43fd3e8 100644 --- a/MifareOneTool/app.config +++ b/MifareOneTool/app.config @@ -35,6 +35,9 @@ False + + False + \ No newline at end of file