async Task LoadSource(Uri fileUri) { var fontSize = (int)UIFont.PreferredSubheadline.PointSize; var content = System.IO.File.ReadAllText(fileUri.LocalPath, System.Text.Encoding.UTF8); if (ViewModel.IsMarkdown) { var markdownContent = await Mvx.Resolve <IApplicationService>().Client.Markdown.GetMarkdown(content); var model = new MarkdownModel(markdownContent, fontSize); var htmlContent = new MarkdownWebView { Model = model }; LoadContent(htmlContent.GenerateString()); } else { var zoom = UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone; var model = new SyntaxHighlighterModel(content, "idea", fontSize, zoom, fileUri.LocalPath); var contentView = new SyntaxHighlighterWebView { Model = model }; LoadContent(contentView.GenerateString()); } }
async Task LoadSource(string content, string filename, bool isMarkdown) { var fontSize = (int)UIFont.PreferredSubheadline.PointSize; if (isMarkdown) { var markdownContent = await _applicationService.Client.Markdown.GetMarkdown(content); var model = new MarkdownModel(markdownContent, fontSize); var htmlContent = new MarkdownWebView { Model = model }; LoadContent(htmlContent.GenerateString()); } else { var zoom = UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone; var theme = _applicationService.Account.CodeEditTheme; var model = new SyntaxHighlighterModel(content, theme, fontSize, zoom, file: filename); var contentView = new SyntaxHighlighterWebView { Model = model }; LoadContent(contentView.GenerateString()); } }
private async Task LoadTheme(string theme) { var assembly = Assembly.GetExecutingAssembly(); using (var stream = assembly.GetManifestResourceStream(_resourceName)) using (var reader = new StreamReader(stream)) { var content = await reader.ReadToEndAsync(); var zoom = UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone; var model = new SyntaxHighlighterModel( content, theme ?? "idea", (int)UIFont.PreferredSubheadline.PointSize, zoom, lockWidth: true); var razorView = new SyntaxHighlighterWebView { Model = model }; LoadContent(razorView.GenerateString()); } }