Exemple #1
0
        public void DrawArrow(Graphics gr)
        {
            int         num          = 1;
            RibbonColor ribbonColor  = new RibbonColor(Color.FromArgb(this.R0, this.G0, this.B0));
            RibbonColor ribbonColor2 = new RibbonColor(this.ForeColor);

            if (ribbonColor.GetBrightness() > 50)
            {
                ribbonColor2.BC = 1;
                ribbonColor2.SC = 80f;
            }
            else
            {
                ribbonColor2.BC = 99;
                ribbonColor2.SC = 20f;
            }
            Color color = ribbonColor2.GetColor();

            switch (this._arrow)
            {
            case RibbonMenuButton.e_arrow.ToRight:
                if (this._imagelocation == RibbonMenuButton.e_imagelocation.Left)
                {
                    int     num2   = base.Width - this._splitdistance + 2 * this._imageoffset;
                    Point[] points = new Point[]
                    {
                        new Point(num2 + 4, base.Height / 2 - 4 * num),
                        new Point(num2 + 8, base.Height / 2),
                        new Point(num2 + 4, base.Height / 2 + 4 * num)
                    };
                    gr.FillPolygon(new SolidBrush(color), points);
                }
                break;

            case RibbonMenuButton.e_arrow.ToDown:
                if (this._imagelocation == RibbonMenuButton.e_imagelocation.Left)
                {
                    Point[] points = new Point[]
                    {
                        new Point(base.Width - 8 * num - this._imageoffset, base.Height / 2 - num / 2),
                        new Point(base.Width - 2 * num - this._imageoffset, base.Height / 2 - num / 2),
                        new Point(base.Width - 5 * num - this._imageoffset, base.Height / 2 + num * 2)
                    };
                    gr.FillPolygon(new SolidBrush(color), points);
                }
                else if (this._imagelocation == RibbonMenuButton.e_imagelocation.Top)
                {
                    Point[] points = new Point[]
                    {
                        new Point(base.Width / 2 + 8 * num - this._imageoffset, base.Height - this._imageoffset - 5 * num),
                        new Point(base.Width / 2 + 2 * num - this._imageoffset, base.Height - this._imageoffset - 5 * num),
                        new Point(base.Width / 2 + 5 * num - this._imageoffset, base.Height - this._imageoffset - 2 * num)
                    };
                    gr.FillPolygon(new SolidBrush(color), points);
                }
                break;
            }
        }
Exemple #2
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 - _imageoffset, this.Height / 2 - _size / 2);
                    points[1] = new Point(this.Width - 2 * _size - _imageoffset, this.Height / 2 - _size / 2);
                    points[2] = new Point(this.Width - 5 * _size - _imageoffset, 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 - _imageoffset, this.Height - _imageoffset - 5 * _size);
                    points[1] = new Point(this.Width / 2 + 2 * _size - _imageoffset, this.Height - _imageoffset - 5 * _size);
                    points[2] = new Point(this.Width / 2 + 5 * _size - _imageoffset, this.Height - _imageoffset - 2 * _size);
                    gr.FillPolygon(new SolidBrush(_forecolor), points);
                }
                break;

            case e_arrow.ToRight:
                if (_imagelocation == e_imagelocation.Left)
                {
                    int     arrowxpos = this.Width - _splitdistance + 2 * _imageoffset;
                    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;
            }
        }
Exemple #3
0
        public Color GetColorIncreased(Color color, int h, int s, int b)
        {
            RibbonColor ribbonColor = new RibbonColor(color);
            int         saturation  = ribbonColor.GetSaturation();
            float       vC          = (float)(b + ribbonColor.GetBrightness());
            float       hC          = (float)(h + ribbonColor.GetHue());
            float       sC          = (float)(s + saturation);

            ribbonColor.VC = vC;
            ribbonColor.HC = hC;
            ribbonColor.SC = sC;
            return(ribbonColor.GetColor());
        }
Exemple #4
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());
        }
Exemple #5
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;
                }

                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

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

                    break;

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

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

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

                default:
                    break;
                }

                fontb.Dispose();
            }
        }
Exemple #6
0
        public void DrawString(Graphics gr)
        {
            if (this.Text != "")
            {
                int  num  = (int)gr.MeasureString(this.Text, this.Font).Width;
                int  num2 = (int)gr.MeasureString(this.Text, this.Font).Height;
                int  num3 = 0;
                Font font = new Font(this.Font, FontStyle.Bold);
                if (this._title != "")
                {
                    num3 = num2 / 2;
                }
                string text = this.Text;
                string s    = "";
                int    num4 = this.Text.IndexOf("\\n");
                if (num4 != -1)
                {
                    s    = text.Substring(num4 + 3);
                    text = text.Substring(0, num4);
                }
                RibbonColor ribbonColor  = new RibbonColor(Color.FromArgb(this.R0, this.G0, this.B0));
                RibbonColor ribbonColor2 = new RibbonColor(this.ForeColor);
                if (ribbonColor.GetBrightness() > 50)
                {
                    ribbonColor2.BC = 1;
                    ribbonColor2.SC = 80f;
                }
                else
                {
                    ribbonColor2.BC = 99;
                    ribbonColor2.SC = 20f;
                }
                Color color = ribbonColor2.GetColor();
                switch (this._imagelocation)
                {
                case RibbonMenuButton.e_imagelocation.Top:
                    gr.DrawString(this.Text, this.Font, new SolidBrush(color), new PointF((float)(base.Width / 2 - num / 2 - 1), (float)(this.offsety + this.imageheight)));
                    break;

                case RibbonMenuButton.e_imagelocation.Bottom:
                    gr.DrawString(this.Text, this.Font, new SolidBrush(color), new PointF((float)(base.Width / 2 - num / 2 - 1), (float)(base.Height - this.imageheight - num2 - 1)));
                    break;

                case RibbonMenuButton.e_imagelocation.Left:
                    if (this.Title != "")
                    {
                        gr.DrawString(this.Title, font, new SolidBrush(color), new PointF((float)(this.offsetx + this.imagewidth + 4), this.Font.Size / 2f));
                        gr.DrawString(text, this.Font, new SolidBrush(color), new PointF((float)(this.offsetx + this.imagewidth + 4), 2f * this.Font.Size + 1f));
                        gr.DrawString(s, this.Font, new SolidBrush(color), new PointF((float)(this.offsetx + this.imagewidth + 4), 3f * this.Font.Size + 4f));
                    }
                    else
                    {
                        gr.DrawString(text, this.Font, new SolidBrush(color), new PointF((float)(this.offsetx + this.imagewidth + 4), (float)(base.Height / 2) - this.Font.Size + 1f));
                    }
                    break;

                case RibbonMenuButton.e_imagelocation.Right:
                    gr.DrawString(this.Title, font, new SolidBrush(color), new PointF((float)this.offsetx, (float)(base.Height / 2) - this.Font.Size + 1f - (float)num3));
                    gr.DrawString(this.Text, this.Font, new SolidBrush(color), new PointF((float)this.offsetx, (float)(num3 + base.Height / 2) - this.Font.Size + 1f));
                    break;
                }
                font.Dispose();
            }
        }