예제 #1
0
        private static int MeasureTabLength(ViewTabBase tab, Graphics graphics)
        {
            var length = GitterApplication.TextRenderer.MeasureText(
                graphics, tab.Text, GitterApplication.FontManager.UIFont, int.MaxValue, NormalStringFormat).Width;

            if (tab.Image != null)
            {
                length += 16 + ViewConstants.ImageSpacing;
            }
            length += ViewConstants.BeforeTabContent + ViewConstants.AfterTabContent;
            return(length);
        }
예제 #2
0
 private static void RenderTabContent(ViewTabBase tab, Rectangle bounds, Graphics graphics)
 {
     int x = bounds.X;
     int y = bounds.Y;
     int w = bounds.Width;
     int h = bounds.Height;
     Brush textBrush;
     Rectangle imageRect;
     StringFormat stringFormat;
     switch(tab.Anchor)
     {
         case AnchorStyles.Right:
             imageRect = new Rectangle(x + (w - 16) / 2, y + 3, 16, 16);
             stringFormat = VerticalStringFormat;
             break;
         case AnchorStyles.Left:
             imageRect = new Rectangle(x + (w - 16) / 2, y + 3, 16, 16);
             stringFormat = VerticalStringFormat;
             break;
         case AnchorStyles.Top:
             imageRect = new Rectangle(x + 3, y + (h - 16) / 2, 16, 16);
             stringFormat = NormalStringFormat;
             break;
         case AnchorStyles.Bottom:
             imageRect = new Rectangle(x + 3, y + (h - 16) / 2, 16, 16);
             stringFormat = NormalStringFormat;
             break;
         default:
             throw new ApplicationException();
     }
     var host = tab.View.Host;
     if(tab.IsActive)
     {
         textBrush = Brushes.Black;
     }
     else
     {
         textBrush = Brushes.White;
     }
     var image = tab.Image;
     if(image != null)
     {
         switch(tab.Orientation)
         {
             case Orientation.Horizontal:
                 {
                     graphics.DrawImage(image, imageRect);
                     bounds.Width -= imageRect.Width + 3;
                     bounds.X += imageRect.Width + 3;
                 }
                 break;
             case Orientation.Vertical:
                 using(var rotatedImage = (Image)image.Clone())
                 {
                     rotatedImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                     graphics.DrawImage(rotatedImage, imageRect);
                     bounds.Height -= imageRect.Height + 3;
                     bounds.Y += imageRect.Height + 3;
                 }
                 break;
             default:
                 throw new ApplicationException();
         }
     }
     switch(tab.Orientation)
     {
         case Orientation.Horizontal:
             bounds.X += ViewConstants.BeforeTabContent;
             bounds.Width -= ViewConstants.BeforeTabContent + ViewConstants.AfterTabContent - 1;
             GitterApplication.TextRenderer.DrawText(
                 graphics, tab.Text, GitterApplication.FontManager.UIFont, textBrush, bounds, stringFormat);
             break;
         case Orientation.Vertical:
             bounds.Y += ViewConstants.BeforeTabContent;
             bounds.Height -= ViewConstants.BeforeTabContent + ViewConstants.AfterTabContent - 1;
             bounds.Height += 10;
             GitterApplication.GdiPlusTextRenderer.DrawText(
                 graphics, tab.Text, GitterApplication.FontManager.UIFont, textBrush, bounds, stringFormat);
             break;
         default:
             throw new ApplicationException();
     }
 }
예제 #3
0
 private static void RenderTabBackground(ViewTabBase tab, Rectangle bounds, Graphics graphics)
 {
     const int corner = 1;
     int x = bounds.X;
     int y = bounds.Y;
     int w = bounds.Width;
     int h = bounds.Height;
     var linePoints = new Point[6];
     var polyPoints = new Point[6];
     LinearGradientMode gradient;
     switch(tab.Anchor)
     {
         case AnchorStyles.Right:
             linePoints[0] = new Point(x, y);
             linePoints[1] = new Point(x + w - corner - 1, y);
             linePoints[2] = new Point(x + w - 1, y + corner);
             linePoints[3] = new Point(x + w - 1, y + h - corner - 1);
             linePoints[4] = new Point(x + w - corner - 1, y + h - 1);
             linePoints[5] = new Point(x, y + h - 1);
             polyPoints[0] = new Point(x, y);
             polyPoints[1] = new Point(x + w - corner - 1, y);
             polyPoints[2] = new Point(x + w - 1, y + corner);
             polyPoints[3] = new Point(x + w - 1, y + h - corner - 1);
             polyPoints[4] = new Point(x + w - corner - 1, y + h - 1);
             polyPoints[5] = new Point(x, y + h - 1);
             break;
         case AnchorStyles.Left:
             linePoints[0] = new Point(x + w - 1, y);
             linePoints[1] = new Point(x + corner, y);
             linePoints[2] = new Point(x, y + corner);
             linePoints[3] = new Point(x, y + h - corner - 1);
             linePoints[4] = new Point(x + corner, y + h - 1);
             linePoints[5] = new Point(x + w - 1, y + h - 1);
             polyPoints[0] = new Point(x + w - 1, y);
             polyPoints[1] = new Point(x + corner, y);
             polyPoints[2] = new Point(x, y + corner);
             polyPoints[3] = new Point(x, y + h - corner - 1);
             polyPoints[4] = new Point(x + corner, y + h - 1);
             polyPoints[5] = new Point(x + w - 1, y + h - 1);
             break;
         case AnchorStyles.Top:
             linePoints[0] = new Point(x, y + h - 1);
             linePoints[1] = new Point(x, y + corner);
             linePoints[2] = new Point(x + corner, y);
             linePoints[3] = new Point(x + w - corner - 1, y);
             linePoints[4] = new Point(x + w - 1, y + corner);
             linePoints[5] = new Point(x + w - 1, y + h - 1);
             polyPoints[0] = new Point(x, y + h);
             polyPoints[1] = new Point(x, y + corner);
             polyPoints[2] = new Point(x + corner, y);
             polyPoints[3] = new Point(x + w - corner, y);
             polyPoints[4] = new Point(x + w, y + corner);
             polyPoints[5] = new Point(x + w, y + h);
             break;
         case AnchorStyles.Bottom:
             linePoints[0] = new Point(x, y);
             linePoints[1] = new Point(x, y + h - corner - 1);
             linePoints[2] = new Point(x + corner, y + h - 1);
             linePoints[3] = new Point(x + w - corner - 1, y + h - 1);
             linePoints[4] = new Point(x + w - 1, y + h - corner - 1);
             linePoints[5] = new Point(x + w - 1, y);
             polyPoints[0] = new Point(x, y);
             polyPoints[1] = new Point(x, y + h - corner - 1);
             polyPoints[2] = new Point(x + corner + 1, y + h);
             polyPoints[3] = new Point(x + w - corner - 1, y + h);
             polyPoints[4] = new Point(x + w, y + h - corner - 1);
             polyPoints[5] = new Point(x + w, y);
             break;
         default:
             throw new ApplicationException();
     }
     switch(tab.Orientation)
     {
         case Orientation.Horizontal:
             gradient = LinearGradientMode.Vertical;
             break;
         case Orientation.Vertical:
             gradient = LinearGradientMode.Horizontal;
             break;
         default:
             throw new ApplicationException();
     }
     var host = tab.View.Host;
     if(tab.IsActive)
     {
         if(host.IsDocumentWell)
         {
             Color start, end;
             if(host.IsActive)
             {
                 start = ColorTable.TabSelectedBackgroundActiveStart;
                 end = ColorTable.TabSelectedBackgroundActiveEnd;
             }
             else
             {
                 start = ColorTable.TabSelectedBackgroundNormalStart;
                 end = ColorTable.TabSelectedBackgroundNormalEnd;
             }
             using(var brush = new LinearGradientBrush(
                 bounds, start, end, gradient))
             {
                 graphics.FillPolygon(brush, polyPoints);
             }
         }
         else
         {
             using(var brush = new SolidBrush(ColorTable.TabSelectedBackground))
             {
                 graphics.FillPolygon(brush, polyPoints);
             }
         }
     }
     else if(tab.IsMouseOver)
     {
         using(var brush = new LinearGradientBrush(bounds,
             ColorTable.TabHoverBackgroundStart,
             ColorTable.TabHoverBackgroundEnd,
             gradient))
         {
             graphics.FillPolygon(brush, polyPoints);
         }
         using(var pen = new Pen(ColorTable.TabHoverBorder))
         {
             graphics.DrawLines(pen, linePoints);
         }
     }
     else
     {
         if(!host.IsDocumentWell)
         {
             using(var brush = new LinearGradientBrush(bounds,
                 ColorTable.TabNormalBackgroundStart,
                 ColorTable.TabNormalBackgroundEnd,
                 gradient))
             {
                 graphics.FillPolygon(brush, polyPoints);
             }
             using(var pen = new Pen(ColorTable.TabNormalBorder))
             {
                 graphics.DrawLines(pen, linePoints);
             }
         }
     }
 }
예제 #4
0
 private static int MeasureTabLength(ViewTabBase tab, Graphics graphics)
 {
     var length = GitterApplication.TextRenderer.MeasureText(
         graphics, tab.Text, GitterApplication.FontManager.UIFont, int.MaxValue, NormalStringFormat).Width;
     if(tab.Image != null)
     {
         length += 16 + ViewConstants.ImageSpacing;
     }
     length += ViewConstants.BeforeTabContent + ViewConstants.AfterTabContent;
     return length;
 }
예제 #5
0
        private static void RenderTabContent(ViewTabBase tab, Rectangle bounds, Graphics graphics)
        {
            int          x = bounds.X;
            int          y = bounds.Y;
            int          w = bounds.Width;
            int          h = bounds.Height;
            Brush        textBrush;
            Rectangle    imageRect;
            StringFormat stringFormat;

            switch (tab.Anchor)
            {
            case AnchorStyles.Right:
                imageRect    = new Rectangle(x + (w - 16) / 2, y + 3, 16, 16);
                stringFormat = VerticalStringFormat;
                break;

            case AnchorStyles.Left:
                imageRect    = new Rectangle(x + (w - 16) / 2, y + 3, 16, 16);
                stringFormat = VerticalStringFormat;
                break;

            case AnchorStyles.Top:
                imageRect    = new Rectangle(x + 3, y + (h - 16) / 2, 16, 16);
                stringFormat = NormalStringFormat;
                break;

            case AnchorStyles.Bottom:
                imageRect    = new Rectangle(x + 3, y + (h - 16) / 2, 16, 16);
                stringFormat = NormalStringFormat;
                break;

            default:
                throw new ApplicationException();
            }
            var host = tab.View.Host;

            if (tab.IsActive)
            {
                textBrush = Brushes.Black;
            }
            else
            {
                textBrush = Brushes.White;
            }
            var image = tab.Image;

            if (image != null)
            {
                switch (tab.Orientation)
                {
                case Orientation.Horizontal:
                {
                    graphics.DrawImage(image, imageRect);
                    bounds.Width -= imageRect.Width + 3;
                    bounds.X     += imageRect.Width + 3;
                }
                break;

                case Orientation.Vertical:
                    using (var rotatedImage = (Image)image.Clone())
                    {
                        rotatedImage.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        graphics.DrawImage(rotatedImage, imageRect);
                        bounds.Height -= imageRect.Height + 3;
                        bounds.Y      += imageRect.Height + 3;
                    }
                    break;

                default:
                    throw new ApplicationException();
                }
            }
            switch (tab.Orientation)
            {
            case Orientation.Horizontal:
                bounds.X     += ViewConstants.BeforeTabContent;
                bounds.Width -= ViewConstants.BeforeTabContent + ViewConstants.AfterTabContent - 1;
                GitterApplication.TextRenderer.DrawText(
                    graphics, tab.Text, GitterApplication.FontManager.UIFont, textBrush, bounds, stringFormat);
                break;

            case Orientation.Vertical:
                bounds.Y      += ViewConstants.BeforeTabContent;
                bounds.Height -= ViewConstants.BeforeTabContent + ViewConstants.AfterTabContent - 1;
                bounds.Height += 10;
                GitterApplication.GdiPlusTextRenderer.DrawText(
                    graphics, tab.Text, GitterApplication.FontManager.UIFont, textBrush, bounds, stringFormat);
                break;

            default:
                throw new ApplicationException();
            }
        }
예제 #6
0
        private static void RenderTabBackground(ViewTabBase tab, Rectangle bounds, Graphics graphics)
        {
            const int          corner     = 1;
            int                x          = bounds.X;
            int                y          = bounds.Y;
            int                w          = bounds.Width;
            int                h          = bounds.Height;
            var                linePoints = new Point[6];
            var                polyPoints = new Point[6];
            LinearGradientMode gradient;

            switch (tab.Anchor)
            {
            case AnchorStyles.Right:
                linePoints[0] = new Point(x, y);
                linePoints[1] = new Point(x + w - corner - 1, y);
                linePoints[2] = new Point(x + w - 1, y + corner);
                linePoints[3] = new Point(x + w - 1, y + h - corner - 1);
                linePoints[4] = new Point(x + w - corner - 1, y + h - 1);
                linePoints[5] = new Point(x, y + h - 1);
                polyPoints[0] = new Point(x, y);
                polyPoints[1] = new Point(x + w - corner - 1, y);
                polyPoints[2] = new Point(x + w - 1, y + corner);
                polyPoints[3] = new Point(x + w - 1, y + h - corner - 1);
                polyPoints[4] = new Point(x + w - corner - 1, y + h - 1);
                polyPoints[5] = new Point(x, y + h - 1);
                break;

            case AnchorStyles.Left:
                linePoints[0] = new Point(x + w - 1, y);
                linePoints[1] = new Point(x + corner, y);
                linePoints[2] = new Point(x, y + corner);
                linePoints[3] = new Point(x, y + h - corner - 1);
                linePoints[4] = new Point(x + corner, y + h - 1);
                linePoints[5] = new Point(x + w - 1, y + h - 1);
                polyPoints[0] = new Point(x + w - 1, y);
                polyPoints[1] = new Point(x + corner, y);
                polyPoints[2] = new Point(x, y + corner);
                polyPoints[3] = new Point(x, y + h - corner - 1);
                polyPoints[4] = new Point(x + corner, y + h - 1);
                polyPoints[5] = new Point(x + w - 1, y + h - 1);
                break;

            case AnchorStyles.Top:
                linePoints[0] = new Point(x, y + h - 1);
                linePoints[1] = new Point(x, y + corner);
                linePoints[2] = new Point(x + corner, y);
                linePoints[3] = new Point(x + w - corner - 1, y);
                linePoints[4] = new Point(x + w - 1, y + corner);
                linePoints[5] = new Point(x + w - 1, y + h - 1);
                polyPoints[0] = new Point(x, y + h);
                polyPoints[1] = new Point(x, y + corner);
                polyPoints[2] = new Point(x + corner, y);
                polyPoints[3] = new Point(x + w - corner, y);
                polyPoints[4] = new Point(x + w, y + corner);
                polyPoints[5] = new Point(x + w, y + h);
                break;

            case AnchorStyles.Bottom:
                linePoints[0] = new Point(x, y);
                linePoints[1] = new Point(x, y + h - corner - 1);
                linePoints[2] = new Point(x + corner, y + h - 1);
                linePoints[3] = new Point(x + w - corner - 1, y + h - 1);
                linePoints[4] = new Point(x + w - 1, y + h - corner - 1);
                linePoints[5] = new Point(x + w - 1, y);
                polyPoints[0] = new Point(x, y);
                polyPoints[1] = new Point(x, y + h - corner - 1);
                polyPoints[2] = new Point(x + corner + 1, y + h);
                polyPoints[3] = new Point(x + w - corner - 1, y + h);
                polyPoints[4] = new Point(x + w, y + h - corner - 1);
                polyPoints[5] = new Point(x + w, y);
                break;

            default:
                throw new ApplicationException();
            }
            switch (tab.Orientation)
            {
            case Orientation.Horizontal:
                gradient = LinearGradientMode.Vertical;
                break;

            case Orientation.Vertical:
                gradient = LinearGradientMode.Horizontal;
                break;

            default:
                throw new ApplicationException();
            }
            var host = tab.View.Host;

            if (tab.IsActive)
            {
                if (host.IsDocumentWell)
                {
                    Color start, end;
                    if (host.IsActive)
                    {
                        start = ColorTable.TabSelectedBackgroundActiveStart;
                        end   = ColorTable.TabSelectedBackgroundActiveEnd;
                    }
                    else
                    {
                        start = ColorTable.TabSelectedBackgroundNormalStart;
                        end   = ColorTable.TabSelectedBackgroundNormalEnd;
                    }
                    using (var brush = new LinearGradientBrush(
                               bounds, start, end, gradient))
                    {
                        graphics.FillPolygon(brush, polyPoints);
                    }
                }
                else
                {
                    using (var brush = new SolidBrush(ColorTable.TabSelectedBackground))
                    {
                        graphics.FillPolygon(brush, polyPoints);
                    }
                }
            }
            else if (tab.IsMouseOver)
            {
                using (var brush = new LinearGradientBrush(bounds,
                                                           ColorTable.TabHoverBackgroundStart,
                                                           ColorTable.TabHoverBackgroundEnd,
                                                           gradient))
                {
                    graphics.FillPolygon(brush, polyPoints);
                }
                using (var pen = new Pen(ColorTable.TabHoverBorder))
                {
                    graphics.DrawLines(pen, linePoints);
                }
            }
            else
            {
                if (!host.IsDocumentWell)
                {
                    using (var brush = new LinearGradientBrush(bounds,
                                                               ColorTable.TabNormalBackgroundStart,
                                                               ColorTable.TabNormalBackgroundEnd,
                                                               gradient))
                    {
                        graphics.FillPolygon(brush, polyPoints);
                    }
                    using (var pen = new Pen(ColorTable.TabNormalBorder))
                    {
                        graphics.DrawLines(pen, linePoints);
                    }
                }
            }
        }