Esempio n. 1
0
        internal void AddAttachmentRiskControl(AttachmentRiskControl rc)
        {
            lock (_attachmentLock)
            {
                cbPerformAction.CheckedChanged += rc.PerformActionCheckChanged;
                rc.MetadataTypeCheckChanged += OnMetadataTypeCheckChanged;
                pnlContent.Controls.Add(rc);
                rc.EnableControls(cbPerformAction.Checked);

                // Auto expand - when a password protected file is added
                if (rc.Attachment.HasPassword && !AutoSize)
                {
                    ExpanderClicked();
                    this.AutoSize = true;
                }

                if (AnyAttachmentsWithMetadata())
                {
                    cbPerformAction.Enabled = (PolicyBridge.IsEnabled("InteractiveProtectAllowUsersToSkipCleaning") && PolicyBridge.IsEnabled("InteractiveProtectShowAdvancedSendOptions"));
                    cbPerformAction.Checked = true;
                }
                else
                {
                    cbPerformAction.Enabled = false;
                    cbPerformAction.Checked = false;
                }
            }
        }
Esempio n. 2
0
        public void AddAttachment(IProtectAttachment attachment)
        {
            try
            {
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(() => AddAttachment(attachment)));
                    return;
                }

                if (_cleanFilesControl.pnlContent.Controls.ContainsKey(attachment.Id))
                {
                    _cleanFilesControl.pnlContent.Controls.RemoveByKey(attachment.Id);
                }

                var rc = new AttachmentRiskControl(attachment, PropertyChanged) { Dock = DockStyle.Top, Name = attachment.Id };

                // Do not touch the following code, there is a race condition whereby the control's handle is not created by the
                // time the statusupdate events start firing. This ensures that it is created immediately.
                var handle = rc.Handle;
                if (handle == IntPtr.Zero)
                {
                    Logger.LogError("Attachment risk control's handle is invalid.");
                }
                rc.DecryptAttachmentClicked += OnDecryptAttachmentClicked;
                rc.ViewRiskReportClicked += (sender, args) => _presenter.ViewRiskReport(args.Attachment);
                rc.RemoveEncryptedAttachment += (sender, args) => RemoveAttachment(args.Attachment, false);

                _cleanFilesControl.AddAttachmentRiskControl(rc);

                _convertToPdfControl.AddAttachment(attachment);
            }
            catch (ObjectDisposedException e)
            {
                Logger.LogError(e);
            }
        }
        private void AddAttachment(IProtectAttachment attachment)
        {
            try
            {
                if (InvokeRequired)
                {
                    Invoke(new MethodInvoker(() => AddAttachment(attachment)));
                    return;
                }

                if (_filesPanel.Controls.ContainsKey(attachment.Id))
                    _filesPanel.Controls.RemoveByKey(attachment.Id);

                var rc = new AttachmentRiskControl(attachment, PropertyChanged) { Dock = DockStyle.Top, Name = attachment.Id };
                // Do not touch the following code, there is a race condition whereby the control's handle is not created by the
                // time the statusupdate events start firing. This ensures that it is created immediately.
                var handle = rc.Handle;
                if (handle == IntPtr.Zero)
                {
                    Logger.LogError("Attachment risk control's handle is invalid.");
                }
                rc.AllowedToExpand = false;
                rc.DecryptAttachmentClicked += OnDecryptAttachmentClicked;
                _filesPanel.Controls.Add(rc);
            }
            catch (ObjectDisposedException e)
            {
                Logger.LogError(e);
            }
        }