Esempio n. 1
0
        public void DrawArrow(Graphics gr)
        {
            int _size = 1;

            RibbonColor __color   = new RibbonColor(Color.FromArgb(R0, G0, B0));
            RibbonColor forecolor = new RibbonColor(this.ForeColor);
            Color       _forecolor;

            if (__color.GetBrightness() > 50)
            {
                forecolor.BC = 1;
                forecolor.SC = 80;
            }
            else
            {
                forecolor.BC = 99;
                forecolor.SC = 20;
            }
            _forecolor = forecolor.GetColor();

            switch (_arrow)
            {
            case e_arrow.ToDown:
                if (_imagelocation == e_imagelocation.Left)
                {
                    Point[] points = new Point[3];
                    points[0] = new Point(this.Width - 8 * _size - _imageoffsetY, this.Height / 2 - _size / 2);
                    points[1] = new Point(this.Width - 2 * _size - _imageoffsetY, this.Height / 2 - _size / 2);
                    points[2] = new Point(this.Width - 5 * _size - _imageoffsetY, this.Height / 2 + _size * 2);
                    gr.FillPolygon(new SolidBrush(_forecolor), points);
                }
                else if (_imagelocation == e_imagelocation.Top)
                {
                    Point[] points = new Point[3];
                    points[0] = new Point(this.Width / 2 + 8 * _size - _imageoffsetY, this.Height - _imageoffsetY - 5 * _size);
                    points[1] = new Point(this.Width / 2 + 2 * _size - _imageoffsetY, this.Height - _imageoffsetY - 5 * _size);
                    points[2] = new Point(this.Width / 2 + 5 * _size - _imageoffsetY, this.Height - _imageoffsetY - 2 * _size);
                    gr.FillPolygon(new SolidBrush(_forecolor), points);
                }
                break;

            case e_arrow.ToRight:
                if (_imagelocation == e_imagelocation.Left)
                {
                    int     arrowxpos = this.Width - _splitdistance + 2 * _imageoffsetY;
                    Point[] points    = new Point[3];
                    points[0] = new Point(arrowxpos + 4, this.Height / 2 - 4 * _size);
                    points[1] = new Point(arrowxpos + 8, this.Height / 2);
                    points[2] = new Point(arrowxpos + 4, this.Height / 2 + 4 * _size);
                    gr.FillPolygon(new SolidBrush(_forecolor), points);
                }
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        public Color GetColorIncreased(Color color, int h, int s, int b)
        {
            RibbonColor _color = new RibbonColor(color);
            int         ss     = _color.GetSaturation();
            float       vc     = b + _color.GetBrightness();
            float       hc     = h + _color.GetHue();
            float       sc     = s + ss;


            _color.VC = vc;
            _color.HC = hc;
            _color.SC = sc;

            return(_color.GetColor());
        }
Esempio n. 3
0
        public void DrawString(Graphics gr)
        {
            if (this.Text != "")
            {
                int textwidth  = (int)gr.MeasureString(this.Text, this.Font).Width;
                int textheight = (int)gr.MeasureString(this.Text, this.Font).Height;

                int  extraoffset = 0;
                Font fontb       = new Font(this.Font, FontStyle.Bold);
                if (_title != "")
                {
                    extraoffset = textheight / 2;
                }

                if (string.IsNullOrEmpty(this.Text))
                {
                    this.Text = " ";
                }

                string s1   = this.Text;
                string s2   = "";
                int    jump = this.Text.IndexOf("\\n");

                if (jump != -1)
                {
                    s2 = s1.Substring(jump + 3);
                    s1 = s1.Substring(0, jump);
                }

                #region Calc Color Brightness
                RibbonColor __color   = new RibbonColor(Color.FromArgb(R0, G0, B0));
                RibbonColor forecolor = new RibbonColor(this.ForeColor);
                Color       _forecolor;

                if (__color.GetBrightness() > 50)
                {
                    forecolor.BC = 1;
                    forecolor.SC = 80;
                }
                else
                {
                    forecolor.BC = 99;
                    forecolor.SC = 20;
                }
                _forecolor = forecolor.GetColor();
                #endregion

                _forecolor = this.ForeColor;
                switch (_imagelocation)
                {
                case e_imagelocation.Left:
                    if (this.Title != "")
                    {
                        gr.DrawString(this.Title, this.Font, new SolidBrush(_titleForeColor), new PointF(_textOffsetX + imagewidth + 4, this.Font.Size / 2 + _textOffsetY));
                        gr.DrawString(s1, fontb, new SolidBrush(this.ForeColor), new PointF(_textOffsetX + imagewidth + 4, 2 * this.Font.Size + 4 + _textOffsetY));
                        gr.DrawString(s2, fontb, new SolidBrush(this.ForeColor), new PointF(_textOffsetX + imagewidth + 4, 3 * this.Font.Size + 2 + _textOffsetY));
                    }
                    else
                    {
                        gr.DrawString(s1, fontb, new SolidBrush(this.ForeColor), new PointF(_textOffsetX + imagewidth + 4, this.Height / 2 - this.Font.Size + _textOffsetY));
                    }

                    break;

                case e_imagelocation.Right:
                    gr.DrawString(this.Title, fontb, new SolidBrush(_titleForeColor), new PointF(_textOffsetX, this.Height / 2 - this.Font.Size + 1 - extraoffset + _textOffsetY));
                    gr.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(_textOffsetX, extraoffset + this.Height / 2 - this.Font.Size + _textOffsetY));
                    break;

                case e_imagelocation.Top:
                    gr.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(_textOffsetX + this.Width / 2 - textwidth / 2 - 1, offsety + imageheight + _textOffsetY));
                    break;

                case e_imagelocation.Bottom:
                    gr.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(_textOffsetX + this.Width / 2 - textwidth / 2 - 1, this.Height - imageheight - textheight + _textOffsetY));
                    break;

                case e_imagelocation.None:
                    _forecolor = this.ForeColor;
                    gr.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(_textOffsetX + this.Width / 2 - textwidth / 2 - 1, this.Height / 2 - textheight / 2 + _textOffsetY));
                    break;

                default:
                    break;
                }

                fontb.Dispose();
            }
        }