本文整理汇总了C#中System.Drawing.Drawing2D.PathGradientBrush.SetSigmaBellShape方法的典型用法代码示例。如果您正苦于以下问题:C# PathGradientBrush.SetSigmaBellShape方法的具体用法?C# PathGradientBrush.SetSigmaBellShape怎么用?C# PathGradientBrush.SetSigmaBellShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.PathGradientBrush
的用法示例。
在下文中一共展示了PathGradientBrush.SetSigmaBellShape方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderFrameByCenter
protected override void RenderFrameByCenter(PaintEventArgs e, Rectangle r)
{
Graphics g = e.Graphics;
using (GraphicsPath path = new GraphicsPath())
{
path.AddRectangle(GaugeFrame.Bounds);
using (PathGradientBrush br = new PathGradientBrush(path))
{
br.CenterPoint = GaugeFrame.Center;
br.CenterColor = GaugeFrame.FrameColor.Start;
br.SurroundColors = new Color[] { GaugeFrame.FrameColor.End };
br.SetSigmaBellShape(GaugeFrame.FrameSigmaFocus, GaugeFrame.FrameSigmaScale);
g.FillRectangle(br, GaugeFrame.Bounds);
}
path.AddRectangle(r);
using (PathGradientBrush br = new PathGradientBrush(path))
{
br.CenterPoint = GaugeFrame.Center;
br.CenterColor = GaugeFrame.FrameColor.End;
br.SurroundColors = new Color[] { GaugeFrame.FrameColor.Start };
g.FillRectangle(br, r);
}
}
RenderFrameBorder(g, GaugeFrame.Bounds);
}
示例2: FillButton
/// <summary>
/// Fills titlebar button.
/// </summary>
/// <param name="rcBtn">Button bounding rectangle.</param>
/// <param name="g">Graphics object.</param>
/// <param name="clrStart">Color used to fill the button.</param>
/// <param name="clrEnd">Color used to fill the outer glow.</param>
/// <param name="XBoxClip">Path to perform clipping tasks.</param>
private void FillButton(Rectangle rcBtn, Graphics g, Color clrStart, Color clrEnd, GraphicsPath XBoxClip)
{
switch (m_eFillMode)
{
case EButtonFillMode.UpperGlow:
rcBtn.Height = 3;
using (LinearGradientBrush lgb = new LinearGradientBrush(rcBtn, clrStart, clrEnd, LinearGradientMode.Vertical))
{
g.FillRectangle(lgb, rcBtn);
}
break;
case EButtonFillMode.FullFill:
// restrict drawing inside button box / rectangle:
g.SetClip(XBoxClip);
g.SetClip(rcBtn, CombineMode.Intersect);
#region Fill button
using (SolidBrush sb = new SolidBrush(clrStart))
{
g.FillRectangle(sb, rcBtn);
}
#endregion
using (EAntiAlias xaa = new EAntiAlias(g))
{
#region Fill shine
using (GraphicsPath XBtnGlow = new GraphicsPath())
{
XBtnGlow.AddEllipse(rcBtn.Left - 5, rcBtn.Bottom - rcBtn.Height / 2 + 3, rcBtn.Width + 11, rcBtn.Height + 11);
using (PathGradientBrush pgb = new PathGradientBrush(XBtnGlow))
{
pgb.CenterColor = Color.FromArgb(235, Color.White);
pgb.SurroundColors = new Color[] { Color.FromArgb(0, clrEnd) };
pgb.SetSigmaBellShape(0.8f);
g.FillPath(pgb, XBtnGlow);
}
}
#endregion
#region Fill upper glow
rcBtn.Height = rcBtn.Height / 2 - 2;
using (LinearGradientBrush lgb = new LinearGradientBrush(rcBtn, Color.FromArgb(80, Color.White), Color.FromArgb(140, Color.White), LinearGradientMode.Vertical))
{
using (GraphicsPath XGlowPath = EFormHelper.RoundRect((RectangleF)rcBtn, 0, 0, 4, 4))
{
lgb.WrapMode = WrapMode.TileFlipXY;
g.FillPath(lgb, XGlowPath);
}
}
#endregion
}
// reset clipping back:
g.ResetClip();
break;
}
}
示例3: DrawPanelSelected
//.........这里部分代码省略.........
e.Panel.Bounds.Bottom);
Rectangle darkBorder = Rectangle.FromLTRB(
e.Panel.Bounds.Left,
e.Panel.Bounds.Top,
e.Panel.Bounds.Right - 1,
e.Panel.Bounds.Bottom);
Rectangle outerLightBorder = Rectangle.FromLTRB(
e.Panel.Bounds.Left,
e.Panel.Bounds.Top,
e.Panel.Bounds.Right,
e.Panel.Bounds.Bottom);
//Glow appears as a tall elipse, rather than circle
Rectangle glowR = new Rectangle(
e.Panel.Bounds.Left + (int)(0.1 * e.Panel.Bounds.Width),
e.Panel.Bounds.Top,
e.Panel.Bounds.Width - (int)(0.2 * e.Panel.Bounds.Width),
(2 * e.Panel.Bounds.Height) - 1);
//Highlight glow in panel
using (GraphicsPath radialPath = new GraphicsPath())
{
radialPath.AddArc(glowR, 180, 180);
radialPath.CloseFigure();
PathGradientBrush gr = new PathGradientBrush(radialPath);
gr.CenterPoint = new PointF(
Convert.ToSingle(innerLightBorder.Left + innerLightBorder.Width / 2),
Convert.ToSingle(innerLightBorder.Bottom));
gr.CenterColor = ColorTable.PanelBackgroundSelected;
gr.SurroundColors = new Color[] { Color.Transparent };
gr.SetSigmaBellShape(1.0f, 1.0f);
SmoothingMode sm = e.Graphics.SmoothingMode;
e.Graphics.SmoothingMode = SmoothingMode.None;
e.Graphics.FillPath(gr, radialPath);
e.Graphics.SmoothingMode = sm;
gr.Dispose();
}
// Panel divider left highlight
using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(90, Color.White),
Color.FromArgb(220, Color.White), LinearGradientMode.Vertical))
{
Blend blend = new Blend();
blend.Factors = new float[] { 0f, 1f, 1f };
blend.Positions = new float[] { 0f, 0.5f, 1f };
blendBrush.Blend = blend;
blendBrush.WrapMode = WrapMode.TileFlipX; //This is here to stop an annoying single pixel being drawn at the top of the line.
using (Pen p = new Pen(blendBrush))
{
SmoothingMode sm = e.Graphics.SmoothingMode;
e.Graphics.SmoothingMode = SmoothingMode.None;
e.Graphics.DrawLine(p, innerLightBorder.Right, innerLightBorder.Top, innerLightBorder.Right, innerLightBorder.Bottom);
e.Graphics.SmoothingMode = sm;
}
}
// Panel divider right highlight
using (LinearGradientBrush blendBrush = new LinearGradientBrush(e.Panel.Bounds, Color.FromArgb(30, ColorTable.PanelLightBorder),
ColorTable.PanelLightBorder, LinearGradientMode.Vertical))
{
示例4: UpdateBitmapAtImageIndex
/// <summary>
/// Update the button bitmap because the color changed
/// </summary>
protected internal virtual void UpdateBitmapAtImageIndex()
{
// Get the bitmap on which we will draw an icon.
Image image;
if (this.Parent == null || ((ToolStrip)this.Parent).ImageList == null)
return;
if (this.ImageIndex >= 0)
image = this.Parent.ImageList.Images[this.ImageIndex];
else
image = this.Image;
if( image.Width != templateImage.Width ||
image.Height != templateImage.Height ||
image.PixelFormat != templateImage.PixelFormat ) {
Graphics g = Graphics.FromImage( image );
g.Clear( Color.Transparent );
// Draw the icon as a 3D-ish sphere.
// FIXME: Use other attributes of DrawingAttributes besides color and transparency.
// Srink the circle by -1 to compensate for pixel model, and by -3x-2 more
// to compensate for ToolBarButton border.
GraphicsPath ellipse = new GraphicsPath();
ellipse.AddEllipse( new Rectangle( 0, 0, image.Size.Width - 4, image.Size.Height - 3 ) );
// We'll now need this.DrawingAttributes, so lock to make sure it isn't changed unexpectedly.
// Keep the lock until after we're done setting the bitmap to ensure it doesn't get out of sync
// with the DrawingAttributes via a race condition.
// Define the gradient to be light-colored in the middle and slightly off-center.
if( this.CurrentStylusEntry != null ) {
PathGradientBrush gradient = new PathGradientBrush( ellipse );
gradient.CenterColor = Color.WhiteSmoke;
float sqrt2 = (float)Math.Sqrt( 2d );
gradient.CenterPoint = new PointF( gradient.CenterPoint.X / sqrt2, gradient.CenterPoint.Y / sqrt2 );
Color color = Color.FromArgb( byte.MaxValue - this.CurrentStylusEntry.DrawingAttributes.Transparency,
this.CurrentStylusEntry.DrawingAttributes.Color );
gradient.SurroundColors = new Color[] { color };
gradient.SetSigmaBellShape( 1f, 0.4f );
// Fill with a white background first to make the transparency look better.
// TODO: Maybe fill with a pattern to make the transparency more obvious.
g.FillPath( new SolidBrush( Color.White ), ellipse );
// Now fill the gradient.
g.FillPath( gradient, ellipse );
}
// Surround it with a thin black border. In the unlikely case
// that the current DrawingAttributes is null, this is all that will be visible.
g.DrawPath( new Pen( Color.Black, 0.1f ), ellipse );
// Force the button to reload its image (even though it's probably the same object as before).
this.Parent.ImageList.Images[this.ImageIndex] = image;
} else {
// Sanity Check
if( this.CurrentStylusEntry != null ) {
Color basecolor = this.CurrentStylusEntry.DrawingAttributes.Color;
// Draw each pixel in the image
for( int y = 0; y < this.templateImage.Height; y++ ) {
for( int x = 0; x < this.templateImage.Width; x++ ) {
Color col = templateImage.GetPixel( x, y );
// Check if this pixel is transparent or not
if( col.A != 0 ) {
int r = ((int)col.R + (int)basecolor.R) - 119;
r = Math.Min( 255, Math.Max( 0, r ) );
int g = ((int)col.G + (int)basecolor.G) - 119;
g = Math.Min( 255, Math.Max( 0, g ) );
int b = ((int)col.B + (int)basecolor.B) - 119;
b = Math.Min( 255, Math.Max( 0, b ) );
((Bitmap)image).SetPixel( x, y,
Color.FromArgb( col.A, r, g, b ) );
} else {
((Bitmap)image).SetPixel( x, y,
Color.FromArgb( 0, 0, 0, 0 ) );
}
}
}
// Replace the existing image with this one
Misc.ImageListHelper.Replace( (Bitmap)image, this.ImageIndex, this.Parent.ImageList );
this.Image = image;
this.Invalidate();
}
}
}
示例5: GenerateRadialBrush
/// <summary>
/// Approximates a radial brush using a high-rez PathGradientBrush.
/// </summary>
/// <param name="inner"></param>
/// <param name="outer"></param>
/// <param name="pt"></param>
/// <param name="width"></param>
/// <returns></returns>
public static Brush GenerateRadialBrush(Color inner, Color outer, PointF pt, float width)
{
//This should approximate one outer point per pixel.
PointF[] path = new PointF[(int)Math.Round(width * 2 * Math.PI) + 1];
for (int i = 0; i < path.Length - 1; i++)
{
double radians = ((double)i - width) / width; //calculate the radians at this index.
//Calculate a point based off the radians.
path[i] = new PointF((float)(Math.Sin(radians) * width + pt.X), (float)(Math.Cos(radians) * width + pt.Y));
}
path[path.Length - 1] = path[0]; //Loop back to complete the circle.
PathGradientBrush b = new PathGradientBrush(path);
b.CenterColor = inner;
b.CenterPoint = pt;
b.WrapMode = WrapMode.Clamp;
//All outer colors are the same.
Color[] colors = new Color[path.Length];
for (int i = 0; i < colors.Length; i++) colors[i] = outer;
b.SurroundColors = colors;
b.SetSigmaBellShape(1);
return b;
}
示例6: PrepareBitmap
/// <summary>
/// Prepares the bitmap used to draw the window. Layered windows (like this one) use a bitmap for their
/// content, including alpha channel.
/// </summary>
protected void PrepareBitmap(bool showCancelButton)
{
if (contentBitmap != null)
contentBitmap.Dispose();
contentBitmap = new Bitmap(Width, Height);
GraphicsPath path = GetPath();
GraphicsPath innerPath = (GraphicsPath)path.Clone();
// Increase size of the outline by the shadow size and move it to the center.
// The inner path keeps the original bounds for clipping.
Matrix matrix = new Matrix();
float offsetX = Width / 2;
float offsetY = Height / 2;
matrix.Translate(offsetX + shadowOffset, offsetY + shadowOffset);
matrix.Scale(1 + (2 * shadowSize + borderSize) / (float)baseSize.Width, 1 + (2 * shadowSize + borderSize) / (float)baseSize.Height);
path.Transform(matrix);
// Also move the inner part to its final place.
matrix.Reset();
matrix.Translate(offsetX, offsetY);
innerPath.Transform(matrix);
Graphics g = Graphics.FromImage(contentBitmap);
g.SmoothingMode = SmoothingMode.HighQuality;
using (Brush brush = new SolidBrush(Color.FromArgb(10, 0, 0, 0)))
g.FillRectangle(brush, ClientRectangle);
// Fill interior.
using (Brush brush = new SolidBrush(Color.FromArgb(191, 0, 0, 0)))
g.FillPath(brush, innerPath);
// ... and draw border around the interior.
using (Pen borderPen = new Pen(Color.FromArgb(200, Color.White)))
{
borderPen.EndCap = LineCap.Round;
borderPen.StartCap = LineCap.Round;
borderPen.Width = borderSize;
GraphicsPath borderPath = (GraphicsPath)innerPath.Clone();
borderPath.Widen(borderPen);
using (SolidBrush brush = new SolidBrush(Color.FromArgb(255, Color.White)))
g.FillPath(brush, borderPath);
// Clip out interior. Exclude both, the panel itself as well as its border.
using (Region region = new Region(innerPath))
g.SetClip(region, CombineMode.Exclude);
innerPath.Widen(borderPen);
using (Region region = new Region(innerPath))
g.SetClip(region, CombineMode.Exclude);
}
using (PathGradientBrush backStyle = new PathGradientBrush(path))
{
backStyle.CenterColor = shadowColor;
backStyle.SurroundColors = new Color[] { Color.Transparent };
// Make a smooth fade out of the shadow color using the built-in sigma bell curve generator.
backStyle.SetSigmaBellShape(0.4f, 1f);
// Now draw the shadow.
g.FillPath(backStyle, path);
}
// Remove clipping for the remaining interior.
g.ResetClip();
RectangleF innerBounds = innerPath.GetBounds();
Point targetLocation = pictureBox1.Location;
targetLocation.Offset((int)innerBounds.Left, (int)innerBounds.Top);
g.DrawImageUnscaled(pictureBox1.Image, targetLocation);
// Message text output.
using (StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox))
{
targetLocation = label1.Location;
targetLocation.Offset((int)innerBounds.Left, (int)innerBounds.Top);
RectangleF textBounds = new RectangleF(targetLocation,
new SizeF(
innerBounds.Right - targetLocation.X - Padding.Right,
innerBounds.Bottom - targetLocation.Y - Padding.Bottom
)
);
path.Dispose();
innerPath.Dispose();
using (Brush textBrush = new SolidBrush(label1.ForeColor))
g.DrawString(label1.Text, label1.Font, textBrush, textBounds, format);
targetLocation = label2.Location;
targetLocation.Offset((int)innerBounds.Left, (int)innerBounds.Top);
textBounds = new RectangleF(targetLocation,
new SizeF(
innerBounds.Right - targetLocation.X - Padding.Right,
innerBounds.Bottom - targetLocation.Y - Padding.Bottom
//.........这里部分代码省略.........
示例7: creat_image
private void creat_image()
{
Point point;
int num;
GraphicsPath path;
PathGradientBrush brush;
System.Drawing.Color[] colorArray;
Bitmap image = new Bitmap(0x1388, 0x1388);
Graphics graphics = Graphics.FromImage(image);
if (this.comboBox1.SelectedIndex == 4)
{
this.button18.Visible = false;
this.button19.Visible = false;
this.button20.Visible = false;
this.label23.Visible = false;
this.numericUpDown5.Visible = false;
point = new Point(0x9c4, 0x9c4);
num = (int) (2500.0 / Math.Cos(45.0));
path = new GraphicsPath();
path.AddEllipse((int) (point.X - num), (int) (point.Y - num), (int) (2 * num), (int) (2 * num));
brush = new PathGradientBrush(path) {
CenterPoint = (PointF) point,
CenterColor = this.button11.BackColor
};
colorArray = new System.Drawing.Color[] { this.button10.BackColor };
brush.SurroundColors = colorArray;
brush.SetSigmaBellShape((float) this.numericUpDown2.Value);
graphics.FillEllipse(brush, (int) (point.X - num), (int) (point.Y - num), (int) (2 * num), (int) (2 * num));
brush.Dispose();
graphics.Dispose();
this.pictureBox3.Image = image;
}
else
{
Rectangle rectangle;
LinearGradientBrush brush2;
Point point2;
int num2;
GraphicsPath path2;
PathGradientBrush brush3;
if (this.comboBox1.SelectedIndex == 5)
{
this.button18.Visible = true;
this.button19.Visible = true;
this.button20.Visible = true;
this.label23.Visible = true;
this.numericUpDown5.Visible = true;
rectangle = new Rectangle {
Width = 0x1388,
Height = 0x1388
};
brush2 = null;
brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button19.BackColor, LinearGradientMode.Vertical);
brush2.SetSigmaBellShape((float) this.numericUpDown2.Value);
graphics.FillRectangle(brush2, 0, 0, 0x1388, 0x1388);
brush2.Dispose();
point2 = new Point(0x9c4, 0x9c4);
num2 = (int) (1000M * this.numericUpDown5.Value);
path2 = new GraphicsPath();
path2.AddEllipse((int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
brush3 = new PathGradientBrush(path2) {
CenterPoint = (PointF) point2,
CenterColor = this.button18.BackColor
};
colorArray = new System.Drawing.Color[] { this.button11.BackColor };
brush3.SurroundColors = colorArray;
graphics.FillEllipse(brush3, (int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
brush3.Dispose();
graphics.Dispose();
this.pictureBox3.Image = image;
}
else if (this.comboBox1.SelectedIndex == 6)
{
this.button18.Visible = true;
this.button19.Visible = true;
this.button20.Visible = true;
this.label23.Visible = true;
this.numericUpDown5.Visible = true;
rectangle = new Rectangle {
Width = 0x1388,
Height = 0x1388
};
brush2 = null;
brush2 = new LinearGradientBrush(rectangle, this.button10.BackColor, this.button19.BackColor, LinearGradientMode.Horizontal);
brush2.SetSigmaBellShape((float) this.numericUpDown2.Value);
graphics.FillRectangle(brush2, 0, 0, 0x1388, 0x1388);
brush2.Dispose();
point2 = new Point(0x9c4, 0x9c4);
num2 = (int) (1000M * this.numericUpDown5.Value);
path2 = new GraphicsPath();
path2.AddEllipse((int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
brush3 = new PathGradientBrush(path2) {
CenterPoint = (PointF) point2,
CenterColor = this.button18.BackColor
};
colorArray = new System.Drawing.Color[] { this.button11.BackColor };
brush3.SurroundColors = colorArray;
graphics.FillEllipse(brush3, (int) (point2.X - num2), (int) (point2.Y - num2), (int) (2 * num2), (int) (2 * num2));
brush3.Dispose();
graphics.Dispose();
//.........这里部分代码省略.........
示例8: RenderBackByCenter
protected override void RenderBackByCenter(PaintEventArgs e, Rectangle r)
{
Graphics g = e.Graphics;
using (GraphicsPath path = GetRoundRectPath(r))
{
using (PathGradientBrush br = new PathGradientBrush(path))
{
br.CenterColor = GaugeFrame.BackColor.Start;
br.SurroundColors = new Color[] { GaugeFrame.BackColor.End };
br.CenterPoint = GaugeFrame.Center;
br.SetSigmaBellShape(GaugeFrame.BackSigmaFocus, GaugeFrame.BackSigmaScale);
g.FillRectangle(br, r);
}
RenderBackBorder(g, path);
}
}
示例9: SetSigmaBellShape_ScaleTooBig
public void SetSigmaBellShape_ScaleTooBig ()
{
using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
pgb.SetSigmaBellShape (1, 1.01f);
}
}
示例10: SetSigmaBellShape_FocusTooSmall
public void SetSigmaBellShape_FocusTooSmall ()
{
using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
pgb.SetSigmaBellShape (-1);
}
}
示例11: SetSigmaBellShape_Scale
public void SetSigmaBellShape_Scale ()
{
using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
// max valid
pgb.SetSigmaBellShape (0, 1);
Assert.IsTrue (pgb.Transform.IsIdentity, "Transform.IsIdentity-1");
// min valid
pgb.SetSigmaBellShape (1, 0);
Assert.IsTrue (pgb.Transform.IsIdentity, "Transform.IsIdentity-2");
// middle
pgb.SetSigmaBellShape (0.5f, 0.5f);
Assert.IsTrue (pgb.Transform.IsIdentity, "Transform.IsIdentity-3");
// no impact on matrix
}
}
示例12: Rectangle
public void Rectangle ()
{
using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.TileFlipXY)) {
CheckDefaultRectangle ("Original", pgb.Rectangle);
pgb.MultiplyTransform (new Matrix (2, 0, 0, 2, 2, 2));
CheckDefaultRectangle ("Multiply", pgb.Rectangle);
pgb.ResetTransform ();
CheckDefaultRectangle ("Reset", pgb.Rectangle);
pgb.RotateTransform (90);
CheckDefaultRectangle ("Rotate", pgb.Rectangle);
pgb.ScaleTransform (4, 0.25f);
CheckDefaultRectangle ("Scale", pgb.Rectangle);
pgb.TranslateTransform (-10, -20);
CheckDefaultRectangle ("Translate", pgb.Rectangle);
pgb.SetBlendTriangularShape (0.5f);
CheckDefaultRectangle ("SetBlendTriangularShape", pgb.Rectangle);
pgb.SetSigmaBellShape (0.5f);
CheckDefaultRectangle ("SetSigmaBellShape", pgb.Rectangle);
}
}