예제 #1
0
파일: HideIt.cs 프로젝트: cornerback/hideit
        /// <summary>
        /// Called when an application request to send a file
        /// </summary>
        /// <param name="client"></param>
        private void AcceptFile(Socket client)
        {
            try
            {
                HandshakeData data = this._receiver.Handshake(client);

                if (data == null)
                {
                    return;
                }

                DialogResult result = UIMessage.Ask(this, "A computer " + data.MachineName +
                                                    " wishes to transfer a file " + data.FileName +
                                                    " of size" + this.ToSize(data.FileLen) +
                                                    "\r\nAccept?", "Receive file");

                this._receiver.HandshakeResponse(client, result == DialogResult.Yes);

                ///If user decided to not receive the file
                if (result == DialogResult.No)
                {
                    return;
                }

                ///Fire the delegate that will call the ShowReceiveFileForm method
                this.BeginInvoke(new OpenReceiveFormCallback(this.ShowReceiveFileForm), client, data);
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
파일: HideIt.cs 프로젝트: cornerback/hideit
        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;
                }
            }
        }