/// <summary> /// 检查事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCheck_Click(object sender, EventArgs e) { //检查文件路径 if (cbJGFHX.Checked) { CheckPath checkPath = new CheckPath(); checkPath.CheckPathMsg(tbBrowse.Text, this); } //成果文件配置 if (cbJGFHX.Checked) { CheckFile checkFile = new CheckFile(); checkFile.CheckFileMsg(checkFile.ReturnFiles(tbBrowse.Text, this), tbBrowse.Text, this); } if (cbJCZB.Checked) { CheckFile checkFile = new CheckFile(); CheckZhiBiao zhibiao = new CheckZhiBiao(); //zhibiao.CheckZhiBiaoMsg(ComMsg.infoList, tbBrowse.Text, this); Thread thread = new Thread(delegate() { zhibiao.CheckZhiBiaoMsg(ComMsg.infoList, tbBrowse.Text, this); }); thread.Start(); } if (cbJCZB.Checked) { CheckGuiZe guize = new CheckGuiZe(); guize.CheckSempleGuiZe(tbBrowse.Text, this); } /********************此区域预留用于检查其它项目,代码参考CheckPathMsg**************************/ /********************************************************************************************/ //将错误信息写入首页的DataGridView WriteFile writeFile = new WriteFile(); this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入列表文件"; writeFile.WriteDataGridView(ComMsg.ResultShow, this.dgCheckResult); //生成文档 CreateFile createFile = new CreateFile(); createFile.CreateDoc(tbBrowse.Text, cmbType.Text); //创建word文档 createFile.CreateXls(tbBrowse.Text, cmbType.Text); //创建Excel文档 //写入文档 this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入Excel文件"; writeFile.WriteXls(ComMsg.xlsPath); //向Excel文档中写入检查结果 this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入Word文件"; createFile.WrithDocFile(ComMsg.docPath); //向doc文档中写入检查结果 //清空相关的文档 ComMsg.docPath = string.Empty; ComMsg.xlsPath = string.Empty; ComMsg.infoList = new List <FileInfo>(); ComMsg.ResultShow = new List <ResultEntity>(); }
protected override void OnPaint(PaintEventArgs pevent) { if (!DesignMode && !Visible) { return; } var g = pevent.Graphics; //g.SmoothingMode = SmoothingMode.AntiAlias; //g.TextRenderingHint = TextRenderingHint.AntiAlias; Share.GraphicSetup(g); var pen = new Pen(Share.BorderColor); var sb = new SolidBrush(Share.FocusBackColor); if (Enabled) { if (!base.Checked) { g.DrawPath(pen, rectPath); g.DrawPath(pen, CheckPath); pen.Dispose(); TextRenderer.DrawText(g, Text, Font, textRect, Color.Black, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter); //g.DrawString(base.Text, base.Font, Brushes.Black, new PointF(0, 0),StringFormatFlags.DirectionVertical); } else { g.FillPath(sb, rectPath); pen.Color = Share.FocusBackColor; g.DrawPath(pen, rectPath); sb.Color = Share.BackColor; g.FillPath(sb, CheckPath); sb.Dispose(); TextRenderer.DrawText(g, Text, Font, textRect, Color.White, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter); } } else { sb.Color = Share.DisabelBackColor; pen.Color = Share.DisableBorderColor; g.FillPath(sb, rectPath); g.DrawPath(pen, rectPath); g.FillPath(sb, CheckPath); g.DrawPath(pen, CheckPath); TextRenderer.DrawText(g, Text, Font, textRect, Share.DisabelFontColor, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter); pen.Dispose(); sb.Dispose(); } rectPath.Dispose(); CheckPath.Dispose(); }
//Alpha alpha = Alpha.Normal; //Color bdcolor { get { return Color.FromArgb((int)Alpha.a180, bgColor.R, bgColor.G, bgColor.B); } } //Color color { get { return Color.FromArgb((int)alpha, bgColor.R, bgColor.G, bgColor.B); } } //Color bgColor = Share.BackColor; //public Color BgColor { get { return bgColor; } set { bgColor = value; this.Invalidate(); } } protected override void OnPaint(PaintEventArgs pevent) { if (!DesignMode && !Visible) { return; } var g = pevent.Graphics; //g.SmoothingMode = SmoothingMode.AntiAlias; //g.TextRenderingHint = TextRenderingHint.AntiAlias; Share.GraphicSetup(g); if (!Checked) { using (var sb = new SolidBrush(BgColor)) { g.FillPath(sb, radioPath); } using (var p = new Pen(borderColor, 1)) { g.DrawPath(p, radioPath); } //g.DrawPath(new Pen(Color.White, 1.8f), gp); } else { using (var sb = new SolidBrush(Share.FocusBackColor)) { g.FillPath(sb, radioPath); var p = new Pen(Share.FocusBackColor, 1); g.DrawPath(p, radioPath); p.Dispose(); } using (var p = new Pen(Share.BackColor, 1.55f)) { g.DrawPath(p, CheckPath); } } var TextRect = new Rectangle(radioRect.Width + 3, (int)(Height - g.MeasureString(Text, Font).Height) / 2, Width - radioRect.Width - 3, Height); //TextRenderer.DrawText(g, base.Text, base.Font, TextRect, base.ForeColor, TextFormatFlags.VerticalCenter | // TextFormatFlags.Left | // TextFormatFlags.SingleLine); if (Text != "") { DrawHelper.DrawCaptionText(g, TextRect, Text, Font, true, Color.White, 3, ForeColor); } radioPath.Dispose(); CheckPath.Dispose(); }
// 页面初始化 protected virtual void Page_Init(object sender, EventArgs e) { string path = Request.Url.LocalPath.ToLower(); if (path.Contains(RedirectPath.ToLower())) { return; } if (path.Contains(CheckPath.ToLower())) { if (Session[SessionName.ToLower()] == null) { Response.Redirect("~" + RedirectPath.ToLower()); return; } } }
private static void WorkWithOneFile() { Console.WriteLine("1 - Зашифровать один файл\n"); Console.WriteLine("2 - Расшифровать один файл\n"); string selection = Console.ReadLine(); string path; switch (selection) { case "1": using (Aes myAes = Aes.Create()) { Console.WriteLine("Введите полное имя файла(с указанием пути)"); path = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); byte[] encrypted; try { if (ReadWriteFile.ReadFile(path).Length != 0) { // Encrypt the string to an array of bytes. encrypted = CifherAes.EncryptBytes_Aes(ReadWriteFile.ReadFile(path), myAes.Key, myAes.IV); ReadWriteFile.WriteFile(path, encrypted); } else { Console.WriteLine("файл " + path + "пустой "); } Console.WriteLine("\nВведите полное имя файла для хранения ключа (с указанием пути)"); path = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); ReadWriteFile.WriteFile(path, myAes.Key); Console.WriteLine("Ключ "); foreach (var value in myAes.Key) { Console.Write(value); } Console.WriteLine(); Console.WriteLine("Введите полное имя файла для хранения вектора инициаизации (с указанием пути)"); path = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); ReadWriteFile.WriteFile(path, myAes.IV); Console.WriteLine("Вектор инициализации {0}"); foreach (var value in myAes.IV) { Console.Write(value); } } catch (Exception e) { Console.WriteLine(e); } } break; case "2": Console.WriteLine("Введите полное имя файла(с указанием пути)"); path = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); byte[] decripted; try { Console.WriteLine("Введите полное имя ключа(с указанием пути)"); string pathToKey = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); Console.WriteLine("Ключ "); foreach (var value in ReadWriteFile.ReadFile(pathToKey)) { Console.Write(value); } Console.WriteLine(); Console.WriteLine("Введите полное имя вектора инициализации (с указанием пути)"); string pathToIV = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); foreach (var value in ReadWriteFile.ReadFile(pathToIV)) { Console.Write(value); } // Encrypt the string to an array of bytes. if (ReadWriteFile.ReadFile(path).Length != 0) { decripted = CifherAes.DecryptBytes_Aes(ReadWriteFile.ReadFile(path), ReadWriteFile.ReadFile(pathToKey), ReadWriteFile.ReadFile(pathToIV)); ReadWriteFile.WriteFile(path, decripted); } else { Console.WriteLine("файл " + path + "пустой. с ним нельзя работать"); } } catch (Exception e) { Console.WriteLine(e); } break; default: Console.WriteLine("Вы нажали неизвестную букву"); break; } }
private static void WorkWithFolderOrDisk() { Console.Clear(); Console.WriteLine("1 - Зашифровать папку или диск\n"); Console.WriteLine("Помниет что ключ и вектор инициализации хранить отдельно от пути объекта шифрации"); Console.WriteLine("2 - Расшифровать папку или диск\n"); string selection = Console.ReadLine(); switch (selection) { case "1": using (Aes myAes = Aes.Create()) { Console.WriteLine("Введите полное имя папки(с указанием пути)"); string path = Console.ReadLine(); CheckPath.СhekedPathToDirectory(ref path); byte[] encrypted; try { foreach (var i in GettFiles.LookIn(path)) { Console.WriteLine(i); // Encrypt the string to an array of bytes. if (ReadWriteFile.ReadFile(i).Length != 0) { encrypted = CifherAes.EncryptBytes_Aes(ReadWriteFile.ReadFile(i), myAes.Key, myAes.IV); ReadWriteFile.WriteFile(i, encrypted); } else { Console.WriteLine("файл " + i + " пустой"); } } GettFiles.LookIn(path).Clear(); Console.WriteLine("\nВведите полное имя файла для хранения ключа (с указанием пути)"); path = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); ReadWriteFile.WriteFile(path, myAes.Key); Console.WriteLine("Ключ "); foreach (var value in myAes.Key) { Console.Write(value); } Console.WriteLine(); Console.WriteLine("Введите полное имя файла для хранения вектора инициаизации (с указанием пути)"); path = Console.ReadLine(); CheckPath.СhekedPathToFile(ref path); ReadWriteFile.WriteFile(path, myAes.IV); Console.WriteLine("Вектор инициализации {0}"); foreach (var value in myAes.IV) { Console.Write(value); } } catch (Exception e) { Console.WriteLine(e); } } break; case "2": using (Aes myAes = Aes.Create()) { Console.WriteLine("Введите полное имя папки или диска (с указанием пути)"); string path = Console.ReadLine(); CheckPath.СhekedPathToDirectory(ref path); byte[] decripted; try { Console.WriteLine("Введите полное имя ключа(с указанием пути)"); string pathToKey = Console.ReadLine(); CheckPath.СhekedPathToFile(ref pathToKey); Console.WriteLine("Ключ "); foreach (var value in ReadWriteFile.ReadFile(pathToKey)) { Console.Write(value); } Console.WriteLine(); Console.WriteLine("Введите полное имя вектора инициализации (с указанием пути)"); string pathToIV = Console.ReadLine(); CheckPath.СhekedPathToFile(ref pathToKey); foreach (var value in ReadWriteFile.ReadFile(pathToIV)) { Console.Write(value); } // Encrypt the string to an array of bytes. foreach (var i in GettFiles.LookIn(path)) { Console.WriteLine(i); // Encrypt the string to an array of bytes. if (ReadWriteFile.ReadFile(i).Length != 0) { decripted = CifherAes.DecryptBytes_Aes(ReadWriteFile.ReadFile(i), ReadWriteFile.ReadFile(pathToKey), ReadWriteFile.ReadFile(pathToIV)); ReadWriteFile.WriteFile(i, decripted); } else { Console.WriteLine("файл пустой, " + i + " с ним нельзя работать "); } } GettFiles.LookIn(path).Clear(); } catch (Exception e) { Console.WriteLine(e); } } break; default: Console.WriteLine("Вы нажали неизвестную команду"); break; } }
public void RemoveLastPath() { int index = CheckPath.Count - 1; CheckPath.RemoveAt(index); }
/// <summary> /// When king is checked, store the path from the piece checking the king, to the king /// into CheckPath /// </summary> /// <param name="path"></param> public void AddCheckPath(List <string> path) { CheckPath.Add(path); }