コード例 #1
0
ファイル: NomadButton.cs プロジェクト: NanoLP/FC3Editor
        protected override void OnPaint(PaintEventArgs pevent)
        {
            Graphics     graphics     = pevent.Graphics;
            ButtonShader buttonShader = ButtonShader.normalShader;

            if (this.mouseOver)
            {
                buttonShader = ButtonShader.hoverShader;
            }
            if (this.pushed)
            {
                buttonShader = ButtonShader.pushShader;
            }
            if (!base.Enabled)
            {
                buttonShader = ButtonShader.disableShader;
            }
            Rectangle clientRectangle = base.ClientRectangle;

            using (Pen pen = new Pen(this.BackColor))
            {
                graphics.DrawRectangle(pen, clientRectangle.X, clientRectangle.Y, clientRectangle.Width - 1, clientRectangle.Height - 1);
            }
            clientRectangle.Inflate(-1, -1);
            buttonShader.DrawButton(graphics, clientRectangle, this.BackColor);
            if (this.Focused)
            {
                Rectangle rectangle = clientRectangle;
                rectangle.Inflate(-2, -2);
                ControlPaint.DrawFocusRectangle(graphics, rectangle);
            }
            if (base.Image != null)
            {
                ImageAttributes imageAttributes = new ImageAttributes();
                if (!base.Enabled)
                {
                    imageAttributes.SetColorMatrix(NomadButton.disableMatrix);
                }
                Rectangle destRect = new Rectangle(clientRectangle.X + (clientRectangle.Width - base.Image.Width) / 2, clientRectangle.Y + (clientRectangle.Height - base.Image.Height) / 2, base.Image.Width, base.Image.Height);
                graphics.DrawImage(base.Image, destRect, 0, 0, base.Image.Width, base.Image.Height, GraphicsUnit.Pixel, imageAttributes);
                return;
            }
            Rectangle rect = clientRectangle;

            if (this.pushed)
            {
                rect.Offset(1, 1);
            }
            Color controlText = SystemColors.ControlText;

            if (!base.Enabled)
            {
                controlText = NomadButton.disableText;
            }
            buttonShader.DrawText(graphics, rect, this.Text, this.Font, controlText);
        }
コード例 #2
0
ファイル: ButtonShader.cs プロジェクト: Azerothian/fc3editor
 public static void InitShaders()
 {
     if (ButtonShader.shadersInit)
     {
         return;
     }
     float hue;
     float saturation;
     float num;
     ColorUtils.RGBToHSL(SystemColors.ControlLight, out hue, out saturation, out num);
     ButtonShader.normalShader = new ButtonShader(hue, saturation, 1f, 1f, 0.72f, 0.63f, 0.33f, 1);
     ButtonShader.hoverShader = new ButtonShader(hue, saturation, 1f, 1f, 0.87f, 0.72f, 0.33f, 1);
     ButtonShader.pushShader = new ButtonShader(hue, saturation, 0.5f, 0.65f, 0.95f, 1f, 0.33f, 0);
     ButtonShader.disableShader = new ButtonShader(hue, saturation, 0.97f, 0.93f, 0.9f, 0.78f, 0.83f, 0);
     ColorUtils.RGBToHSL(SystemColors.Highlight, out hue, out saturation, out num);
     ButtonShader.checkShader = new ButtonShader(hue, 0.75f, 0.8f, 0.7f, 0.95f, 1f, 0.24f, 0);
     ButtonShader.shadersInit = true;
 }
コード例 #3
0
ファイル: ButtonShader.cs プロジェクト: NanoLP/FC3Editor
        public static void InitShaders()
        {
            if (ButtonShader.shadersInit)
            {
                return;
            }
            float hue;
            float saturation;
            float num;

            ColorUtils.RGBToHSL(SystemColors.ControlLight, out hue, out saturation, out num);
            ButtonShader.normalShader  = new ButtonShader(hue, saturation, 1f, 1f, 0.72f, 0.63f, 0.33f, 1);
            ButtonShader.hoverShader   = new ButtonShader(hue, saturation, 1f, 1f, 0.87f, 0.72f, 0.33f, 1);
            ButtonShader.pushShader    = new ButtonShader(hue, saturation, 0.5f, 0.65f, 0.95f, 1f, 0.33f, 0);
            ButtonShader.disableShader = new ButtonShader(hue, saturation, 0.97f, 0.93f, 0.9f, 0.78f, 0.83f, 0);
            ColorUtils.RGBToHSL(SystemColors.Highlight, out hue, out saturation, out num);
            ButtonShader.checkShader = new ButtonShader(hue, 0.75f, 0.8f, 0.7f, 0.95f, 1f, 0.24f, 0);
            ButtonShader.shadersInit = true;
        }
コード例 #4
0
ファイル: NomadCheckButton.cs プロジェクト: NanoLP/FC3Editor
 public NomadCheckButton()
 {
     ButtonShader.InitShaders();
 }
コード例 #5
0
ファイル: NomadRadioButton.cs プロジェクト: NanoLP/FC3Editor
 public NomadRadioButton()
 {
     ButtonShader.InitShaders();
 }