/// <summary> /// 这个函数的功能就是读取图片,初始化左边面板图片列表 /// </summary> /// <param name="strLabelList"></param> /// <param name="str"></param> private void createLeftPictureBoxList(List<string> strLabelList, string str = "filter", string mirrorDirection= "mirrorRight", int coolingType = 5) { string imagePath = "../../image/" + str; ImageList imageList = getLeftImageUrl(imagePath); //两个If防止清空作用 if (leftPictureBoxDictionary != null && leftPictureBoxDictionary.Count > 0) { leftPictureBoxDictionary.Clear(); } if (leftLabelDictionary != null && leftLabelDictionary.Count > 0) { leftLabelDictionary.Clear(); } if (imageList != null) { if (imageList.Images.Count == strLabelList.Count) { //设置pictruebox 中文件名称需要,他的长度和imageList相同,同时文件名称一一对应 // string[] imagePathArray = Directory.GetFiles(imagePath); // List<string> tempImageFileNameList = getimageFileName(imagePathArray); //修改时间2012-7-12 List<GraphicText> tempImageFileNameList = GraphicControlService.initLeftGraphicText(str); List<string> imageEntityNameList = ImageBlockBLL.getImageNames(coolingType); for (int i = 0; i < imageList.Images.Count; i++) { string simpleImageEntityName = tempImageFileNameList.ElementAt(i).realLetterAndNumName.ToString().Substring(1, 3); if(imageEntityNameList.Contains(simpleImageEntityName)){ PictureBox leftPb = new PictureBox(); // leftPb.Name = "pictrueBox" + tempImageFileNameList.ElementAt(i).ToString(); //注意此处必须进行这样命名 //leftPb.Name = "pictrueBox" + tempImageFileNameList.ElementAt(i).realLetterAndNumName.ToString().Substring(1,3); leftPb.Name = tempImageFileNameList.ElementAt(i).realLetterAndNumName.ToString().Substring(1, 3); if (mirrorDirection.Equals("mirrorRight")) { leftPb.Image = imageList.Images[i]; } else { Bitmap bmp = new Bitmap(imageList.Images[i]); bmp.RotateFlip(RotateFlipType.RotateNoneFlipX); leftPb.Image = bmp; } leftPb.Width = imageList.Images[i].Width + 2; leftPb.Height = imageList.Images[i].Height + 3; leftPictureBoxDictionary.Add(leftPb.GetHashCode().ToString(), leftPb); Label leftLabel = new Label(); leftLabel.Text = strLabelList.ElementAt(i).ToString(); leftLabelDictionary.Add(leftPb.GetHashCode().ToString(), leftLabel); } } } else { MessageBox.Show("图片数目和图片说明数量不一致!"); } } }