/*▶↑圖片預覽框的滑鼠事件*/ private void btn_save_Click(object sender, EventArgs e) //▶儲存,下一張圖片 { ImageCrop.clear(YT_Label, YB_Label, XL_Label, XR_Label); BlockerUtils.setBlockerVisibility(Blocker_Upper, Blocker_Lower, Blocker_Left, Blocker_Right, false); //遮擋塊不可見 ImageCrop.recoverXY(); //將縮放後的座標回復為影像座標 Dirs.thisDirDisplayStr += //用來顯示的文字 "(" + ImageCrop.xL + "," + ImageCrop.yT + ") , (" + ImageCrop.xR + "," + ImageCrop.yB + ")\r\n"; Dirs.thisDirBbInfoText += StringUtils.filePathToName(Dirs.thisImg()) + " " + //即將寫入檔案的文字 ImageCrop.xL + " " + ImageCrop.yT + " " + ImageCrop.xR + " " + ImageCrop.yB + "\r\n"; if (Dirs.nextImg() == null) { this.Close(); return; } ; //沒有下一張了,結束程式 ImageList.Text = Dirs.imgFileNameList; //顯示(重製)影像檔案列表 ImageBbList.Text = Dirs.thisDirDisplayStr; //顯示即將寫入檔案的文字 Image thisImg = Image.FromFile(Dirs.thisImg()); //讀取影像 thisImg = ImageUtils.resizeImage(thisImg, pictureBox1.Width, pictureBox1.Height); //縮放至適合大小 pictureBox1.Image = thisImg; //顯示影像 }
public static bool nextDir(bool isInit /*是否是開始*/) //檢查有沒有下一個資料夾 { if (isInit) { dirIndex = 0; } else //寫入檔案 { thisBBInfoWriter = new StreamWriter(dirCollection[dirIndex] + @"\bb_info.txt"); //開檔 thisBBInfoWriter.WriteLine("img x1 y1 x2 y2"); thisBBInfoWriter.Write(thisDirBbInfoText); thisBBInfoWriter.Close(); //關檔 thisDirDisplayStr = ""; //即將寫入檔案的字串 dirIndex++; } if (dirIndex < dirCollection.Length) { Dirs.getImgCollection(); //掃描資料夾下所有檔案 } else { return(false); //沒有資料夾了 } imgIndex = 0; //歸零imgIndex imgFileNameList = StringUtils.filePathArrayToFileString(imgCollectionInDir); //顯示 檔案名稱字串 return(true); }
private void ImageRootLabel_Click(object sender, EventArgs e) //▶選擇根目錄 { Dirs.getSubdirCollection(); ImageRootLabel.Text = Dirs.rootDirPath; DirList.Text = StringUtils.filePathArrayToFileString(Dirs.dirCollection); //顯示目錄列表 //允許開始 StartLabel.Enabled = true; }
private void StartLabel_Click(object sender, EventArgs e) //▶開始 { StartLabel.Enabled = ImageRootLabel.Enabled = false; pictureBox1.Enabled = btn_save.Enabled = btn_again.Enabled = true; Dirs.dirIndex = 0; Dirs.imgIndex = 0; Dirs.nextDir(true); //指向第1(0)個資料夾 ImageList.Text = Dirs.imgFileNameList; //顯示影像檔案列表 Image thisImg = Image.FromFile(Dirs.thisImg()); //讀取影像 thisImg = ImageUtils.resizeImage(thisImg, pictureBox1.Width, pictureBox1.Height); //縮放至適合大小 pictureBox1.Image = thisImg; //顯示影像 }