UI展示:
ExcelHelper.cs:
using NPOI.HSSF.UserModel;using NPOI.SS.UserModel;using NPOI.SS.Util;using NPOI.XSSF.UserModel;using System;using System.Collections.Generic;using System.Data;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;namespace IMEIConvertPwdTools.V1._00{public static class ExcelHelper{/// /// Excel导入成DataTable/// ///
导入路径(包含文件名与扩展名)/// public static DataTable ExcelToTable(string file){if (file == "") return null;DataTable dt = new DataTable();IWorkbook workbook;//工作簿接口string fileExt = Path.GetExtension(file).ToLower();using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read)){//XSSFWorkbook 适用XLSX格式,HSSFWorkbook 适用XLS格式if (fileExt == ".xlsx")//新版本excel2007{workbook = new XSSFWorkbook(fs);}else if (fileExt == ".xls")//早期版本excel2003{workbook = new HSSFWorkbook(fs);}else{workbook = null;}if (workbook == null) { return null; }ISheet sheet = workbook.GetSheetAt(0);//下标为零的工作簿//创建表头 FirstRowNum:获取第一个有数据的行好(默认0)IRow header = sheet.GetRow(sheet.FirstRowNum);//第一行是头部信息List columns = new List();for (int i = 0; i /// Datable导出成Excel/// ///
///
导出路径(包括文件名与扩展名)public static void TableToExcel(DataTable dt, string file){IWorkbook workbook;string fileExt = Path.GetExtension(file).ToLower();if (fileExt == ".xlsx"){ workbook = new XSSFWorkbook(); }else if (fileExt == ".xls"){ workbook = new HSSFWorkbook(); }else { workbook = null; }if (workbook == null) { return; }ISheet sheet = string.IsNullOrEmpty(dt.TableName) ? workbook.CreateSheet("Sheet1") : workbook.CreateSheet(dt.TableName);#region 添加一行合并头部并居中显示的列//ICellStyle style = workbook.CreateCellStyle();//创建头部列样式单独合并头部列//IRow h_row = sheet.CreateRow(0);//ICell h_cell = h_row.CreateCell(0);//h_cell.SetCellValue("测试头部列");//设置单元格细信息//h_row.Height = 30 * 20;//sheet.SetColumnWidth(0, 30 * 256);//设置单元格的宽度//sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, 10));//合并列//style.Alignment = HorizontalAlignment.Center;//居中显示新建一个字体样式对象//IFont fOnt= workbook.CreateFont();//设置字体加粗样式//font.Boldweight = short.MaxValue;//使用SetFont方法将字体样式添加到单元格样式中 //style.SetFont(font);//将新的样式赋给单元格//h_cell.CellStyle = style;#endregion//表头 IRow row = sheet.CreateRow(0);//去头部修改for (int i = 0; i
CsvHelper.cs
using System;using System.Collections.Generic;using System.Data;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;namespace IMEIConvertPwdTools.V1._00{public class CSVFileHelper{/// /// 将DataTable中数据写入到CSV文件中/// ///
提供保存数据的DataTable///
CSV的文件路径public static void SaveCSV(DataTable dt, string fullPath){FileInfo fi = new FileInfo(fullPath);if (!fi.Directory.Exists){fi.Directory.Create();}FileStream fs = new FileStream(fullPath, System.IO.FileMode.Create, System.IO.FileAccess.Write);//StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);string data = "";//写出列名称for (int i = 0; i
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace IMEIConvertPwdTools.V1._00{public class IMEIConvertPwdEntity{/// /// 序号/// public int NO { get; set; }/// /// 16位IMEI/// public string IMEI{ get; set; }/// /// 转换的密码/// public string Pwd { get; set; }}}
AutoSizeFormClass.cs
using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;namespace IMEIConvertPwdTools.V1._00{public class AutoSizeFormClass{//(1).声明结构,只记录窗体和其控件的初始位置和大小。 public struct controlRect{public int Left;public int Top;public int Width;public int Height;}//(2).声明 1个对象 //注意这里不能使用控件列表记录 List nCtrl;,因为控件的关联性,记录的始终是当前的大小。 public List oldCtrl;//int ctrl_first = 0; //(3). 创建两个函数 //(3.1)记录窗体和其控件的初始位置和大小, public AutoSizeFormClass(Form mForm){// if (ctrl_first == 0) {// ctrl_first = 1; oldCtrl = new List();controlRect cR;cR.Left = mForm.Left; cR.Top = mForm.Top; cR.Width = mForm.Width; cR.Height = mForm.Height;oldCtrl.Add(cR);foreach (Control c in mForm.Controls){controlRect objCtrl;objCtrl.Left = c.Left; objCtrl.Top = c.Top; objCtrl.Width = c.Width; objCtrl.Height = c.Height;oldCtrl.Add(objCtrl);}}// this.WindowState = (System.Windows.Forms.FormWindowState)(2);//记录完控件的初始位置和大小后,再最大化 //0 - Normalize , 1 - Minimize,2- Maximize }//(3.2)控件自适应大小, public void controlAutoSize(Form mForm){//int wLeft0 = oldCtrl[0].Left; ;//窗体最初的位置 //int wTop0 = oldCtrl[0].Top; int wLeft1 = this.Left;//窗体当前的位置 //int wTop1 = this.Top; float wScale = (float)mForm.Width / (float)oldCtrl[0].Width;//新旧窗体之间的比例,与最早的旧窗体 float hScale = (float)mForm.Height / (float)oldCtrl[0].Height;//.Height; int ctrLeft0, ctrTop0, ctrWidth0, ctrHeight0;int ctrlNo = 1;//第1个是窗体自身的 Left,Top,Width,Height,所以窗体控件从ctrlNo=1开始 foreach (Control c in mForm.Controls){ctrLeft0 = oldCtrl[ctrlNo].Left;ctrTop0 = oldCtrl[ctrlNo].Top;ctrWidth0 = oldCtrl[ctrlNo].Width;ctrHeight0 = oldCtrl[ctrlNo].Height;//c.Left = (int)((ctrLeft0 - wLeft0) * wScale) + wLeft1;//新旧控件之间的线性比例 //c.Top = (int)((ctrTop0 - wTop0) * h) + wTop1; c.Left = (int)((ctrLeft0) * wScale);//新旧控件之间的线性比例。控件位置只相对于窗体,所以不能加 + wLeft1 c.Top = (int)((ctrTop0) * hScale);// c.Width = (int)(ctrWidth0 * wScale);//只与最初的大小相关,所以不能与现在的宽度相乘 (int)(c.Width * w); c.Height = (int)(ctrHeight0 * hScale);// ctrlNo += 1;}}}}
AutoSetControlSize.cs
using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace IMEIConvertPwdTools.V1._00{public class AutoSetControlSize{#region 控件大小随窗体大小等比例缩放public float X { get; set; }//定义当前窗体的宽度public float Y { get; set; }//定义当前窗体的高度/// /// 原始X,Y的座标/// ///
///
///
public AutoSetControlSize(Form form,float x,float y){this.X = x;this.Y = y;setTag(form);}private void setTag(Control cons){foreach (Control con in cons.Controls){con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;if (con.Controls.Count > 0){setTag(con);}}}public void setControls(float newx, float newy, Control cons){//遍历窗体中的控件,重新设置控件的值foreach (Control con in cons.Controls){//获取控件的Tag属性值,并分割后存储字符串数组if (con.Tag != null){string[] mytag = con.Tag.ToString().Split(new char[] { ; });//根据窗体缩放的比例确定控件的值con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距//Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小//con.FOnt= new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);if (con.Controls.Count > 0){setControls(newx, newy, con);}}}}#endregion}}
MainForm.cs
namespace IMEIConvertPwdTools.V1._00{partial class MainForm{/// /// 必需的设计器变量。/// private System.ComponentModel.IContainer compOnents= null;/// /// 清理所有正在使用的资源。/// ///
如果应释放托管资源,为 true;否则为 false。protected override void Dispose(bool disposing){if (disposing }base.Dispose(disposing);}#region Windows 窗体设计器生成的代码/// /// 设计器支持所需的方法 - 不要修改/// 使用代码编辑器修改此方法的内容。/// private void InitializeComponent(){this.compOnents= new System.ComponentModel.Container();System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));this.splitContainer1 = new System.Windows.Forms.SplitContainer();this.panel1 = new System.Windows.Forms.Panel();this.btn_Close = new System.Windows.Forms.Button();this.imageList1 = new System.Windows.Forms.ImageList(this.components);this.label5 = new System.Windows.Forms.Label();this.label1 = new System.Windows.Forms.Label();this.statusStrip1 = new System.Windows.Forms.StatusStrip();this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel();this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();this.t_SystemDateTime = new System.Windows.Forms.ToolStripStatusLabel();this.toolStripStatusLabel5 = new System.Windows.Forms.ToolStripStatusLabel();this.toolStripStatusLabel6 = new System.Windows.Forms.ToolStripStatusLabel();this.t_DataCount = new System.Windows.Forms.ToolStripStatusLabel();this.btn_Import = new System.Windows.Forms.Button();this.txt_IEMIFilePath = new System.Windows.Forms.TextBox();this.label4 = new System.Windows.Forms.Label();this.label3 = new System.Windows.Forms.Label();this.dtgrive_ImeiData = new System.Windows.Forms.DataGridView();this.NO = new System.Windows.Forms.DataGridViewTextBoxColumn();this.IMEI_15Bit = new System.Windows.Forms.DataGridViewTextBoxColumn();this.PassWord_8Bit = new System.Windows.Forms.DataGridViewTextBoxColumn();this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);this.Men_txt = new System.Windows.Forms.ToolStripMenuItem();this.Men_csv = new System.Windows.Forms.ToolStripMenuItem();this.Men_xls = new System.Windows.Forms.ToolStripMenuItem();this.label2 = new System.Windows.Forms.Label();this.timer1 = new System.Windows.Forms.Timer(this.components);((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();this.splitContainer1.Panel1.SuspendLayout();this.splitContainer1.Panel2.SuspendLayout();this.splitContainer1.SuspendLayout();this.panel1.SuspendLayout();this.statusStrip1.SuspendLayout();((System.ComponentModel.ISupportInitialize)(this.dtgrive_ImeiData)).BeginInit();this.contextMenuStrip1.SuspendLayout();this.SuspendLayout();// // splitContainer1// this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;this.splitContainer1.Location = new System.Drawing.Point(0, 0);this.splitContainer1.Name = "splitContainer1";this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;// // splitContainer1.Panel1// this.splitContainer1.Panel1.Controls.Add(this.panel1);// // splitContainer1.Panel2// this.splitContainer1.Panel2.Controls.Add(this.statusStrip1);this.splitContainer1.Panel2.Controls.Add(this.btn_Import);this.splitContainer1.Panel2.Controls.Add(this.txt_IEMIFilePath);this.splitContainer1.Panel2.Controls.Add(this.label4);this.splitContainer1.Panel2.Controls.Add(this.label3);this.splitContainer1.Panel2.Controls.Add(this.dtgrive_ImeiData);this.splitContainer1.Panel2.Controls.Add(this.label2);this.splitContainer1.Size = new System.Drawing.Size(1037, 900);this.splitContainer1.SplitterDistance = 48;this.splitContainer1.SplitterWidth = 1;this.splitContainer1.TabIndex = 0;// // panel1// this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(161)))), ((int)(((byte)(188)))), ((int)(((byte)(219)))));this.panel1.Controls.Add(this.btn_Close);this.panel1.Controls.Add(this.label5);this.panel1.Controls.Add(this.label1);this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;this.panel1.Location = new System.Drawing.Point(0, 0);this.panel1.Name = "panel1";this.panel1.Size = new System.Drawing.Size(1037, 48);this.panel1.TabIndex = 0;this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Frm_MouseDown);this.panel1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Frm_MouseMove);this.panel1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Frm_MouseUp);// // btn_Close// this.btn_Close.FlatAppearance.BorderSize = 0;this.btn_Close.FlatStyle = System.Windows.Forms.FlatStyle.Flat;this.btn_Close.ImageIndex = 1;this.btn_Close.ImageList = this.imageList1;this.btn_Close.Location = new System.Drawing.Point(990, 11);this.btn_Close.Name = "btn_Close";this.btn_Close.Size = new System.Drawing.Size(28, 27);this.btn_Close.TabIndex = 2;this.btn_Close.UseVisualStyleBackColor = true;this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click);// // imageList1// this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));this.imageList1.TransparentColor = System.Drawing.Color.Transparent;this.imageList1.Images.SetKeyName(0, "链接转换工具集.png");this.imageList1.Images.SetKeyName(1, "关闭.png");this.imageList1.Images.SetKeyName(2, "导入.png");this.imageList1.Images.SetKeyName(3, "导入项目_操作_jurassic.png");this.imageList1.Images.SetKeyName(4, "数据导入.png");// // label5// this.label5.ForeColor = System.Drawing.Color.White;this.label5.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;this.label5.ImageIndex = 0;this.label5.ImageList = this.imageList1;this.label5.Location = new System.Drawing.Point(383, 0);this.label5.Name = "label5";this.label5.Size = new System.Drawing.Size(40, 47);this.label5.TabIndex = 0;this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;// // label1// this.label1.ForeColor = System.Drawing.Color.White;this.label1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;this.label1.ImageList = this.imageList1;this.label1.Location = new System.Drawing.Point(418, 1);this.label1.Name = "label1";this.label1.Size = new System.Drawing.Size(191, 47);this.label1.TabIndex = 0;this.label1.Text = "IMEI Convert Pwd Tools";this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;// // statusStrip1// this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.toolStripStatusLabel1,this.toolStripStatusLabel2,this.toolStripStatusLabel3,this.toolStripStatusLabel4,this.t_SystemDateTime,this.toolStripStatusLabel5,this.toolStripStatusLabel6,this.t_DataCount});this.statusStrip1.Location = new System.Drawing.Point(0, 829);this.statusStrip1.Name = "statusStrip1";this.statusStrip1.Size = new System.Drawing.Size(1037, 22);this.statusStrip1.TabIndex = 1;this.statusStrip1.Text = "statusStrip1";// // toolStripStatusLabel1// this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";this.toolStripStatusLabel1.Size = new System.Drawing.Size(110, 17);this.toolStripStatusLabel1.Text = "Software Version:";// // toolStripStatusLabel2// this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";this.toolStripStatusLabel2.Size = new System.Drawing.Size(40, 17);this.toolStripStatusLabel2.Text = "V1.00";// // toolStripStatusLabel3// this.toolStripStatusLabel3.Name = "toolStripStatusLabel3";this.toolStripStatusLabel3.Size = new System.Drawing.Size(296, 17);this.toolStripStatusLabel3.Text = " ";// // toolStripStatusLabel4// this.toolStripStatusLabel4.Name = "toolStripStatusLabel4";this.toolStripStatusLabel4.Size = new System.Drawing.Size(111, 17);this.toolStripStatusLabel4.Text = "System DateTime:";// // t_SystemDateTime// this.t_SystemDateTime.Name = "t_SystemDateTime";this.t_SystemDateTime.Size = new System.Drawing.Size(32, 17);this.t_SystemDateTime.Text = "xxxx";// // toolStripStatusLabel5// this.toolStripStatusLabel5.Name = "toolStripStatusLabel5";this.toolStripStatusLabel5.Size = new System.Drawing.Size(208, 17);this.toolStripStatusLabel5.Text = " ";// // toolStripStatusLabel6// this.toolStripStatusLabel6.Name = "toolStripStatusLabel6";this.toolStripStatusLabel6.Size = new System.Drawing.Size(67, 17);this.toolStripStatusLabel6.Text = "DataTotal:";// // t_DataCount// this.t_DataCount.Name = "t_DataCount";this.t_DataCount.Size = new System.Drawing.Size(0, 17);// // btn_Import// this.btn_Import.FlatAppearance.BorderSize = 0;this.btn_Import.FlatStyle = System.Windows.Forms.FlatStyle.Flat;this.btn_Import.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;this.btn_Import.ImageIndex = 3;this.btn_Import.ImageList = this.imageList1;this.btn_Import.Location = new System.Drawing.Point(936, 23);this.btn_Import.Name = "btn_Import";this.btn_Import.Size = new System.Drawing.Size(82, 33);this.btn_Import.TabIndex = 1;this.btn_Import.Text = "....";this.btn_Import.TextAlign = System.Drawing.ContentAlignment.MiddleRight;this.btn_Import.UseVisualStyleBackColor = true;this.btn_Import.Click += new System.EventHandler(this.btn_Import_Click);// // txt_IEMIFilePath// this.txt_IEMIFilePath.BorderStyle = System.Windows.Forms.BorderStyle.None;this.txt_IEMIFilePath.Enabled = false;this.txt_IEMIFilePath.Location = new System.Drawing.Point(170, 36);this.txt_IEMIFilePath.Name = "txt_IEMIFilePath";this.txt_IEMIFilePath.ReadOnly= true;this.txt_IEMIFilePath.Size = new System.Drawing.Size(760, 19);this.txt_IEMIFilePath.TabIndex = 5;// // label4// this.label4.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;this.label4.Location = new System.Drawing.Point(170, 56);this.label4.Name = "label4";this.label4.Size = new System.Drawing.Size(760, 1);this.label4.TabIndex = 4;// // label3// this.label3.AutoSize = true;this.label3.Location = new System.Drawing.Point(5, 37);this.label3.Name = "label3";this.label3.Size = new System.Drawing.Size(168, 16);this.label3.TabIndex = 3;this.label3.Text = "Load IMEI File Path:";// // dtgrive_ImeiData// this.dtgrive_ImeiData.AllowUserToAddRows = false;this.dtgrive_ImeiData.AllowUserToDeleteRows = false;this.dtgrive_ImeiData.BackgroundColor = System.Drawing.Color.White;this.dtgrive_ImeiData.BorderStyle = System.Windows.Forms.BorderStyle.None;this.dtgrive_ImeiData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;this.dtgrive_ImeiData.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {this.NO,this.IMEI_15Bit,this.PassWord_8Bit});this.dtgrive_ImeiData.COntextMenuStrip= this.contextMenuStrip1;this.dtgrive_ImeiData.Location = new System.Drawing.Point(33, 92);this.dtgrive_ImeiData.Name = "dtgrive_ImeiData";this.dtgrive_ImeiData.ReadOnly= true;this.dtgrive_ImeiData.RowTemplate.Height = 23;this.dtgrive_ImeiData.Size = new System.Drawing.Size(974, 734);this.dtgrive_ImeiData.TabIndex = 2;this.dtgrive_ImeiData.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.dtgrive_ImeiData_RowsAdded);// // NO// this.NO.DataPropertyName = "NO";this.NO.HeaderText = "NO";this.NO.Name = "NO";this.NO.ReadOnly= true;this.NO.Width = 150;// // IMEI_15Bit// this.IMEI_15Bit.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;this.IMEI_15Bit.DataPropertyName = "IMEI";this.IMEI_15Bit.HeaderText = "IMEI_15Bit";this.IMEI_15Bit.Name = "IMEI_15Bit";this.IMEI_15Bit.ReadOnly= true;// // PassWord_8Bit// this.PassWord_8Bit.DataPropertyName = "Pwd";this.PassWord_8Bit.HeaderText = "PassWord_8Bit";this.PassWord_8Bit.Name = "PassWord_8Bit";this.PassWord_8Bit.ReadOnly= true;this.PassWord_8Bit.Width = 300;// // contextMenuStrip1// this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.Men_txt,this.Men_csv,this.Men_xls});this.contextMenuStrip1.Name = "contextMenuStrip1";this.contextMenuStrip1.Size = new System.Drawing.Size(181, 92);// // Men_txt// this.Men_txt.Enabled = false;this.Men_txt.Image = global::IMEIConvertPwdTools.V1._00.Properties.Resources.txt;this.Men_txt.Name = "Men_txt";this.Men_txt.Size = new System.Drawing.Size(180, 22);this.Men_txt.Text = "Export Data *.txt";this.Men_txt.Click += new System.EventHandler(this.Men_txt_Click);// // Men_csv// this.Men_csv.Enabled = false;this.Men_csv.Image = global::IMEIConvertPwdTools.V1._00.Properties.Resources.csv;this.Men_csv.Name = "Men_csv";this.Men_csv.Size = new System.Drawing.Size(180, 22);this.Men_csv.Text = "Export Data *.csv";this.Men_csv.Click += new System.EventHandler(this.Men_csv_Click);// // Men_xls// this.Men_xls.Enabled = false;this.Men_xls.Image = global::IMEIConvertPwdTools.V1._00.Properties.Resources.xls;this.Men_xls.Name = "Men_xls";this.Men_xls.Size = new System.Drawing.Size(180, 22);this.Men_xls.Text = "Export Data *.xlsx";this.Men_xls.Click += new System.EventHandler(this.Men_xls_Click);// // label2// this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;this.label2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;this.label2.Location = new System.Drawing.Point(3, 92);this.label2.Name = "label2";this.label2.Size = new System.Drawing.Size(1034, 1);this.label2.TabIndex = 0;// // timer1// this.timer1.Enabled = true;this.timer1.Tick += new System.EventHandler(this.timer1_Tick);// // MainForm// this.AutoScaleDimensiOns= new System.Drawing.SizeF(8F, 16F);this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.ClientSize = new System.Drawing.Size(1037, 900);this.Controls.Add(this.splitContainer1);this.FOnt= new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));this.Margin = new System.Windows.Forms.Padding(4);this.Name = "MainForm";this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;this.Text = "Form1";this.SizeChanged += new System.EventHandler(this.MainWinForm_SizeChanged);this.Resize += new System.EventHandler(this.MainWinForm_Resize);this.splitContainer1.Panel1.ResumeLayout(false);this.splitContainer1.Panel2.ResumeLayout(false);this.splitContainer1.Panel2.PerformLayout();((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();this.splitContainer1.ResumeLayout(false);this.panel1.ResumeLayout(false);this.statusStrip1.ResumeLayout(false);this.statusStrip1.PerformLayout();((System.ComponentModel.ISupportInitialize)(this.dtgrive_ImeiData)).EndInit();this.contextMenuStrip1.ResumeLayout(false);this.ResumeLayout(false);}#endregionprivate System.Windows.Forms.SplitContainer splitContainer1;private System.Windows.Forms.Panel panel1;private System.Windows.Forms.Label label1;private System.Windows.Forms.ImageList imageList1;private System.Windows.Forms.Button btn_Close;private System.Windows.Forms.StatusStrip statusStrip1;private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3;private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;private System.Windows.Forms.ToolStripStatusLabel t_SystemDateTime;private System.Windows.Forms.Label label2;private System.Windows.Forms.Timer timer1;private System.Windows.Forms.DataGridView dtgrive_ImeiData;private System.Windows.Forms.Label label4;private System.Windows.Forms.Label label3;private System.Windows.Forms.TextBox txt_IEMIFilePath;private System.Windows.Forms.Button btn_Import;private System.Windows.Forms.DataGridViewTextBoxColumn NO;private System.Windows.Forms.DataGridViewTextBoxColumn IMEI_15Bit;private System.Windows.Forms.DataGridViewTextBoxColumn PassWord_8Bit;private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;private System.Windows.Forms.ToolStripMenuItem Men_txt;private System.Windows.Forms.ToolStripMenuItem Men_csv;private System.Windows.Forms.ToolStripMenuItem Men_xls;private System.Windows.Forms.Label label5;private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5;private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel6;private System.Windows.Forms.ToolStripStatusLabel t_DataCount;}}
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace IMEIConvertPwdTools.V1._00{public partial class MainForm : Form{private AutoSizeFormClass asc = null;private AutoSetControlSize ass = null;private List iMEIdata;private List iMEIConvertPwdEntities;public MainForm(){InitializeComponent();ass = new AutoSetControlSize(this, this.Width, this.Height);}#region 窗体自适应private void MainWinForm_SizeChanged(object sender, EventArgs e){asc = new AutoSizeFormClass(this);asc.controlAutoSize(this);}private void MainWinForm_Resize(object sender, EventArgs e){ass.setControls((this.Width) / ass.X, (this.Height) / ass.Y, this);}#endregion#region 窗体移动private Point mouseOff;//鼠标移动位置变量private bool leftFlag;//标签是否为左键private void Frm_MouseDown(object sender, MouseEventArgs e){if (e.Button == MouseButtons.Left){mouseOff = new Point(-e.X, -e.Y); //得到变量的值leftFlag = true; //点击左键按下时标注为true;}}private void Frm_MouseMove(object sender, MouseEventArgs e){if (leftFlag){Point mouseSet = Control.MousePosition;mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置Location = mouseSet;}}private void Frm_MouseUp(object sender, MouseEventArgs e){if (leftFlag){leftFlag = false;//释放鼠标后标注为false;}}#endregion#region 同步系统时间private void timer1_Tick(object sender, EventArgs e){t_SystemDateTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");}#endregion#region 关闭窗体private void btn_Close_Click(object sender, EventArgs e){DialogResult dialogResult = MessageBox.Show("Confirm Exit!!", "Remind",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);if (dialogResult==DialogResult.Yes)Application.Exit();}#endregion#region 导入数据private void btn_Import_Click(object sender, EventArgs e){OpenFileDialog dialog = new OpenFileDialog();dialog.Multiselect = false;//该值确定是滞可以选择多个文件dialog.Title = "Please select file";dialog.Filter = "(*.txt)|*.txt";if (dialog.ShowDialog() == DialogResult.OK){txt_IEMIFilePath.Text = dialog.FileName;if (this.ReadImeiFileData(txt_IEMIFilePath.Text)){if (this.BatchImeiConvertPwsData(iMEIdata)){dtgrive_ImeiData.DataSource = new List();dtgrive_ImeiData.DataSource = iMEIConvertPwdEntities;}}}}#endregion#region 批量转换ImeiDataprivate bool BatchImeiConvertPwsData(List data){iMEICOnvertPwdEntities= new List();for (int i = 0; i 0)return true;return false;}#endregion#region 单项转换Imei 数据private string temp;private bool ImeiConvertPwsData(string strdata){temp = string.Empty;for (int i = 0; i Program.cs using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;namespace IMEIConvertPwdTools.V1._00{static class Program{/// /// 应用程序的主入口点。/// [STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new MainForm());}}}