public static void Create(System.Threading.SynchronizationContext scontext, Office.IRibbonUI ribbonUI) { scontext.Post((o) => { var hwnd = BackStageTool.GetActiveWindowHwnd(); if (hwnd != IntPtr.Zero) { lock (dic) { CustomPrintBackstageWindow w; if (!dic.TryGetValue(hwnd, out w)) { w = new CustomPrintBackstageWindow(); w.AssignHandle(BackStageTool.GetActiveWindowHwnd()); w.scontext = scontext; w.ribbonUI = ribbonUI; w.inspector = Globals.ThisAddIn.Application.ActiveInspector() as Microsoft.Office.Interop.Outlook.Inspector; w.mail = w.inspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem; if (w.mail != null) { w.Page.Html = w.mail.HTMLBody; } dic.Add(hwnd, w); } } } }, null); }
private void CreateBitmap() { if (!this.Page.CanPrint) { return; } var rects = BackStageTool.GetBackStageRect(this.Handle); if (rects.Columns.Count < 2) { return; } double w = Math.Max(0, rects.Columns[1].Width - 20); double h = Math.Max(0, rects.BackStageView.Height - 20); this.Page.CreateBitmap(w, h, this.Handle); this.ribbonUI.InvalidateControl(IMAGECONTROL_PRINTIMAGE); }
public void onChangeToggle(Office.IRibbonControl control, bool isPressed) { var ins = Globals.ThisAddIn.Application.ActiveInspector() as Microsoft.Office.Interop.Outlook.Inspector; if (ins == null) { return; } var mail = ins.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem; if (mail != null) { string originalHTML; if (dicHTML.ContainsKey(ins)) { originalHTML = dicHTML[ins]; } else { dicHTML.Add(ins, mail.HTMLBody); originalHTML = mail.HTMLBody; } if (isPressed) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Key1", "あいうえお"); dic.Add("key2", "かきくけこ"); mail.HTMLBody = CreateTestHtml(originalHTML, dic); } else { mail.HTMLBody = originalHTML; } } IntPtr hwnd = BackStageTool.GetActiveWindowHwnd(); BackStageTool.RefreshPrintTab(hwnd); }