private void PaintTemplateBackground() { Graphics g = Graphics; Rectangle r = ClientBounds; Color color = BackColor; if (IsTransparent) { color = ColorConverter.AlphaColor(color, 220); using (GraphicsPlus gp = new GraphicsPlus(g)) { using (SolidBrushPlus backGround = new SolidBrushPlus(color)) { gp.FillRectangle(backGround, r); } } } else { using (SolidBrush brush = new SolidBrush(color)) { g.FillRectangle(brush, r); } } }
protected virtual void OnPaintBackground(FluidPaintEventArgs e) { if (PaintBackground != null) { PaintBackground(this, e); } else { if (!BackColor.IsEmpty && BackColor != Color.Transparent) { Graphics g = e.Graphics; if (BackColor.A == 255 || BackColor.A == 0) { SolidBrush brush = Brushes.GetBrush(BackColor); g.FillRectangle(brush, e.ControlBounds); } else { using (GraphicsPlus gp = new GraphicsPlus(g)) { using (SolidBrushPlus brush = new SolidBrushPlus(BackColor)) { gp.FillRectangle(brush, e.ControlBounds); } } } } } }
/// <summary> /// Creates and paints the button bitmap of the virtual scrollbar. /// </summary> /// <param name="width">The width of the button.</param> /// <param name="height">The height of the button.</param> /// <returns>The button image.</returns> protected virtual Image CreateScrollButtonBitmap(int width, int height) { Bitmap bm = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(bm)) { int r = Math.Min(width, height / 2) - 1; if (r < 1) { r = 1; } backgroundBrush.Color = Color.Fuchsia; //g.Clear(Color.Fuchsia); g.FillRectangle(backgroundBrush, 0, 0, width, height); using (GraphicsPlus gp = new GraphicsPlus(g)) { Rectangle bounds = new Rectangle(0, 0, width - 1, height - 1); gp.SmoothingMode = SmoothingMode.None; Color color = scrollbarButtonColor; using (SolidBrushPlus brush = new SolidBrushPlus(color, true)) { gp.FillRoundRectangle(bounds, r, brush); } using (PenPlus pen = new PenPlus(ScrollBarButtonBorderColor, 1, true)) { gp.DrawRoundRectangle(bounds, r, pen); } } } return(bm); }
private void CreateObjects() { brSolid = new SolidBrushPlus(Color.CornflowerBlue); brHatch = new HatchBrush(HatchStyle.HatchStyle25Percent, Color.Black, Color.White); string bitmapPath = System.IO.Path.GetDirectoryName(GetType().Assembly.GetModules()[0].FullyQualifiedName); bitmapPath = System.IO.Path.Combine(bitmapPath, "brushPattern.bmp"); StreamOnFile sf = new StreamOnFile(bitmapPath); ImagePlus img = new ImagePlus(sf, false); brTexture = new TextureBrushPlus(img, WrapMode.WrapModeTile); brLinGrad = new LinearGradientBrush(new GpPointF(0, 0), new GpPointF(50, 50), Color.Black, Color.White); // Create rectangular path GraphicsPath path = new GraphicsPath(FillMode.FillModeAlternate); path.AddRectangle(new GpRectF(0, 0, ClientRectangle.Width, ClientRectangle.Height / 5)); // Create rectangular gradient brush // with red in center and black in the corners brPathGrad = new PathGradientBrush(path); brPathGrad.SetCenterColor(Color.Red); int count = 2; brPathGrad.SetSurroundColors(new Color[] { Color.Black, Color.Black }, ref count); }
private void CreateObjects() { brSolid = new SolidBrushPlus(Color.CornflowerBlue); penSolid = new PenPlus(Color.Red, 10); penSolid.SetEndCap(LineCap.LineCapRound); penSolid.SetStartCap(LineCap.LineCapArrowAnchor); brHatch = new HatchBrush(HatchStyle.HatchStyle25Percent, Color.Black, Color.White); penHatch = new PenPlus(brHatch, 10); penSolidTrans = new PenPlus(Color.FromArgb(-0x5f7f7f7f), 10); penSolidCustomCap = new PenPlus(Color.Black, 20); GraphicsPath path = new GraphicsPath(FillMode.FillModeAlternate); path.AddEllipse(-0.5f, -1.5f, 1, 3); CustomLineCap cap = new CustomLineCap(null, path, LineCap.LineCapFlat, 0); penSolidCustomCap.SetCustomEndCap(cap); penDash = new PenPlus(Color.Black, 5); penDash.SetDashStyle(DashStyle.DashStyleDot); brGrad = new LinearGradientBrush( new GpPointF(0, 0), new GpPointF(100, 100), Color.Black, Color.White); penGradient = new PenPlus(brGrad, 30); }