public void InitializeResponseDocumentsFromCache(Lib.Caching.DocumentCacheManager cache) { _cache = cache; this.documents = (cache.GetResponseDocuments() ?? Array.Empty <Document>()).ToArray(); FileListDataSource = documents; // If "documents" is null, then no document is available, show a message. if (documents == null || documents.Length == 0) { //initial view does not show a message //ShowView = DisplayType.HTML; //DataSource = "<html><body><p style='text-align:center;color:gray;font-family:arial'>No Result Documents Available.</p></body></html>"; return; } Document d = documents.Where(f => f.IsViewable).FirstOrDefault(); if (d != null) { Document s = documents.Where(f => f.Filename == "ViewableDocumentStyle.xml").FirstOrDefault(); Document j = documents.Where(f => f.Filename == "response.json").FirstOrDefault(); using (Stream contentStream = (j != null) ? cache.GetDocumentStream(Guid.Parse(j.DocumentID)) : cache.GetDocumentStream(Guid.Parse(d.DocumentID))) { ShowMimeType = d.MimeType; if (s != null) { using (Stream styleStream = cache.GetDocumentStream(Guid.Parse(s.DocumentID))) { XmlSerializer serializer = new XmlSerializer(typeof(ViewableDocumentStyle)); SetDataSourceStream(contentStream, (ViewableDocumentStyle)serializer.Deserialize(new StreamReader(styleStream))); } } else if (j != null) { ShowView = DisplayType.JSON; SetDataSourceStream(contentStream, null); } else { SetDataSourceStream(contentStream); } } } else { ShowView = DisplayType.FILELIST; FILELIST.BringToFront(); } }
public void ToggleFileView(object sender, EventArgs e) { if (View != FILELIST) { LastView = View; ShowView = DisplayType.FILELIST; FILELIST.BringToFront(); } else { View = LastView; } }