//evry click on list will appear in pictureresult private void MatchesList_SelectedIndexChanged_1(object sender, EventArgs e) { try { if (image != null) { image.Dispose(); } image = null; // Check if textbox has a value if (MatchesList.SelectedItem.ToString() != String.Empty) { image = Image.FromFile(MatchesList.SelectedItem.ToString()); } // Check if image exists if (image != null) { ResulutionLbl.Text = (image.Width + "x" + image.Height); // pictureNameLbl.Text = image. PictureResult.Image = image.GetThumbnailImage(186, 148, null, new IntPtr()); pathLbl.Text = MatchesList.SelectedItem.ToString(); } } catch { MessageBox.Show("An error occured"); } PictureResult.Refresh(); }
/// <summary> /// 视频图片上传 /// </summary> /// <returns></returns> public PictureResult AddImage(IFormFile files) { PictureResult result = new PictureResult(); try { var fileName = ContentDispositionHeaderValue.Parse(files.ContentDisposition).FileName.Trim('"'); //string filePath = hostingEnv.WebRootPath+ $@"\Files\Pictures\"; string filePath = Directory.GetCurrentDirectory() + $@"\Files\Pictures\"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string suffix = fileName.Split('.')[1]; fileName = Guid.NewGuid() + "." + suffix; string fileFullName = filePath + fileName; using (FileStream fs = File.Create(fileFullName)) { files.CopyTo(fs); fs.Flush(); } result.code = "0"; result.msg = "图片上传成功"; result.image = $"../Files/Pictures/{fileName}"; } catch (Exception ex) { result.code = "1"; } return(result); }
public ActionResult Test([Bind(Include = "AnimalName,EnteredName")] PictureResult result) { if (ModelState.IsValid && result.EnteredName != null && result.EnteredName.Length > 0) { if (PictureExercises.Test(result.AnimalName, result.EnteredName)) { return(RedirectToAction("Test", new { @continue = true })); } else { Picture picture = db.Picture(result.AnimalName); return(RedirectToAction("WrongAnswer", new PictureWrongAnswerVM { EnteredName = result.EnteredName, PictureName = picture.PictureName, AnimalName = picture.AnimalName })); } } else { ViewBag.Picture = db.Picture(result.AnimalName); ViewBag.NbTests = PictureExercises.NB_TESTS; ViewBag.NoTest = PictureExercises.NoTest; ViewBag.Score = PictureExercises.Score; return(View(result)); } }
protected void SendPictureResult(byte[] bytes) { var result = new PictureResult() { Id = Id, EncodedPictureBytes = Convert.ToBase64String(bytes), }; Send(result); }
private void buttonForward_Click(object sender, EventArgs e) { if (core.Res.BitExact.Matches.Count > bitcurr) { bitcurr++; } if (core.Res.BitExact.Matches.Count >= bitcurr) { MatchesList.Items.Clear(); for (int i = 0; i < core.Res.BitExact.Matches[bitcurr - 1].Count; i++) { MatchesList.Items.Add(core.Res.BitExact.Matches[bitcurr - 1][i]); } labelnow.Text = bitcurr.ToString(); //--- load auto image --------------------------------------------------- try { if (image != null) { image.Dispose(); } image = null; // Check if textbox has a value image = Image.FromFile(core.Res.BitExact.Matches[bitcurr - 1][0].ToString()); // Check if image exists if (image != null) { PictureResult.Image = image.GetThumbnailImage(186, 148, null, new IntPtr()); pathLbl.Text = core.Res.BitExact.Matches[bitcurr - 1][0].ToString(); } } catch { MessageBox.Show("An error occured"); } PictureResult.Refresh(); //----------------------------------------------------------------------- } }
public PictureResult AddImage() //IFormFileCollection formCollection { PictureResult result = new PictureResult(); var files = Request.Form.Files; long size = files.Sum(f => f.Length); if (size > 10485760) { result.code = "1"; result.msg = "图片最大允许上传10M!"; return(result); } var fileName = ContentDispositionHeaderValue.Parse(files[0].ContentDisposition).FileName.Trim('"'); string suffix = fileName.Split('.')[1]; if (!pictureFormatArray.Contains(suffix)) { result.code = "1"; result.msg = "图片只允许上传png,jpg,jpeg类型的图片!"; return(result); } return(_uploadService.AddImage(files[0])); }
private void bitExactProgressTimer_Tick(object sender, EventArgs e) { BitExactProgressBar.Value = core.RunStatus; if (BitExactProgressBar.Value == BitExactProgressBar.Maximum) { bitExactProgressTimer.Stop(); // changing form. for now its to the bitmap exact - need to change in future if (featuresArr[(int)Feature.BIT_EXACT] == true) { framesMoveHorizon(progressFr, bitExactFr); } else if (featuresArr[(int)Feature.BAD_CONTRAST] == true) { framesMoveHorizon(progressFr, badContrastFr); } /*else{if(featuresArr[(int)Feature.SIMILARITY] == true) * framesMoveHorizon(progressFr, similarityFr); * else{if(featuresArr[(int)Feature.PARTIAL_BLOCKAGE] == true) * framesMoveHorizon(progressFr, parBlockFr); * } * } * }*/ DBprogressBar.Value = 0; //-------------- starting to load results after loading as done -------// //int bitXCurrent //current head to show on bitexact if (featuresArr[(int)Feature.BIT_EXACT] == true) { MatchesList.Items.Clear(); if (core.Res.BitExact.Matches.Count != 0) { for (int i = 0; i < core.Res.BitExact.Matches[bitcurr - 1].Count; i++) { MatchesList.Items.Add(core.Res.BitExact.Matches[bitcurr - 1][i]); } labelcurr.Text = core.Res.BitExact.Matches.Count.ToString(); labelnow.Text = "1"; try { if (image != null) { image.Dispose(); } image = null; // Check if textbox has a value image = Image.FromFile(core.Res.BitExact.Matches[bitcurr - 1][0].ToString()); // Check if image exists if (image != null) { PictureResult.Image = image.GetThumbnailImage(186, 148, null, new IntPtr()); pathLbl.Text = core.Res.BitExact.Matches[bitcurr - 1][0].ToString(); } } catch { MessageBox.Show("An error occured"); } PictureResult.Refresh(); } else { MessageBox.Show("there are no identical pictures"); } //-------------------end of load results -----------------------------// //-------------------sending badcontrast photos to frame--------------// } if (featuresArr[(int)Feature.BAD_CONTRAST] == true) { BadConPhotos.Items.Clear(); if (core.Res.BadContrast.Matches.Count != 0) { for (int i = 0; i < core.Res.BadContrast.Matches.Count; i++) { BadConPhotos.Items.Add(core.Res.BadContrast.Matches[i]); } try { if (image != null) { image.Dispose(); } image = null; // setting image value image = Image.FromFile(core.Res.BadContrast.Matches[0].ToString()); // Check if image exists if (image != null) { PicBadCon.Image = image.GetThumbnailImage(311, 191, null, new IntPtr()); pathbad.Text = core.Res.BadContrast.Matches[0].ToString(); } } catch { MessageBox.Show("An error occured"); } PictureResult.Refresh(); labelfound.Text = core.Res.BadContrast.Matches.Count.ToString(); } else { MessageBox.Show("there are no BadContrast pictures"); } //-------------------end of load results -----------------------------// } } }
public ArticleResult() { Picture = new PictureResult(); }