Exemplo n.º 1
0
        /// <summary>
        /// Called when background worker completes the task
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            BackgroundWorkerArgs args = e.Result as BackgroundWorkerArgs;

            ///If an error occured during process
            if (e.Error != null)
            {
                string caption = "HideIt";
                if (args != null)
                {
                    caption = ((args.Action == ActionType.Hide) ? "Hide Message" : "Extract Message");
                }
                UIMessage.Error(e.Error.Message, caption);
            }

            if (args != null)
            {
                try
                {
                    args.Message.Dispose();
                    this._processor.Dispose();
                    this._processor = null;
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// When the form is closing (exiting)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HideIt_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this._processor != null)
            {
                try
                {
                    this._processor.Dispose();
                    this._processor = null;
                }
                catch (Exception)
                {
                }
            }

            if (this._liveProcessor != null)
            {
                this._liveProcessor.Dispose();
                this._liveProcessor = null;
            }

            if (this._receiver != null)
            {
                try
                {
                    this._receiver.Dispose();
                }
                catch (Exception)
                {
                }
            }

            if (this.pic_coverPreview.Image != null)
            {
                ///Dispose off the image displayed in preview box
                this.pic_coverPreview.Image.Dispose();
            }

            if (this.pic_stegoPreview.Image != null)
            {
                ///Dipose off the stego object image displayed in preview box
                this.pic_stegoPreview.Image.Dispose();
            }

            if (this._selectDevice != null)
            {
                if (this._selectDevice.CaptureDevice != null)
                {
                    try
                    {
                        this._selectDevice.CaptureDevice.Dispose();
                    }
                    catch (Exception)
                    {
                    }
                    this._selectDevice.CaptureDevice = null;
                }
                this._selectDevice = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Select a bitmap file as stago file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_browseStego_Click(object sender, EventArgs e)
        {
            using (Status status = new Status(null, this.lbl_status, "Open stego file"))
            {
                try
                {
                    string path = AppUtil.SelectFile("Open stego file", "Bitmap (*.bmp)|*.bmp|AVI (*.avi)|*.avi|WAV (*.wav)|*.wav", "bmp").ToLower();

                    if (!string.IsNullOrEmpty(path))
                    {
                        this.txt_stegoObject.Text = path;

                        ///Dispose the previous processor
                        if (this._processor != null)
                        {
                            this._processor.Dispose();
                        }

                        this._processor = StegoProcessorBase.GetProcessor(path, false);
                        this._processor.LoadHost(path, true);

                        if (this._processor.MType == HostMediaType.Bitmap)
                        {
                            ///Let show the pic in preview box. Open the image by giving the path
                            ///The size mode of this image is set to zoom. So if the image is bigger then the
                            ///frame it will automatically adjust it to fit the frame. Same happens if it is smaller
                            ///then the frame
                            this.pic_stegoPreview.Image = new System.Drawing.Bitmap(this.txt_stegoObject.Text);
                        }
                        else if (this._processor.MType == HostMediaType.Wave)
                        {
                            this.pic_stegoPreview.Image = global::HideIt.Properties.Resources.wav;
                        }
                        else
                        {
                            ///setup the Avi icon image
                            this.pic_stegoPreview.Image = global::HideIt.Properties.Resources.avi;
                        }
                    }
                }
                catch (Exception exc)
                {
                    UIMessage.Error(exc.Message, TITLE);

                    if (this._processor != null)
                    {
                        try
                        {
                            this._processor.Dispose();
                        }
                        catch (Exception)
                        {
                        }
                        this._processor = null;
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Select a bitmap file as cover object
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_browseCover_Click(object sender, EventArgs e)
        {
            using (Status status = new Status(null, this.lbl_status, "Open cover file"))
            {
                try
                {
                    string path = AppUtil.SelectFile("Open cover file", "Bitmap (*.bmp)|*.bmp|AVI (*.avi)|*.avi|WAV (*.wav)|*.wav", "bmp").ToLower();

                    if (!string.IsNullOrEmpty(path))
                    {
                        this.txt_coverFileName.Text = path;

                        if (this._processor != null)
                        {
                            this._processor.Dispose();
                        }

                        LoadProcessor(path);
                    }
                }
                catch (Exception exc)
                {
                    UIMessage.Error(exc.Message, TITLE);
                    if (this._processor != null)
                    {
                        try
                        {
                            this._processor.Dispose();
                        }
                        catch (Exception)
                        {
                        }
                        this._processor = null;
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Clear all the data that in form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.backgroundWorker.Dispose();

            if (this._processor != null)
            {
                try
                {
                    this._processor.Dispose();
                }
                catch (Exception)
                {
                }
                this._processor = null;
            }

            if (this._liveProcessor != null)
            {
                try
                {
                    this._liveProcessor.Dispose();
                }
                catch (Exception)
                {
                }
                this._liveProcessor = null;
            }

            this._hidingCapacity = 0;

            ///Clear summary
            ///

            foreach (Control control in this.gb_summary.Controls)
            {
                control.Dispose();
            }
            this.gb_summary.Controls.Clear();
            this.lbl_status.Text = Status.DEFUALT_STATUS;

            ///Clear up all the text box fields
            this.txt_coverFileName.Text = string.Empty;
            this.txt_key.Text           = string.Empty;
            this.txt_stegoKey.Text      = string.Empty;
            this.txt_saveStego.Text     = string.Empty;
            this.txt_stegoObject.Text   = string.Empty;

            this.rtxt_message.Text   = string.Empty;
            this.rtxt_hiddenMsg.Text = string.Empty;

            this.txt_selected.Text         = string.Empty;
            this.rtxt_liveMessage.Text     = string.Empty;
            this.txt_keyLive.Text          = string.Empty;
            this.txt_saveCapturedPath.Text = string.Empty;

            if (this.pic_coverPreview.Image != null)
            {
                this.pic_coverPreview.Image.Dispose();
                this.pic_coverPreview.Image = null;
            }

            if (this.pic_stegoPreview.Image != null)
            {
                this.pic_stegoPreview.Image.Dispose();
                this.pic_stegoPreview.Image = null;
            }

            this.progress.Value = 0;
        }
Exemplo n.º 6
0
        private void LoadProcessor(string path)
        {
            this._processor = StegoProcessorBase.GetProcessor(path, false);
            if (this._processor == null)
            {
                return;
            }

            this._processor.LoadHost(path, true);

            if (this._processor.MType != HostMediaType.Video)
            {
                this.cb_watermark.Enabled = false;
            }

            if (this._processor.MType == HostMediaType.Bitmap)
            {
                ///Show the bitmap summary control
                BitmapSummary summaryControl = new BitmapSummary();
                this._currentControl = summaryControl;
                this.ShowNewSummaryControl(summaryControl);

                ///Display cover file size
                summaryControl.HostSize = this.ToSize(this._processor.HostSize);

                ///Save and display hiding capacity of cover object
                this._hidingCapacity          = (int)this._processor.HidingCapacity / 2;
                summaryControl.HidingCapacity = this.ToSize(this._hidingCapacity);

                ///Setup the maximum length of message
                this.rtxt_message.MaxLength = this._hidingCapacity - (Stego.Message.MAX_KEY_LEN + 8);

                ///Let show the pic in preview box. Open the image by giving the path
                ///The size mode of this image is set to zoom. So if the image is bigger then the
                ///frame it will automatically adjust it to fit the frame. Same happens if it is smaller
                ///then the frame
                this.pic_coverPreview.Image = new System.Drawing.Bitmap(this.txt_coverFileName.Text);
            }
            else if (this._processor.MType == HostMediaType.Wave)
            {
                ///Show the bitmap summary control
                WaveSummary summaryControl = new WaveSummary();
                this._currentControl = summaryControl;
                this.ShowNewSummaryControl(summaryControl);

                Wave host = (Wave)this._processor.HostObject;

                ///Display number of channels
                summaryControl.Channels = host.Format.nChannels.ToString();

                ///Display samples/sec
                summaryControl.SamplesPerSec = host.Format.nSamplesPerSec.ToString();

                ///Save and display hiding capacity of cover object
                this._hidingCapacity          = (int)this._processor.HidingCapacity / 2;
                summaryControl.HidingCapacity = this.ToSize(this._hidingCapacity);

                ///Setup the maximum length of message
                this.rtxt_message.MaxLength = this._hidingCapacity - (Stego.Message.MAX_KEY_LEN + 8);

                ///Setup the Avi icon image in the preview box
                this.pic_coverPreview.Image = global::HideIt.Properties.Resources.wav;
            }
            else
            {
                if (this.cb_watermark.Checked)
                {
                    this.LoadWatermarkingStegoProcessor();
                }
                else
                {
                    this.LoadAviStegoProcessor();
                }
            }
        }
Exemplo n.º 7
0
        private void LoadWatermarkingStegoProcessor()
        {
            try
            {
                ///Reduce the message length to 256 character
                if (this.cb_watermark.Checked)
                {
                    ///Change summary controls
                    WatermarkSummary summaryControl = new WatermarkSummary();
                    this._currentControl = summaryControl;
                    this.ShowNewSummaryControl(summaryControl);

                    if (this._processor != null)
                    {
                        try
                        {
                            this._processor.Dispose();
                        }
                        catch (Exception)
                        {
                        }
                        this._processor = null;
                    }

                    this._processor = StegoProcessorBase.GetProcessor(this.txt_coverFileName.Text, true);
                    if (this._processor == null)
                    {
                        return;
                    }
                    this._processor.LoadHost(this.txt_coverFileName.Text, true);

                    WatermarkingStegoProcessor processor = (WatermarkingStegoProcessor)this._processor;

                    ///Display the length of video
                    summaryControl.VideoLength = processor.Length.ToString() + " sec";

                    ///Display the framerate
                    summaryControl.FrameRate = processor.FrameRate.ToString();

                    ///Display the dimensions
                    summaryControl.Dimension = processor.Width.ToString() + " x " + processor.Height.ToString() + " px";

                    ///Display the hiding capacity
                    this._hidingCapacity = (int)processor.HidingCapacity / 2;

                    this.rtxt_message.MaxLength = WATERMARK_LEN;

                    ///If there is already text in text box
                    if (rtxt_message.Text.Length > WATERMARK_LEN)
                    {
                        DialogResult result = UIMessage.Ask(this, @"Enabling watermarking allows only " + WATERMARK_LEN.ToString() + " characters for hiding.\r\n"
                                                            + "The current length of message is " + this.rtxt_message.Text.Length.ToString() + ".\r\n"
                                                            + "Do you wish to automatically strip the mssage to " + WATERMARK_LEN.ToString() + " characters?",
                                                            TITLE);

                        if (result == DialogResult.Yes)
                        {
                            this.rtxt_message.Text = this.rtxt_message.Text.Substring(0, WATERMARK_LEN - 1);
                        }
                        else
                        {
                            this.cb_watermark.Checked = false;
                        }
                    }
                }
                else
                {
                    this.LoadProcessor(this.txt_coverFileName.Text);
                }
            }
            catch (Exception exc)
            {
                UIMessage.Error(exc.Message, TITLE);
                if (this._processor != null)
                {
                    try
                    {
                        this._processor.Dispose();
                    }
                    catch (Exception)
                    {
                    }
                    this._processor = null;
                }
            }
        }