//CoNSTRUCTOR USED WHEN DISPLAYING DETAILS ABOUT A PERPETRATOR public PerpetratorDetailsForm(Perpetrator perpetrator,bool alert_mode) { InitializeComponent(); another_crime = true; this.perpetrator = perpetrator; SetPerpetratorDetails(); DisableControls(); }
//private bool another_crime; //NEW VICTIM CONSTRUCTOR public VictimsDetailsForm(Perpetrator perp,Crime crime) { //this.another_crime = false; this.perpetrator = perp; this.crime = crime; InitializeComponent(); ResetTextValues(); }
//CONSTRUCTOR USED WHEN U WANT TO CAPTURE DETAILS ABOUT A PERP public PerpetratorDetailsForm(Perpetrator perpetrator) { InitializeComponent(); another_crime = true; this.perpetrator = perpetrator; comboBox_is_a_student.SelectedIndex = 0; comboBox_gender.SelectedIndex = 0; button_getCrimes.Visible = false; button_getCrimes.Enabled = false; button_is_apprehended.Visible = false; }
public CrimeDetailsForm(Perpetrator perpetrator_id) { this.perpetrator = perpetrator_id; InitializeComponent(); this.button_getVictims.Visible = false; }
private Panel CreateNewPerpPanel(Perpetrator perp) { ComboBox comboBox_gender = CreateGenderField(perp.gender); Label gender_label = CreateGenderLabel(); ComboBox comboBox_is_active = CreateIsActiveField(perp.is_still_active); Label is_active_label = CreateIsActiveLabel(); ComboBox comboBox_is_a_student = CreateIsAStudentField(perp.is_a_student); Label is_a_student_label = CreateIsAStudentLabel(); TextBox textBox_perpetrator_name = CreatePerpsNameField(perp.name); Label perps_name_label = CreatePerpsNameLabel(); PictureBox perpetrator_picture_box = CreatePerpsPictureBox(perp.faces[0].ToBitmap()); Label vertical_separator = CreateVerticalSeparator(); Control[] all_controls = { vertical_separator, comboBox_gender, gender_label, comboBox_is_active, is_active_label, comboBox_is_a_student, is_a_student_label, textBox_perpetrator_name, perps_name_label, perpetrator_picture_box }; Panel a_panel = new Panel(); a_panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; a_panel.Controls.AddRange(all_controls); a_panel.Font = new System.Drawing.Font("Calibri", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); a_panel.ForeColor = System.Drawing.SystemColors.ControlLight; a_panel.Location = new System.Drawing.Point(x, y); a_panel.Name = "panel2"; a_panel.Size = new System.Drawing.Size(515, 191); a_panel.TabIndex = 1; return a_panel; }
private void DoneButton_Click(object sender, EventArgs e) { //reset mode of face detecting thread ReviewFaceDetectingThread.its_time_to_pick_perpetrator_faces = false; //create array for the identified perpetrator faces Image<Bgr, byte>[] perpetrator_faces = new Image<Bgr, byte>[image_list_view.SelectedItems.Count]; int i = 0; //save perpetrator images foreach (var item in image_list_view.SelectedItems) { //get the perpetrator face from the list of suspects faces suspect_faces.TryRemove(item.Index, out perpetrator_faces[i]); i++; } Perpetrator perpetrator = new Perpetrator(perpetrator_faces, true, ""); //clear datastore suspect_faces.Clear(); //open perpetrator details box PerpetratorDetailsForm form = new PerpetratorDetailsForm(perpetrator); //close this form this.Close(); form.ShowDialog(); }
private int GetTotalNumberOfPerpFaces(Perpetrator[] perps) { int total = 0; foreach (var perp in perps) { foreach (var face in perp.faces) { total++; } } return total; }
private int GetIncrementPerIteration(Perpetrator[] active_perpetrators) { int total_num_of_faces = GetTotalNumberOfPerpFaces(active_perpetrators); if (total_num_of_faces != 0) { int increment = 100 / total_num_of_faces; return increment; } return 0; }
public static bool Update(Perpetrator perp) { try { String update_sql = "UPDATE " + TABLE_NAME + " SET NAME=@name ,IS_A_STUDENT=@student,IS_ACTIVE=@active,GENDER=@gender WHERE ID=@id"; //Sql command sql_command = new MySqlCommand(); sql_command.Connection = (MySqlConnection)database.OpenConnection(); sql_command.CommandText = update_sql; sql_command.Parameters.AddWithValue("@id", perp.id); sql_command.Parameters.AddWithValue("@name", perp.name); sql_command.Parameters.AddWithValue("@student", "" + perp.is_a_student); sql_command.Parameters.AddWithValue("@active", "" + perp.is_still_active); sql_command.Parameters.AddWithValue("@gender", perp.gender); sql_command.Prepare(); //execute command database.Update(sql_command); Singleton.Update(perp); return true; } catch (Exception) { return false; } finally { CloseDatabaseConnection(); } }
public static bool Save(Perpetrator perp) { try { String insert_sql = "INSERT INTO " + TABLE_NAME + " (NAME,IS_A_STUDENT,IS_ACTIVE,GENDER)"+ " values(@name,@is_a_student,@is_active,@gender) "; //sql command sql_command = new MySqlCommand(); sql_command.Connection = (MySqlConnection)database.OpenConnection(); sql_command.CommandText = insert_sql; sql_command.Parameters.AddWithValue("@name", perp.name); sql_command.Parameters.AddWithValue("@is_a_student", "" + perp.is_a_student); sql_command.Parameters.AddWithValue("@is_active", "" + perp.is_still_active); sql_command.Parameters.AddWithValue("@gender", perp.gender); sql_command.Prepare(); //execute query database.Insert(sql_command); //set perp id perp.id = (int)sql_command.LastInsertedId; //create file path String path = PATH_TO_IMAGES + perp.id + @"\"; //create folder for the perpetrator images FileManager.CreateFolderIfMissing(path); //save each face in that folder for (int i= 0; i < perp.faces.Length; i++) { //save using the perps name plus a unique number FileManager.SaveImage(path + perp.name + " " + i + ".png", perp.faces[i]); } return true; } catch (Exception) { return false; } finally { CloseDatabaseConnection(); } }
public static Perpetrator GetPerpetrator(int id) { List<Perpetrator> perpetrators = new List<Perpetrator>(); try { //select sql String select_sql = "SELECT * FROM " + TABLE_NAME + " WHERE ID=@id"; //Sql command sql_command = new MySqlCommand(); sql_command.Connection = (MySqlConnection)database.OpenConnection(); sql_command.CommandText = select_sql; sql_command.Parameters.AddWithValue("@id", id); sql_command.Prepare(); //get results in enum object data_reader = database.Select(sql_command); //loop thru em while (data_reader.Read()) { //create new student String name = data_reader.GetString(NAME); Image<Bgr, byte>[] faces = GetPerpetratorFaces(id); bool is_a_student = data_reader.GetBoolean(IS_A_STUDENT); bool is_active = data_reader.GetBoolean(IS_ACTIVE); String gender = data_reader.GetString(GENDER); String created_at = data_reader.GetString(CREATED_AT); Perpetrator perp = new Perpetrator(id, name, faces, is_a_student, is_active, gender, created_at); //add student to list perpetrators.Add(perp); } } catch (Exception e) { Debug.WriteLine(e.Message); } finally { CloseDatabaseConnection(); } //return array of results return perpetrators.ToArray()[0]; }
public static Perpetrator[] GetAllPerpetrators() { List<Perpetrator> perpetrators = new List<Perpetrator>(); try { //select sql String select_sql = "SELECT * FROM " + TABLE_NAME; //Sql command sql_command = new MySqlCommand(); sql_command.Connection = (MySqlConnection)database.OpenConnection(); sql_command.CommandText = select_sql; sql_command.Prepare(); //get results in enum object data_reader = database.Select(sql_command); //loop thru em while (data_reader.Read()) { //create new perp int id = data_reader.GetInt32(ID); String name = data_reader.GetString(NAME); Image<Bgr, byte>[] faces = GetPerpetratorFaces(id); bool is_a_student = data_reader.GetBoolean(IS_A_STUDENT); bool is_active = data_reader.GetBoolean(IS_ACTIVE); String gender = data_reader.GetString(GENDER); String created_at = data_reader.GetString(CREATED_AT); Perpetrator perp = new Perpetrator(id, name, faces, is_a_student, is_active, gender, created_at); //add perp to list perpetrators.Add(perp); } } catch (Exception) { } finally { CloseDatabaseConnection(); } //return array of results return perpetrators.ToArray(); }