Exemplo n.º 1
0
 protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
 {
     var graphics = paintEventArgs.Graphics;
     var rect = paintEventArgs.Bounds;
     switch(_style)
     {
         case FlowPanelSeparatorStyle.Line:
             {
                 var y = _height / 2;
                 var x = y;
                 var w = Math.Max(FlowControl.ContentSize.Width, FlowControl.ContentArea.Width) - 2 * x;
                 if(w > 0)
                 {
                     x += rect.X;
                     y += rect.Y;
                     graphics.DrawLine(Pens.Gray, x, y, x + w, y);
                 }
             }
             break;
     }
 }
Exemplo n.º 2
0
        protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
        {
            var graphics = paintEventArgs.Graphics;
            var rect     = paintEventArgs.Bounds;

            switch (_style)
            {
            case FlowPanelSeparatorStyle.Line:
            {
                var y = _height / 2;
                var x = y;
                var w = Math.Max(FlowControl.ContentSize.Width, FlowControl.ContentArea.Width) - 2 * x;
                if (w > 0)
                {
                    x += rect.X;
                    y += rect.Y;
                    graphics.DrawLine(Pens.Gray, x, y, x + w, y);
                }
            }
            break;
            }
        }
Exemplo n.º 3
0
        protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
        {
            var graphics = paintEventArgs.Graphics;
            var rect     = paintEventArgs.Bounds;

            var mw = Math.Max(FlowControl.ContentSize.Width, FlowControl.ContentArea.Width);
            var w  = mw - 5 * 2;
            int h  = _height - 5 * 2;

            if (w > 300)
            {
                w = 300;
            }
            if (h > 85)
            {
                h = 85;
            }
            var rc = new Rectangle(
                rect.X + (mw - w) / 2,
                rect.Y + (rect.Height - h) / 2,
                w, h);

            if (_overlay != null)
            {
                if (_overlay.IsVisible)
                {
                    _overlay.OnPaint(graphics, rc);
                }
                else
                {
                    if (!string.IsNullOrEmpty(_message))
                    {
                        _overlay.DrawMessage(graphics, rc, _message);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
        {
            var graphics = paintEventArgs.Graphics;
            var rect = paintEventArgs.Bounds;

            var mw = Math.Max(FlowControl.ContentSize.Width, FlowControl.ContentArea.Width);
            var w = mw - 5 * 2;
            int h = _height  - 5 * 2;
            if(w > 300) w = 300;
            if(h > 85) h = 85;
            var rc = new Rectangle(
                rect.X + (mw - w) / 2,
                rect.Y + (rect.Height - h) / 2,
                w, h);
            if(_overlay != null)
            {
                if(_overlay.IsVisible)
                {
                    _overlay.OnPaint(graphics, rc);
                }
                else
                {
                    if(!string.IsNullOrEmpty(_message))
                    {
                        _overlay.DrawMessage(graphics, rc, _message);
                    }
                }
            }
        }
Exemplo n.º 5
0
 protected abstract void OnPaint(FlowPanelPaintEventArgs paintEventArgs);
Exemplo n.º 6
0
 public void Paint(FlowPanelPaintEventArgs paintEventArgs)
 {
     OnPaint(paintEventArgs);
 }
Exemplo n.º 7
0
 protected abstract void OnPaint(FlowPanelPaintEventArgs paintEventArgs);
Exemplo n.º 8
0
        protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
        {
            if(_diff == null) return;
            var graphics	= paintEventArgs.Graphics;
            var rect		= paintEventArgs.Bounds;
            var clip		= paintEventArgs.ClipRectangle;

            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
            if(FontHeight == -1)
            {
                FontHeight = (int)(GitterApplication.TextRenderer.GetFontHeight(graphics, Font) + 0.5);
            }
            var rcHeader = new Rectangle(rect.X + 5, rect.Y, FlowControl.ContentArea.Width - 10, HeaderHeight);
            var rcClip = Rectangle.Intersect(rcHeader, clip);
            if(_diff.FilesCount == 0)
            {
                if(rcClip.Width <= 0 || rcClip.Height <= 0)
                {
                    return;
                }
                using(var brush = new SolidBrush(Style.Colors.GrayText))
                {
                    GitterApplication.TextRenderer.DrawText(
                        graphics, Resources.StrNoChangedFiles, Font, brush, rcHeader, ContentFormat);
                }
            }
            else
            {
                using(var textBrush = new SolidBrush(Style.Colors.WindowText))
                {
                    if(rcClip.Width > 0 || rcClip.Height > 0)
                    {
                        var headerBounds = rcHeader;

                        headerBounds.X += 5;
                        headerBounds.Width -= 5;

                        for(int i = 0; i < _changesByType.Length; ++i)
                        {
                            if(headerBounds.Width <= 0) break;

                            if(_changesByType[i].Count != 0)
                            {
                                // prepare
                                var headerText = _changesByType[i].DisplayText;
                                var headerTextSize = GitterApplication.TextRenderer.MeasureText(
                                    graphics, headerText, Font, short.MaxValue, ContentFormat);
                                var headerWidth = headerTextSize.Width;
                                var image = _changesByType[i].Image;
                                var displayBounds = new Rectangle(
                                    headerBounds.X - HeaderContentPadding,
                                    headerBounds.Y,
                                    headerWidth + (image != null ? image.Width + 3 : 0) + HeaderContentPadding * 2,
                                    headerBounds.Height);
                                _changesByType[i].DisplayBounds = new Rectangle(
                                    displayBounds.X - rect.X, displayBounds.Y - rect.Y, displayBounds.Width, displayBounds.Height);
                                // background
                                if(StatusFilter == _changesByType[i].Status)
                                {
                                    Style.ItemBackgroundStyles.Selected.Draw(graphics, displayBounds);
                                }
                                else if(_filterHover.Index == i)
                                {
                                    Style.ItemBackgroundStyles.Hovered.Draw(graphics, displayBounds);
                                }
                                // header icon
                                if(image != null)
                                {
                                    graphics.DrawImage(image, headerBounds.X, headerBounds.Y + (headerBounds.Height - image.Height) / 2);
                                    headerBounds.X += image.Width + 3;
                                    headerBounds.Width -= image.Width + 3;
                                }

                                if(headerBounds.Width <= 0) break;
                                // header text
                                GitterApplication.TextRenderer.DrawText(
                                    graphics, headerText, Font, textBrush, headerBounds, HeaderFormat);

                                headerBounds.X += headerWidth + HeaderSpacing;
                                headerBounds.Width -= headerWidth + HeaderSpacing;
                                if(i == 0)
                                {
                                    headerBounds.X += HeaderSpacing;
                                    headerBounds.Width -= HeaderSpacing;
                                }
                            }
                            else
                            {
                                _changesByType[i].DisplayBounds = Rectangle.Empty;
                            }
                        }
                    }
                    var rcLine = rcHeader;
                    rcLine.Y += HeaderBottomMargin + HeaderHeight;
                    rcLine.Height = LineHeight;
                    using(var alternateBackgroundBrush = new SolidBrush(Style.Colors.Alternate))
                    {
                        bool alternate = false;
                        for(int i = 0; i < _items.Length; ++i)
                        {
                            if((_items[i].File.Status & StatusFilter) != FileStatus.Unknown)
                            {
                                rcClip = Rectangle.Intersect(rcLine, clip);
                                if(rcClip.Height > 0 && rcClip.Width > 0)
                                {
                                    if(alternate)
                                    {
                                        graphics.FillRectangle(alternateBackgroundBrush, rcClip);
                                    }
                                    if(i == _fileHover.Index)
                                    {
                                        Style.ItemBackgroundStyles.Hovered.Draw(graphics, rcLine);
                                    }
                                    _items[i].Draw(graphics, Font, textBrush, rcLine);
                                }
                                alternate = !alternate;
                                rcLine.Y += LineHeight;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
 protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
 {
     var graphics = paintEventArgs.Graphics;
     var rect = paintEventArgs.Bounds;
     var clip = paintEventArgs.ClipRectangle;
     var contentWidth = Math.Max(FlowControl.ContentSize.Width, FlowControl.ContentArea.Width);
     var x = rect.X + Margin;
     var y = 0;
     if(ShowHeader)
     {
         var rcHeader = new Rectangle(rect.X + Margin, rect.Y, contentWidth - 2 * Margin, HeaderHeight);
         var rcHeaderClip = Rectangle.Intersect(clip, rcHeader);
         if(rcHeaderClip.Width != 0 && rcHeaderClip.Height != 0)
         {
             PaintHeader(graphics, rcHeader, GraphicsUtility.QueryIcon(_blameFile.Name), null, _blameFile.Name);
         }
         y += rcHeader.Bottom;
     }
     else
     {
         if(_blameFile.LineCount != 0)
         {
             graphics.DrawLine(Pens.Gray, x, rect.Y, rect.X + contentWidth - Margin, rect.Y);
         }
         y += rect.Y + 1;
     }
     int maxLineNum = _blameFile.LineCount;
     int digits = GetDecimalDigits(maxLineNum);
     var font = GitterApplication.FontManager.ViewerFont.Font;
     bool reachedEnd = false;
     int lineIndex = 0;
     bool alternate = false;
     bool first;
     foreach(var hunk in _blameFile)
     {
         first = true;
         foreach(var line in hunk)
         {
             if(y >= clip.Bottom)
             {
                 reachedEnd = true;
                 break;
             }
             if(y + CellSize.Height >= clip.Y)
             {
                 PaintLine(
                     lineIndex, hunk, line, first, digits,
                     graphics, font, lineIndex == _lineHover.Index,
                     lineIndex >= _selStart && lineIndex <= _selEnd,
                     alternate,
                     x, y, contentWidth);
             }
             y += CellSize.Height;
             ++lineIndex;
             first = false;
         }
         alternate = !alternate;
         if(reachedEnd) break;
     }
     if(!reachedEnd && _blameFile.LineCount != 0)
     {
         graphics.DrawLine(Pens.Gray, x, y, rect.X + contentWidth - Margin - 1, y);
     }
 }
Exemplo n.º 10
0
 protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
 {
     var graphics = paintEventArgs.Graphics;
     var rect = paintEventArgs.Bounds;
     var clip = paintEventArgs.ClipRectangle;
     var contentWidth = Math.Max(_size.Width, FlowControl.ContentArea.Width);
     var rcHeader = new Rectangle(rect.X + Margin, rect.Y, contentWidth - 2 * Margin, HeaderHeight);
     var rcHeaderClip = Rectangle.Intersect(clip, rcHeader);
     if(rcHeaderClip.Width > 0 && rcHeaderClip.Height > 0)
     {
         graphics.SetClip(rcHeaderClip);
         PaintHeader(graphics, rcHeader, GetHeaderIcon(), GetHeaderIconOverlay(), GetHeaderText());
     }
     var x = rect.X + Margin;
     var y = rcHeader.Bottom;
     int maxLineNum = _diffFile.MaxLineNum;
     int digits = GetDecimalDigits(maxLineNum);
     var font = GitterApplication.FontManager.ViewerFont.Font;
     bool reachedEnd = false;
     int lineIndex = 0;
     graphics.SetClip(clip);
     graphics.SmoothingMode = SmoothingMode.Default;
     foreach(var hunk in _diffFile)
     {
         foreach(var line in hunk)
         {
             if(y >= clip.Bottom)
             {
                 reachedEnd = true;
                 break;
             }
             if(y + CellSize.Height >= clip.Y)
             {
                 PaintLine(
                     lineIndex, line, digits,
                     graphics, font, lineIndex == _lineHover.Index,
                     lineIndex >= _selStart && lineIndex <= _selEnd,
                     rect.X + Margin, y, contentWidth);
             }
             y += CellSize.Height;
             ++lineIndex;
         }
         if(reachedEnd) break;
     }
     if(!reachedEnd && _diffFile.LineCount != 0)
     {
         graphics.DrawLine(Pens.Gray, rect.X + Margin, y, rect.X + contentWidth - Margin - 1, y);
     }
     graphics.ResetClip();
 }
Exemplo n.º 11
0
 public void Paint(FlowPanelPaintEventArgs paintEventArgs)
 {
     OnPaint(paintEventArgs);
 }
Exemplo n.º 12
0
 protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
 {
     if(_items == null || _items.Length == 0) return;
     var graphics = paintEventArgs.Graphics;
     var rect = paintEventArgs.Bounds;
     var clip = paintEventArgs.ClipRectangle;
     int y = rect.Y;
     if(FontHeight == -1)
     {
         FontHeight = (int)(GitterApplication.TextRenderer.GetFontHeight(graphics, Font) + 0.5);
     }
     var rc = new Rectangle(rect.X + 5, rect.Y, FlowControl.ContentArea.Width - 10, LineHeight);
     var rcClip = Rectangle.Intersect(rc, clip);
     using(var textBrush = new SolidBrush(FlowControl.Style.Colors.WindowText))
     using(var alternateBackgroundBrush = new SolidBrush(FlowControl.Style.Colors.Alternate))
     {
         if(rcClip.Width > 0 && rcClip.Height > 0)
         {
             GitterApplication.TextRenderer.DrawText(
                 graphics, Resources.StrUntrackedFiles.AddColon(), Font, textBrush, rc, ContentFormat);
         }
         for(int i = 0; i < _items.Length; ++i)
         {
             rc.Y += LineHeight;
             rcClip = Rectangle.Intersect(rc, clip);
             if(rcClip.Width > 0 && rcClip.Height > 0)
             {
                 if(i % 2 == 1)
                 {
                     graphics.FillRectangle(alternateBackgroundBrush, rcClip);
                 }
                 if(i == _fileHover.Index)
                 {
                     FlowControl.Style.ItemBackgroundStyles.Hovered.Draw(graphics, rc);
                 }
                 _items[i].Draw(graphics, Font, textBrush, rc, i);
             }
         }
     }
 }
Exemplo n.º 13
0
        protected override void OnPaint(FlowPanelPaintEventArgs paintEventArgs)
        {
            Assert.IsNotNull(paintEventArgs);

            var bounds		= paintEventArgs.Bounds;
            var graphics	= paintEventArgs.Graphics;
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
            if(IsSelectable)
            {
                if(IsSelected)
                {
                    graphics.FillRectangle(
                        SystemBrushes.Highlight, new Rectangle(bounds.X, bounds.Y, SelectionMargin, bounds.Height));
                }
                bounds.Width -= SelectionMargin;
                bounds.X += SelectionMargin;
            }
            _content.Style = Style;
            var clip = Rectangle.Intersect(paintEventArgs.ClipRectangle, bounds);
            if(clip.Width > 0 && clip.Height > 0)
            {
                graphics.SetClip(clip);
                _content.OnPaint(graphics, bounds);
            }
        }