Exemple #1
0
        internal override void DrawHeaderText(HeaderStrip control, PaintEventArgs e)
        {
            if (!string.IsNullOrEmpty(control.Text) && control.Tabs.Count == 0)
            {
                using (Font font = new Font(FontFamily.GenericSansSerif, HeaderFontSize, FontStyle.Bold))
                    using (Brush brush = new SolidBrush(Strings.ToColor(HeaderFontColor)))
                    {
                        SizeF textSize = e.Graphics.MeasureString(control.Text, font);

                        e.Graphics.DrawString(control.Text, font, brush, 12 * ScaleFactor.Width, 7 * ScaleFactor.Height);
                    }
            }
        }
Exemple #2
0
        internal override void DrawHeaderBackGround(HeaderStrip control, PaintEventArgs eventArgs)
        {
            Size controlSize = control.Size;

            if (control.Tabs.Count > 0)
            {
                controlSize.Height -= HeaderSelectedTabStrip * ScaleFactor.Height;
            }

            Rectangle rect  = new Rectangle(eventArgs.ClipRectangle.X, 0, eventArgs.ClipRectangle.Width, controlSize.Height);
            Color     start = Strings.ToColor(HeaderStartColor);
            Color     end   = Strings.ToColor(HeaderEndColor);

            GradientFill.Fill(eventArgs.Graphics, rect, start, end, GradientFill.FillDirection.TopToBottom);

            eventArgs.Graphics.DrawLine(new Pen(Strings.ToColor(BorderLineColor)), rect.X, rect.Height - 1, rect.Width, rect.Height - 1);
        }
Exemple #3
0
 internal abstract void DrawTabs(HeaderStrip control, PaintEventArgs e);
Exemple #4
0
 internal abstract void DrawHeaderBackGround(HeaderStrip control, PaintEventArgs eventArgs);
Exemple #5
0
        internal override void DrawTabs(HeaderStrip control, PaintEventArgs e)
        {
            if (control.Tabs.Count == 0)
            {
                return;
            }
            Size size = control.Size;

            size.Height -= HeaderSelectedTabStrip * ScaleFactor.Height;

            IList <HeaderTab> tabs = control.Tabs;
            int bottomHeight       = 15 * ScaleFactor.Height;

            Point offset       = new Point(2 * ScaleFactor.Width, 2 * ScaleFactor.Width);
            int   defaultWidth = 42 * ScaleFactor.Width;
            Size  corner       = new Size(8 * ScaleFactor.Width, 8 * ScaleFactor.Height);

            Pen penBorder = new Pen(Strings.ToColor(BorderLineColor));

            try
            {
                HeaderTab selected = null;
                foreach (HeaderTab tab in tabs)
                {
                    tab.area = new Rectangle(offset.X + tab.TabIndex * defaultWidth, offset.Y, defaultWidth, size.Height - offset.Y + corner.Height);
                    if (tab.Selected)
                    {
                        selected = tab;
                        using (SolidBrush backColor = new SolidBrush(Color.Black))
                            RoundedRectangle.Fill(e.Graphics, penBorder, backColor, tab.area, corner);
                    }

                    if (tab.Image != null)
                    {
                        //draw icon
                        Rectangle destImg = new Rectangle(0, 0, tab.Image.Width, tab.Image.Height);
                        if (tab.Image.Size.Height > tab.area.Height || tab.Image.Size.Width > tab.area.Width)
                        {
                            int oX = 8 * ScaleFactor.Width;
                            int oY = 8 * ScaleFactor.Height;

                            int imageSize = tab.area.Height - ((tab.area.Y + oY) * 2);
                            destImg = new Rectangle(tab.area.X + oX, tab.area.Y + oY, imageSize, imageSize);
                        }

                        destImg = new Rectangle(tab.area.X + (tab.area.Width / 2) - (destImg.Width / 2), (tab.area.Height / 2) - (destImg.Height / 2), destImg.Width, destImg.Height);

                        using (AlphaImage image = new AlphaImage(tab.Image))
                        {
                            image.Draw(e.Graphics, destImg);
                        }
                    }

                    if (!tab.Selected && (tab.TabIndex == tabs.Count - 1 || !tabs[tab.TabIndex + 1].Selected))
                    {
                        Point sep = new Point(tab.area.Right, offset.Y);
                        DrawSeparator(e, sep, size.Height - (sep.Y * 2), Orientation.Vertical);
                    }
                }

                Font       font   = new Font(FontFamily.GenericSansSerif, HeaderSelectedTabStripFontSize, FontStyle.Regular);
                SolidBrush brush  = new SolidBrush(ControlBackColor);
                SolidBrush fBrush = new SolidBrush(Strings.ToColor(HeaderSelectedTabStripFontColor));
                Rectangle  rect   = new Rectangle(0, size.Height, control.Width, control.Height - size.Height);
                e.Graphics.FillRectangle(brush, rect);
                SizeF textSize = e.Graphics.MeasureString(selected.Text, font);

                Rectangle stringRect = rect;
                stringRect.X = Convert.ToInt32(selected.area.X + ((selected.area.Width / 2) - (textSize.Width / 2)));
                if (stringRect.X < 0)
                {
                    stringRect.X = 2 * ScaleFactor.Width;
                }

                e.Graphics.DrawString(selected.Text, font, fBrush, stringRect);
                e.Graphics.DrawLine(new Pen(Strings.ToColor(HeaderSelectedTabStripBorderColor)), rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
                brush.Dispose(); fBrush.Dispose(); font.Dispose();
            }
            finally
            {
                penBorder.Dispose();
            }
        }
Exemple #6
0
 internal TabsCollection(HeaderStrip control)
 {
     this.Control = control;
 }