private void PersistDocumentsJson() { Documents docs = new TagCommon.Documents(); List <DocumentInfo> docsRelevant = new List <DocumentInfo>(); DocumentInfo docA1 = new DocumentInfo(); DocumentInfo docA2 = new DocumentInfo(); DocumentInfo docA3 = new DocumentInfo(); docA1.Name = "documentA1"; docA2.Name = "documentA2"; docA3.Name = "documentA3"; docsRelevant.Add(docA1); docsRelevant.Add(docA2); docsRelevant.Add(docA3); docs.RelevantDocuments = docsRelevant; List <DocumentInfo> docsRecent = new List <DocumentInfo>(); DocumentInfo docA4 = new DocumentInfo(); DocumentInfo docA5 = new DocumentInfo(); DocumentInfo docA6 = new DocumentInfo(); docA4.Name = "documentA4"; docA5.Name = "documentA5"; docA6.Name = "documentA6"; docsRecent.Add(docA4); docsRecent.Add(docA5); docsRecent.Add(docA6); docs.MruDocuments = docsRecent; string output = TagCommon.Utils.SerializeObjectToString(docs); System.Diagnostics.Debug.Write("serialized Documents : \n\n" + output); }
private void AddMenusFromJson(Button b, String json, Outlook.MailItem mailItem) { TagCommon.Documents docs = TagCommon.Utils.GetDocumentsForJson(json); List <DocumentInfo> relevantDocs = docs.RelevantDocuments; List <DocumentInfo> mruDocs = docs.MruDocuments; ContextMenuStrip menuStrip = new ContextMenuStrip(); ToolStripMenuItem pdfItem = new ToolStripMenuItem(); pdfItem.Text = "Documents"; foreach (DocumentInfo di in relevantDocs) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = di.Name; pdfItem.DropDownItems.Add(item); AttachOpenAndAttachMenusToDocName(item, di.Name, mailItem); } /* * RE-ENGAGE THIS CODE IF WE ADD BACK IN MRUs * if (relevantDocs.Count > 0 && mruDocs.Count > 0) * { * ToolStripSeparator sep = new ToolStripSeparator(); * pdfItem.DropDownItems.Add(sep); * } * * * foreach (DocumentInfo di in mruDocs) * { * ToolStripMenuItem item = new ToolStripMenuItem(); * item.Text = "*" + di.Name; * pdfItem.DropDownItems.Add(item); * AttachOpenAndAttachMenusToDocName(item, di.Name, mailItem); * } */ menuStrip.Items.Add(pdfItem); b.ContextMenuStrip = menuStrip; }
public static Documents GetDocumentsForJson(String json) { Documents docs = JsonConvert.DeserializeObject <Documents>(json); return(docs); }