private string getContextHtmlText(DiffPosition position, IGitCommandService git, out string stylesheet) { stylesheet = String.Empty; DiffContext?context; try { ContextDepth depth = new ContextDepth(0, 3); IContextMaker textContextMaker = new SimpleContextMaker(git); context = textContextMaker.GetContext(position, depth); } catch (Exception ex) { if (ex is ArgumentException || ex is ContextMakingException) { string errorMessage = "Cannot render HTML context."; ExceptionHandlers.Handle(errorMessage, ex); return(String.Format("<html><body>{0} See logs for details</body></html>", errorMessage)); } throw; } Debug.Assert(context.HasValue); DiffContextFormatter formatter = new DiffContextFormatter(WinFormsHelpers.GetFontSizeInPixels(htmlPanelContext), 2); stylesheet = formatter.GetStylesheet(); return(formatter.GetBody(context.Value)); }
private string getContext(IContextMaker contextMaker, DiffPosition position, ContextDepth depth, double fontSizePx, out string stylesheet) { stylesheet = String.Empty; if (contextMaker == null) { return("<html><body>Cannot access file storage and render diff context</body></html>"); } try { DiffContext context = contextMaker.GetContext(position, depth); DiffContextFormatter formatter = new DiffContextFormatter(fontSizePx, 2); stylesheet = formatter.GetStylesheet(); return(formatter.GetBody(context)); } catch (Exception ex) { if (ex is ArgumentException || ex is ContextMakingException) { string errorMessage = "Cannot render HTML context."; ExceptionHandlers.Handle(errorMessage, ex); return(String.Format("<html><body>{0} See logs for details</body></html>", errorMessage)); } throw; } }
/// <summary> /// Throws ArgumentException. /// Throws GitOperationException and GitObjectException in case of problems with git. /// </summary> private void showDiscussionContext(HtmlPanel htmlPanel, TextBox tbFileName) { ContextDepth depth = new ContextDepth(0, 3); IContextMaker textContextMaker = new EnhancedContextMaker(_gitRepository); DiffContext context = textContextMaker.GetContext(_position, depth); DiffContextFormatter formatter = new DiffContextFormatter(); htmlPanel.Text = formatter.FormatAsHTML(context); tbFileName.Text = "Left: " + (_difftoolInfo.Left?.FileName ?? "N/A") + " Right: " + (_difftoolInfo.Right?.FileName ?? "N/A"); }
internal DiscussionBox( CustomFontForm parent, SingleDiscussionAccessor accessor, IGitCommandService git, User currentUser, ProjectKey projectKey, Discussion discussion, User mergeRequestAuthor, int diffContextDepth, ColorScheme colorScheme, Action <DiscussionBox> preContentChange, Action <DiscussionBox, bool> onContentChanged, Action <Control> onControlGotFocus) { Parent = parent; Discussion = discussion; _accessor = accessor; _editor = accessor.GetDiscussionEditor(); _mergeRequestAuthor = mergeRequestAuthor; _currentUser = currentUser; _imagePath = StringUtils.GetHostWithPrefix(projectKey.HostName) + "/" + projectKey.ProjectName; _diffContextDepth = new ContextDepth(0, diffContextDepth); _tooltipContextDepth = new ContextDepth(5, 5); if (git != null) { _panelContextMaker = new EnhancedContextMaker(git); _tooltipContextMaker = new CombinedContextMaker(git); } _colorScheme = colorScheme; _preContentChange = preContentChange; _onContentChanged = onContentChanged; _onControlGotFocus = onControlGotFocus; _htmlDiffContextToolTip = new HtmlToolTip { AutoPopDelay = 20000, // 20s InitialDelay = 300 }; _htmlDiscussionNoteToolTip = new HtmlToolTip { AutoPopDelay = 20000, // 20s InitialDelay = 300, }; _specialDiscussionNoteMarkdownPipeline = MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl()); onCreate(); }
internal DiscussionBox(Discussion discussion, DiscussionEditor editor, User mergeRequestAuthor, User currentUser, int diffContextDepth, IGitRepository gitRepository, ColorScheme colorScheme, Action <DiscussionBox> preContentChange, Action <DiscussionBox> onContentChanged) { Discussion = discussion; _editor = editor; _mergeRequestAuthor = mergeRequestAuthor; _currentUser = currentUser; _diffContextDepth = new ContextDepth(0, diffContextDepth); _tooltipContextDepth = new ContextDepth(5, 5); _formatter = new DiffContextFormatter(); if (gitRepository != null) { _panelContextMaker = new EnhancedContextMaker(gitRepository); _tooltipContextMaker = new CombinedContextMaker(gitRepository); } _colorScheme = colorScheme; _preContentChange = preContentChange; _onContentChanged = onContentChanged; _toolTip = new ToolTip { AutoPopDelay = 5000, InitialDelay = 500, ReshowDelay = 100 }; _toolTipNotifier = new ToolTip(); _htmlToolTip = new HtmlToolTip { AutoPopDelay = 10000, // 10s BaseStylesheet = ".htmltooltip { padding: 1px; }" }; onCreate(); }
private string getContext(IContextMaker contextMaker, DiffPosition position, ContextDepth depth, int fontSizePx, int rowsVPaddingPx) { if (contextMaker == null || _formatter == null) { return("<html><body>Cannot access git repository and render diff context</body></html>"); } try { DiffContext context = contextMaker.GetContext(position, depth); return(_formatter.FormatAsHTML(context, fontSizePx, rowsVPaddingPx)); } catch (Exception ex) { if (ex is ArgumentException || ex is GitOperationException || ex is GitObjectException) { ExceptionHandlers.Handle(ex, "Cannot render HTML context"); string errorMessage = System.Net.WebUtility.HtmlEncode(ex.Message).Replace("\n", "<br>"); return(String.Format("<html><body>{0}</body></html>", errorMessage)); } throw; } }