Пример #1
0
        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));
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
        private string getContextHtmlText(DiffPosition position, HtmlPanel htmlPanel, out string stylesheet)
        {
            stylesheet = String.Empty;
            double fontSizePx = WinFormsHelpers.GetFontSizeInPixels(htmlPanel);
            var    getContext = isCurrentNoteNew() ? _getNewDiscussionDiffContext(position) : _getDiffContext(position);

            return(DiffContextFormatter.GetHtml(getContext, fontSizePx, 2, true));
        }
Пример #4
0
        /// <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");
        }
Пример #5
0
        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();
        }