private void createimages() { if (_iconoBoton != null) { Color style = MetroPaint.GetStyleColor(Style); _styleColorImg = MetroImage.WhiteBlackToTransparentFore(new Bitmap(_iconoBoton), style); if (!applyGrayToIcon) { Color fore = MetroPaint.ForeColor.IconButton.Normal(MetroThemeStyle.Light); _lightimg = MetroImage.WhiteBlackToTransparentForeStyle(new Bitmap(_iconoBoton), fore, style); fore = MetroPaint.ForeColor.IconButton.Normal(MetroThemeStyle.Dark); _darkimg = MetroImage.WhiteBlackToTransparentForeStyle(new Bitmap(_iconoBoton), fore, style); fore = MetroPaint.ForeColor.IconButton.Hover(MetroThemeStyle.Light); _lightlightimg = MetroImage.WhiteBlackToTransparentForeStyle(new Bitmap(_iconoBoton), fore, style); fore = MetroPaint.ForeColor.IconButton.Hover(MetroThemeStyle.Dark); _darklightimg = MetroImage.WhiteBlackToTransparentForeStyle(new Bitmap(_iconoBoton), fore, style); fore = MetroPaint.ForeColor.IconButton.Disable(MetroThemeStyle.Light); _disableLight = MetroImage.WhiteBlackToTransparentForeStyle(new Bitmap(_iconoBoton), fore, fore); _disableLight = MetroImage.ConvertGrayScale(_disableLight); fore = MetroPaint.ForeColor.IconButton.Disable(MetroThemeStyle.Dark); _disableDark = MetroImage.WhiteBlackToTransparentForeStyle(new Bitmap(_iconoBoton), fore, fore); _disableDark = MetroImage.ConvertGrayScale(_disableDark); } else { if (useCustomBackColor) { Color fore = MetroPaint.ForeColor.IconButton.Normal(MetroThemeStyle.Light); Color back = BackColor; _lightimg = MetroImage.WhiteBlackToBackFore(new Bitmap(_iconoBoton), back, fore); fore = MetroPaint.ForeColor.IconButton.Normal(MetroThemeStyle.Dark); _darkimg = MetroImage.WhiteBlackToBackFore(new Bitmap(_iconoBoton), back, fore); fore = MetroPaint.ForeColor.IconButton.Hover(MetroThemeStyle.Dark); _lightlightimg = MetroImage.WhiteBlackToBackFore(new Bitmap(_iconoBoton), back, fore); _darklightimg = _lightlightimg; } else { Color fore = MetroPaint.ForeColor.IconButton.Normal(MetroThemeStyle.Light); _lightimg = MetroImage.WhiteBlackToTransparentFore(new Bitmap(_iconoBoton), fore); fore = MetroPaint.ForeColor.IconButton.Normal(MetroThemeStyle.Dark); _darkimg = MetroImage.WhiteBlackToTransparentFore(new Bitmap(_iconoBoton), fore); fore = MetroPaint.ForeColor.IconButton.Hover(MetroThemeStyle.Dark); _lightlightimg = MetroImage.WhiteBlackToTransparentFore(new Bitmap(_iconoBoton), fore); _darklightimg = _lightlightimg; } } } }
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) { if (e.Item.Selected) { e.TextColor = MetroImage.ContrastColor(MetroPaint.GetStyleColor(_style)); } else { e.TextColor = MetroImage.ContrastColor(MetroPaint.BackColor.Form(_theme)); } base.OnRenderItemText(e); }
protected override void OnPaint(PaintEventArgs e) { Color backColor = MetroPaint.BackColor.Form(Theme); Color foreColor = MetroPaint.ForeColor.Title(Theme); e.Graphics.Clear(backColor); using (SolidBrush b = new SolidBrush(BackColor)) // MetroPaint.GetStyleBrush(Style)) { //Rectangle topRect = new Rectangle(0, 0, Width, borderWidth); //e.Graphics.FillRectangle(b, topRect); e.Graphics.FillRectangle(b, new RectangleF(0, 0, Width, Height)); } using (SolidBrush b = new SolidBrush(HeaderColor)) // MetroPaint.GetStyleBrush(Style)) { e.Graphics.FillRectangle(b, new RectangleF(2, 2, Width - 4, Padding.Top + Padding.Bottom - 2)); } if (BorderShow) { Color bcolor = UseCustomBorderColor ? BorderColor : (null != metroStyleManager) ? MetroPaint.GetStyleColor(metroStyleManager.Style) : BorderColor; using (Pen pen = new Pen(bcolor)) { e.Graphics.DrawRectangle(pen, new Rectangle(0, 0, Width - 1, Height - 1)); } } if (HeaderImage != null) { int width = Padding.Top - 1 - HeaderImagePadding.Top - HeaderImagePadding.Bottom; int height = width; Image img = MetroImage.ResizeImage(HeaderImage, new Rectangle(0, 0, width, height)); e.Graphics.DrawImage(img, HeaderImagePadding.Left, HeaderImagePadding.Top); int titleleft = width + HeaderImagePadding.Left + HeaderImagePadding.Right + TitlePadding.Left; int titletop = TitlePadding.Top; using (SolidBrush TB = new SolidBrush(TitleColor)) { string text = Title; if ((null != TitleAppendText) && (0 != TitleAppendText.Length)) { text += " - " + TitleAppendText; } e.Graphics.DrawString(text, TitleFont, TB, new Point(titleleft, titletop), StringFormat.GenericDefault); } } else { int titleleft = TitlePadding.Left; int titletop = TitlePadding.Top; using (SolidBrush TB = new SolidBrush(TitleColor)) { e.Graphics.DrawString(Title, TitleFont, TB, new Point(titleleft, titletop), StringFormat.GenericDefault); } } if (backImage != null && backMaxSize != 0) { Image img = MetroImage.ResizeImage(backImage, new Rectangle(0, 0, backMaxSize, backMaxSize)); if (_imageinvert) { img = MetroImage.ResizeImage((Theme == MetroThemeStyle.Dark) ? _image : backImage, new Rectangle(0, 0, backMaxSize, backMaxSize)); } switch (backLocation) { case BackLocation.TopLeft: e.Graphics.DrawImage(img, 0 + backImagePadding.Left, 0 + backImagePadding.Top); break; case BackLocation.TopRight: e.Graphics.DrawImage(img, ClientRectangle.Right - (backImagePadding.Right + img.Width), 0 + backImagePadding.Top); break; case BackLocation.BottomLeft: e.Graphics.DrawImage(img, 0 + backImagePadding.Left, ClientRectangle.Bottom - (img.Height + backImagePadding.Bottom)); break; case BackLocation.BottomRight: e.Graphics.DrawImage(img, ClientRectangle.Right - (backImagePadding.Right + img.Width), ClientRectangle.Bottom - (img.Height + backImagePadding.Bottom)); break; } } if (Resizable && (SizeGripStyle == SizeGripStyle.Auto || SizeGripStyle == SizeGripStyle.Show)) { using (SolidBrush b = new SolidBrush(MetroPaint.ForeColor.Button.Disabled(Theme))) { Size resizeHandleSize = new Size(2, 2); e.Graphics.FillRectangles(b, new Rectangle[] { new Rectangle(new Point(ClientRectangle.Width - 6, ClientRectangle.Height - 6), resizeHandleSize), new Rectangle(new Point(ClientRectangle.Width - 10, ClientRectangle.Height - 10), resizeHandleSize), new Rectangle(new Point(ClientRectangle.Width - 10, ClientRectangle.Height - 6), resizeHandleSize), new Rectangle(new Point(ClientRectangle.Width - 6, ClientRectangle.Height - 10), resizeHandleSize), new Rectangle(new Point(ClientRectangle.Width - 14, ClientRectangle.Height - 6), resizeHandleSize), new Rectangle(new Point(ClientRectangle.Width - 6, ClientRectangle.Height - 14), resizeHandleSize) }); } } }