/// <summary> /// 确认切割点击事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cut_isOk_Click(object sender, EventArgs e) { int i = convert.ConfirmCut(multiple); if (i != 0) { if (convert.images.Count >= 0) { foreach (Image ima in convert.images) { ima.Dispose(); } } string fileaName = convert.imagesPath[page]; image = System.Drawing.Image.FromFile(fileaName); Bitmap bit = new Bitmap(image); Bitmap getbit = PictureMerge.GetThumbnail(bit, show_pic.Width, 0); image = getbit; show_pic.Image = image; convert.imagesPath.Remove(convert.imagesPath[convert.imagesPath.Count - 1]); convert.imagesPath.Remove(convert.imagesPath[convert.imagesPath.Count - 1]); ++count; //textBox1.Text = "第" + count + "题"; //显示下一个 skinLabel3.Visible = true; all_thing_isOk.Visible = true; } else { return; } }
private void SolutionPanel_Load(object sender, EventArgs e) { Bitmap b = new Bitmap(solutionPath); Image a = PictureMerge.GetThumbnail(b, 736, 0); pictureBox1.Image = a; }
private void skinButton3_Click(object sender, EventArgs e) { page++; //this.show_pic.Image = Image.FromFile(convert.AllImagePath[page]); if (convert.AllImagePath.Count > 0) { MessageBox.Show(convert.AllImagePath.Count.ToString()); image = System.Drawing.Image.FromFile(convert.AllImagePath[page]); //FromFile里是图片的路径; oldImage = image; cutPath = convert.AllImagePath[page]; //切割而成的图片保存的地方 multiple = ((double)image.Width) / show_pic.Width; //得到原图片和pictureBox1比例,进行图片的缩略和描点的恢复 MessageBox.Show(multiple + " " + image.Width + " " + show_pic.Width); Bitmap bit = new Bitmap(image); Bitmap getbit = PictureMerge.GetThumbnail(bit, show_pic.Width, 0);//缩略图 image = getbit; show_pic.Image = image; /*convert.count1 = 1; * convert.imagesPath.Clear(); * convert.imagesHeigt.Clear(); * convert.titles.Clear(); * convert.startAndEnd.Clear(); * convert.count = 1;*/ image.Save(convert.AllImagePath[page].Split('.')[0] + "缩略图" + ".png"); MessageBox.Show(convert.AllImagePath[page].Split('.')[0] + "缩略图" + ".png"); convert.imagesPath.Add(convert.AllImagePath[page].Split('.')[0] + "缩略图" + ".png"); convert.images.Add(image); } else { return; } }
/*参数;图片列表 * 参数:面板 * 参数传递:showlist 用于保存已选择的图片 * 参数:pictureBox 用于保存生成picturebox的列表 * 参数:panel 传递主面板 过来 用于把控件添加到主面板中 * 参数:pictureRightBoxlist 用于保存 右边生成的picturebox的面板 * 参数:erroButtonRightBoxlist 用于保存 错误率的按钮列表 * 参数:erro_count 错误率列表 * 参数:solutionButtonRightBoxlist 解析按钮 把解析的按钮保存到这个列表 中 * 参数:answerList 答案的地址 用于传递到解析按钮中 处理事件 * 添加控件 * */ public static void createControl(List <Image> imgList, Panel panel1, List <Image> showImglist, List <MyPic> pictureBoxList, Panel panel, List <MyPic> pictureRightBoxlist, List <MyButton> erroButtonRightBoxlist, List <double> erro_count, List <MyButton> solutionButtonRightBoxlist, List <String> answerList) { int imgheight = 0; for (int i = 0; i < imgList.Count; i++) { Bitmap aa = new Bitmap(imgList[i]); Image a = PictureMerge.GetThumbnail(aa, 1240, 0); Bitmap ac = new Bitmap(a); Image b = PictureMerge.GetThumbnail(ac, 578, 0); Panel p = createPanel(0, imgheight, 578, b.Height + 25); MyPic pb = createPictureBox(0, 0, 578, b.Height, b); pb.indexCount = i; pb.MouseClick += (e, f) => pictureBox_MouseClick(pb, imgList[pb.indexCount], showImglist, pb.indexCount, panel, pictureRightBoxlist, imgList, pictureBoxList); pictureBoxList.Add(pb); p.CreateGraphics().DrawLine(Pens.Red, 0, b.Height, 578, b.Height); //graph.DrawLine(new Pen(Color.Red, 2), new System.Drawing.Font("宋体", 50, FontStyle.Bold), Brushes.DimGray, 0, iHeight); MyButton solution_Button = createButton("解析", 0, pb.Height + 1, 80, 23); if (i < answerList.Count) { solution_Button.solutionPath = answerList[i]; } solution_Button.MouseClick += (e, f) => solution_MouseClick("解析", solution_Button.solutionPath);//添加事件 solutionButtonRightBoxlist.Add(solution_Button); Button join_Button = createButton("加入组卷车", 120, pb.Height + 1, 80, 23); join_Button.MouseClick += (e, f) => join_MouseClick("加入组卷车"); Button remind_Button = createButton("特别提醒", 240, pb.Height + 1, 80, 23); remind_Button.MouseClick += (e, f) => remind_MouseClick("特别提醒"); Button count_Button = createButton("组卷次数", 360, pb.Height + 1, 80, 23); count_Button.MouseClick += (e, f) => count_MouseClick("组卷次数"); MyButton error_Button = createButton("错误率" + erro_count[i], 478, pb.Height + 1, 80, 23); if (i < erro_count.Count) { error_Button.error_Count = erro_count[i]; } error_Button.MouseClick += (e, f) => error_MouseClick("错误率", error_Button.error_Count); erroButtonRightBoxlist.Add(error_Button); //p.Size = new Size(578, b.Height + 23); p.Controls.Add(solution_Button); p.Controls.Add(join_Button); p.Controls.Add(remind_Button); p.Controls.Add(count_Button); p.Controls.Add(error_Button); p.Controls.Add(pb); if (p != null) { panel1.Controls.Add(p); } imgheight += b.Height + 50; } }
/*参数:图片 设置picturebox的图片 * 参数:面板 传递面板2 修改里面的控件 * 参数;控件列表 管理PictureBox控件 * 参数:i 传递标记 * 参数:imgheight 用来设置picturebox控件的位置 * 参数:showImglist 管理显示的图片 * 参数:imgList 管理显示的图片在imgList的索引 * 添加控件 * */ public static void createRightControl(Image img, Panel panel1, List <MyPic> pictureRightBoxlist, int i, int imgheight, List <Image> showImglist, List <Image> imgList, List <MyPic> pictureBoxList) { Bitmap ac = new Bitmap(img); Image b = PictureMerge.GetThumbnail(ac, 578, 0); MyPic pb = createPictureBox(0, imgheight, 578, b.Height, b); pb.indexCount = i; pictureRightBoxlist.Add(pb); panel1.VerticalScroll.Value = 0; panel1.Controls.Add(pb); panel1.Refresh(); pb.MouseClick += (e, f) => pictureBoxRight_MouseClick(pb.indexCount, showImglist, imgList, pictureRightBoxlist, panel1, pictureBoxList); //MessageBox.Show(pb.Location.ToString()); }
/// <summary> /// 选择照片点击事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void choose_Pic_Click(object sender, EventArgs e) { show_pic.Enabled = true; comboBox1.Visible = true; string path = convert.MyOpenFileDialog(); if (path != null) { page = 0; string[] ImageName = path.Split('\\'); newImageName = ImageName[ImageName.Length - 1].Split('.'); image = System.Drawing.Image.FromFile(path); //FromFile里是图片的路径; oldImage = image; cutPath = path; //切割而成的图片保存的地方 multiple = ((double)image.Width) / show_pic.Width; //得到原图片和pictureBox1比例,进行图片的缩略和描点的恢复 MessageBox.Show(multiple + " " + image.Width + " " + show_pic.Width); Bitmap bit = new Bitmap(image); Bitmap getbit = PictureMerge.GetThumbnail(bit, show_pic.Width, 0);//缩略图 image = getbit; show_pic.Image = image; convert.count1 = 1; convert.imagesPath.Clear(); convert.imagesHeigt.Clear(); convert.titles.Clear(); convert.startAndEnd.Clear(); convert.count = 1; image.Save(path.Split('.')[0] + "缩略图" + ".png"); MessageBox.Show(path.Split('.')[0] + "缩略图" + ".png"); convert.imagesPath.Add(path.Split('.')[0] + "缩略图" + ".png"); convert.images.Add(image); } else { } //显示下一个 skinButton2.Visible = true; skinLabel2.Visible = true; cut_isOk.Visible = true; skinButton3.Visible = true; }
private void button1_Click(object sender, EventArgs e) { List <Image> img = new List <Image>(); imgFilePath = new List <string>(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = true; file.SupportMultiDottedExtensions = true; file.ShowDialog(); foreach (string path in file.FileNames) { img.Add(Image.FromFile(path)); imgFilePath.Add(path); } pictureBox1.BackColor = Color.Black; Image aPicture = PictureMerge.PictureBoxShow(img); Bitmap c = new Bitmap(aPicture); Image b = PictureMerge.GetThumbnail(c, 640, 0); this.pictureBox1.Image = b; }