Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace imgMessCons
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- String pathTxtWrite = string.Empty,
- pathImgWrite = string.Empty,
- pathTxtRead = string.Empty,
- pathImgRead = string.Empty;
- ImgProc bmpWrite,
- bmpRead;
- int step;
- private void Form1_Load(object sender, EventArgs e)
- {
- labelSeparation1.AutoSize = false;
- labelSeparation1.Height = 4;
- labelSeparation1.BorderStyle = BorderStyle.Fixed3D;
- labelSepatation2.AutoSize = false;
- labelSepatation2.Height = 4;
- labelSepatation2.BorderStyle = BorderStyle.Fixed3D;
- numericUpDownWriteStep.Minimum = 1;
- numericUpDownWriteStep.Maximum = 255;
- labelWriteTxtPathState.Text = "Empty";
- labelWriteImgPathState.Text = "Empty";
- labelWriteState.Text = "Lock";
- labelWriteBusyReady.Text = "Ready";
- buttonWriteMess.Enabled = false;
- labelReadTxtPathState.Text = "Empty";
- labelReadImgPathState.Text = "Empty";
- labelReadState.Text = "Lock";
- labelReadBuseReady.Text = "Ready";
- buttonReadMess.Enabled = false;
- }
- private void buttonTextPath_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Message original (TXT)|*.txt";
- if(ofd.ShowDialog() == DialogResult.OK)
- {
- pathTxtWrite = ofd.FileName;
- textBoxWriteTxtPath.Text = pathTxtWrite;
- }
- CheckWriteMessageState();
- }
- private void CheckWriteMessageState()
- {
- labelWriteState.Text = "Lock";
- buttonWriteMess.Enabled = false;
- if((textBoxWriteTxtPath.Text.Length > 0) && (textBoxWriteImgPath.Text.Length > 0))
- {
- labelWriteState.Text = "Unlock";
- buttonWriteMess.Enabled = true;
- }
- }
- private void buttonClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void buttonWriteImgPath_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Image for message (PNG)|*png";
- if(ofd.ShowDialog() == DialogResult.OK)
- {
- pathImgWrite = ofd.FileName;
- textBoxWriteImgPath.Text = pathImgWrite;
- }
- CheckWriteMessageState();
- }
- private void buttonReadTxtPath_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Message from image (TXT)|*txt";
- if(ofd.ShowDialog() == DialogResult.OK)
- {
- pathTxtRead = ofd.FileName;
- textBoxReadTxtPath.Text = pathTxtRead;
- }
- CheckReadMessageState();
- }
- private void CheckReadMessageState()
- {
- labelReadState.Text = "Lock";
- buttonReadMess.Enabled = false;
- if((textBoxReadTxtPath.Text.Length > 0) && (textBoxReadImgPath.Text.Length > 0))
- {
- labelReadState.Text = "Unlock";
- buttonReadMess.Enabled = true;
- }
- }
- private void buttonReadImgPath_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Image with message (PNG)|*png";
- if(ofd.ShowDialog() == DialogResult.OK)
- {
- pathImgRead = ofd.FileName;
- textBoxReadImgPath.Text = pathImgRead;
- }
- CheckReadMessageState();
- }
- private void buttonWriteMess_Click(object sender, EventArgs e)
- {
- labelWriteBusyReady.Text = "Busy";
- step = (int)numericUpDownWriteStep.Value;
- bmpWrite = new ImgProc(pathImgWrite);
- bmpWrite.WriteMessage(pathTxtWrite, step);
- bmpWrite.SaveImg(pathImgWrite);
- bmpWrite = null;
- pathTxtWrite = string.Empty;
- pathImgWrite = string.Empty;
- textBoxWriteTxtPath.Text = string.Empty;
- textBoxWriteImgPath.Text = string.Empty;
- CheckWriteMessageState();
- labelWriteBusyReady.Text = "Ready";
- }
- private void buttonReadMess_Click(object sender, EventArgs e)
- {
- labelReadBuseReady.Text = "Busy";
- bmpRead = new ImgProc(pathImgRead);
- bmpRead.ReadMessage(pathTxtRead);
- bmpRead = null;
- pathTxtRead = string.Empty;
- pathImgRead = string.Empty;
- textBoxReadTxtPath.Text = string.Empty;
- textBoxReadImgPath.Text = string.Empty;
- CheckReadMessageState();
- labelReadBuseReady.Text = "Ready";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment