private void button6_Click(object sender, EventArgs e) { using (ImageEditorForm dlg = new ImageEditorForm()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LogImage li = new LogImage(); li.FileName = dlg.Filename; li.imgFile = dlg.ImageFilePath; li.Caption = dlg.Caption; li.Description = dlg.Description; _logImages.Add(li); PictureBox pb = new PictureBox(); li.PB = pb; pb.Tag = li; pb.Size = new Size(50, 50); pb.SizeMode = PictureBoxSizeMode.CenterImage; pb.Image = Utils.ImageUtilities.ResizeImage(Image.FromFile(li.imgFile.Path), pb.Width, pb.Height); toolTip1.SetToolTip(pb, li.Caption); pb.ContextMenuStrip = this.contextMenuStrip1; pb.MouseDown += new MouseEventHandler(pb_MouseDown); flowLayoutPanel1.Controls.Add(pb); } else { dlg.Clear(); } } }
private void removeToolStripMenuItem_Click(object sender, EventArgs e) { if (_activepb != null) { flowLayoutPanel1.Controls.Remove(_activepb); LogImage li = _activepb.Tag as LogImage; _logImages.Remove(li); li.imgFile.Dispose(); _activepb.Dispose(); _activepb = null; } }
public void Log() { if (this.LogImage != null) { LogImage.Freeze(); //Must freeze the image first before updating UI } Application.Current.Dispatcher.Invoke(new Action(() => { MainWindow.LogDataGrid.Items.Add(this); MainWindow.LogDataGrid.UpdateLayout(); MainWindow.LogDataGrid.ScrollIntoView(this); })); }
public static bool AddLogImage(Database db, LogImageData gd) { bool result = true; LogImage gc = db.LogImageCollection.GetLogImage(gd.ID); if (gc == null) { gc = new LogImage(db, gd); } else { if (gc.DataFromDate < gd.DataFromDate) { gc.BeginUpdate(); LogImageData.Copy(gd, gc); gc.EndUpdate(); } } return(result); }
public Image GetLogImage(LogImage logImage) { Image result = Resources.Empty; switch (logImage) { case LogImage.Info: result = Resources.Information; break; case LogImage.Warning: result = Resources.Warning; break; case LogImage.Error: result = Resources.Error; break; } return(result); }
protected Bitmap getImage(LogImage type) { switch (type) { case LogImage.NONE: return(null); case LogImage.WARNING: return(Resources.if_warning_16263); case LogImage.ERROR: return(Resources.if_error_14415); case LogImage.SUCCESS: return(Resources.if_agt_action_success_3807); case LogImage.INFO: return(Resources.if_info_3238); default: throw new ArgumentException("Unknown image for this LogImage enum: " + type); } }
public DataLog(LogImage type, string message) { this.type = type; this.message = message; }
public Image GetLogImage(LogImage logImage) { return(mainForm.GetLogImage(logImage)); }
public AttendanceLog WriteAttendanceAutoLog(int RollCallID, List <RecognizerResult> RecognizerResults) { if (RecognizerResults.Count == 0) { return(null); } //Tim xem da co log auto cho hom nay chua AttendanceLog Log = GetAttendanceLogAtDate(RollCallID, DateTime.Today, 1); bool LogExist = true; if (Log == null) { Log = new AttendanceLog() { RollCallID = RollCallID, LogDate = DateTime.Today, TypeID = 1 }; LogExist = false; } //Dua danh sach nhan vao, loc ra ID nhung sinh vien co mat HashSet <int> StudentIDs = new HashSet <int>(); foreach (var result in RecognizerResults) { foreach (var face in result.FaceList) { //ID phai khac -1, moi tinh la nhan duoc if (face.StudentID != -1) { StudentIDs.Add(face.StudentID); } } //Save hinh cho log, neu hinh da trung thi ko save if (!Log.LogImages.Any(image => image.ImageLink.Equals(result.ImageLink))) { LogImage LogImg = new LogImage() { ImageLink = result.ImageLink }; Log.LogImages.Add(LogImg); } } //Lay toan bo student cua roll call RollCallBusiness RollBO = new RollCallBusiness(this.RollSystemDB); RollCall rollCall = RollBO.GetRollCallByID(RollCallID); List <int> RollCallStudentIDs = rollCall.Students.Select(s => s.StudentID).ToList(); foreach (int StudentID in RollCallStudentIDs) { //Neu student chua co trong log thi add vao if (!Log.StudentAttendances.Any(attendace => attendace.StudentID == StudentID)) { StudentAttendance Attendance = new StudentAttendance() { StudentID = StudentID, }; //Xem co ten trong list cac id da nhan dc hay ko if (StudentIDs.Contains(StudentID)) { Attendance.IsPresent = true; } else { Attendance.IsPresent = false; } Log.StudentAttendances.Add(Attendance); } else { StudentAttendance Attendance = Log.StudentAttendances.SingleOrDefault(attendance => attendance.StudentID == StudentID); if (StudentIDs.Contains(StudentID)) { Attendance.IsPresent = true; } //Ko chuyen tu true sang false, vi moi lan diem danh co the thieu nguoi } } //Neu log chua co thi them vao, da co thi edit lai if (LogExist) { Update(Log); } else { Insert(Log); } //Tra Log ra de show return(Log); }