Exemplo n.º 1
0
 protected override void OnBackColorChanged(EventArgs e)
 {
     this.Text = this.BackColor.Name;
     if (BackColor.GetBrightness() > 0.5)
     {
         this.ForeColor = Color.Black;
     }
     else
     {
         this.ForeColor = Color.White;
     }
     base.OnBackColorChanged(e);
 }
Exemplo n.º 2
0
        public void UpdateButton()
        {
            BackColor = CLUTEntry.Color;
            if (BackColor.GetBrightness() > 0.5)
            {
                ForeColor = Color.Black;
            }
            else
            {
                ForeColor = Color.White;
            }

            if (CLUTEntry.SemiTransparentBit)
            {
                Text = "T";
            }
            else
            {
                Text = "";
            }
        }
Exemplo n.º 3
0
        private void OnPaintDesignMode(PaintEventArgs e)
        {
            Rectangle rc = ClientRectangle;
            Color     penColor;

            // Choose black or white pen, depending on the color of the control.
            if (BackColor.GetBrightness() < .5)
            {
                penColor = ControlPaint.Light(BackColor);
            }
            else
            {
                penColor = ControlPaint.Dark(BackColor);
            };

            using (Pen pen = new Pen(penColor))
            {
                pen.DashStyle = DashStyle.Dash;

                rc.Width--;
                rc.Height--;
                e.Graphics.DrawRectangle(pen, rc);
            }
        }
        private void PreferencesDialog_Load(object sender, EventArgs e)
        {
            if (TextColor.GetBrightness() <= 0.6f)
            {
                this.TextColorButton.ForeColor = Color.White;
            }

            if (BackColor.GetBrightness() <= 0.6f)
            {
                this.BackColorButton.ForeColor = Color.White;
            }

            //set button colors and font on load
            this.TextColorButton.BackColor = TextColor;
            this.BackColorButton.BackColor = BackColor;
            this.TextFontButton.Font       = Font;

            //set textbox text on load
            this.DocumentSizeWidthTextBox.Text  = DocumentSize.Width.ToString();
            this.DocumentSizeHeightTextBox.Text = DocumentSize.Height.ToString();
            this.DocumentLocationXTextBox.Text  = DocumentLocation.X.ToString();
            this.DocumentLocationYTextBox.Text  = DocumentLocation.Y.ToString();
            this.DocumentTitleTextBox.Text      = DocumentTitle;
        }
Exemplo n.º 5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, ClientSize.Width - Padding.Horizontal, ClientSize.Height - Padding.Vertical);
            //e.Graphics.DrawRectangle( Pens.Magenta, basearea.X, basearea.Y, basearea.Width - 1, basearea.Height - 1 );

            Rectangle imagearea = new Rectangle(basearea.X, basearea.Y, ImageSize.Width, ImageSize.Height);

            switch (ImageAlign)
            {
            case ContentAlignment.TopLeft:
                break;

            case ContentAlignment.MiddleLeft:
                imagearea.Y += (basearea.Height - imagearea.Height) / 2;
                break;

            case ContentAlignment.BottomLeft:
                imagearea.Y = basearea.Bottom - imagearea.Height;
                break;

            case ContentAlignment.TopCenter:
                imagearea.X += (basearea.Width - imagearea.Width) / 2;
                break;

            case ContentAlignment.MiddleCenter:
                imagearea.X += (basearea.Width - imagearea.Width) / 2;
                imagearea.Y += (basearea.Height - imagearea.Height) / 2;
                break;

            case ContentAlignment.BottomCenter:
                imagearea.X += (basearea.Width - imagearea.Width) / 2;
                imagearea.Y  = basearea.Bottom - imagearea.Height;
                break;

            case ContentAlignment.TopRight:
                imagearea.X = basearea.Right - imagearea.Width;
                break;

            case ContentAlignment.MiddleRight:
                imagearea.X  = basearea.Right - imagearea.Width;
                imagearea.Y += (basearea.Height - imagearea.Height) / 2;
                break;

            case ContentAlignment.BottomRight:
                imagearea.X = basearea.Right - imagearea.Width;
                imagearea.Y = basearea.Bottom - imagearea.Height;
                break;
            }


            if (Image != null)
            {
                if (Enabled)
                {
                    e.Graphics.DrawImage(Image, imagearea);
                }
                else
                {
                    ControlPaint.DrawImageDisabled(e.Graphics, Image, imagearea.X, imagearea.Y, BackColor);
                }

                //e.Graphics.DrawRectangle( Pens.Orange, imagearea.X, imagearea.Y, imagearea.Width - 1, imagearea.Height - 1 );
            }


            Color textcolor;

            if (Enabled)
            {
                textcolor = ForeColor;
            }
            else
            {
                if (BackColor.GetBrightness() < SystemColors.Control.GetBrightness())
                {
                    textcolor = ControlPaint.Dark(BackColor);
                }
                else
                {
                    textcolor = SystemColors.ControlDark;
                }
            }

            var textarea = GetTextArea(basearea);

            //e.Graphics.DrawRectangle( Pens.Orange, textrect.X, textrect.Y, textrect.Width - 1, textrect.Height - 1 );
            TextRenderer.DrawText(e.Graphics, Text, Font, textarea, textcolor, GetTextFormat());

            //base.OnPaint( e );
        }