예제 #1
0
        protected virtual bool OnPaint(ThumbViewPaintEventArgs e)
        {
            e.PaintBackground();

            // text
            var textHeight = e.Font.Height + 6;
            var rectText   = new Rectangle(Left, Bottom - textHeight, Width, textHeight);

            if (!string.IsNullOrEmpty(Text))
            {
                var sf = PaintHelper.SFCenter;
                sf.Trimming     = StringTrimming.EllipsisCharacter;
                sf.FormatFlags |= StringFormatFlags.NoWrap;

                e.Graphics.DrawString(Text,
                                      e.Font,
                                      Selected ? new SolidBrush(e.View.ActiveCellForeColor) : new SolidBrush(e.View.CellForeColor),
                                      rectText,
                                      sf);
            }

            // image
            if (Image != null)
            {
                var rectImg = new Rectangle(Left, Top, Width, Height - textHeight - 4);
                PaintHelper.DrawImageInRange(e.Graphics, Image, rectImg);
            }

            return(true);
        }
예제 #2
0
        void DrawButton(PaintEventArgs e, ButtonInfo button, int iconX, int textX)
        {
            Color backColor = ButtonBackColor;
            Color foreColor = ButtonForeColor;

            if (button == PressedObject || button == HoverObject)
            {
                backColor = ButtonHoverBackColor;
                foreColor = ButtonHoverForeColor;
            }

            var rect = button.Bounds;
            var font = Font;

            e.Graphics.FillRectangle(new SolidBrush(backColor), rect);

            if (button.Image != null)
            {
                var rectIcon = new Rectangle(iconX, rect.Y, IconSize.Width, rect.Height);
                PaintHelper.DrawImageInRange(e.Graphics, button.Image, rectIcon);
            }

            if (!string.IsNullOrEmpty(button.Text))
            {
                var rectText = new Rectangle(textX, rect.Y, rect.Right - textX, rect.Height);

                var sf = PaintHelper.SFLeft;
                sf.FormatFlags |= StringFormatFlags.NoWrap;
                sf.Trimming     = StringTrimming.EllipsisCharacter;

                e.Graphics.DrawString(button.Text, Font, new SolidBrush(foreColor), rectText, sf);
            }
        }
예제 #3
0
        protected override void DrawCloseButton(TabItemPaintEventArgs e, Rectangle rect)
        {
            //Skin.Instance.DrawTaskBarItemCloseButton(new SkinPaintEventArgs(this, e), rect, tis, Alignment, item == SelectedItem);
            Image image = Properties.Resources.close_button; // Images.close_button;

            Rectangle rectS = new Rectangle(0, 0, image.Width / 4, image.Height);

            if (!e.Selected)
            {
                rectS.X = rectS.Width * 3;
            }

            switch (e.CloseButtonStatus)
            {
            case UIControlStatus.Hover:
                rectS.X = rectS.Width * 1;
                break;

            case UIControlStatus.Selected:
                rectS.X = rectS.Width * 2;
                break;

            case UIControlStatus.Disabled:
                rectS.X = rectS.Width * 3;
                break;
            }

            PaintHelper.DrawImageInRange(e.Graphics, image, rect, rectS);
        }
예제 #4
0
        void DrawButtonImageAndText(PaintEventArgs e, TabBarButton button, UIControlStatus ucs)
        {
            if (button.Icon != null && string.IsNullOrEmpty(button.Text))
            {
                PaintHelper.DrawImageInRange(e.Graphics, button.Icon, button.Bounds);
            }
            else if (button.Icon == null && string.IsNullOrEmpty(button.Text))
            {
                DrawButtonText(e, button, ucs);
            }
            else
            {
                Size size = Size.Ceiling(e.Graphics.MeasureString(button.Text, Bar.Font));
                size.Width += button.Icon.Width;
                Rectangle rect = new Rectangle(
                    button.Bounds.X + (button.Bounds.Width - size.Width) / 2,
                    button.Bounds.Y + (button.Bounds.Height - size.Height) / 2,
                    size.Width,
                    size.Height);

                e.Graphics.DrawImage(button.Icon,
                                     new Rectangle(rect.Left, rect.Top + (rect.Height - button.Icon.Height) / 2, button.Icon.Width, button.Icon.Height),
                                     0, 0, button.Icon.Width, button.Icon.Height, GraphicsUnit.Pixel);

                rect.X     += button.Icon.Width;
                rect.Width -= button.Icon.Width;

                e.Graphics.DrawString(button.Text, Bar.Font, new SolidBrush(Bar.ForeColor), rect, PaintHelper.SFCenter);
            }
        }
예제 #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (ExternalMode)
            {
                var image = Properties.Resources.external;
                var rect  = ClientRectangle;
                PaintHelper.DrawImageInRange(e.Graphics, image, rect);
            }
        }
예제 #6
0
        protected override void DrawCell(int index, Rectangle rect, PaintEventArgs e)
        {
            Image image = Items[index];

            if (image == null)
            {
                return;
            }

            PaintHelper.DrawImageInRange(e.Graphics, image, rect);
        }
예제 #7
0
        protected override void DrawCell(int index, Rectangle rect, PaintEventArgs e)
        {
            Picture picture = Items[index];

            if (picture == null || picture.Data == null)
            {
                return;
            }

            PaintHelper.DrawImageInRange(e.Graphics, picture.Data, rect);
        }
예제 #8
0
            public virtual void OnPaint(PaintEventArgs e, Color backColor, Color foreColor, Font font, bool hover, bool pressed)
            {
                DrawItemBackground(e, hover, pressed);

                if (Image != null)
                {
                    if (Enabled && this.Enabled)
                    {
                        PaintHelper.DrawImageInRange(e.Graphics, Image, Bounds);
                    }
                    else
                    {
                        PaintHelper.DrawImageDisabledInRect(e.Graphics, Image, Bounds, backColor);
                    }
                }
            }
예제 #9
0
        public bool Draw(Graphics graphics, UIControlStatus status, Rectangle targetRectangle)
        {
            if (this.Image == null)
            {
                return(false);
            }

            var rectSource = GetBounds(status);

            if (rectSource.Width <= 0 || rectSource.Height <= 0)
            {
                return(false);
            }

            return(PaintHelper.DrawImageInRange(graphics, Image, targetRectangle, rectSource));
        }
예제 #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            InvokePaintBackground(this, e);

            Rectangle rectTitle = ClientRectangle;

            rectTitle.Height = FoldingButtonRect.Height;

            Size sizeText = Size.Ceiling(e.Graphics.MeasureString(Text, Font));

            rectTitle.Height = Math.Max(rectTitle.Height, sizeText.Height);

            Image image = Folded ? Properties.Resources.folding_expand : Properties.Resources.folding_collapse;

            PaintHelper.DrawImageInRange(e.Graphics, image, FoldingButtonRect);
            rectTitle.X     += FoldingButtonRect.Width;
            rectTitle.Width -= FoldingButtonRect.Width;

            e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), rectTitle, PaintHelper.SFLeft);
            rectTitle.X     += sizeText.Width;
            rectTitle.Width -= sizeText.Width;

            PaintHelper.SetHighQualityRender(e.Graphics);
            e.Graphics.ExcludeClip(new Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width - rectTitle.Width, rectTitle.Height));
            Rectangle rectBorder = new Rectangle(0, rectTitle.Y + rectTitle.Height / 2, ClientSize.Width, ClientSize.Height - rectTitle.Height / 2);
            Pen       penLine    = new Pen(PaintHelper.GetDarkColor(BackColor));

            if (Folded)
            {
                e.Graphics.DrawLine(penLine, rectBorder.X, rectBorder.Y, rectBorder.Right, rectBorder.Y);
            }
            else
            {
                GraphicsPath path = PaintHelper.GetRoundRectangle(rectBorder, 6);
                e.Graphics.DrawPath(penLine, path);
                path.Dispose();
            }

            if (Focused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));
            }
        }
예제 #11
0
        protected override void DrawButton(PaintEventArgs e, TabBarButton button, UIControlStatus ucs)
        {
            DrawButtonBackground(e, button, ucs);

            if (button.DisplayStyle == ToolStripItemDisplayStyle.Image)
            {
                if (button.Icon != null)
                {
                    PaintHelper.DrawImageInRange(e.Graphics, button.Icon, button.Bounds);
                }
            }
            else if (button.DisplayStyle == ToolStripItemDisplayStyle.ImageAndText)
            {
                DrawButtonImageAndText(e, button, ucs);
            }
            else if (button.DisplayStyle == ToolStripItemDisplayStyle.Text)
            {
                DrawButtonText(e, button, ucs);
            }
        }
예제 #12
0
        public override void DrawItem(TabItemPaintEventArgs e)
        {
            Rectangle rect = e.Bounds;

            if (rect.Width <= 0 || rect.Height <= 0)
            {
                return;
            }

            // draw background
            DrawItemBackground(e);

            rect = e.ContentRectangle;
            // draw icon
            if (e.Item.Icon != null)
            {
                Rectangle rect_icon;
                if (e.IsHorizontal)
                {
                    if (string.IsNullOrEmpty(e.Item.Text) && !e.Item.CanClose)
                    {
                        rect_icon = new Rectangle(rect.Left + (rect.Width - e.IconSize.Width) / 2, rect.Top + (rect.Height - e.IconSize.Height) / 2, e.IconSize.Width, e.IconSize.Height);
                    }
                    else
                    {
                        rect_icon = new Rectangle(rect.Left, rect.Top + (rect.Height - e.IconSize.Height) / 2, e.IconSize.Width, e.IconSize.Height);
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(e.Item.Text) && !e.Item.CanClose)
                    {
                        rect_icon = new Rectangle(rect.Left + (rect.Width - e.IconSize.Width) / 2, rect.Top + (rect.Height - e.IconSize.Height) / 2, e.IconSize.Width, e.IconSize.Height);
                    }
                    else
                    {
                        rect_icon = new Rectangle(rect.Left + (rect.Width - e.IconSize.Width) / 2, rect.Top, e.IconSize.Width, e.IconSize.Height);
                    }
                }

                PaintHelper.DrawImageInRange(e.Graphics, e.Item.Icon, rect_icon);
                if (e.IsHorizontal)
                {
                    rect.X     += rect_icon.Width;
                    rect.Width -= rect_icon.Width;
                }
                else
                {
                    rect.Y      += rect_icon.Height;
                    rect.Height -= rect_icon.Height;
                }
            }

            if (e.Item.CanClose)
            {
                //System.Diagnostics.Debug.WriteLine(string.Format("> {0}, {1}", HoverHitResult.Item, HoverHitResult.InCloseButton));

                Rectangle rect_close_btn = e.Item.GetCloseButtonRect();
                DrawCloseButton(e, rect_close_btn);
                if (e.IsHorizontal)
                {
                    rect.Width -= e.Bar.CloseButtonSize.Width;
                }
                else
                {
                    rect.Height -= e.Bar.CloseButtonSize.Height;
                }
            }

            if (!string.IsNullOrEmpty(e.Item.Text))
            {
                Rectangle     rect_text = rect;
                GraphicsState gs        = null;
                if (!e.IsHorizontal)
                {
                    gs = e.Graphics.Save();
                    e.Graphics.RotateTransform(90);
                    rect_text = new Rectangle(rect.Y, -rect.X - rect.Width, rect.Height, rect.Width);
                    //e.Graphics.DrawRectangle(Pens.Blue, rect_text);
                }

                DrawItemText(e, rect_text);

                if (!e.IsHorizontal)
                {
                    e.Graphics.Restore(gs);
                }
            }
        }