private void btnStop_Click(object sender, EventArgs e) { try { if (btnStop.Text == "Lưu") { AlertBoxs.Show("Thông báo", "Lưu thành công", (int)AlertBoxs.TypeAlert.AlertSuccess); btnStop.Text = "Dừng"; btnStop.BackColor = Color.Empty; if (FinalFrame == null) { return; } if (FinalFrame.IsRunning) { FileWriter.Close(); //ngừng quay CameraBox.Image = null; } } else { this.FinalFrame.Stop(); // tắt máy ảnh FileWriter.Close(); CameraBox.Image = null; } } catch (Exception ex) { AlertBoxs.Show("Dừng Video", ex.Message, (int)AlertBoxs.TypeAlert.AlertError); } }
private void btnCaptureImage_Click(object sender, EventArgs e) { if (CameraBox.Image == null) { AlertBoxs.Show("Hệ Thống", "Vui lòng bật máy ảnh!", (int)AlertBoxs.TypeAlert.AlertWarning); } else { CopyBox.Image = (Bitmap)CameraBox.Image.Clone(); } }
private void btnSave_Click(object sender, EventArgs e) { //string projectPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; string projectPath = Path.GetTempPath(); // C:\Users\DELL\AppData\Local\Temp string folderName = Path.Combine(projectPath, "Images"); // C:\Users\DELL\AppData\Local\Temp\Images folderName = Path.Combine(folderName, txtPatientID.Text); // C:\Users\DELL\AppData\Local\Temp\Images\PatientID try { if (txtPatientID == null) { AlertBoxs.Show("Thông báo", "Vui lòng nhập PatientID", (int)AlertBoxs.TypeAlert.AlertWarning); } else { if (!Directory.Exists(folderName) && txtPatientID.Text != null) { System.IO.Directory.CreateDirectory(folderName); if (CopyBox.Image == null) { AlertBoxs.Show("Thông báo", "Không có ảnh để lưu", (int)AlertBoxs.TypeAlert.AlertInfo); } else { CopyBox.Image.Save(folderName + @"\" + "IMG_" + DateTime.Now.ToString("ddMMyyyy_HHmmss") + ".jpg", ImageFormat.Jpeg); AlertBoxs.Show("Thông báo", "Lưu thành công", (int)AlertBoxs.TypeAlert.AlertSuccess); } } else { if (CopyBox.Image == null) { AlertBoxs.Show("Thông báo", "Không có ảnh để lưu", (int)AlertBoxs.TypeAlert.AlertInfo); } else { CopyBox.Image.Save(folderName + @"\" + "IMG" + DateTime.Now.ToString("ddMMyyyy_HHmmss") + ".jpg", ImageFormat.Jpeg); //MessageBox.Show("Lưu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); AlertBoxs.Show("Thông báo", "Lưu thành công", (int)AlertBoxs.TypeAlert.AlertSuccess); } } } } catch (Exception ex) { AlertBoxs.Show("Lỗi", ex.Message, (int)AlertBoxs.TypeAlert.AlertError); } }
private void removeToolStripMenuItem_Click(object sender, EventArgs e) { int selectedIndex = listFile.SelectedIndex; if (selectedIndex == -1) { AlertBoxs.Show("Thông báo", "Không có hình ảnh trong danh sách", (int)AlertBoxs.TypeAlert.AlertInfo); } else { files.RemoveAt(selectedIndex); axWindowsMediaPlayer.Ctlcontrols.stop(); AlertBoxs.Show("Thông báo", "Đã di chuyển file khỏi danh sách", (int)AlertBoxs.TypeAlert.AlertInfo); listFile.DataSource = files; } }
private void btnDeleteVideo_Click(object sender, EventArgs e) { GC.Collect(); GC.WaitForPendingFinalizers(); if (File.Exists(lblPathFileVideo.Text)) { int selectedIndex = listFile.SelectedIndex; // Remove the item in the List. var result = MessageBox.Show("Bạn có chắc xóa file " + lblPathFileVideo.Text, "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { File.Delete(lblPathFileVideo.Text); axWindowsMediaPlayer.Ctlcontrols.stop(); files.RemoveAt(selectedIndex); lblPathFileVideo.Text = ""; AlertBoxs.Show("Thông báo", "Xóa thành công!", (int)AlertBoxs.TypeAlert.AlertSuccess); } } }
private void btnDeleteFile_Click(object sender, EventArgs e) { if (ReviewPicture_Box_.Image != null || TrackingImage_Box.Image != null) { AlertBoxs.Show("Hệ Thống", "Xóa các ảnh khỏi khung trước!", (int)AlertBoxs.TypeAlert.AlertWarning); } else { var result = MessageBox.Show("Bạn có chắc xóa file " + lblPathFileImage.Text, "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { GC.Collect(); GC.WaitForPendingFinalizers(); if (File.Exists(lblPathFileImage.Text)) { File.Delete(lblPathFileImage.Text); lblPathFileImage.Text = ""; AlertBoxs.Show("Thông báo", "Xóa thành công!", (int)AlertBoxs.TypeAlert.AlertSuccess); } } } }
private void btnRecord_Click(object sender, EventArgs e) { string projectPath = Path.GetTempPath(); string folderName = Path.Combine(projectPath, "Videos"); folderName = Path.Combine(folderName, txtPatientID.Text); try { if (!Directory.Exists(folderName)) { System.IO.Directory.CreateDirectory(folderName); if (CameraBox.Image == null) { AlertBoxs.Show("Hệ Thống", "Vui lòng bật máy ảnh!", (int)AlertBoxs.TypeAlert.AlertWarning); } else { if (btnStop.Text == "Lưu") { AlertBoxs.Show("Hệ Thống", "Hãy -LƯU- video trước khi thao tác tiếp!", (int)AlertBoxs.TypeAlert.AlertWarning); } else { System.Threading.Thread.Sleep(500); //saveAvi = new SaveFileDialog(); //saveAvi.Filter = "Mp4 Files (*.mp4)|*.mp4"; //if (saveAvi.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ int h = captureDevice.VideoDevice.VideoResolution.FrameSize.Height; int w = captureDevice.VideoDevice.VideoResolution.FrameSize.Width; FileWriter.Open(folderName + @"\" + "Video_" + DateTime.Now.ToString("ddMMyyyy_HHmmss") + ".mp4", w, h, 15, VideoCodec.MPEG4, 200000); FileWriter.WriteVideoFrame(video); btnStop.BackColor = Color.Red; btnStop.Text = "Lưu"; //} } } } else { if (CameraBox.Image == null) { AlertBoxs.Show("Hệ Thống", "Vui lòng bật máy ảnh!", (int)AlertBoxs.TypeAlert.AlertWarning); } else { if (btnStop.Text == "Lưu") { AlertBoxs.Show("Hệ Thống", "Hãy -LƯU- video trước khi thao tác tiếp!", (int)AlertBoxs.TypeAlert.AlertWarning); } else { System.Threading.Thread.Sleep(500); //saveAvi = new SaveFileDialog(); //saveAvi.Filter = "Mp4 Files (*.mp4)|*.mp4"; //if (saveAvi.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ int h = captureDevice.VideoDevice.VideoResolution.FrameSize.Height; int w = captureDevice.VideoDevice.VideoResolution.FrameSize.Width; FileWriter.Open(folderName + @"\" + "Video_" + DateTime.Now.ToString("ddMMyyyy_HHmmss") + ".mp4", w, h, 15, VideoCodec.MPEG4, 200000); FileWriter.WriteVideoFrame(video); btnStop.BackColor = Color.Red; btnStop.Text = "Lưu"; //} } } } } catch (Exception ex) { AlertBoxs.Show("Lỗi Record", ex.Message, (int)AlertBoxs.TypeAlert.AlertError); } }