private void AddGnuPGCommandBar(Outlook.Explorer activeExplorer) { if (_gpgCommandBar != null) return; try { _gpgCommandBar = new GnuPGCommandBar(activeExplorer); _gpgCommandBar.Remove(); _gpgCommandBar.Add(); _gpgCommandBar.GetButton("Verify").Click += VerifyButton_Click; _gpgCommandBar.GetButton("Decrypt").Click += DecryptButton_Click; _gpgCommandBar.GetButton("Settings").Click += SettingsButton_Click; _gpgCommandBar.GetButton("About").Click += AboutButton_Click; _gpgCommandBar.RestorePosition(_settings); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// WrapEvent fired for SelectionChange event. /// </summary> /// <param name="explorer">the explorer for which a selectionchange event fired.</param> void wrappedExplorer_SelectionChange(Outlook.Explorer explorer) { Outlook.Selection Selection = explorer.Selection; if (Selection.Count != 1) return; Outlook.MailItem mailItem = Selection[1] as Outlook.MailItem; if (mailItem == null) return; if (mailItem.BodyFormat == Outlook.OlBodyFormat.olFormatPlain) { Match match = Regex.Match(mailItem.Body, _pgpHeaderPattern); _gpgCommandBar.GetButton("Verify").Enabled = (match.Value == _pgpSignedHeader); _gpgCommandBar.GetButton("Decrypt").Enabled = (match.Value == _pgpEncryptedHeader); } else { _gpgCommandBar.GetButton("Verify").Enabled = false; _gpgCommandBar.GetButton("Decrypt").Enabled = false; } }