Ejemplo 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)
                {
                }
            }
        }
Ejemplo n.º 2
0
        private void btnStop_Click(object sender, EventArgs e)
        {
            if (this._initialized)
            {
                this._liveProcessor.StopCapturing();
                this._isPlaying = false;

                this.txt_saveCapturedPath.Text = string.Empty;

                if (this._message != null)
                {
                    this._message.Dispose();
                }
                try
                {
                    this._liveProcessor.Dispose();
                }
                catch (Exception exc)
                {
                    UIMessage.Error(exc.Message, TITLE);
                }

                this._initialized = false;
            }
        }
Ejemplo n.º 3
0
 void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     ///If any exception occured while running worker_DoWork method
     if (e.Error != null)
     {
         UIMessage.Error(e.Error.Message, TITLE);
     }
 }
Ejemplo n.º 4
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;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Called when the form is first shown
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void HideIt_Shown(object sender, EventArgs e)
 {
     this._receiver = new FileReceiver(this._acceptFile);
     try
     {
         this._receiver.Listen(Options_Form.Port);
     }
     catch (Exception exc)
     {
         UIMessage.Error("An error occured while starting the listener. " +
                         "Application will not be able to receive files.\r\n" +
                         "Error: " + exc.Message, TITLE);
     }
 }
Ejemplo n.º 6
0
        private void btn_browseAvi_Click(object sender, EventArgs e)
        {
            this._srcFile        = AppUtil.SelectFile("Open video file", "AVI (*.avi)|*.avi", "avi");
            this.txtLoadAvi.Text = this._srcFile;

            try
            {
                if (this._srcFile != string.Empty)
                {
                    ///Get basic file information
                    Type      t        = Type.GetTypeFromCLSID(ComGuids.MediaDetGuid);
                    IMediaDet mediaDet = (IMediaDet)Activator.CreateInstance(t);

                    ///Set the avi file name for which we have to find information
                    mediaDet.put_Filename(this._srcFile);

                    ///Check for the current stream. If it is audio, set it up for video
                    AMMediaType mediaType = new AMMediaType();
                    mediaDet.get_StreamMediaType(mediaType);

                    ///If format type is not video
                    if (mediaType.formatType != ComGuids.VideoFormatGuid)
                    {
                        mediaDet.put_CurrentStream(1);
                        mediaDet.get_StreamMediaType(mediaType);
                    }

                    double prop = 0;
                    ///Get media length
                    mediaDet.get_StreamLength(out prop);
                    this._totalFrames = prop;

                    ///Get frame rate
                    mediaDet.get_FrameRate(out prop);
                    this._totalFrames = Math.Floor(this._totalFrames * prop);

                    AppUtil.SetupProgressBar(this.progress, 0, (int)this._totalFrames);
                }
            }
            catch (Exception exc)
            {
                UIMessage.Error(exc.Message, TITLE);
            }
        }
Ejemplo n.º 7
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            this.FileName = AppUtil.SelectFile("Open video file", "AVI (*.avi)|*.avi", "avi");
            if (this.FileName != string.Empty)
            {
                try
                {
                    this.CloseInterfaces();
                    this.PopulateMediaInformation();
                    this.BuildGraph();

                    ///Get file name from path
                    this.lbl_movieName.Text = Path.GetFileName(this.FileName);
                }
                catch (Exception ex)
                {
                    UIMessage.Error(ex.Message, TITLE);
                }
            }
        }
Ejemplo n.º 8
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;
                    }
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Hide the message in cover object
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_hide_Click(object sender, EventArgs e)
        {
            this.progress.Value = 0;

            ///If no cover object selected yet
            if (this._processor == null)
            {
                UIMessage.Info("Please select a cover object to hide message in", "Hide Message");
                return;
            }

            ///Check the legth of key
            if (this.txt_key.Text.Length < 4 || this.txt_key.Text.Length > Stego.Message.MAX_KEY_LEN)
            {
                UIMessage.Info("Key lenght must be atleast 4 characters and atmost 256 characters",
                               "Hide Message");
                return;
            }

            ///Check if there is enough room in cover object to store secret message and key in it
            if (this._hidingCapacity < (this.rtxt_message.Text.Length + this.txt_key.Text.Length + 8))
            {
                UIMessage.Error("Message is bigger then hiding capacity", "Hide Message");
                return;
            }

            ///Initialize the porgress bar
            this.progress.Minimum = 0;
            this.progress.Maximum = (int)this._processor.HostObject.Length;

            ///See if user hasn't entered the save path for stego object
            if (string.IsNullOrEmpty(this.txt_saveStego.Text))
            {
                UIMessage.Info("Please select a path to save stego object", "Hide Message");
                return;
            }

            ///Run the hiding process in background worker thread
            this.backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgs()
            {
                Action   = ActionType.Hide,
                Message  = new HideIt.Stego.Message(this.txt_key.Text, this.rtxt_message.Text),
                SinkPath = this.txt_saveStego.Text
            });

            using (new Status(this, this.lbl_status, "Logging information in database..."))
            {
                ///data insertion to maintain log table
                string        _stego_file_name = txt_saveStego.Text;
                string        _key             = txt_key.Text;
                string        _time            = DateTime.Now.ToLongTimeString();
                string        _date            = DateTime.Now.ToShortDateString();
                SqlConnection con = new SqlConnection(DB.DbConnectionStr.conect());
                ///SqlConnection con = new SqlConnection(constr);
                SqlCommand query = new SqlCommand("insert into Log_Table values('" + _stego_file_name + "','" + _key + "', '" + _date + "', '" + _time + "')", con);
                try
                {
                    con.Open();
                    query.ExecuteNonQuery();
                    MessageBox.Show("Record entered successfully.");
                    con.Close();
                }
                catch (SqlException ex)
                {
                    UIMessage.Error(ex.Message, TITLE);
                }
            }
        }
Ejemplo n.º 10
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;
                }
            }
        }