예제 #1
0
        protected override Size OnMeasure(FlowPanelMeasureEventArgs measureEventArgs)
        {
            if (_diff == null)
            {
                return(Size.Empty);
            }
            if (FontHeight == -1)
            {
                FontHeight = (int)(GitterApplication.TextRenderer.GetFontHeight(measureEventArgs.Graphics, Font) + 0.5f);
            }
            int lineCount;

            if (StatusFilter == StatusFilterAll)
            {
                lineCount = _diff.FilesCount;
            }
            else
            {
                lineCount = 0;
                for (int i = 0; i < _diff.FilesCount; ++i)
                {
                    if ((_diff[i].Status & StatusFilter) != FileStatus.Unknown)
                    {
                        ++lineCount;
                    }
                }
            }
            return(new Size(0, HeaderHeight + (lineCount == 0 ? 0 : HeaderBottomMargin) + lineCount * LineHeight));
        }
예제 #2
0
        protected override Size OnMeasure(FlowPanelMeasureEventArgs measureEventArgs)
        {
            if (_items == null || _items.Length == 0)
            {
                return(Size.Empty);
            }
            var font = FlowControl.Font;

            if (FontHeight == -1)
            {
                FontHeight = (int)(GitterApplication.TextRenderer.GetFontHeight(measureEventArgs.Graphics, font) + 0.5);
            }
            return(new Size(0, (_items.Length + 1) * (LineHeight)));
        }
예제 #3
0
        protected override Size OnMeasure(FlowPanelMeasureEventArgs measureEventArgs)
        {
            Assert.IsNotNull(measureEventArgs);

            var width = measureEventArgs.Width;

            if (IsSelectable)
            {
                width -= SelectionMargin;
            }
            _content.Style = Style;
            var size = _content.OnMeasure(measureEventArgs.Graphics, width);

            if (IsSelectable)
            {
                size.Width += SelectionMargin;
            }
            return(size);
        }
예제 #4
0
 protected override Size OnMeasure(FlowPanelMeasureEventArgs measureEventArgs)
 {
     if (BlameFile == null)
     {
         return(Size.Empty);
     }
     if (_size.IsEmpty)
     {
         int       maxLength     = 0;
         BlameLine longestLine   = null;
         string    longestAuthor = string.Empty;
         foreach (var hunk in BlameFile)
         {
             foreach (var line in hunk)
             {
                 int l = line.GetCharacterPositions(TabSize);
                 if (l > maxLength)
                 {
                     maxLength   = l;
                     longestLine = line;
                 }
             }
             if (hunk.Commit.Author.Length > longestAuthor.Length)
             {
                 longestAuthor = hunk.Commit.Author;
             }
         }
         var digits = GetDecimalDigits(BlameFile.LineCount) + 1;
         var font   = GitterApplication.FontManager.ViewerFont.Font;
         int w      = CellSize.Width * digits + 2 * Margin;
         if (longestLine != null)
         {
             int longestLineWidth;
             try
             {
                 longestLineWidth = GitterApplication.TextRenderer.MeasureText(
                     measureEventArgs.Graphics, longestLine.Text, font, int.MaxValue, ContentFormat).Width + (CellSize.Width / 2);
             }
             catch (Exception exc) when(!exc.IsCritical())
             {
                 longestLineWidth = (int)(maxLength * CellSize.Width);
             }
             int longestAuthorWidth;
             try
             {
                 longestAuthorWidth = GitterApplication.TextRenderer.MeasureText(
                     measureEventArgs.Graphics, longestAuthor, font, int.MaxValue, ContentFormat).Width + CellSize.Width;
             }
             catch (Exception exc) when(!exc.IsCritical())
             {
                 longestAuthorWidth = (int)(longestAuthor.Length * CellSize.Width);
             }
             longestAuthorWidth += CellSize.Width;
             _autorColumnWidth   = longestAuthorWidth;
             w += longestLineWidth + longestAuthorWidth;
             _hashColumnWidth = CellSize.Width * 7 + CellSize.Width;
             w += _hashColumnWidth;
         }
         var h = BlameFile.LineCount * CellSize.Height;
         if (ShowHeader)
         {
             h += HeaderHeight;
         }
         if (BlameFile.LineCount != 0)
         {
             h += 2;
         }
         _size = new Size(w, h);
     }
     return(_size);
 }
예제 #5
0
 protected override Size OnMeasure(FlowPanelMeasureEventArgs measureEventArgs)
 {
     if (_diffFile == null)
     {
         return(Size.Empty);
     }
     if (_size.IsEmpty)
     {
         int      maxLength     = 0;
         int      lines         = 0;
         DiffLine longestLine   = null;
         int      largestNumber = 0;
         int      maxCols       = 0;
         foreach (var hunk in _diffFile)
         {
             foreach (var line in hunk)
             {
                 int l = line.GetCharacterPositions(TabSize);
                 if (l > maxLength)
                 {
                     maxLength   = l;
                     longestLine = line;
                 }
                 ++lines;
             }
             if (hunk.ColumnCount != 0)
             {
                 var num = hunk.MaxLineNum;
                 if (num > largestNumber)
                 {
                     largestNumber = num;
                 }
                 if (hunk.ColumnCount > maxCols)
                 {
                     maxCols = hunk.ColumnCount;
                 }
             }
         }
         int digits;
         if (maxCols != 0)
         {
             digits = GetDecimalDigits(largestNumber);
         }
         else
         {
             digits = 0;
         }
         var font = GitterApplication.FontManager.ViewerFont.Font;
         int w    = CellSize.Width * maxCols * digits + 2 * Margin;
         if (longestLine != null)
         {
             int longestLineWidth;
             try
             {
                 longestLineWidth = GitterApplication.TextRenderer.MeasureText(
                     measureEventArgs.Graphics, longestLine.Text, font, int.MaxValue, ContentFormat).Width + CellSize.Width;
             }
             catch (Exception exc)
             {
                 if (exc.IsCritical())
                 {
                     throw;
                 }
                 longestLineWidth = (int)(maxLength * CellSize.Width);
             }
             w += longestLineWidth;
         }
         var h = HeaderHeight + lines * CellSize.Height +
                 (_diffFile.LineCount != 0 ? 1 : 0);
         _size = new Size(w, h);
     }
     return(_size);
 }