本文整理汇总了C#中System.Drawing.Graphics.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.Flush方法的具体用法?C# Graphics.Flush怎么用?C# Graphics.Flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.Flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderClock
public static void RenderClock(RectangleF area, Graphics graphics, bool isPreview)
{
int tempBrushWeight = isPreview ? 2 : brushWeight;
int tempSpacing = isPreview ? 4 : spacing;
Pen penSecond = new Pen(new SolidBrush(Color.FromArgb(alpha, secondColor)), tempBrushWeight);
Pen penMinute = new Pen(new SolidBrush(Color.FromArgb(alpha, minuteColor)), tempBrushWeight);
Pen penHour = new Pen(new SolidBrush(Color.FromArgb(alpha, hourColor)), tempBrushWeight);
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
// Formula
// 1. Subdivide the circle by the total count of each sec, min or hours
// 2. Multiply the value from 1. by the current sec, min or hour
// 3. ==> For ex, for sec (360/60)*current second
DateTime now = DateTime.Now;
// Draw second arc
// For smooth animation consider the current seconds in terms of floating point number like below instead of this --> graphics.DrawArc(penSecond, area, -90f, 6*now.Second);
graphics.DrawArc(penSecond, area, -90f, 6F * ((now.Second + now.Millisecond / 1000F)));
// Draw minute arc
graphics.DrawArc(penMinute, new RectangleF(area.X + tempSpacing * 2, area.Y + tempSpacing * 2, area.Width - tempSpacing * 4, area.Height - tempSpacing * 4), -90f, 6F * (now.Minute + now.Second / 60F));
int hour = enable24HourFormat ? int.Parse(now.ToString("HH")) : int.Parse(now.ToString("%h"));
float hourMultiplier = enable24HourFormat ? 360 / 24f : 360 / 12f;
// Draw hour arc
graphics.DrawArc(penHour, new RectangleF(area.X + tempSpacing * 4, area.Y + tempSpacing * 4, area.Width - tempSpacing * 8, area.Height - tempSpacing * 8), -90f, hourMultiplier * (hour + now.Minute / 60F));
graphics.Flush();
}
示例2: DrawTextOnBitmap
private static void DrawTextOnBitmap(System.Drawing.Bitmap objBmpImage, Graphics objGraphics, string text, Font objFont, InputOptions options)
{
objGraphics = Graphics.FromImage(objBmpImage);
objGraphics.Clear(ColorTranslator.FromHtml(options.BackgroundColor));
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
objGraphics.DrawString(text, objFont, new SolidBrush(ColorTranslator.FromHtml(options.TextColor)), 0, 0);
objGraphics.Flush();
}
示例3: DrawString
public virtual void DrawString(RectangleF area, Graphics g, String text, FontFamily ff, Color c)
{
SizeF size = g.MeasureString(text, new Font(ff, 32));
double difX = (size.Width - area.Width) / -size.Width;
double difY = (size.Height - area.Height) / -size.Height;
float finalFontSize = 32 + (float)(32 * Math.Min(difX, difY));
SizeF finalSize = g.MeasureString(text, new Font(ff, finalFontSize));
g.DrawString(text, new Font(ff, finalFontSize), new SolidBrush(c),
new PointF((area.Width - finalSize.Width) / 2 + area.Left, (area.Height - finalSize.Height) / 2 + area.Height));
g.Flush();
}
示例4: draw
public void draw(Graphics graphics, Bitmap bmp, int offsetX, int offsetY)
{
graphics.Clear(Color.White);
for (double i = 0; i <= 1; i += stepLength)
{
int x = PointPostion(i, PointPostion(i, p1.X, p2.X), PointPostion(i, p2.X, p3.X));
int y = PointPostion(i, PointPostion(i, p1.Y, p2.Y), PointPostion(i, p2.Y, p3.Y));
bmp.SetPixel(x, y, Color.White);
}
graphics.DrawImage(bmp, -offsetX, -offsetY);
graphics.Flush();
}
示例5: PreprocessFrame
private void PreprocessFrame( Graphics gr, RecordSettings settings ) {
if ( !settings.Private ) return;
gr.Clear( Color.Black );
gr.Flush();
}
示例6: makeLayer
//, int Alpha)
public void makeLayer(String RedDataSetName, String GreenDataSetName, String BlueDataSetName)
{
//blue only
ViewArea = Control.ViewArea;
//int x = (int)Control.FromLatLngToLocal(ViewArea.LocationRightBottom).X;
curLayer = new Bitmap((int)Control.FromLatLngToLocal(ViewArea.LocationRightBottom).X,(int) Control.FromLatLngToLocal(ViewArea.LocationRightBottom).Y);
g = System.Drawing.Graphics.FromImage(curLayer);
//g.Clear(Color.Black);
//
allPoints = GDSM.DataSets[BlueDataSetName];
Console.WriteLine(BlueDataSetName + GDSM.DataSets.ContainsKey(BlueDataSetName));
activePoints = activeData(allPoints, ViewArea, BlueDataSetName);
GPoint TL;
GPoint BR;
foreach (GridDataPoint p in activePoints.points)
{
TL = Control.FromLatLngToLocal(p.loc.LocationTopLeft);
BR = Control.FromLatLngToLocal(p.loc.LocationRightBottom);
//Console.WriteLine("Drawing: [" + TL.X + ", " + TL.Y + "] [" + BR.X + ", " + BR.Y + "] - " + p.value + " - (" + p.loc.LocationRightBottom.Lat + ", " + p.loc.LocationRightBottom.Lng +")");
g.FillRectangle(new SolidBrush(Color.FromArgb(125, Color.FromArgb(0,0,p.value))),new Rectangle((int)TL.X, (int)TL.Y, (int)(BR.X - TL.X), (int)(BR.Y - TL.Y)));
}
g.Flush();
Layers.Add(curLayer);
}
示例7: CycleDrawArea
private void CycleDrawArea()
{
g = this.CreateGraphics();
g.ResetClip();
SolidBrush myBrush = new SolidBrush(Color.SteelBlue);
g.FillRectangle(myBrush, 23, 43, 589, 184);
// background
if ((inPort) && (portBmp != null))
{
g.DrawImage(portBmp, new RectangleF(new PointF(23, 43), new SizeF(589, 184)));
}
else if ((water1Bmp != null) && (water2Bmp != null))
{
if (waterSwitch)
{
g.DrawImage(water1Bmp, new RectangleF(new PointF(23, 43), new SizeF(589, 184)));
}
else
{
g.DrawImage(water2Bmp, new RectangleF(new PointF(23, 43), new SizeF(589, 184)));
}
}
if (inPort) // draw ship docked at port
{
if (shipBmpArr[Player.CurrentShip.ID - 1] != null)
{
g.DrawImage(shipBmpArr[Player.CurrentShip.ID - 1], new RectangleF(new PointF(188, 54), new SizeF(261, 123)));
}
}
else // draw player ship and enemy
{
if (shipBmpArr[Player.CurrentShip.ID - 1] != null)
{
if (Player.CurrentShip.HP > 0)
{
// Player still alive, draw ship
g.DrawImage(shipBmpArr[Player.CurrentShip.ID - 1], new RectangleF(new PointF(40, 71), new SizeF(261, 123)));
}
else
{
AddStatusLine("Player dead");
// draw the blood pool, if available
if (bloodBmp != null)
{
AddStatusLine("drawing blood bmp");
g.DrawImage(bloodBmp, new RectangleF(new PointF(40, 71), new SizeF(261, 123)));
}
}
}
if ((CurrentEnemy != null) && (CurrentEnemy.ID >= 0))
{
if ((fishBmpArr[CurrentEnemy.ID - 1] != null) && (inCombat && !isDead))
{
g.DrawImage(fishBmpArr[CurrentEnemy.ID - 1], new RectangleF(new PointF(317, 43), new SizeF(294, 184)));
}
}
}
g.Flush();
g.Dispose();
}
示例8: DrawImage
/// <summary>
/// Creates a Bitmap Image.
/// </summary>
/// <returns> Bitmap image.</returns>
public Bitmap DrawImage()
{
// Create the bmpImage again with the correct size for the text and font.
_objBmpImage = new Bitmap(_objBmpImage, new Size(ImageWidth.Value, ImageHeight.Value));
// Add the colors to the new bitmap.
_objGraphics = Graphics.FromImage(_objBmpImage);
_objRectangle = new Rectangle(new Point(0, 0), new Size(ImageWidth.Value - 1, ImageHeight.Value - 1));
_objGraphics.DrawString(Text, TextFont, new SolidBrush(TextColor.Value), _objRectangle, _stringFormat);
if (IsBorderRequired)
{
_objGraphics.DrawRectangle(this.BorderColor, _objRectangle);
}
_objGraphics.Flush();
return (_objBmpImage);
}
示例9: DrawImage
/// <summary>
/// Whenever the textbox is repainted, we have to draw the image.
/// </summary>
public void DrawImage()
{
if((CurrentIcon!=null))
{
// Gets a GDI drawing surface from the textbox.
gfx = Graphics.FromHwnd (this.Handle);
bool rightToLeft = false;
if(Owner.RightToLeft == RightToLeft.Inherit)
{
if(Owner.Parent.RightToLeft == RightToLeft.Yes)
rightToLeft = true;
}
if(Owner.RightToLeft == RightToLeft.Yes || rightToLeft)
{
gfx.DrawImage(CurrentIcon,gfx.VisibleClipBounds.Width - CurrentIcon.Width,0);
}
else if(Owner.RightToLeft == RightToLeft.No || rightToLeft)
gfx.DrawImage(CurrentIcon,0,0);
gfx.Flush();
gfx.Dispose();
}
}
示例10: draw_invalidData
private void draw_invalidData()
{
drawBitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(drawBitmap);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.DrawString("Invalid Data", new Font("Tahoma", 60), Brushes.Black, 0, 0);
g.Flush();
pictureBox1.Image = drawBitmap;
pictureBox1.Image.Tag = "jhn";
}
示例11: OnNonClientPaint
//-------------------------------------------------------------------------------------
/// <summary>
/// ќсуществл¤ет рисование в неклиенской области.
/// </summary>
/// <param name="g"></param>
protected void OnNonClientPaint(Graphics g)
{
bool useVS = VisualStyleInformation.IsEnabledByUser &&
VisualStyleInformation.IsSupportedByOS &&
Application.RenderWithVisualStyles &&
useVisualStyleBorderColor;
Rectangle r = Rectangle.Round(g.VisibleClipBounds);
if(borderStyle == BorderStyle.FixedSingle)
{
SolidBrush b;
if(useVS)
b = new SolidBrush(VisualStyleInformation.TextControlBorder);
else
b = new SolidBrush(this.BorderColor);
using(b) //
{
g.FillRectangle(b, 0, 0, r.Width, borderWidth.Top);
g.FillRectangle(b, r.Width - borderWidth.Right, 0, r.Width, r.Height);
g.FillRectangle(b, 0, r.Height - borderWidth.Bottom, r.Width, r.Height);
g.FillRectangle(b, 0, 0, borderWidth.Left, r.Height);
}
}
else if(borderStyle == BorderStyle.Fixed3D)
{
g.DrawLine(SystemPens.ControlDarkDark, 1, 1, r.Width - 3, 1); // Top
g.DrawLine(SystemPens.ControlDarkDark, 1, 1, 1, r.Height - 3); // Left
g.DrawLine(SystemPens.ControlLight, 1, r.Height - 2, r.Width - 2, r.Height - 2); // Bottom
g.DrawLine(SystemPens.ControlLight, r.Width - 2, 1, r.Width - 2, r.Height - 2); // Right
g.DrawLine(SystemPens.ControlDark, 0, 0, r.Width - 2, 0); // Top
g.DrawLine(SystemPens.ControlDark, 0, 0, 0, r.Height - 2); // Left
g.DrawLine(SystemPens.ControlLightLight, 0, r.Height - 1, r.Width - 1, r.Height - 1); // Bottom
g.DrawLine(SystemPens.ControlLightLight, r.Width - 1, 0, r.Width - 1, r.Height - 1); // Right
}
g.Flush();
}
示例12: ImportCharacter
private static CharacterGlyph ImportCharacter(char character, Font font, Bitmap stagingBitmap, Graphics stagingGraphics)
{
var str = character.ToString();
var characterSize = stagingGraphics.MeasureString(str, font, Point.Empty, NoFontFallbackFormat);
var abcSpacing = CalculateABCSpacing(character, font, stagingGraphics);
uint width = (uint)Math.Ceiling(abcSpacing.A + abcSpacing.B + abcSpacing.C);
uint height = (uint)Math.Ceiling(characterSize.Height);
Debug.Assert(width <= BitmapSize && height < BitmapSize);
stagingGraphics.Clear(Color.Black);
stagingGraphics.DrawString(str, font, ForegroundBrush, 0, 0, NoFontFallbackFormat);
stagingGraphics.Flush();
var characterBitmap = stagingBitmap.Clone(new Rectangle(0, 0, (int)width, (int)height), PixelFormat.Format32bppArgb);
return new CharacterGlyph(character, characterBitmap, width, height);
}
示例13: OnNonClientPaint
//.........这里部分代码省略.........
rr = new Rectangle(r.Width - pd.Right, 0, pd.Right, r.Height);
if(rr.Width > 0 && rr.Height > 0)
WinFormsUtils.CallPaint(Parent, new PaintEventArgs(g, rr));
rr = new Rectangle(0, r.Height - pd.Bottom, r.Width, pd.Bottom);
if(rr.Width > 0 && rr.Height > 0)
WinFormsUtils.CallPaint(Parent, new PaintEventArgs(g, rr));
rr = new Rectangle(0, 0, pd.Left, r.Height);
if(rr.Width > 0 && rr.Height > 0)
WinFormsUtils.CallPaint(Parent, new PaintEventArgs(g, rr));
}
if(borderStyle != System.Windows.Forms.BorderStyle.None)
{
r.X += Margin.Left;
r.Width -= Margin.Horizontal;
r.Y += Margin.Top;
r.Height -= Margin.Vertical;
}
if(borderStyle == BorderStyle.FixedSingle)
{
bool useVS = VisualStyleInformation.IsEnabledByUser &&
VisualStyleInformation.IsSupportedByOS &&
Application.RenderWithVisualStyles &&
useVisualStyleBorderColor;
SolidBrush b;
if(useVS)
b = new SolidBrush(VisualStyleInformation.TextControlBorder);
else
b = new SolidBrush(this.BorderColor);
using(b) //
{
//g.FillRectangle(Brushes.Red, 0, 0, r.Width, r.Height);
g.FillRectangle(b, r.X, r.Y, r.Width, borderWidth.Top);
g.FillRectangle(b, r.X + r.Width - borderWidth.Right, r.Y, borderWidth.Right, r.Height);
g.FillRectangle(b, r.X, r.Y + r.Height - borderWidth.Bottom, r.Width, borderWidth.Bottom);
g.FillRectangle(b, r.X, r.Y, borderWidth.Left, r.Height);
}
}
else if(borderStyle == BorderStyle.Fixed3D)
{
switch(b3Dstyle)
{
case Border3DKind.Sunken:
g.DrawLine(SystemPens.ControlDarkDark, r.X+1, r.Y+1, r.Width, r.Y+1); // Top
g.DrawLine(SystemPens.ControlDarkDark, r.X+1, r.Y+1, r.X+1, r.Height); // Left
g.DrawLine(SystemPens.ControlLight, r.X+1, r.Y + r.Height - 2, r.Width, r.Y + r.Height - 2); // Bottom
g.DrawLine(SystemPens.ControlLight, r.X + r.Width - 2, r.Y+1, r.X + r.Width - 2, r.Height - 1); // Right
goto case Border3DKind.SunkenFlat;
case Border3DKind.SunkenFlat:
g.DrawLine(SystemPens.ControlDark, r.X, r.Y, r.Width, r.Y); // Top
g.DrawLine(SystemPens.ControlDark, r.X, r.Y, r.X, r.Y + r.Height - 2); // Left
g.DrawLine(SystemPens.ControlLightLight, r.X, r.Y + r.Height - 1, r.Width + 1, r.Y + r.Height - 1); // Bottom
g.DrawLine(SystemPens.ControlLightLight, r.X + r.Width - 1, r.Y, r.X + r.Width - 1, r.Height); // Right
break;
case Border3DKind.Raised:
g.DrawLine(SystemPens.ControlLight, r.X, r.Y, r.X + r.Width - 2, r.Y); // Top
g.DrawLine(SystemPens.ControlLight, r.X, r.Y, r.X, r.Y + r.Height - 2); // Left
g.DrawLine(SystemPens.ControlDarkDark, r.X, r.Y + r.Height - 1, r.X + r.Width - 1, r.Y + r.Height - 1); // Bottom
g.DrawLine(SystemPens.ControlDarkDark, r.X + r.Width - 1, r.Y, r.X + r.Width - 1, r.Y + r.Height - 1); // Right
g.DrawLine(SystemPens.ControlLightLight, r.X + 1, r.Y + 1, r.X + r.Width - 3, r.Y + 1); // Top
g.DrawLine(SystemPens.ControlLightLight, r.X + 1, r.Y + 1, r.X + 1, r.Y + r.Height - 3); // Left
g.DrawLine(SystemPens.ControlDark, r.X + 1, r.Y + r.Height - 2, r.X + r.Width - 2, r.Y + r.Height - 2); // Bottom
g.DrawLine(SystemPens.ControlDark, r.X + r.Width - 2, r.Y + 1, r.X + r.Width - 2, r.Y + r.Height - 2); // Right
break;
case Border3DKind.RaisedFlat:
g.DrawLine(SystemPens.ControlLightLight, r.X, r.Y, r.X + r.Width - 2, r.Y); // Top
g.DrawLine(SystemPens.ControlLightLight, r.X, r.Y, r.X, r.Y + r.Height - 2); // Left
g.DrawLine(SystemPens.ControlDark, r.X, r.Y + r.Height - 1, r.X + r.Width - 1,r.Y + r.Height - 1); // Bottom
g.DrawLine(SystemPens.ControlDark, r.X + r.Width - 1, r.Y, r.X + r.Width - 1, r.Y + r.Height - 1); // Right
break;
case Border3DKind.Etched:
g.DrawLine(SystemPens.ControlDark, r.X, r.Y, r.X + r.Width - 2, r.Y); // Top
g.DrawLine(SystemPens.ControlDark, r.X, r.Y, r.X, r.Y + r.Height - 2); // Left
g.DrawLine(SystemPens.ControlLightLight, r.X, r.Y + r.Height - 1, r.X + r.Width - 1, r.Y + r.Height - 1); // Bottom
g.DrawLine(SystemPens.ControlLightLight, r.X + r.Width - 1, r.Y, r.X + r.Width - 1, r.Y + r.Height - 1); // Right
g.DrawLine(SystemPens.ControlLightLight, r.X + 1, r.Y + 1, r.X + r.Width - 3, r.Y + 1); // Top
g.DrawLine(SystemPens.ControlLightLight, r.X + 1, r.Y + 1, r.X + 1, r.Y + r.Height - 3); // Left
g.DrawLine(SystemPens.ControlDark, r.X + 1, r.Y + r.Height - 2, r.X + r.Width - 2, r.Y + r.Height - 2); // Bottom
g.DrawLine(SystemPens.ControlDark, r.X + r.Width - 2, r.Y + 1, r.X + r.Width - 2, r.Y + r.Height - 2); // Right
break;
case Border3DKind.Bump:
g.DrawLine(SystemPens.ControlLightLight, r.X, r.Y, r.X + r.Width - 2, r.Y); // Top
g.DrawLine(SystemPens.ControlLightLight, r.X, r.Y, r.X, r.Y + r.Height - 2); // Left
g.DrawLine(SystemPens.ControlDark, r.X, r.Y + r.Height - 1, r.X + r.Width - 1, r.Y + r.Height - 1); // Bottom
g.DrawLine(SystemPens.ControlDark, r.X + r.Width - 1, r.Y, r.X + r.Width - 1, r.Y + r.Height - 1); // Right
g.DrawLine(SystemPens.ControlDark, r.X + 1, r.Y + 1, r.X + r.Width - 3, r.Y + 1); // Top
g.DrawLine(SystemPens.ControlDark, r.X + 1, r.Y + 1, r.X + 1, r.Y + r.Height - 3); // Left
g.DrawLine(SystemPens.ControlLightLight, r.X + 1, r.Y + r.Height - 2, r.X + r.Width - 2, r.Y + r.Height - 2); // Bottom
g.DrawLine(SystemPens.ControlLightLight, r.X + r.Width - 2, r.Y + 1, r.X + r.Width - 2, r.Y + r.Height - 2); // Right
break;
}
}
g.Flush();
}
示例14: saveImage
protected void saveImage(Graphics g, Bitmap bmp, string quadKey)
{
g.Flush();
var level = quadKey.Length;
var tile = merc.QuadTreeToTile(quadKey, level);
string filename = Path.Combine(tileDir, string.Format("{0}\\{1}\\{2}.png", level, tile.X, tile.Y));
Directory.CreateDirectory(Path.GetDirectoryName(filename));
bmp.Save(filename);
}
示例15: DrawDebug
/// <summary>
/// The draw debug method for <see cref="Engine"/>
/// </summary>
/// <param name="g">
/// The <see cref="Graphics"/> for the Draw Debug method..
/// </param>
public void DrawDebug(Graphics g)
{
g.DrawString(
string.Format("FPS: {0}", this.engine.CurrentFPS),
new Font("Serif", 12, FontStyle.Bold),
Brushes.Aqua,
new PointF(5, 5));
g.FillEllipse(
this.environment.Players[0].IsActionPressed(
new Core.Players.Actions.KeyMapping { Action = Core.Players.Actions.KeyMapping.KeyAction.JUMP })
? Brushes.Aquamarine
: Brushes.Red,
new Rectangle(50, 60, 8, 8));
g.FillRectangle(
this.environment.Players[0].IsActionPressed(
new Core.Players.Actions.KeyMapping { Action = Core.Players.Actions.KeyMapping.KeyAction.UP })
? Brushes.Aquamarine
: Brushes.Red,
new Rectangle(50, 80, 8, 15));
g.FillRectangle(
this.environment.Players[0].IsActionPressed(
new Core.Players.Actions.KeyMapping { Action = Core.Players.Actions.KeyMapping.KeyAction.DOWN })
? Brushes.Aquamarine
: Brushes.Red,
new Rectangle(50, 100, 8, 15));
g.FillRectangle(
this.environment.Players[0].IsActionPressed(
new Core.Players.Actions.KeyMapping { Action = Core.Players.Actions.KeyMapping.KeyAction.RIGHT })
? Brushes.Aquamarine
: Brushes.Red,
new Rectangle(61, 93, 15, 8));
g.FillRectangle(
this.environment.Players[0].IsActionPressed(
new Core.Players.Actions.KeyMapping { Action = Core.Players.Actions.KeyMapping.KeyAction.LEFT })
? Brushes.Aquamarine
: Brushes.Red,
new Rectangle(32, 93, 15, 8));
g.Flush();
}