namespace VaioxOnline
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Text;
    using System.Windows.Forms;

    internal class FlatContextMenuStrip : ContextMenuStrip
    {
        public FlatContextMenuStrip()
        {
            base.Renderer = new ToolStripProfessionalRenderer(new TColorTable());
            base.ShowImageMargin = false;
            base.ForeColor = Color.White;
            this.Font = new Font("Segoe UI", 8f);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
        }

        protected override void OnTextChanged(EventArgs e)
        {
            base.OnTextChanged(e);
            base.Invalidate();
        }

        public class TColorTable : ProfessionalColorTable
        {
            private Color BackColor = Color.FromArgb(0x2d, 0x2f, 0x31);
            private Color BorderColor = Color.FromArgb(0x35, 0x3a, 60);
            private Color CheckedColor = Helpers._FlatColor;

            [Category("Colors")]
            public Color _BackColor
            {
                get => 
                    this.BackColor
                set
                {
                    this.BackColor = value;
                }
            }

            [Category("Colors")]
            public Color _BorderColor
            {
                get => 
                    this.BorderColor
                set
                {
                    this.BorderColor = value;
                }
            }

            [Category("Colors")]
            public Color _CheckedColor
            {
                get => 
                    this.CheckedColor
                set
                {
                    this.CheckedColor = value;
                }
            }

            public override Color ButtonSelectedBorder =>
                this.BackColor

            public override Color CheckBackground =>
                this.CheckedColor

            public override Color CheckPressedBackground =>
                this.CheckedColor

            public override Color CheckSelectedBackground =>
                this.CheckedColor

            public override Color ImageMarginGradientBegin =>
                this.CheckedColor

            public override Color ImageMarginGradientEnd =>
                this.CheckedColor

            public override Color ImageMarginGradientMiddle =>
                this.CheckedColor

            public override Color MenuBorder =>
                this.BorderColor

            public override Color MenuItemBorder =>
                this.BorderColor

            public override Color MenuItemSelected =>
                this.CheckedColor

            public override Color SeparatorDark =>
                this.BorderColor

            public override Color ToolStripDropDownBackground =>
                this.BackColor
        }
    }
}

