private void hideInImage(byte[,] red1, byte[,] green1, byte[,] blue1) { byte[,] red = red1; int randh = 0, randw = 0; byte[,] green = green1; byte[,] blue = blue1; #region hide data in image int height = red.GetLength(0), width = red.GetLength(1); /*Since data will be added from 5th pixel. 1st three pixels used to store * the position of lastpixel in which data is stored * and 4th pixel storing whether the last pixel has used all it's capacity or not */ long encryption = 0, hidetime; int j = 4; try { string filinter = "C:\\temp\\example\\Data\\hello.txt"; timer.Start(); f(textfile, filinter); timer.Stop(); encryption = timer.ElapsedMilliseconds; label7.Text = (encryption.ToString()); byte[] fileData = StreamFile(filinter); textfile = filinter; int len = fileData.Length; int i; int requiredBitsRed, requiredBitsGreen, requiredBitsBlue; var encryptbmp = new Bitmap(width, height); if ((len * 8 > capacity) || (width < 5)) { throw new ImageToSmall("Image is too small to use"); } else { timer.Start(); int currentByte = 0; bool isDone = false; int less; byte byte_to_replace, a, b; int offset = 0; int pixel_row = 0, pixel_column = 0, pixel_color = 0, num_of_bits_stored = 5; for (i = 0; i < height; i++) { for (; j < width; j++) { a = 0; b = 0; requiredBitsRed = requiredBit(red[i, j]); requiredBitsGreen = requiredBit(green[i, j]); requiredBitsBlue = requiredBit(blue[i, j]); #region replace red pixel byte_to_replace = 0; if (requiredBitsRed <= 8 - offset) { byte_to_replace = get_byte(offset, fileData[currentByte], requiredBitsRed); offset += requiredBitsRed; if (offset == 8) { offset = 0; ++currentByte; } if (currentByte == len) { pixel_row = i; pixel_column = j; pixel_color = 1; num_of_bits_stored = requiredBitsRed; isDone = true; } } else if (requiredBitsRed > 8 - offset) { less = 8 - offset; a = get_byte(offset, fileData[currentByte], less); currentByte += 1; if (currentByte == len) { pixel_row = i; pixel_column = j; pixel_color = 1; num_of_bits_stored = less; b = 0; isDone = true; } else { offset = 0; b = get_byte(offset, fileData[currentByte], requiredBitsRed - less); offset += requiredBitsRed - less; } byte_to_replace = (byte)((a << requiredBitsRed - less) | b); } red[i, j] = (byte)(maskByte(red[i, j], requiredBitsRed) | byte_to_replace); if (isDone) { break; } #endregion #region replace blue pixel byte_to_replace = 0; if (requiredBitsBlue <= 8 - offset) { byte_to_replace = get_byte(offset, fileData[currentByte], requiredBitsBlue); offset += requiredBitsBlue; if (offset == 8) { offset = 0; ++currentByte; } if (currentByte == len) { pixel_row = i; pixel_column = j; pixel_color = 2; num_of_bits_stored = requiredBitsBlue; isDone = true; } } else if (requiredBitsBlue > 8 - offset) { less = 8 - offset; a = get_byte(offset, fileData[currentByte], less); currentByte += 1; if (currentByte == len) { pixel_row = i; pixel_column = j; pixel_color = 2; num_of_bits_stored = less; b = 0; isDone = true; } else { offset = 0; b = get_byte(offset, fileData[currentByte], requiredBitsBlue - less); offset += requiredBitsBlue - less; } byte_to_replace = (byte)((a << requiredBitsBlue - less) | b); } blue[i, j] = (byte)(maskByte(blue[i, j], requiredBitsBlue) | byte_to_replace); if (isDone) { break; } #endregion #region replace green pixel byte_to_replace = 0; if (requiredBitsGreen <= 8 - offset) { byte_to_replace = get_byte(offset, fileData[currentByte], requiredBitsGreen); offset += requiredBitsGreen; if (offset == 8) { offset = 0; ++currentByte; } if (currentByte == len) { pixel_row = i; pixel_column = j; pixel_color = 3; num_of_bits_stored = requiredBitsGreen; isDone = true; } } else if (requiredBitsGreen > 8 - offset) { less = 8 - offset; a = get_byte(offset, fileData[currentByte], less); currentByte += 1; if (currentByte == len) { pixel_row = i; pixel_column = j; pixel_color = 3; num_of_bits_stored = less; b = 0; isDone = true; } else { offset = 0; b = get_byte(offset, fileData[currentByte], requiredBitsGreen - less); offset += requiredBitsGreen - less; } byte_to_replace = (byte)((a << requiredBitsGreen - less) | b); } green[i, j] = (byte)(maskByte(green[i, j], requiredBitsGreen) | byte_to_replace); if (isDone) { break; } #endregion } if (isDone) { break; } j = 0; } byte[] numb = new byte[4], Color = new byte[4], Row = new byte[4], Col = new byte[4]; if (isDone) { Row = BitConverter.GetBytes(pixel_row); Col = BitConverter.GetBytes(pixel_column); Color = BitConverter.GetBytes(pixel_color); numb = BitConverter.GetBytes(num_of_bits_stored); } for (i = 0; i < 4; i++) { red[0, i] = Row[i]; blue[0, i] = Col[i]; } green[0, 0] = Color[0]; green[0, 1] = Color[1]; green[0, 2] = numb[0]; green[0, 3] = numb[1]; randw = (pixel_column + 1) % (width - 1); randh = (j == 0) ? pixel_row + 1 : pixel_row; } } catch (Exception ex) { label4.Text = ex.Message; } if (randh != height) { j = randw; byte randRed, randGreen, randBlue; Random rnd = new Random(); for (i = randh; i < height; i++) { for (; j < width; j++) { int requiredBitsRed, requiredBitsGreen, requiredBitsBlue; requiredBitsRed = requiredBit(red[i, j]); requiredBitsGreen = requiredBit(green[i, j]); requiredBitsBlue = requiredBit(blue[i, j]); randRed = (byte)rnd.Next((int)Math.Pow(2, requiredBitsRed)); randBlue = (byte)rnd.Next((int)Math.Pow(2, requiredBitsBlue)); randGreen = (byte)rnd.Next((int)Math.Pow(2, requiredBitsGreen)); red[i, j] = (byte)(maskByte(red[i, j], requiredBitsRed) | maskByte(randRed, requiredBitsRed)); blue[i, j] = (byte)(maskByte(blue[i, j], requiredBitsBlue) | maskByte(randBlue, requiredBitsBlue)); green[i, j] = (byte)(maskByte(green[i, j], requiredBitsGreen) | maskByte(randGreen, requiredBitsGreen)); } j = 0; } } #endregion timer.Stop(); hidetime = timer.ElapsedMilliseconds; label8.Text = hidetime.ToString(); label6.Text = (encryption + hidetime).ToString(); MLApp.MLApp matlab = new MLApp.MLApp(); matlab.PutWorkspaceData("red", "base", red); matlab.PutWorkspaceData("green", "base", green); matlab.PutWorkspaceData("blue", "base", blue); matlab.Execute("im = cat(3,red,blue,green)"); Console.WriteLine(matlab.Execute("imwrite(im,'C:\\temp\\example\\Data\\after2222.png')")); label3.Text = label3.Text + "completed"; var form = new Form2("C:\\temp\\example\\Data\\after2222.png"); form.Show(); }
private void Form1_Load(object sender, EventArgs e) { frm.Show(); }
private void metroButton5_Click(object sender, EventArgs e) { Form2 buscar = new Form2(); buscar.Show(); }
private void admin_Click(object sender, EventArgs e) { Form2 f = new Form2(); f.Show(); }
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { MySql.Data.MySqlClient.MySqlConnection conn = new MySqlConnection(); string myConnectionString; myConnectionString = "server=127.0.0.1;" + "uid=root;" + "pwd=root;" + "SslMode=none;" + "database=db"; var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { if (e.ColumnIndex == 0) { var a = new Form2(); forEdit = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); forEditID = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString(); a.Show(); } if (e.ColumnIndex == 1) { DialogResult dialogResult = MessageBox.Show("Are you sure?", "Processing...;", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { //do something else } if (dialogResult == DialogResult.Yes) { //do something conn.ConnectionString = myConnectionString; conn.Open(); using (MySqlConnection con = new MySqlConnection(myConnectionString)) { using (MySqlCommand cmd = new MySqlCommand("DELETE FROM itemcontent WHERE id ='" + dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString() + "' and itemID =" + EquipmentUI.sendtext, conn)) { cmd.CommandType = CommandType.Text; if (cmd.ExecuteNonQuery() > 0) { using (MySqlConnection con1 = new MySqlConnection(myConnectionString)) { using (MySql.Data.MySqlClient.MySqlCommand cmd1 = new MySql.Data.MySqlClient.MySqlCommand("SELECT items.id,itemcontent.modelNumber,itemcontent.id from items left join itemcontent on items.id = itemcontent.itemID where items.id =" + EquipmentUI.sendtext + " and itemcontent.tagID = 1", conn)) { cmd1.CommandType = CommandType.Text; using (MySqlDataAdapter sda = new MySqlDataAdapter(cmd1)) { using (DataTable dt = new DataTable()) { sda.Fill(dt); dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Transparent; dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Transparent; dataGridView1.DataSource = dt; dataGridView1.ClearSelection(); dataGridView1.Columns[2].Visible = false; dataGridView1.Columns[4].Visible = false; dataGridView1.Columns[3].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns[3].HeaderCell.Value = "Name / Model Number"; dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns[3].DefaultCellStyle.ForeColor = Color.Black; dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns[1].HeaderCell.Value = ""; dataGridView1.Columns[1].Width = 50; dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Columns[0].HeaderCell.Value = ""; dataGridView1.Columns[0].Width = 50; dataGridView1.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; MessageBox.Show("Successful!", "Successful ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } } } } } conn.Close(); } } }
/*DESCRIPTION -- This Function will create an instant of a client form with the tittle name of the string passed to it * (ARGUMENTS) -- (String) -> Void * PRECONDITION -- This function accepts one parameter of type String * POSTCONDITION -- Will Show a client Form on Screen * EXAMPLE (s) -- createClient("Student") -> A instant of client form with the title name student will be shown on screen */ private void createClient(String clientName) { form = new Form2(clientName); form.Text = clientName; form.Show(); }
private void button3_Click(object sender, EventArgs e) { var alph = new Form2(); alph.Show(); }
private void button2_Click(object sender, EventArgs e) { Form2 F = new Form2(arr, i); F.Show(); }
private void button1_Click_2(object sender, EventArgs e) { myform.Show(); }