private void Draw(Graphics graphics, GraphicsPlus g) { StringFormat sf = new StringFormat(); sf.LineAlignment = sf.Alignment = System.Drawing.StringAlignment.Center; int deltaH = ClientRectangle.Height / 8; GpRectF rc = new GpRectF(0, 0, ClientRectangle.Width, deltaH); RectangleF rcf = new RectangleF(0, 0, ClientRectangle.Width, deltaH); using (SolidBrush brText = new SolidBrush(Color.Black)) using (Font fnt = new Font("Tahoma", 9, System.Drawing.FontStyle.Bold)) { penSolid.SetWidth(15); g.DrawLine(penSolid, 5, rcf.Top + 10, rc.Width - 10, rcf.Top + 10); graphics.DrawString("Solid with caps", fnt, brText, rcf, sf); rcf.Y += deltaH; rc.Offset(0, deltaH); SmoothingMode mode = g.GetSmoothingMode(); g.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias); penSolid.SetColor(Color.Blue); g.DrawLine(penSolid, 5, rcf.Top + 10, rc.Width - 10, rcf.Top + 10); graphics.DrawString("Solid with caps and anitalising", fnt, brText, rcf, sf); rcf.Y += deltaH; rc.Offset(0, deltaH); g.DrawLine(penHatch, 5, rcf.Top + 10, rc.Width - 10, rcf.Top + 10); graphics.DrawString("Hatched", fnt, brText, rcf, sf); rcf.Y += deltaH; rc.Offset(0, deltaH); penSolidTrans.SetWidth(20); penSolidTrans.SetLineCap(LineCap.LineCapRound, LineCap.LineCapDiamondAnchor, DashCap.DashCapRound); graphics.DrawString("Solid with transparency", fnt, brText, rcf, sf); g.DrawLine(penSolidTrans, 15, rcf.Top + 10, rc.Width - 30, rcf.Top + 10); rcf.Y += deltaH; rc.Offset(0, deltaH); g.SetSmoothingMode(SmoothingMode.SmoothingModeAntiAlias); brText.Color = Color.White; g.DrawLine(penSolidCustomCap, 15, rcf.Top + 15, rc.Width - 50, rcf.Top + 15); graphics.DrawString("Custom cap", fnt, brText, rcf, sf); rcf.Y += deltaH; rc.Offset(0, deltaH); g.SetSmoothingMode(mode); brText.Color = Color.Gray; g.DrawLine(penDash, 5, rcf.Top + 10, rc.Width - 10, rcf.Top + 10); graphics.DrawString("Dash (round)", fnt, brText, rcf, sf); rcf.Y += deltaH; rc.Offset(0, deltaH); brText.Color = Color.White; g.DrawLine(penGradient, 15, rcf.Top + 20, rc.Width - 30, rcf.Top + 20); graphics.DrawString("Gradient brush-based", fnt, brText, rcf, sf); rcf.Y += deltaH; rc.Offset(0, deltaH); } }
private void Draw(Graphics graphics, GraphicsPlus g) { int deltaH = ClientRectangle.Height / 5; GpRectF rc = new GpRectF(0, 0, ClientRectangle.Width, deltaH); g.FillRectangle(brPathGrad, rc); rc.Offset(0, deltaH); g.FillRectangle(brSolid, rc); rc.Offset(0, deltaH); g.FillRectangle(brHatch, rc); rc.Offset(0, deltaH); g.FillRectangle(brLinGrad, rc); rc.Offset(0, deltaH); g.FillRectangle(brTexture, rc); rc.Offset(0, deltaH); Rectangle rcText = new Rectangle(0, 0, ClientRectangle.Width, deltaH); StringFormat sf = new StringFormat(); sf.LineAlignment = sf.Alignment = System.Drawing.StringAlignment.Center; using (SolidBrush brText =new SolidBrush(Color.White)) using (Font fnt = new Font("Tahoma", 9, System.Drawing.FontStyle.Bold)) { graphics.DrawString("PathGradient Brush", fnt, brText, rcText, sf); rcText.Offset(0, deltaH); brText.Color = Color.Black; graphics.DrawString("Solid Brush", fnt, brText, rcText, sf); rcText.Offset(0, deltaH); graphics.DrawString("Hatch Brush", fnt, brText, rcText, sf); rcText.Offset(0, deltaH); graphics.DrawString("LinearGradient Brush", fnt, brText, rcText, sf); rcText.Offset(0, deltaH); graphics.DrawString("Texture Brush", fnt, brText, rcText, sf); rcText.Offset(0, deltaH); } }