private void btnAdd_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = true; openFileDialog.Filter = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg;*.gif;*.bmp"; if (openFileDialog.ShowDialog() == DialogResult.OK) { if (openFileDialog.FileNames.Count() + picNames.Count > maxPic) { ClientUtils.WarningCode("TOO_MANY_PICTURES"); return; } foreach (string file in openFileDialog.FileNames) { var result = AppUtils.JsonDeserialize <WebResult>(WebCall.UploadFile(file)); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { picNames.Add(result.Message); PictureBox pic = new PictureBox(); pic.SizeMode = PictureBoxSizeMode.StretchImage; pic.Image = Image.FromFile(file); pic.Size = new Size(picSize, picSize); pic.Left = 5 + picNames.Count % rowCount * picSize + picNames.Count % rowCount * 5; pic.Top = 5 + picNames.Count / rowCount * picSize + picNames.Count / rowCount * 5; this.Controls.Add(pic); } else { ClientUtils.WarningCode(result.Message); } } } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "图片文件(*.jpg,*.gif,*.bmp)|*.jpg;*.gif;*.bmp"; if (openFileDialog.ShowDialog() == DialogResult.OK) { var result = AppUtils.JsonDeserialize <WebResult>(WebCall.UploadFile(openFileDialog.FileName)); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { } else { ClientUtils.WarningCode(result.Message); } } }