public static bool CanViewInBrowser(this Part part) { var contentType = part?.ContentType; return(part.IsAnyTextType() || ContentTypes.IsSupportedAudioType(contentType) || ContentTypes.IsSupportedVideoType(contentType) || ContentTypes.IsSupportedImageType(contentType)); }
void UpdatePartView() { var uri = new UriBuilder(); string viewType; PartModel.DirtyChanged += PartModel_DirtyChanged; var part = PartModel.Part; if (ContentTypes.IsMonacoSupportedType(part.ContentType)) { uri = new UriBuilder(Data.WebHost.GetUrl(part.GetMonacoEditorUrl())); viewType = "⚡"; if (Data.Settings.EditorDarkMode) { uri.Query += "&theme=dark"; } if (Data.Settings.EditorReadOnlyMode) { uri.Query += "&readonly=true"; } } else if (ContentTypes.IsSupportedAudioType(part.ContentType)) { uri = new UriBuilder(Data.WebHost.GetUrl($"part/{part.Uri}")); viewType = "🎵"; } else if (ContentTypes.IsSupportedImageType(part.ContentType)) { uri = new UriBuilder(Data.WebHost.GetUrl($"part/{part.Uri}")); viewType = "🎨"; } else if (ContentTypes.IsSupportedVideoType(part.ContentType)) { uri = new UriBuilder(Data.WebHost.GetUrl($"part/{part.Uri}")); viewType = "🖥"; } else { uri = new UriBuilder("about:blank"); viewType = "?"; } var header = ((CloseButtonTabHeader)Header); header.Text = $"{part.Uri}"; header.ViewType = viewType; Browser.Source = uri.Uri; }
public BitmapCollection <BitmapSource> GetIconForContentType(string contentType) { if (string.Equals(contentType, "application/vnd.openxmlformats-package.relationships+xml", StringComparison.Ordinal)) { return(RelsIcon); } if (ContentTypes.IsSupportedAudioType(contentType)) { return(AudioIcon); } if (ContentTypes.IsSupportedImageType(contentType)) { return(ImageIcon); } if (ContentTypes.IsSupportedVideoType(contentType)) { return(VideoIcon); } if (ContentTypes.IsXmlType(contentType)) { return(XmlIcon); } if (ContentTypes.IsXmlType(contentType)) { return(CodeIcon); } switch (contentType) { case "application/rtf": case "message/rfc822": return(DocumentIcon); case "application/vnd.openxmlformats-officedocument.vmlDrawing": return(CodeIcon); case "application/msword": case "application/vnd.ms-word.document.macroEnabled.12": case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return(WordIcon); case "application/vnd.ms-powerpoint": case "application/vnd.ms-powerpoint.presentation.macroEnabled.12": case "application/vnd.openxmlformats-officedocument.presentationml.presentation": case "application/vnd.openxmlformats-package.relationships+xml": case "application/vnd.ms-powerpoint.slide.macroEnabled.12": case "application/vnd.openxmlformats-officedocument.presentationml.slide": return(PptIcon); case "application/vnd.visio": case "application/vnd.ms-visio.drawing.macroEnabled": case "application/vnd.ms-visio.drawing": return(VisioIcon); case "application/vnd.ms-excel": case "application/vnd.ms-excel.sheet.binary.macroEnabled.12": case "application/vnd.ms-excel.sheet.macroEnabled.12": case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": return(ExcelIcon); default: return(UnknownIcon); } }