本文整理汇总了C#中System.Drawing.BufferedGraphics.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# BufferedGraphics.Dispose方法的具体用法?C# BufferedGraphics.Dispose怎么用?C# BufferedGraphics.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.BufferedGraphics
的用法示例。
在下文中一共展示了BufferedGraphics.Dispose方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
BufferedGraphicsContext currentContext;
currentContext = BufferedGraphicsManager.Current;
myBuffer = currentContext.Allocate(this.CreateGraphics(), this.DisplayRectangle);
PaintEventArgs args = new PaintEventArgs(myBuffer.Graphics, e.ClipRectangle);
base.OnPaint(args);
myBuffer.Render(e.Graphics);
myBuffer.Dispose();
}
示例2: clock_Tick
private void clock_Tick(object sender, EventArgs e)
{
// Make the draw buffer and set background color
myBuffer = currentContext.Allocate(canvas.CreateGraphics(), canvas.DisplayRectangle);
myBuffer.Graphics.FillRectangle(Brushes.WhiteSmoke, canvas.DisplayRectangle);
// Move Update Draw Simulation Objects
foreach (SimulationObject so in objects)
{
so.UpdateState();
so.PerformAction();
so.Draw(myBuffer.Graphics);
}
// Main draw
myBuffer.Render();
myBuffer.Dispose();
}
示例3: accel_AccelerationChange
void accel_AccelerationChange(object sender, AccelerationChangeEventArgs e)
{
formGraphicsContext = new BufferedGraphicsContext();
formGraphicsBuffer = formGraphicsContext.Allocate(Graphics.FromImage(formDrawingSurface), rectBounds);
formGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
formGraphicsBuffer.Graphics.Clear(SystemColors.Control);
int i = 0;
//low pass filtering
switch (e.Index)
{
case 0:
xOut = 0;
xFilt[6] = e.Acceleration;
for (i = 0; i < 6; i++)
{
xFilt[i] = xFilt[i + 1];
xOut = xOut + xFilt[i];
}
xOut = xOut / 6;
label6.Text = e.Acceleration.ToString();
break;
case 1:
yOut = 0;
yFilt[6] = e.Acceleration;
for (i = 0; i < 6; i++)
{
yFilt[i] = yFilt[i + 1];
yOut = yOut + yFilt[i];
}
yOut = yOut / 6;
label7.Text = e.Acceleration.ToString();
break;
case 2:
zOut = 0;
zFilt[6] = e.Acceleration;
for (i = 0; i < 6; i++)
{
zFilt[i] = zFilt[i + 1];
zOut = zOut + zFilt[i];
}
zOut = zOut / 6;
label8.Text = e.Acceleration.ToString();
break;
}
x1Old = xCenter - (float)xOut * circleRadius;
y1Old = yCenter + (float)yOut * circleRadius;
formGraphicsBuffer.Graphics.DrawLine(xyAxisPen, xCenter, yCenter, x1Old, y1Old);
formGraphicsBuffer.Graphics.DrawEllipse(circlePen, circleRectangle);
if (accel.axes.Count == 3)
{
if (zOut > 0)
{
formGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Red, 2),
new Rectangle((int)xCenter - (int)(circleRadius * zOut), (int)yCenter - (int)(circleRadius * zOut),
(int)(circleDiameter * zOut), (int)(circleDiameter * zOut)));
}
else
{
formGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Green, 2),
new Rectangle((int)xCenter - (int)(circleRadius * -zOut), (int)yCenter - (int)(circleRadius * -zOut),
(int)(circleDiameter * -zOut), (int)(circleDiameter * -zOut)));
}
}
formGraphicsBuffer.Render(panel1.CreateGraphics());
formGraphicsBuffer.Dispose();
formGraphicsContext.Dispose();
}
示例4: BufferedDrawImg
/// <summary>
/// 双缓冲画图,用于画map底图
/// </summary>
/// <param name="g">目标设备的Graphics</param>
/// <param name="PicImg">底图的Image实例</param>
/// <param name="left">底图左边线X坐标</param>
/// <param name="top">底图上边线Y坐标</param>
/// <param name="width">底图宽</param>
/// <param name="height">底图的高</param>
private void BufferedDrawImg(Graphics g, Image PicImg, int left, int top, float width, float height)
{
if (PicImg != null)
{
context = BufferedGraphicsManager.Current;
context.MaximumBuffer = new Size(this.Width + 1, this.Height + 1);
bgraph = context.Allocate(g, new Rectangle(0, 0, this.Width + 1, this.Height + 1));
bgraph.Graphics.Clear(this.BackColor);
bgraph.Graphics.DrawImage(PicImg, left, top, width, height);
bgraph.Graphics.DrawRectangle(Pens.Black, rect);
PaintStation(bgraph.Graphics);
PaintMover(bgraph.Graphics);
PaintRoute(bgraph.Graphics);
if (IsPaintRoute)
{
PaintStation(bgraph.Graphics);
PaintMover(bgraph.Graphics);
}
PaintMoverRoute(bgraph.Graphics);
//bgraph.Graphics.DrawImage(myimage, 200, 200, 50, 50);
bgraph.Render();
bgraph.Dispose();
}
}
示例5: accel_AccelerationChange
//acceleration change event handler
void accel_AccelerationChange(object sender, AccelerationChangeEventArgs e)
{
//get our graphics buffer going so we can draw to our panel
accelGraphicsContext = new BufferedGraphicsContext();
accelGraphicsBuffer = accelGraphicsContext.Allocate(Graphics.FromImage(accelDrawingSurface), boundsRectangle);
accelGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
accelGraphicsBuffer.Graphics.Clear(SystemColors.Control);
Accelerometer attached = (Accelerometer)sender;
//in this switch statement we will do a bit of simple low pass filtering to smooth out the motion of the graphical representation of the
//acceleration data. We will also write the raw data to the textbox for the appropriate axis.
int i = 0;
try
{
switch (e.Index)
{
case 0:
xOut = 0;
xFilt[6] = e.Acceleration;
for (i = 0; i < 6; i++)
{
xFilt[i] = xFilt[i + 1];
xOut = xOut + xFilt[i];
}
xOut = xOut / 6;
axis1AccelTxt.Text = e.Acceleration.ToString();
break;
case 1:
yOut = 0;
yFilt[6] = e.Acceleration;
for (i = 0; i < 6; i++)
{
yFilt[i] = yFilt[i + 1];
yOut = yOut + yFilt[i];
}
yOut = yOut / 6;
axis2AccelTxt.Text = e.Acceleration.ToString();
break;
case 2:
zOut = 0;
zFilt[6] = e.Acceleration;
for (i = 0; i < 6; i++)
{
zFilt[i] = zFilt[i + 1];
zOut = zOut + zFilt[i];
}
zOut = zOut / 6;
axis3AccelTxt.Text = e.Acceleration.ToString();
break;
}
}
catch (PhidgetException ex)
{
MessageBox.Show(ex.Description);
}
xOld = xCenter - (float)xOut * circleRadius;
yOld = yCenter + (float)yOut * circleRadius;
accelGraphicsBuffer.Graphics.DrawLine(xyAxisPen, xCenter, yCenter, xOld, yOld);
accelGraphicsBuffer.Graphics.DrawEllipse(circlePen, circleRectangle);
if (attached.axes.Count == 3)
{
if (zOut > 0)
{
accelGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Red, 2),
new Rectangle((int)xCenter - (int)(circleRadius * zOut), (int)yCenter - (int)(circleRadius * zOut),
(int)(circleDiameter * zOut), (int)(circleDiameter * zOut)));
}
else
{
accelGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Green, 2),
new Rectangle((int)xCenter - (int)(circleRadius * -zOut), (int)yCenter - (int)(circleRadius * -zOut),
(int)(circleDiameter * -zOut), (int)(circleDiameter * -zOut)));
}
}
accelGraphicsBuffer.Render(panel1.CreateGraphics());
accelGraphicsBuffer.Dispose();
accelGraphicsContext.Dispose();
}
示例6: drawMagFieldGraph
private void drawMagFieldGraph()
{
magFieldGraphicsContext = new BufferedGraphicsContext();
magFieldGraphicsBuffer = magFieldGraphicsContext.Allocate(Graphics.FromImage(magFieldDrawingSurface), magFieldBoundsRectangle);
magFieldGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
magFieldGraphicsBuffer.Graphics.Clear(SystemColors.Control);
float xCenter = (float)(magFieldBoundsRectangle.Width / 2.0);
float yCenter = (float)(magFieldBoundsRectangle.Height / 2.0);
float xOld = xCenter + (float)(spatial.compassAxes[0].MagneticField) * magFieldCircleRadius * (float)(1 / ambientMagneticField);
float yOld = yCenter + (float)(spatial.compassAxes[1].MagneticField) * magFieldCircleRadius * (float)(1 / ambientMagneticField);
magFieldGraphicsBuffer.Graphics.DrawLine(magFieldXYAxisPen, xCenter, yCenter, xOld, yOld);
magFieldGraphicsBuffer.Graphics.DrawEllipse(magFieldCirclePen, magFieldCircleRectangle);
if (spatial.compassAxes.Count == 3)
{
double zOut = (spatial.compassAxes[2].MagneticField) * (float)(1 / ambientMagneticField);
if (zOut > 0)
{
magFieldGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Red, 2),
new Rectangle((int)xCenter - (int)(magFieldCircleRadius * zOut), (int)yCenter - (int)(magFieldCircleRadius * zOut),
(int)(magFieldCircleDiameter * zOut), (int)(magFieldCircleDiameter * zOut)));
}
else
{
magFieldGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Green, 2),
new Rectangle((int)xCenter - (int)(magFieldCircleRadius * -zOut), (int)yCenter - (int)(magFieldCircleRadius * -zOut),
(int)(magFieldCircleDiameter * -zOut), (int)(magFieldCircleDiameter * -zOut)));
}
}
magFieldGraphicsBuffer.Render(magFieldView.CreateGraphics());
magFieldGraphicsBuffer.Dispose();
magFieldGraphicsContext.Dispose();
}
示例7: drawGyroGraph
private void drawGyroGraph()
{
//get our graphics buffer going so we can draw to our panel
gyroGraphicsContext = new BufferedGraphicsContext();
gyroGraphicsBuffer = gyroGraphicsContext.Allocate(Graphics.FromImage(gyroDrawingSurface), gyroboundsRectangle);
gyroGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
gyroGraphicsBuffer.Graphics.Clear(SystemColors.Control);
float xCenter = (float)(gyroboundsRectangle.Width / 2.0);
float yCenter = (float)(gyroboundsRectangle.Height / 2.0);
//heading circles
for (int i = 0; i < spatial.gyroAxes.Count; i++)
{
gyroGraphicsBuffer.Graphics.DrawEllipse(gyrocirclePen, gyrocircleRectangle[i]);
gyroGraphicsBuffer.Graphics.DrawEllipse(
gyroxyAxisPen[i],
(float)(gyrocircleRadius[i] * Math.Cos(gyroHeading[i] * (Math.PI / 180.0)) + xCenter) - 2,
(float)(-gyrocircleRadius[i] * Math.Sin(gyroHeading[i] * (Math.PI / 180.0)) + yCenter) - 2,
4,
4
);
}
gyroGraphicsBuffer.Render(gyroView.CreateGraphics());
gyroGraphicsBuffer.Dispose();
gyroGraphicsContext.Dispose();
}
示例8: drawCompassBearingGraph
private void drawCompassBearingGraph()
{
compassGraphicsContext = new BufferedGraphicsContext();
compassGraphicsBuffer = compassGraphicsContext.Allocate(Graphics.FromImage(compassDrawingSurface), compassboundsRectangle);
compassGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
compassGraphicsBuffer.Graphics.Clear(SystemColors.Control);
float xCenter = (float)(compassboundsRectangle.Width / 2.0);
float yCenter = (float)(compassboundsRectangle.Height / 2.0);
compassGraphicsBuffer.Graphics.DrawEllipse(compassCirclePen, compasscircleRectangle);
Point pt = new Point((int)(xCenter - spatialImage.Width / 2), (int)(yCenter - spatialImage.Height / 2));
compassGraphicsBuffer.Graphics.DrawImageUnscaled(rotateImage(spatialImage, (float)compassBearing), pt);
compassGraphicsBuffer.Graphics.DrawString("N", new Font("Arial", 16), new SolidBrush(Color.Black), xCenter-10, 0);
compassGraphicsBuffer.Graphics.DrawString("E", new Font("Arial", 16), new SolidBrush(Color.Black), xCenter*2-20, yCenter-12);
compassGraphicsBuffer.Graphics.DrawString("S", new Font("Arial", 16), new SolidBrush(Color.Black), xCenter-10, yCenter*2-20);
compassGraphicsBuffer.Graphics.DrawString("W", new Font("Arial", 16), new SolidBrush(Color.Black), 0, yCenter-12);
//Ticks around the compass circle
for (int i = 0; i < 360; i+=10)
{
Pen p = compassTickPen;
int tickSize = 4;
if (i == 0 || i == 90 || i == 180 || i == 270)
{
p = compassTickPenBig;
tickSize = 6;
}
compassGraphicsBuffer.Graphics.DrawLine(p,
(float)((compassCircleRadius + tickSize) * Math.Cos(i * (Math.PI / 180.0)) + xCenter),
(float)(-(compassCircleRadius + tickSize) * Math.Sin(i * (Math.PI / 180.0)) + yCenter),
(float)((compassCircleRadius - tickSize) * Math.Cos(i * (Math.PI / 180.0)) + xCenter),
(float)(-(compassCircleRadius - tickSize) * Math.Sin(i * (Math.PI / 180.0)) + yCenter));
}
//Marker on the compass circle
compassGraphicsBuffer.Graphics.DrawEllipse(
compassDotPen,
(float)(compassCircleRadius * Math.Cos((-compassBearing+90) * (Math.PI / 180.0)) + xCenter) - 2,
(float)(-compassCircleRadius * Math.Sin((-compassBearing+90) * (Math.PI / 180.0)) + yCenter) - 2,
4,
4
);
compassGraphicsBuffer.Render(compassView.CreateGraphics());
compassGraphicsBuffer.Dispose();
compassGraphicsContext.Dispose();
}
示例9: drawAccelGraph
private void drawAccelGraph()
{
accelGraphicsContext = new BufferedGraphicsContext();
accelGraphicsBuffer = accelGraphicsContext.Allocate(Graphics.FromImage(accelDrawingSurface), accelboundsRectangle);
accelGraphicsBuffer.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
accelGraphicsBuffer.Graphics.Clear(SystemColors.Control);
float xCenter = (float)(accelboundsRectangle.Width / 2.0);
float yCenter = (float)(accelboundsRectangle.Height / 2.0);
float xOld = xCenter - (float)spatial.accelerometerAxes[0].Acceleration * accelcircleRadius * (float)(1 / ambientGravity);
float yOld = yCenter - (float)spatial.accelerometerAxes[1].Acceleration * accelcircleRadius * (float)(1 / ambientGravity);
accelGraphicsBuffer.Graphics.DrawLine(accelxyAxisPen, xCenter, yCenter, xOld, yOld);
accelGraphicsBuffer.Graphics.DrawEllipse(accelcirclePen, new Rectangle((int)(xCenter - accelcircleRadius), (int)(yCenter - accelcircleRadius),
(int)accelcircleDiameter, (int)accelcircleDiameter));
if (spatial.accelerometerAxes.Count == 3)
{
double zOut = spatial.accelerometerAxes[2].Acceleration * (float)(1 / ambientGravity);
if (zOut > 0)
{
accelGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Red, 2),
new Rectangle((int)xCenter - (int)(accelcircleRadius * zOut), (int)yCenter - (int)(accelcircleRadius * zOut),
(int)(accelcircleDiameter * zOut), (int)(accelcircleDiameter * zOut)));
}
else
{
accelGraphicsBuffer.Graphics.DrawEllipse(new Pen(Color.Green, 2),
new Rectangle((int)xCenter - (int)(accelcircleRadius * -zOut), (int)yCenter - (int)(accelcircleRadius * -zOut),
(int)(accelcircleDiameter * -zOut), (int)(accelcircleDiameter * -zOut)));
}
}
accelGraphicsBuffer.Render(panel1.CreateGraphics());
accelGraphicsBuffer.Dispose();
accelGraphicsContext.Dispose();
}