////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void frmDemo_Shown(object sender, EventArgs e) { TGMTregistry.GetInstance().Init("IPSScar"); carDetector = new IPSScar(); if (carDetector == null) { return; } CheckForIllegalCrossThreadCalls = false; this.KeyPreview = true; txtIpAddress.Text = TGMTregistry.GetInstance().ReadRegValueString("cameraAddress"); chkEnableLog.Checked = TGMTregistry.GetInstance().ReadRegValueBool("EnableLog"); carDetector.EnableLog = chkEnableLog.Checked; chkCrop.Checked = TGMTregistry.GetInstance().ReadRegValueBool("CropResultImage"); chkSaveInputImage.Checked = TGMTregistry.GetInstance().ReadRegValueBool("SaveInputImage"); txtFolderOutput.Text = TGMTregistry.GetInstance().ReadRegValueString("folderOutput"); txtFailedDir.Text = TGMTregistry.GetInstance().ReadRegValueString("txtFailedDir"); txtValidDir.Text = TGMTregistry.GetInstance().ReadRegValueString("txtValidDir"); txtInvalidDir.Text = TGMTregistry.GetInstance().ReadRegValueString("txtInvalidDir"); this.Text += " " + carDetector.Version; this.Text += carDetector.IsLicense ? " (Licensed)" : " (Vui lòng liên hệ: 0939.825.125)"; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region group_image_source private void txtFilePath_TextChanged(object sender, EventArgs e) { if (!File.Exists(txtFilePath.Text)) { return; } TGMTregistry.GetInstance().SaveRegValue("txtFilePath", txtFilePath.Text); if (g_bmp != null) { g_bmp.Dispose(); } try { g_bmp = new Bitmap(txtFilePath.Text); picCamera.Image = g_bmp; SetScaleRatio(); } catch (Exception ex) { PrintError(ex.Message); } }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void rdImage_CheckedChanged(object sender, EventArgs e) { if (rdImage.Checked) { StopAllCamera(); grCamera.Visible = false; grImage.Visible = true; grFolder.Visible = false; txtFilePath.Text = TGMTregistry.GetInstance().ReadRegValueString("txtFilePath"); } else { if (picCamera.Image != null) { picCamera.Image.Dispose(); picCamera.Image = null; } if (picResult.Image != null) { picResult.Image.Dispose(); picResult.Image = null; } if (g_bmp != null) { g_bmp.Dispose(); g_bmp = null; } } }
//////////////////////////////////////////////////////////////////////////////////////////////////////// public static TGMTregistry GetInstance() { if (m_instance == null) { m_instance = new TGMTregistry(); } return(m_instance); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void txtFolderInput_TextChanged(object sender, EventArgs e) { if (!Directory.Exists(txtFolderInput.Text)) { return; } TGMTregistry.GetInstance().SaveRegValue("folderInput", txtFolderInput.Text); if (!m_isDrag) { PrintMessage("Loading files..."); lstImage.Items.Clear(); bgLoadFile.RunWorkerAsync(); } m_isDrag = false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void rdFolder_CheckedChanged(object sender, EventArgs e) { txtResult.Text = ""; if (picCamera.Image != null) { picCamera.Image.Dispose(); } if (picResult.Image != null) { picResult.Image = null; } if (rdFolder.Checked) { if (m_isFirstLoading) { txtFolderInput.Text = TGMTregistry.GetInstance().ReadRegValueString("folderInput"); m_isFirstLoading = false; } StopAllCamera(); grFolder.Visible = true; grCamera.Visible = false; grImage.Visible = false; g_scaleX = 1; g_scaleY = 1; picCamera.Visible = false; lstImage.Visible = true; } else { picCamera.Visible = true; lstImage.Visible = false; } }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void txtFolderOutput_TextChanged(object sender, EventArgs e) { TGMTregistry.GetInstance().SaveRegValue("folderOutput", txtFolderOutput.Text); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region group_camera_source private void txtIpAddress_TextChanged(object sender, EventArgs e) { TGMTregistry.GetInstance().SaveRegValue("cameraAddress", txtIpAddress.Text); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void txtValidDir_TextChanged(object sender, EventArgs e) { TGMTregistry.GetInstance().SaveRegValue("txtValidDir", txtValidDir.Text); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void chkCrop_CheckedChanged(object sender, EventArgs e) { carDetector.CropResultImage = chkCrop.Checked; TGMTregistry.GetInstance().SaveRegValue("CropResultImage", carDetector.CropResultImage); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void chkSaveInputImage_CheckedChanged(object sender, EventArgs e) { carDetector.SaveInputImage = chkSaveInputImage.Checked; TGMTregistry.GetInstance().SaveRegValue("SaveInputImage", carDetector.SaveInputImage); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void chkEnableLog_CheckedChanged(object sender, EventArgs e) { carDetector.EnableLog = chkEnableLog.Checked; TGMTregistry.GetInstance().SaveRegValue("EnableLog", carDetector.EnableLog); }