public bool GetPressed(Office.IRibbonControl control) { logger.Trace("GetPressed(" + control.Id + ")"); if (control.Id == SignButton.Id) { Outlook.MailItem mailItem = ((Outlook.Inspector)control.Context).CurrentItem as Outlook.MailItem; return((bool)OutlookPrivacyPlugin.GetProperty(mailItem, "GnuPGSetting.Sign")); } else if (control.Id == EncryptButton.Id) { Outlook.MailItem mailItem = ((Outlook.Inspector)control.Context).CurrentItem as Outlook.MailItem; return((bool)OutlookPrivacyPlugin.GetProperty(mailItem, "GnuPGSetting.Encrypt")); } else { logger.Trace("GetPressed: Button did not match encrypt or sign!"); } if (Buttons.ContainsKey(control.Id)) { return(Buttons[control.Id].Checked); } return(false); }
public void OnEncryptButton(Office.IRibbonControl control, bool isPressed) { logger.Trace("OnEncryptButton(" + control.Id + ", " + isPressed + ")"); var mailItem = ((Outlook.Inspector)control.Context).CurrentItem as Outlook.MailItem; if (mailItem == null) { logger.Trace("OnEncryptButton: mailItem == null"); } if (isPressed == true) { if (mailItem != null) { var settings = new Properties.Settings(); if (settings.Default2PlainFormat) { string body = mailItem.Body; mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; mailItem.Body = body; } } } OutlookPrivacyPlugin.SetProperty(mailItem, "GnuPGSetting.Encrypt", isPressed); EncryptButton.Checked = isPressed; ribbon.InvalidateControl(EncryptButton.Id); }
private void OutlookGnuPG_Startup(object sender, EventArgs e) { _singletonInstance = this; _settings = new Properties.Settings(); _wrappedObjects = new Dictionary<Guid, object>(); // Initialize command bar. // Must be saved/closed in Explorer MyClose event. // See http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/df53276b-6b44-448f-be86-7dd46c3786c7/ AddGnuPGCommandBar(this.Application.ActiveExplorer()); // Register an event for ItemSend Application.ItemSend += Application_ItemSend; // Initialize the outlook explorers _explorers = Application.Explorers; _explorers.NewExplorer += OutlookGnuPG_NewExplorer; for (var i = _explorers.Count; i >= 1; i--) { WrapExplorer(_explorers[i]); } // Initialize the outlook inspectors _inspectors = Application.Inspectors; _inspectors.NewInspector += OutlookGnuPG_NewInspector; }
public void OnSignButton(Office.IRibbonControl control, bool isPressed) { var mailItem = ((Outlook.Inspector)control.Context).CurrentItem as Outlook.MailItem; if (isPressed == true) { if (mailItem != null) { var settings = new Properties.Settings(); if (settings.Default2PlainFormat) { string body = mailItem.Body; mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatPlain; mailItem.Body = body; } } } OutlookPrivacyPlugin.SetProperty(mailItem, "GnuPGSetting.Sign", isPressed); SignButton.Checked = isPressed; ribbon.InvalidateControl(SignButton.Id); }