日期:2014-05-18 浏览次数:21313 次
/// <summary> /// 加载图片 /// </summary> public void LoadImage() { listView1.Groups.Add(group1); listView1.Groups.Add(group2); listView1.Items.Clear(); imageList1.Images.Clear(); this.imageList1.ImageSize = new Size(80, 60); this.listView1.LargeImageList = this.imageList1; string TempDirectory = dateTimePicker1.Value.ToShortDateString(); string[] TempDeal = TempDirectory.Split('-'); if (TempDeal[1].Length < 2) { TempDeal[1] = "0" + TempDeal[1]; } if (TempDeal[2].Length < 2) { TempDeal[2] = "0" + TempDeal[2]; } if (System.IO.Directory.Exists(TempDeal[0] + TempDeal[1] + TempDeal[2])) { tPlist = System.IO.Directory.GetFiles(TempDeal[0] + TempDeal[1] + TempDeal[2]); for (int i = 0; i < tPlist.Length; i++) { System.IO.FileInfo fi = new System.IO.FileInfo(tPlist[i].ToString().Replace(TempDeal[0] + TempDeal[1] + TempDeal[2] + "\\", "")); string[] a = fi.ToString().Split('_'); //fi.Extension.ToUpper() == ".JPG" if (a.Length == 3) { if (a[2].Trim() == "有效.jpg") { imageList1.Images.Add(tPlist[i].ToString(),TempImage(tPlist[i].ToString())); ListViewItem item = new ListViewItem(tPlist[i].ToString().Replace(TempDeal[0] + TempDeal[1] + TempDeal[2] + "\\", ""), i, group1); listView1.Items.Add(item); } else { imageList1.Images.Add(TempImage(tPlist[i].ToString())); ListViewItem item = new ListViewItem(tPlist[i].ToString().Replace(TempDeal[0] + TempDeal[1] + TempDeal[2] + "\\", ""), i, group2); listView1.Items.Add(item); } } } } EffectiveCount.Text = group1.Items.Count.ToString() + " 车"; InvalidCount.Text = group2.Items.Count.ToString() + " 车"; }
/// <summary> /// 有效图 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string[] ChooseDeal=FRM_PIC.PicFath.Split('_'); if (ChooseDeal[2].Trim() == "_有效.jpg") { return; } else { FRM_PIC KP = (FRM_PIC)this.Tag; //int a = FRM_PIC.ListViewCount; //string Filefath=ChooseDeal[0].Substring(ChooseDeal[0].LastIndexOf("\\")); //string FileRemove =Filefath.Replace("\\","")+"_"+ ChooseDeal[1] + "_有效.jpg"; //删除无效组相关图片 KP.listView1.Groups[1].Items[FRM_PIC.ListViewCount].Remove(); //删除imagelist中相关数据 KP.imageList1.Images.RemoveByKey(FRM_PIC.PicFath); //修改文件名 FileInfo Finfo=new FileInfo(ChooseDeal[0] + "_" + ChooseDeal[1] + "_" + ChooseDeal[2]);